diff --git a/.env b/.env index 431fdc073..14e36c5ec 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -VERSION_LATEST="v11.0.0" -VERSION_NEXT="v12.0.0" \ No newline at end of file +VITE_VERSION_LATEST="v11.0.0" +VITE_VERSION_NEXT="v12.0.0" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 31b182d6e..7fc3ed438 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,11 @@ pages/docs/**/**/llms.mdx public/playground-bundles/ public/_redirects + + +dist +build +.react-router + +app/**/*.mjs +!shims.mjs \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..cabf43b5d --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 \ No newline at end of file diff --git a/README.md b/README.md index 7837c53ad..d4de42e59 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ In case you are a blog author, please refer to our [guide on writing blog posts] In case your company is a user of ReScript and wants to be displayed on our front page ("Trusted by our users" section), do the following: - Get your logo as a black / white `.svg` version and use `#979AAD` as a fill color (check out the existing logos on our front page). -- Put your logo into the [`public/static/lp`](./public/static/lp) folder; the file should be named after your company. +- Put your logo into the [`app/public/lp`](./app/public/lp) folder; the file should be named after your company. - Open [src/common/OurUsers.res](./src/common/OurUsers.res) and add your info - Commit, push, and open a PR. diff --git a/_blogposts/2020-08-28-new-rescript-logo.mdx b/_blogposts/2020-08-28-new-rescript-logo.mdx index 1e4c275fb..305d26d70 100644 --- a/_blogposts/2020-08-28-new-rescript-logo.mdx +++ b/_blogposts/2020-08-28-new-rescript-logo.mdx @@ -2,13 +2,11 @@ author: made_by_betty date: "2020-08-27" title: "A New Logo for ReScript" -articleImg: /static/blog/rescript-launch/ReScript-3.jpg +articleImg: /blog/rescript-launch/ReScript-3.jpg description: | Today, our resident designer Bettina is unveiling to us the fresh new ReScript branding we've been long waiting for. We hope you're as excited about the result as us! --- -import Image from "src/components/Image"; - ## Why the Rebranding? ReScript is the evolution and fusion of Reason and BuckleScript. As we're a design-minded community, we'd like to convey this new identity not only through new technical changes as we've done so far, but also through a proper, more professionally crafted logo, color scheme and font. At the same time, we'd like to do so while recalling our roots. diff --git a/_blogposts/2020-11-17-editor-support-custom-operators-and-more.mdx b/_blogposts/2020-11-17-editor-support-custom-operators-and-more.mdx index 43b21fe30..faedd92ad 100644 --- a/_blogposts/2020-11-17-editor-support-custom-operators-and-more.mdx +++ b/_blogposts/2020-11-17-editor-support-custom-operators-and-more.mdx @@ -8,8 +8,6 @@ description: | Update on what we're doing around the end of 2020 and early next year. --- -import Video from "src/components/Video"; - ## Upcoming Improvements As we're approaching the end of 2020, we'd like to inform our community of our remaining tasks for the year and early next year. diff --git a/_blogposts/2020-11-26-editor-support-release-1-0.mdx b/_blogposts/2020-11-26-editor-support-release-1-0.mdx index 08ae79ed0..08fc27fd4 100644 --- a/_blogposts/2020-11-26-editor-support-release-1-0.mdx +++ b/_blogposts/2020-11-26-editor-support-release-1-0.mdx @@ -1,8 +1,8 @@ --- author: rescript-team date: "2020-11-26" -previewImg: /static/blog/editor_support_preview.jpg -articleImg: /static/blog/editor_support_article.jpg +previewImg: /blog/editor_support_preview.jpg +articleImg: /blog/editor_support_article.jpg badge: release title: "Editor Plugin for VSCode and Vim Officially Released!" description: | diff --git a/_blogposts/2021-02-09-release-9-0.mdx b/_blogposts/2021-02-09-release-9-0.mdx index 1238d0788..2551a15c6 100644 --- a/_blogposts/2021-02-09-release-9-0.mdx +++ b/_blogposts/2021-02-09-release-9-0.mdx @@ -1,7 +1,7 @@ --- author: hongbo date: "2021-02-09" -previewImg: /static/blog/compiler_release_9_0.jpg +previewImg: /blog/compiler_release_9_0.jpg title: ReScript 9.0 badge: release description: | diff --git a/_blogposts/2021-03-03-rescript-association-rebranding.mdx b/_blogposts/2021-03-03-rescript-association-rebranding.mdx index e216cb619..cd88f8fc9 100644 --- a/_blogposts/2021-03-03-rescript-association-rebranding.mdx +++ b/_blogposts/2021-03-03-rescript-association-rebranding.mdx @@ -1,7 +1,7 @@ --- author: rescript-association date: "2021-03-03" -previewImg: /static/blog/rescript_assoc_rename_preview.jpg +previewImg: /blog/rescript_assoc_rename_preview.jpg title: The ReScript Association description: | After the rebranding of ReScript, its Reason Association has now followed through to become the ReScript Association. diff --git a/_blogposts/2021-05-07-release-9-1.mdx b/_blogposts/2021-05-07-release-9-1.mdx index 56b4e8b15..105400ecf 100644 --- a/_blogposts/2021-05-07-release-9-1.mdx +++ b/_blogposts/2021-05-07-release-9-1.mdx @@ -1,7 +1,7 @@ --- author: rescript-team date: "2021-05-07" -previewImg: /static/blog/compiler_release_9_1.jpg +previewImg: /blog/compiler_release_9_1.jpg title: ReScript 9.1 badge: release description: | diff --git a/_blogposts/2021-06-25-roadmap-2021-and-new-landing-page.mdx b/_blogposts/2021-06-25-roadmap-2021-and-new-landing-page.mdx index 013f411a5..a8ef9df0e 100644 --- a/_blogposts/2021-06-25-roadmap-2021-and-new-landing-page.mdx +++ b/_blogposts/2021-06-25-roadmap-2021-and-new-landing-page.mdx @@ -7,8 +7,6 @@ description: | Announcing our roadmap for 2021 / 2022, release cycle plans and new landing page. --- -import Image from "src/components/Image.mjs"; - ## Team Update It has almost been a year since we originally [launched our new ReScript brand](/blog/bucklescript-is-rebranding), and we think it has been a pretty successful journey so far: @@ -43,7 +41,7 @@ The detailed roadmap with all our planned changes (and definition of our release After several iterations, we are happy to announce our new [landing page](/). diff --git a/_blogposts/2024-01-11-release-11-0-0.mdx b/_blogposts/2024-01-11-release-11-0-0.mdx index eef0dd5de..b0881f082 100644 --- a/_blogposts/2024-01-11-release-11-0-0.mdx +++ b/_blogposts/2024-01-11-release-11-0-0.mdx @@ -1,7 +1,7 @@ --- author: rescript-team date: "2024-01-11" -previewImg: /static/blog/compiler_release_11_0.jpg +previewImg: /blog/compiler_release_11_0.jpg title: ReScript 11.0 badge: release description: | diff --git a/_blogposts/2024-02-01-release-11-1-0.mdx b/_blogposts/2024-02-01-release-11-1-0.mdx index e9823dda4..05d5420e8 100644 --- a/_blogposts/2024-02-01-release-11-1-0.mdx +++ b/_blogposts/2024-02-01-release-11-1-0.mdx @@ -1,7 +1,7 @@ --- author: rescript-team date: "2024-04-19" -previewImg: /static/blog/compiler_release_11_1.jpg +previewImg: /blog/compiler_release_11_1.jpg title: ReScript 11.1 badge: release description: | diff --git a/_blogposts/2025-03-17-retreats.mdx b/_blogposts/2025-03-17-retreats.mdx index e61a24179..385d08d97 100644 --- a/_blogposts/2025-03-17-retreats.mdx +++ b/_blogposts/2025-03-17-retreats.mdx @@ -1,8 +1,8 @@ --- author: rescript-association date: "2025-03-17" -previewImg: /static/blog/rescript_retreat_2024.jpg -articleImg: /static/blog/rescript_retreat_2024.jpg +previewImg: /blog/rescript_retreat_2024.jpg +articleImg: /blog/rescript_retreat_2024.jpg title: ReScript Retreat description: | Accelerating ReScript development through meeting in-person. @@ -17,7 +17,7 @@ Last year, from the 23rd to the 26th of May, the ReScript Association invited ma ## Talks @@ -32,7 +32,7 @@ Not everybody is on the same level of knowledge about the parser, compiler or ot ## Group work @@ -71,7 +71,7 @@ After every hard working day, we finished the day with a nice dinner. For instance, one day we gathered together at a viennese winery in the evening. @@ -86,7 +86,7 @@ After the retreat, most participants stated that they want to do it again and ov diff --git a/_blogposts/archive/2018-11-19-bucklescript-roadmap-q3-4-2018.mdx b/_blogposts/archive/2018-11-19-bucklescript-roadmap-q3-4-2018.mdx index 5cb04336c..a722d190b 100644 --- a/_blogposts/archive/2018-11-19-bucklescript-roadmap-q3-4-2018.mdx +++ b/_blogposts/archive/2018-11-19-bucklescript-roadmap-q3-4-2018.mdx @@ -63,7 +63,7 @@ style: as an JS dictionary for both global modules and local modules. BuckleScript is focused on making better use of JS ecosystem and provide values to ship JS code in production (produced by BuckleScript). - +{/* There are still bunch of things to address, most importantly */} #### Making Bucklescript toolchain more lightweight diff --git a/_blogposts/archive/2019-05-21-ffi-overview.mdx b/_blogposts/archive/2019-05-21-ffi-overview.mdx index 3ed0d7b8d..1a87663a7 100644 --- a/_blogposts/archive/2019-05-21-ffi-overview.mdx +++ b/_blogposts/archive/2019-05-21-ffi-overview.mdx @@ -191,4 +191,4 @@ setDate(date, 3); var d = getDate(date); ``` - +{/* , and provide various methods over such abstract data type. */} diff --git a/_blogposts/archive/2020-02-07-union-types-in-bucklescript.mdx b/_blogposts/archive/2020-02-07-union-types-in-bucklescript.mdx index 46cc7f6e6..0c8a5a034 100644 --- a/_blogposts/archive/2020-02-07-union-types-in-bucklescript.mdx +++ b/_blogposts/archive/2020-02-07-union-types-in-bucklescript.mdx @@ -77,7 +77,7 @@ module A_b_c: { }; ``` - +{/* Union types are useful for modeling situations when values can overlap in the types they can take on. */} What happens when we need to know specifically whether we have a value of type `a`? This is a case by case issue; it depends on whether there are some intersections in the runtime encoding of `a`, `b` or `c`. For some primitive types, it is easy enough to use `Js.typeof` to tell the difference between, e.g, `number` and `string`. diff --git a/_blogposts/archive/2020-02-20-loading-stdlib-in-memory.mdx b/_blogposts/archive/2020-02-20-loading-stdlib-in-memory.mdx index 640f5c135..9d05e901c 100644 --- a/_blogposts/archive/2020-02-20-loading-stdlib-in-memory.mdx +++ b/_blogposts/archive/2020-02-20-loading-stdlib-in-memory.mdx @@ -10,7 +10,7 @@ description: | ## Loading stdlib from memory - + // {/* Do you mean "external files" instead of "external file system"? In Linux world, a file system is means something like EXT4 or btrfs */} In the next release, we are going to load stdlib from memory instead of from external files, which will make the BuckleScript toolchain more accessible and @@ -61,7 +61,7 @@ file system. ## What are the benefits? - +{/* In the phrase "we can make it installable", what does "it" refer to? */} ### More accessiblity. @@ -71,7 +71,7 @@ subtle interaction with [yarn reinstall](https://github.com/BuckleScript/bucklescript/issues/2799) is also solved once and for all. - +{/* instead of "between compiler and stdlib version schemes", perhaps say "for aligning compiler and stdlib version schemes" */} ### Easy separation between compiler and JS artifacts @@ -89,9 +89,9 @@ now! Depending on your network speed, the installation is reduced from 15 seconds to 3 seconds. Reinstallation is almost a no-op now. - +{/* TODO: collect data points later */} - +{/* I'm not sure what you mean by "compiling a single file to a string" */} ### JS playground is easier to build diff --git a/_blogposts/archive/2020-05-06-state-of-reasonml-org-2020-q2-pt1.mdx b/_blogposts/archive/2020-05-06-state-of-reasonml-org-2020-q2-pt1.mdx index 85d4d830b..19b6e3181 100644 --- a/_blogposts/archive/2020-05-06-state-of-reasonml-org-2020-q2-pt1.mdx +++ b/_blogposts/archive/2020-05-06-state-of-reasonml-org-2020-q2-pt1.mdx @@ -1,16 +1,14 @@ --- author: ryyppy date: "2020-05-06" -previewImg: /static/blog/archive/state-of-reasonml-org-q2-2020.jpg -articleImg: /static/blog/archive/state-of-reasonml-pt1-hero.jpg +previewImg: /blog/archive/state-of-reasonml-org-q2-2020.jpg +articleImg: /blog/archive/state-of-reasonml-pt1-hero.jpg title: State of reasonml.org 2020-Q2 / Pt. 1 description: | A report on recent achievements in the reasonml.org project and what to expect in the future. The first part is an introduction to our project. --- -import Image from "src/components/Image"; - ## Hello World! We are happy to finally show off our brand new blog system for `reasonml.org`. It unifies all the previous articles from the different Reason, BuckleScript, and ReasonReact websites and also acts as a communication channel for community and documentation updates as well. diff --git a/_blogposts/archive/2020-05-11-state-of-reasonml-org-2020-q2-pt2.mdx b/_blogposts/archive/2020-05-11-state-of-reasonml-org-2020-q2-pt2.mdx index 67733aabb..9f6d68f76 100644 --- a/_blogposts/archive/2020-05-11-state-of-reasonml-org-2020-q2-pt2.mdx +++ b/_blogposts/archive/2020-05-11-state-of-reasonml-org-2020-q2-pt2.mdx @@ -1,8 +1,8 @@ --- author: ryyppy date: "2020-05-11" -previewImg: /static/blog/archive/state-of-reasonml-org-q2-2020.jpg -articleImg: /static/blog/archive/state-of-reasonml-2020-q2-pt2-articleimg.jpg +previewImg: /blog/archive/state-of-reasonml-org-q2-2020.jpg +articleImg: /blog/archive/state-of-reasonml-2020-q2-pt2-articleimg.jpg title: State of reasonml.org 2020-Q2 / Pt. 2 description: | A report on recent achievements in the reasonml.org project. This part is all diff --git a/_blogposts/archive/2020-05-12-state-of-reasonml-org-2020-q2-pt3.mdx b/_blogposts/archive/2020-05-12-state-of-reasonml-org-2020-q2-pt3.mdx index 3fdfcc66b..f179af421 100644 --- a/_blogposts/archive/2020-05-12-state-of-reasonml-org-2020-q2-pt3.mdx +++ b/_blogposts/archive/2020-05-12-state-of-reasonml-org-2020-q2-pt3.mdx @@ -1,15 +1,13 @@ --- author: ryyppy date: "2020-05-12" -previewImg: /static/blog/archive/state-of-reasonml-org-q2-2020.jpg +previewImg: /blog/archive/state-of-reasonml-org-q2-2020.jpg title: State of reasonml.org 2020-Q2 / Pt. 3 description: | A report on recent achievements in the reasonml.org project. In this part we talk about upcoming tools and features. --- -import Image from "src/components/Image"; - ## Future Tools for the Community In [part 2](/blog/state-of-reasonml-org-2020-q2-pt2) of this blog series, we talked about the automation process for quality assurance within the documentation platform itself, and how we want to improve the collaboration process for our contributors. diff --git a/_blogposts/archive/2020-05-15-state-of-reasonml-org-2020-q2-pt4.mdx b/_blogposts/archive/2020-05-15-state-of-reasonml-org-2020-q2-pt4.mdx index 4334541c4..5e40fc277 100644 --- a/_blogposts/archive/2020-05-15-state-of-reasonml-org-2020-q2-pt4.mdx +++ b/_blogposts/archive/2020-05-15-state-of-reasonml-org-2020-q2-pt4.mdx @@ -1,15 +1,13 @@ --- author: ryyppy date: "2020-05-15" -previewImg: /static/blog/archive/state-of-reasonml-org-q2-2020.jpg +previewImg: /blog/archive/state-of-reasonml-org-q2-2020.jpg title: State of reasonml.org 2020-Q2 / Pt. 4 description: | A report on recent achievements in the reasonml.org project. This is the final part of the series about our vision of a more accessible Reason platform. --- -import Image from "src/components/Image"; - ## It's all Opinions This is the final part of our "State of reasonml.org Q1-2020" series. In [part 3](/blog/state-of-reasonml-org-2020-q2-pt3), we gave our readers some insights on advanced features we've been working on for `reasonml.org` and showed how our tools might help the community to build better documentation experiences themselves. diff --git a/app/root.res b/app/root.res new file mode 100644 index 000000000..8726ab9a4 --- /dev/null +++ b/app/root.res @@ -0,0 +1,45 @@ +%%raw(` + import "../styles/main.css"; + import "../styles/_hljs.css"; + import "../styles/utils.css"; + + import hljs from 'highlight.js/lib/core'; + import bash from 'highlight.js/lib/languages/bash'; + import css from 'highlight.js/lib/languages/css'; + import diff from 'highlight.js/lib/languages/diff'; + import javascript from 'highlight.js/lib/languages/javascript'; + import json from 'highlight.js/lib/languages/json'; + import text from 'highlight.js/lib/languages/plaintext'; + import html from 'highlight.js/lib/languages/xml'; + import rescript from 'highlightjs-rescript'; + + hljs.registerLanguage('rescript', rescript) + hljs.registerLanguage('javascript', javascript) + hljs.registerLanguage('css', css) + hljs.registerLanguage('ts', javascript) + hljs.registerLanguage('sh', bash) + hljs.registerLanguage('json', json) + hljs.registerLanguage('text', text) + hljs.registerLanguage('html', html) + hljs.registerLanguage('diff', diff) +`) + +open ReactRouter + +@react.component +let default = () => { + let (isOverlayOpen, setOverlayOpen) = React.useState(_ => false) + + + + + + + + + + + + + +} diff --git a/app/root.resi b/app/root.resi new file mode 100644 index 000000000..aa3387f49 --- /dev/null +++ b/app/root.resi @@ -0,0 +1,2 @@ +@react.component +let default: unit => Jsx.element diff --git a/app/routes.mjs b/app/routes.mjs new file mode 100644 index 000000000..239e42a92 --- /dev/null +++ b/app/routes.mjs @@ -0,0 +1,55 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js"; +import * as Promises from "node:fs/promises"; +import * as Server from "react-router-mdx/server"; +import * as Routes from "@react-router/dev/routes"; + +let rawFile = await Promises.readFile("./docs/api/stdlib.json", "utf-8"); + +let json = JSON.parse(rawFile); + +let tmp; + +tmp = typeof json === "object" && json !== null && !Array.isArray(json) ? Object.keys(json) : []; + +let stdlibPaths = tmp.map(key => "docs/manual/api/" + key).filter(path => path !== "docs/manual/api/stdlib"); + +let stdlibRoutes = stdlibPaths.map(path => Routes.route(path, "./routes/ApiRoute.mjs", { + id: path +})); + +let $$default = Belt_Array.concatMany([ + [ + Routes.index("./routes/LandingPageRoute.mjs"), + Routes.route("packages", "./routes/PackagesRoute.mjs"), + Routes.route("try", "./routes/TryRoute.mjs"), + Routes.route("community", "./routes/CommunityRoute.mjs"), + Routes.route("community/overview", "./routes/CommunityRoute.mjs", { + id: "overview" + }), + Routes.route("syntax-lookup", "./routes/SyntaxLookupRoute.mjs"), + Routes.route("blog", "./routes/BlogRoute.mjs"), + Routes.route("docs/manual/api/stdlib", "./routes/ApiRoute.mjs", { + id: "api-stdlib" + }), + Routes.route("docs/manual/api/introduction", "./routes/ApiRoute.mjs", { + id: "api-intro" + }), + Routes.route("docs/manual/api/belt", "./routes/ApiRoute.mjs", { + id: "api-belt" + }), + Routes.route("docs/manual/api/dom", "./routes/ApiRoute.mjs", { + id: "api-dom" + }) + ], + stdlibRoutes, + Server.routes("./routes/MdxRoute.mjs") +]); + +export { + stdlibPaths, + stdlibRoutes, + $$default as default, +} +/* rawFile Not a pure module */ diff --git a/app/routes.res b/app/routes.res new file mode 100644 index 000000000..e3221bd1f --- /dev/null +++ b/app/routes.res @@ -0,0 +1,32 @@ +open ReactRouter.Routes +open ReactRouter.Mdx + +let stdlibPaths = { + let rawFile = await Node.Fs.readFile("./docs/api/stdlib.json", "utf-8") + let json = JSON.parseOrThrow(rawFile) + switch json { + | Object(json) => Dict.keysToArray(json) + | _ => [] + } + ->Array.map(key => "docs/manual/api/" ++ key) + ->Array.filter(path => path !== "docs/manual/api/stdlib") +} + +let stdlibRoutes = + stdlibPaths->Array.map(path => route(path, "./routes/ApiRoute.mjs", ~options={id: path})) + +let default = [ + index("./routes/LandingPageRoute.mjs"), + route("packages", "./routes/PackagesRoute.mjs"), + route("try", "./routes/TryRoute.mjs"), + route("community", "./routes/CommunityRoute.mjs"), + route("community/overview", "./routes/CommunityRoute.mjs", ~options={id: "overview"}), + route("syntax-lookup", "./routes/SyntaxLookupRoute.mjs"), + route("blog", "./routes/BlogRoute.mjs"), + route("docs/manual/api/stdlib", "./routes/ApiRoute.mjs", ~options={id: "api-stdlib"}), + route("docs/manual/api/introduction", "./routes/ApiRoute.mjs", ~options={id: "api-intro"}), + route("docs/manual/api/belt", "./routes/ApiRoute.mjs", ~options={id: "api-belt"}), + route("docs/manual/api/dom", "./routes/ApiRoute.mjs", ~options={id: "api-dom"}), + ...stdlibRoutes, + ...routes("./routes/MdxRoute.mjs"), +] diff --git a/app/routes/ApiRoute.res b/app/routes/ApiRoute.res new file mode 100644 index 000000000..4ee217228 --- /dev/null +++ b/app/routes/ApiRoute.res @@ -0,0 +1,62 @@ +type loaderData = ApiDocs.props + +type rec apiItem = { + id: string, + kind: string, + name: string, + items?: array, + docStrings: array, +} + +let rec rawApiItemToNode = (apiItem: apiItem): ApiDocs.node => { + { + name: apiItem.name, + path: apiItem.id + ->String.toLowerCase + ->String.split(".") + ->Array.filter(segment => segment !== "stdlib"), + children: apiItem.items->Option.map(Array.map(_, rawApiItemToNode))->Option.getOr([]), + } +} + +@scope("JSON") @val +external parseApi: string => Dict.t = "parse" + +let loader: ReactRouter.Loader.t = async args => { + let path = + WebAPI.URL.make(~url=args.request.url).pathname + ->String.replace("/docs/manual/api/", "") + ->String.split("/") + + let apiDocs = parseApi(await Node.Fs.readFile("./docs/api/stdlib.json", "utf-8")) + + let stdlibToc = apiDocs->Dict.get("stdlib") + + let toctree = + apiDocs + ->Dict.keysToArray + ->Array.map(key => Dict.getUnsafe(apiDocs, key)) + ->Array.map(rawApiItemToNode) + + let data = { + // TODO RR7: refactor this function to only return the module and not the toctree + // or move the toc logic to this function + await ApiDocs.getStaticProps(path) + } + + data["props"]->Result.map((item): ApiDocs.api => { + { + module_: item.module_, + toctree: { + name: "Stdlib", + path: [], + children: toctree, + }, + } + }) +} + +let default = () => { + let loaderData: loaderData = ReactRouter.useLoaderData() + +} diff --git a/app/routes/BlogRoute.res b/app/routes/BlogRoute.res new file mode 100644 index 000000000..c273b06ab --- /dev/null +++ b/app/routes/BlogRoute.res @@ -0,0 +1,4 @@ +@react.component +let default = () => { + React.string("Blog Route Placeholder") +} diff --git a/app/routes/CommunityRoute.res b/app/routes/CommunityRoute.res new file mode 100644 index 000000000..e8dd3c1cb --- /dev/null +++ b/app/routes/CommunityRoute.res @@ -0,0 +1,4 @@ +@react.component +let default = () => { + React.string("Community Route Placeholder") +} diff --git a/app/routes/LandingPageRoute.res b/app/routes/LandingPageRoute.res new file mode 100644 index 000000000..7180fbfe0 --- /dev/null +++ b/app/routes/LandingPageRoute.res @@ -0,0 +1,5 @@ +let default = () => { + + <> + +} diff --git a/app/routes/MdxRoute.res b/app/routes/MdxRoute.res new file mode 100644 index 000000000..c00662118 --- /dev/null +++ b/app/routes/MdxRoute.res @@ -0,0 +1,227 @@ +open ReactRouter +open Mdx + +type loaderData = { + ...Mdx.t, + categories: array, + entries: array, +} + +/** + This configures the MDX component to use our custom markdown components + */ +let components = { + // Replacing HTML defaults + "a": Markdown.A.make, + "blockquote": Markdown.Blockquote.make, + "code": Markdown.Code.make, + "h1": Markdown.H1.make, + "h2": Markdown.H2.make, + "h3": Markdown.H3.make, + "h4": Markdown.H4.make, + "h5": Markdown.H5.make, + "hr": Markdown.Hr.make, + "intro": Markdown.Intro.make, + "li": Markdown.Li.make, + "ol": Markdown.Ol.make, + "p": Markdown.P.make, + "pre": Markdown.Pre.make, + "strong": Markdown.Strong.make, + "table": Markdown.Table.make, + "th": Markdown.Th.make, + "thead": Markdown.Thead.make, + "td": Markdown.Td.make, + "ul": Markdown.Ul.make, + // These are custom components we provide + "Cite": Markdown.Cite.make, + "CodeTab": Markdown.CodeTab.make, + "Image": Markdown.Image.make, + "Info": Markdown.Info.make, + "Intro": Markdown.Intro.make, + "UrlBox": Markdown.UrlBox.make, + "Video": Markdown.Video.make, + "Warn": Markdown.Warn.make, +} + +// The loadAllMdx function logs out all of the file contents as it reads them, which is noisy and not useful. +// We can suppress that logging with this helper function. +let allMdx = await Shims.runWithoutLogging(() => loadAllMdx()) + +let sortSection = mdxPages => + Array.toSorted(mdxPages, (a: Mdx.attributes, b: Mdx.attributes) => + switch (a.order, b.order) { + | (Some(a), Some(b)) => a > b ? 1.0 : -1.0 + | _ => -1.0 + } + ) + +let groupBySection = mdxPages => + Array.reduce(mdxPages, (Dict.make() :> Dict.t>), (acc, item) => { + let section = item.section->Option.flatMap(Dict.get(acc, _)) + switch section { + // If the section already exists, add this item to it + | Some(section) => section->Array.push(item) + // otherwise create a new section with this item + | None => item.section->Option.forEach(section => acc->Dict.set(section, [item])) + } + acc + }) + +let convertToNavItems = (items, rootPath) => + Array.map(items, (item): SidebarLayout.Sidebar.NavItem.t => { + { + name: item.title, + href: `${rootPath}/${item.slug}`, + } + }) + +let filterMdxPages = (mdxPages, path) => + Array.filter(mdxPages, mdx => (mdx.path :> string)->String.includes(path)) + +let getGroup = (groups, groupName): SidebarLayout.Sidebar.Category.t => { + { + name: groupName, + items: groups + ->Dict.get(groupName) + ->Option.getOr([]), + } +} + +let getAllGroups = (groups, groupNames): array => + groupNames->Array.map(item => getGroup(groups, item)) + +// These are the pages for the language manual, sorted by their "order" field in the frontmatter +let manualTableOfContents = () => { + let groups = + allMdx + ->filterMdxPages("docs/manual") + ->groupBySection + ->Dict.mapValues(values => values->sortSection->convertToNavItems("/docs/manual")) + + // these are the categories that appear in the sidebar + let categories: array = getAllGroups( + groups, + [ + "Overview", + "Guides", + "Language Features", + "JavaScript Interop", + "Build System", + "Advanced Features", + ], + ) + + categories +} + +let reactTableOfContents = () => { + let groups = + allMdx + ->filterMdxPages("docs/react") + ->groupBySection + ->Dict.mapValues(values => values->sortSection->convertToNavItems("/docs/react")) + + // these are the categories that appear in the sidebar + let categories: array = getAllGroups( + groups, + ["Overview", "Main Concepts", "Hooks & State Management", "Guides", "Extra"], + ) + + categories +} + +let loader: Loader.t = async ({request}) => { + let {pathname} = WebAPI.URL.make(~url=request.url) + + let mdx = await loadMdx(request, ~options={remarkPlugins: [Mdx.gfm]}) + + // TODO: actually render the blog pages + if pathname->String.includes("blog") { + let res: loaderData = { + __raw: mdx.__raw, + attributes: mdx.attributes, + entries: [], + categories: [], + } + + res + } else { + let categories = { + if pathname == "/docs/manual/api" { + [] + } else if pathname->String.includes("docs/manual") { + manualTableOfContents() + } else if pathname->String.includes("docs/react") { + reactTableOfContents() + } else { + [] + } + } + + // TODO: this can be optionally called if we need markdown + // TODO: extract this out into a separate function + let fileContents = await allMdx + ->Array.filter(mdx => (mdx.path :> string)->String.includes(pathname)) + ->Array.get(0) + ->Option.map(mdx => mdx.path) + ->Option.map(path => Node.Fs.readFile((path :> string), "utf-8")) + ->Option.getOrThrow + + let markdownTree = Mdast.fromMarkdown(fileContents) + let tocResult = Mdast.toc(markdownTree, {maxDepth: 2}) + + let headers = Js.Dict.empty() + + Mdast.reduceHeaders(tocResult.map, headers) + + let entries = + headers + ->Dict.toArray + ->Array.map(((header, url)): TableOfContents.entry => { + header, + href: (url :> string), + }) + ->Array.slice(~start=2) // skip first two entries which are the document entry and the H1 title for the page, we just want the h2 sections + + let res: loaderData = { + __raw: mdx.__raw, + attributes: mdx.attributes, + entries, + categories, + } + + res + } +} + +let default = () => { + let {pathname} = useLocation() + let component = useMdxComponent(~components) + let attributes = useMdxAttributes() + + let {categories, entries} = useLoaderData() + + let metaTitleCategory = + (pathname :> string)->String.includes("docs/manual") + ? "ReScript Language Manual" + : "Some other page" + <> + {React.string(attributes.metaTitle->Option.getOr(attributes.title))} + Option.getOr("")} /> + {if (pathname :> string) == "/docs/manual/api" { + {component()} + } else if ( + (pathname :> string)->String.includes("docs/manual") || + (pathname :> string)->String.includes("docs/react") + ) { + +
{component()}
+
+ } else { + // TODO Handle blog pages + React.null + }} + + + // +} diff --git a/app/routes/MdxRoute.resi b/app/routes/MdxRoute.resi new file mode 100644 index 000000000..7d1a35c32 --- /dev/null +++ b/app/routes/MdxRoute.resi @@ -0,0 +1,10 @@ +open ReactRouter + +type loaderData = { + ...Mdx.t, + categories: array, + entries: array, +} + +let loader: ReactRouter.Loader.t +let default: unit => Jsx.element diff --git a/app/routes/PackagesRoute.res b/app/routes/PackagesRoute.res new file mode 100644 index 000000000..4420fa9e5 --- /dev/null +++ b/app/routes/PackagesRoute.res @@ -0,0 +1,3 @@ +let default = () => { + +} diff --git a/app/routes/SyntaxLookupRoute.res b/app/routes/SyntaxLookupRoute.res new file mode 100644 index 000000000..a55937b68 --- /dev/null +++ b/app/routes/SyntaxLookupRoute.res @@ -0,0 +1,4 @@ +let default = () => { + // TODO: RR7 implement syntax lookup page +
{React.string("This is the Syntax Lookup Route")}
+} diff --git a/app/routes/TryRoute.res b/app/routes/TryRoute.res new file mode 100644 index 000000000..fa2d741c9 --- /dev/null +++ b/app/routes/TryRoute.res @@ -0,0 +1,4 @@ +@react.component +let default = () => { +
+} diff --git a/compilers/dummy/Dummy.res b/compilers/dummy/Dummy.res index 216d35a7a..4992ee3d2 100644 --- a/compilers/dummy/Dummy.res +++ b/compilers/dummy/Dummy.res @@ -1 +1 @@ -Console.log("I am a dummy file") +Console.debug("I am a dummy file") diff --git a/data/api/v11.0.0/belt.json b/data/api/v11.0.0/belt.json deleted file mode 100644 index 745744e96..000000000 --- a/data/api/v11.0.0/belt.json +++ /dev/null @@ -1,9082 +0,0 @@ -{ - "belt": { - "id": "Belt", - "name": "Belt", - "docstrings": [ - "The ReScript standard library.\n\nBelt 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.\n\n## Motivation\n\nBelt provides:\n\n- The **highest quality** immutable data structures in JavaScript.\n- Safety by default: A Belt function will never throw exceptions, unless it is\n indicated explicitly in the function name (suffix \"Exn\").\n- Better performance and smaller code size running on the JS platform.\n- Ready for [Tree Shaking](https://webpack.js.org/guides/tree-shaking/).\n\n## Usage\n\nTo use modules from Belt, either refer to them by their fully qualified name (`Belt.List`, `Belt.Array` etc.) or open the `Belt` module by putting\n\n## Examples\n\n```rescript\nopen Belt\n```\n\nat the top of your source files. After opening Belt this way, `Array` will refer to `Belt.Array`, `List` will refer to `Belt.List` etc. in the subsequent code.\n\nIf you want to open Belt globally for all files in your project instead, you can put\n\n```json\n{\n \"bsc-flags\": [\"-open Belt\"]\n}\n```\n\ninto your `bsconfig.json`.\n\n**Note**: this is the **only** `open` we encourage.\n\nExample usage:\n\n## Examples\n\n```rescript\nlet someNumbers = [1, 1, 4, 2, 3, 6, 3, 4, 2]\n\nlet greaterThan2UniqueAndSorted =\n someNumbers\n ->Belt.Array.keep(x => x > 2)\n // convert to and from set to make values unique\n ->Belt.Set.Int.fromArray\n ->Belt.Set.Int.toArray // output is already sorted\n\nJs.log2(\"result\", greaterThan2UniqueAndSorted)\n```\n\n## Curried vs. Uncurried Callbacks\n\nFor functions taking a callback parameter, there are usually two versions\navailable:\n\n- curried (no suffix)\n- uncurried (suffixed with `U`)\n\nE.g.:\n\n## Examples\n\n```rescript\nlet forEach: (t<'a>, 'a => unit) => unit\n\nlet forEachU: (t<'a>, (. 'a) => unit) => unit\n```\n\nThe uncurried version will be faster in some cases, but for simplicity we recommend to stick with the curried version unless you need the extra performance.\n\nThe two versions can be invoked as follows:\n\n## Examples\n\n```rescript\n[\"a\", \"b\", \"c\"]->Belt.Array.forEach(x => Js.log(x))\n\n[\"a\", \"b\", \"c\"]->Belt.Array.forEachU((. x) => Js.log(x))\n```\n\n## Specialized Collections\n\nFor collections types like set or map, Belt provides both a generic module as well as specialized, more efficient implementations for string and int keys.\n\nFor example, Belt has the following set modules:\n\n- [Belt.Set](belt/set)\n- [Belt.Set.Int](belt/set/int)\n- [Belt.Set.String](belt/set/string)\n\n## Implementation Details\n\n### Array access runtime safety\n\nOne common confusion comes from the way Belt handles array access. It differs from than the default standard library's.\n\n## Examples\n\n```rescript\nlet letters = [\"a\", \"b\", \"c\"]\nlet a = letters[0] // a == \"a\"\nlet capitalA = Js.String.toUpperCase(a)\nlet k = letters[10] // Raises an exception! The 10th index doesn't exist.\n```\n\nBecause Belt avoids exceptions and returns `options` instead, this code behaves differently:\n\n## Examples\n\n```rescript\nopen Belt\nlet letters = [\"a\", \"b\", \"c\"]\nlet a = letters[0] // a == Some(\"a\")\nlet captialA = Js.String.toUpperCase(a) // Type error! This code will not compile.\nlet k = letters[10] // k == None\n```\n\nAlthough we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here:\n\n- Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`.\n- The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`.\n- `Belt.Array.get` returns values wrapped in options, so `letters[0] == Some(\"a\")`.\n\nFortunately, this is easy to fix:\n\n## Examples\n\n```rescript\nopen Belt\nlet letters = [\"a\", \"b\", \"c\"]\nlet a = letters[0]\n\n// Use a switch statement:\nlet capitalA =\n switch a {\n | Some(a) => Some(Js.String.toUpperCase(a))\n | None => None\n }\n\nlet k = letters[10] // k == None\n```\n\nWith that little bit of tweaking, our code now compiles successfully and is 100% free of runtime errors!\n\n### A Special Encoding for Collection Safety\n\nWhen we create a collection library for a custom data type we need a way to provide a comparator function. Take Set for example, suppose its element type is a pair of ints, it needs a custom compare function that takes two tuples and returns their order. The Set could not just be typed as Set.t (int \\* int) , its customized compare function needs to manifest itself in the signature, otherwise, if the user creates another customized compare function, the two collection could mix which would result in runtime error.\n\nWe use a phantom type to solve the problem:\n\n## Examples\n\n```rescript\nmodule Comparable1 =\n Belt.Id.MakeComparable(\n {\n type t = (int, int)\n let cmp = ((a0, a1), (b0, b1)) =>\n switch Pervasives.compare(a0, b0) {\n | 0 => Pervasives.compare(a1, b1)\n | c => c\n }\n }\n )\n\nlet mySet1 = Belt.Set.make(~id=module(Comparable1))\n\nmodule Comparable2 =\n Belt.Id.MakeComparable(\n {\n type t = (int, int)\n let cmp = ((a0, a1), (b0, b1)) =>\n switch Pervasives.compare(a0, b0) {\n | 0 => Pervasives.compare(a1, b1)\n | c => c\n }\n }\n )\n\nlet mySet2 = Belt.Set.make(~id=module(Comparable2))\n```\n\nHere, the compiler would infer `mySet1` and `mySet2` having different type, so e.g. a `merge` operation that tries to merge these two sets will correctly fail.\n\n## Examples\n\n```rescript\nlet mySet1: t<(int, int), Comparable1.identity>\nlet mySet2: t<(int, int), Comparable2.identity>\n```\n\n`Comparable1.identity` and `Comparable2.identity` are not the same using our encoding scheme." - ], - "items": [] - }, - "belt/hashmap/string": { - "id": "Belt.HashMap.String", - "name": "String", - "docstrings": [ - "Specalized when key type is `string`, more efficient than the generic type" - ], - "items": [ - { - "id": "Belt.HashMap.String.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = string" - }, - { - "id": "Belt.HashMap.String.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'b>" - }, - { - "id": "Belt.HashMap.String.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~hintSize: int) => t<'b>" - }, - { - "id": "Belt.HashMap.String.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t<'b> => unit" - }, - { - "id": "Belt.HashMap.String.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a> => bool" - }, - { - "id": "Belt.HashMap.String.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`setDone(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise,\nupdate the old value with the new `v`" - ], - "signature": "let set: (t<'a>, key, 'a) => unit" - }, - { - "id": "Belt.HashMap.String.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Belt.HashMap.String.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'a>, key) => option<'a>" - }, - { - "id": "Belt.HashMap.String.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'b>, key) => bool" - }, - { - "id": "Belt.HashMap.String.remove", - "kind": "value", - "name": "remove", - "docstrings": [], - "signature": "let remove: (t<'a>, key) => unit" - }, - { - "id": "Belt.HashMap.String.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'b>, (key, 'b) => unit) => unit" - }, - { - "id": "Belt.HashMap.String.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t<'b>, (key, 'b) => unit) => unit" - }, - { - "id": "Belt.HashMap.String.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c" - }, - { - "id": "Belt.HashMap.String.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c" - }, - { - "id": "Belt.HashMap.String.keepMapInPlaceU", - "kind": "value", - "name": "keepMapInPlaceU", - "docstrings": [], - "signature": "let keepMapInPlaceU: (t<'a>, (key, 'a) => option<'a>) => unit" - }, - { - "id": "Belt.HashMap.String.keepMapInPlace", - "kind": "value", - "name": "keepMapInPlace", - "docstrings": [], - "signature": "let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit" - }, - { - "id": "Belt.HashMap.String.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.HashMap.String.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t<'a> => array<(key, 'a)>" - }, - { - "id": "Belt.HashMap.String.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'a> => array" - }, - { - "id": "Belt.HashMap.String.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'a> => array<'a>" - }, - { - "id": "Belt.HashMap.String.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array<(key, 'a)> => t<'a>" - }, - { - "id": "Belt.HashMap.String.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t<'a>, array<(key, 'a)>) => unit" - }, - { - "id": "Belt.HashMap.String.getBucketHistogram", - "kind": "value", - "name": "getBucketHistogram", - "docstrings": [], - "signature": "let getBucketHistogram: t<'a> => array" - }, - { - "id": "Belt.HashMap.String.logStats", - "kind": "value", - "name": "logStats", - "docstrings": [], - "signature": "let logStats: t<'a> => unit" - } - ] - }, - "belt/hashmap/int": { - "id": "Belt.HashMap.Int", - "name": "Int", - "docstrings": [ - "Specalized when key type is `int`, more efficient than the generic type" - ], - "items": [ - { - "id": "Belt.HashMap.Int.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = int" - }, - { - "id": "Belt.HashMap.Int.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'b>" - }, - { - "id": "Belt.HashMap.Int.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~hintSize: int) => t<'b>" - }, - { - "id": "Belt.HashMap.Int.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t<'b> => unit" - }, - { - "id": "Belt.HashMap.Int.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a> => bool" - }, - { - "id": "Belt.HashMap.Int.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`setDone(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise,\nupdate the old value with the new `v`" - ], - "signature": "let set: (t<'a>, key, 'a) => unit" - }, - { - "id": "Belt.HashMap.Int.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Belt.HashMap.Int.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'a>, key) => option<'a>" - }, - { - "id": "Belt.HashMap.Int.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'b>, key) => bool" - }, - { - "id": "Belt.HashMap.Int.remove", - "kind": "value", - "name": "remove", - "docstrings": [], - "signature": "let remove: (t<'a>, key) => unit" - }, - { - "id": "Belt.HashMap.Int.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'b>, (key, 'b) => unit) => unit" - }, - { - "id": "Belt.HashMap.Int.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t<'b>, (key, 'b) => unit) => unit" - }, - { - "id": "Belt.HashMap.Int.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c" - }, - { - "id": "Belt.HashMap.Int.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c" - }, - { - "id": "Belt.HashMap.Int.keepMapInPlaceU", - "kind": "value", - "name": "keepMapInPlaceU", - "docstrings": [], - "signature": "let keepMapInPlaceU: (t<'a>, (key, 'a) => option<'a>) => unit" - }, - { - "id": "Belt.HashMap.Int.keepMapInPlace", - "kind": "value", - "name": "keepMapInPlace", - "docstrings": [], - "signature": "let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit" - }, - { - "id": "Belt.HashMap.Int.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.HashMap.Int.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t<'a> => array<(key, 'a)>" - }, - { - "id": "Belt.HashMap.Int.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'a> => array" - }, - { - "id": "Belt.HashMap.Int.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'a> => array<'a>" - }, - { - "id": "Belt.HashMap.Int.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array<(key, 'a)> => t<'a>" - }, - { - "id": "Belt.HashMap.Int.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t<'a>, array<(key, 'a)>) => unit" - }, - { - "id": "Belt.HashMap.Int.getBucketHistogram", - "kind": "value", - "name": "getBucketHistogram", - "docstrings": [], - "signature": "let getBucketHistogram: t<'a> => array" - }, - { - "id": "Belt.HashMap.Int.logStats", - "kind": "value", - "name": "logStats", - "docstrings": [], - "signature": "let logStats: t<'a> => unit" - } - ] - }, - "belt/hashset/string": { - "id": "Belt.HashSet.String", - "name": "String", - "docstrings": [ - "Specalized when key type is `string`, more efficient than the generic type", - "This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.\n\nIt is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,\nand identity is not needed(using the built-in one)\n\n**See** [`Belt.HashSet`]()" - ], - "items": [ - { - "id": "Belt.HashSet.String.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = string" - }, - { - "id": "Belt.HashSet.String.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Belt.HashSet.String.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~hintSize: int) => t" - }, - { - "id": "Belt.HashSet.String.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t => unit" - }, - { - "id": "Belt.HashSet.String.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t => bool" - }, - { - "id": "Belt.HashSet.String.add", - "kind": "value", - "name": "add", - "docstrings": [], - "signature": "let add: (t, key) => unit" - }, - { - "id": "Belt.HashSet.String.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Belt.HashSet.String.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t, key) => bool" - }, - { - "id": "Belt.HashSet.String.remove", - "kind": "value", - "name": "remove", - "docstrings": [], - "signature": "let remove: (t, key) => unit" - }, - { - "id": "Belt.HashSet.String.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t, key => unit) => unit" - }, - { - "id": "Belt.HashSet.String.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, key => unit) => unit" - }, - { - "id": "Belt.HashSet.String.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t, 'c, ('c, key) => 'c) => 'c" - }, - { - "id": "Belt.HashSet.String.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, 'c, ('c, key) => 'c) => 'c" - }, - { - "id": "Belt.HashSet.String.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t => int" - }, - { - "id": "Belt.HashSet.String.logStats", - "kind": "value", - "name": "logStats", - "docstrings": [], - "signature": "let logStats: t => unit" - }, - { - "id": "Belt.HashSet.String.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t => array" - }, - { - "id": "Belt.HashSet.String.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array => t" - }, - { - "id": "Belt.HashSet.String.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t, array) => unit" - }, - { - "id": "Belt.HashSet.String.getBucketHistogram", - "kind": "value", - "name": "getBucketHistogram", - "docstrings": [], - "signature": "let getBucketHistogram: t => array" - } - ] - }, - "belt/hashset/int": { - "id": "Belt.HashSet.Int", - "name": "Int", - "docstrings": [ - "Specalized when key type is `int`, more efficient than the generic type", - "This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.\n\nIt is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,\nand identity is not needed(using the built-in one)\n\n**See** [`Belt.HashSet`]()" - ], - "items": [ - { - "id": "Belt.HashSet.Int.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = int" - }, - { - "id": "Belt.HashSet.Int.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Belt.HashSet.Int.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~hintSize: int) => t" - }, - { - "id": "Belt.HashSet.Int.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t => unit" - }, - { - "id": "Belt.HashSet.Int.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t => bool" - }, - { - "id": "Belt.HashSet.Int.add", - "kind": "value", - "name": "add", - "docstrings": [], - "signature": "let add: (t, key) => unit" - }, - { - "id": "Belt.HashSet.Int.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Belt.HashSet.Int.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t, key) => bool" - }, - { - "id": "Belt.HashSet.Int.remove", - "kind": "value", - "name": "remove", - "docstrings": [], - "signature": "let remove: (t, key) => unit" - }, - { - "id": "Belt.HashSet.Int.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t, key => unit) => unit" - }, - { - "id": "Belt.HashSet.Int.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, key => unit) => unit" - }, - { - "id": "Belt.HashSet.Int.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t, 'c, ('c, key) => 'c) => 'c" - }, - { - "id": "Belt.HashSet.Int.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, 'c, ('c, key) => 'c) => 'c" - }, - { - "id": "Belt.HashSet.Int.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t => int" - }, - { - "id": "Belt.HashSet.Int.logStats", - "kind": "value", - "name": "logStats", - "docstrings": [], - "signature": "let logStats: t => unit" - }, - { - "id": "Belt.HashSet.Int.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t => array" - }, - { - "id": "Belt.HashSet.Int.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array => t" - }, - { - "id": "Belt.HashSet.Int.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t, array) => unit" - }, - { - "id": "Belt.HashSet.Int.getBucketHistogram", - "kind": "value", - "name": "getBucketHistogram", - "docstrings": [], - "signature": "let getBucketHistogram: t => array" - } - ] - }, - "belt/mutablemap/string": { - "id": "Belt.MutableMap.String", - "name": "String", - "docstrings": [], - "items": [ - { - "id": "Belt.MutableMap.String.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = string" - }, - { - "id": "Belt.MutableMap.String.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a>" - }, - { - "id": "Belt.MutableMap.String.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: unit => t<'a>" - }, - { - "id": "Belt.MutableMap.String.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t<'a> => unit" - }, - { - "id": "Belt.MutableMap.String.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a> => bool" - }, - { - "id": "Belt.MutableMap.String.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'a>, key) => bool" - }, - { - "id": "Belt.MutableMap.String.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.MutableMap.String.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "`cmp(m1, m2, cmp)`. First compare by size, if size is the same, compare by key,\nvalue pair" - ], - "signature": "let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.MutableMap.String.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.String.eq", - "kind": "value", - "name": "eq", - "docstrings": ["`eq(m1, m2, cmp)`"], - "signature": "let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.String.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'a>, (key, 'a) => unit) => unit" - }, - { - "id": "Belt.MutableMap.String.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as\nfirst argument, and the associated value as second argument. The application \norder of `f` is in increasing order." - ], - "signature": "let forEach: (t<'a>, (key, 'a) => unit) => unit" - }, - { - "id": "Belt.MutableMap.String.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableMap.String.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`, where `k1 ... kN` are\nthe keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the\nassociated data." - ], - "signature": "let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableMap.String.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.String.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`.\nThe application order of `p` is unspecified." - ], - "signature": "let every: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.String.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.String.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`.\nThe application order of `p` is unspecified." - ], - "signature": "let some: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.String.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.MutableMap.String.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order"], - "signature": "let toList: t<'a> => list<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.String.toArray", - "kind": "value", - "name": "toArray", - "docstrings": ["In increasing order"], - "signature": "let toArray: t<'a> => array<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.String.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array<(key, 'a)> => t<'a>" - }, - { - "id": "Belt.MutableMap.String.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'a> => array" - }, - { - "id": "Belt.MutableMap.String.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'a> => array<'a>" - }, - { - "id": "Belt.MutableMap.String.minKey", - "kind": "value", - "name": "minKey", - "docstrings": [], - "signature": "let minKey: t<'a> => option" - }, - { - "id": "Belt.MutableMap.String.minKeyUndefined", - "kind": "value", - "name": "minKeyUndefined", - "docstrings": [], - "signature": "let minKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.MutableMap.String.maxKey", - "kind": "value", - "name": "maxKey", - "docstrings": [], - "signature": "let maxKey: t<'a> => option" - }, - { - "id": "Belt.MutableMap.String.maxKeyUndefined", - "kind": "value", - "name": "maxKeyUndefined", - "docstrings": [], - "signature": "let maxKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.MutableMap.String.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t<'a> => option<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.String.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t<'a> => Js.undefined<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.String.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t<'a> => option<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.String.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t<'a> => Js.undefined<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.String.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'a>, key) => option<'a>" - }, - { - "id": "Belt.MutableMap.String.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t<'a>, key) => Js.undefined<'a>" - }, - { - "id": "Belt.MutableMap.String.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'a>, key, 'a) => 'a" - }, - { - "id": "Belt.MutableMap.String.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t<'a>, key) => 'a" - }, - { - "id": "Belt.MutableMap.String.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a> => unit" - }, - { - "id": "Belt.MutableMap.String.remove", - "kind": "value", - "name": "remove", - "docstrings": ["`remove(m, x)` do the in-place modification"], - "signature": "let remove: (t<'a>, key) => unit" - }, - { - "id": "Belt.MutableMap.String.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t<'a>, array) => unit" - }, - { - "id": "Belt.MutableMap.String.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was\nalready bound in `m`, its previous binding disappears." - ], - "signature": "let set: (t<'a>, key, 'a) => unit" - }, - { - "id": "Belt.MutableMap.String.updateU", - "kind": "value", - "name": "updateU", - "docstrings": [], - "signature": "let updateU: (t<'a>, key, option<'a> => option<'a>) => unit" - }, - { - "id": "Belt.MutableMap.String.update", - "kind": "value", - "name": "update", - "docstrings": [], - "signature": "let update: (t<'a>, key, option<'a> => option<'a>) => unit" - }, - { - "id": "Belt.MutableMap.String.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.MutableMap.String.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(m, f)` returns a map with same domain as `m`, where the associated value `a`\nof all bindings of `m` has been replaced by the result of the application of `f`\nto `a`. The bindings are passed to `f` in increasing order with respect to the\nordering over the type of the keys." - ], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.MutableMap.String.mapWithKeyU", - "kind": "value", - "name": "mapWithKeyU", - "docstrings": [], - "signature": "let mapWithKeyU: (t<'a>, (key, 'a) => 'b) => t<'b>" - }, - { - "id": "Belt.MutableMap.String.mapWithKey", - "kind": "value", - "name": "mapWithKey", - "docstrings": [], - "signature": "let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b>" - } - ] - }, - "belt/mutablemap/int": { - "id": "Belt.MutableMap.Int", - "name": "Int", - "docstrings": [], - "items": [ - { - "id": "Belt.MutableMap.Int.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = int" - }, - { - "id": "Belt.MutableMap.Int.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a>" - }, - { - "id": "Belt.MutableMap.Int.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: unit => t<'a>" - }, - { - "id": "Belt.MutableMap.Int.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t<'a> => unit" - }, - { - "id": "Belt.MutableMap.Int.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a> => bool" - }, - { - "id": "Belt.MutableMap.Int.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'a>, key) => bool" - }, - { - "id": "Belt.MutableMap.Int.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.MutableMap.Int.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "`cmp(m1, m2, cmp)`. First compare by size, if size is the same, compare by key,\nvalue pair" - ], - "signature": "let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.MutableMap.Int.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.Int.eq", - "kind": "value", - "name": "eq", - "docstrings": ["`eq(m1, m2, cmp)`"], - "signature": "let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.Int.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'a>, (key, 'a) => unit) => unit" - }, - { - "id": "Belt.MutableMap.Int.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as\nfirst argument, and the associated value as second argument. The application \norder of `f` is in increasing order." - ], - "signature": "let forEach: (t<'a>, (key, 'a) => unit) => unit" - }, - { - "id": "Belt.MutableMap.Int.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableMap.Int.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`, where `k1 ... kN` are\nthe keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the\nassociated data." - ], - "signature": "let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableMap.Int.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.Int.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`.\nThe application order of `p` is unspecified." - ], - "signature": "let every: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.Int.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.Int.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`.\nThe application order of `p` is unspecified." - ], - "signature": "let some: (t<'a>, (key, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.Int.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.MutableMap.Int.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order"], - "signature": "let toList: t<'a> => list<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.Int.toArray", - "kind": "value", - "name": "toArray", - "docstrings": ["In increasing order"], - "signature": "let toArray: t<'a> => array<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.Int.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array<(key, 'a)> => t<'a>" - }, - { - "id": "Belt.MutableMap.Int.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'a> => array" - }, - { - "id": "Belt.MutableMap.Int.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'a> => array<'a>" - }, - { - "id": "Belt.MutableMap.Int.minKey", - "kind": "value", - "name": "minKey", - "docstrings": [], - "signature": "let minKey: t<'a> => option" - }, - { - "id": "Belt.MutableMap.Int.minKeyUndefined", - "kind": "value", - "name": "minKeyUndefined", - "docstrings": [], - "signature": "let minKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.MutableMap.Int.maxKey", - "kind": "value", - "name": "maxKey", - "docstrings": [], - "signature": "let maxKey: t<'a> => option" - }, - { - "id": "Belt.MutableMap.Int.maxKeyUndefined", - "kind": "value", - "name": "maxKeyUndefined", - "docstrings": [], - "signature": "let maxKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.MutableMap.Int.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t<'a> => option<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.Int.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t<'a> => Js.undefined<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.Int.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t<'a> => option<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.Int.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t<'a> => Js.undefined<(key, 'a)>" - }, - { - "id": "Belt.MutableMap.Int.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'a>, key) => option<'a>" - }, - { - "id": "Belt.MutableMap.Int.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t<'a>, key) => Js.undefined<'a>" - }, - { - "id": "Belt.MutableMap.Int.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'a>, key, 'a) => 'a" - }, - { - "id": "Belt.MutableMap.Int.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t<'a>, key) => 'a" - }, - { - "id": "Belt.MutableMap.Int.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a> => unit" - }, - { - "id": "Belt.MutableMap.Int.remove", - "kind": "value", - "name": "remove", - "docstrings": ["`remove(m, x)` do the in-place modification"], - "signature": "let remove: (t<'a>, key) => unit" - }, - { - "id": "Belt.MutableMap.Int.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t<'a>, array) => unit" - }, - { - "id": "Belt.MutableMap.Int.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was\nalready bound in `m`, its previous binding disappears." - ], - "signature": "let set: (t<'a>, key, 'a) => unit" - }, - { - "id": "Belt.MutableMap.Int.updateU", - "kind": "value", - "name": "updateU", - "docstrings": [], - "signature": "let updateU: (t<'a>, key, option<'a> => option<'a>) => unit" - }, - { - "id": "Belt.MutableMap.Int.update", - "kind": "value", - "name": "update", - "docstrings": [], - "signature": "let update: (t<'a>, key, option<'a> => option<'a>) => unit" - }, - { - "id": "Belt.MutableMap.Int.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.MutableMap.Int.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(m, f)` returns a map with same domain as `m`, where the associated value `a`\nof all bindings of `m` has been replaced by the result of the application of `f`\nto `a`. The bindings are passed to `f` in increasing order with respect to the\nordering over the type of the keys." - ], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.MutableMap.Int.mapWithKeyU", - "kind": "value", - "name": "mapWithKeyU", - "docstrings": [], - "signature": "let mapWithKeyU: (t<'a>, (key, 'a) => 'b) => t<'b>" - }, - { - "id": "Belt.MutableMap.Int.mapWithKey", - "kind": "value", - "name": "mapWithKey", - "docstrings": [], - "signature": "let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b>" - } - ] - }, - "belt/mutableset/string": { - "id": "Belt.MutableSet.String", - "name": "String", - "docstrings": [ - "Specialized when key type is `string`, more efficient than the generic type", - "This module is [`Belt.MutableSet`]() specialized with key type to be a primitive type.\n\nIt is more efficient in general, the API is the same with [`Belt.MutableSet`]() except its key type is fixed,\nand identity is not needed(using the built-in one)\n\n**See** [`Belt.MutableSet`]()" - ], - "items": [ - { - "id": "Belt.MutableSet.String.value", - "kind": "type", - "name": "value", - "docstrings": ["The type of the set elements."], - "signature": "type value = string" - }, - { - "id": "Belt.MutableSet.String.t", - "kind": "type", - "name": "t", - "docstrings": ["The type of sets."], - "signature": "type t" - }, - { - "id": "Belt.MutableSet.String.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: unit => t" - }, - { - "id": "Belt.MutableSet.String.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array => t" - }, - { - "id": "Belt.MutableSet.String.fromSortedArrayUnsafe", - "kind": "value", - "name": "fromSortedArrayUnsafe", - "docstrings": [], - "signature": "let fromSortedArrayUnsafe: array => t" - }, - { - "id": "Belt.MutableSet.String.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Belt.MutableSet.String.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t => bool" - }, - { - "id": "Belt.MutableSet.String.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t, value) => bool" - }, - { - "id": "Belt.MutableSet.String.add", - "kind": "value", - "name": "add", - "docstrings": [], - "signature": "let add: (t, value) => unit" - }, - { - "id": "Belt.MutableSet.String.addCheck", - "kind": "value", - "name": "addCheck", - "docstrings": [], - "signature": "let addCheck: (t, value) => bool" - }, - { - "id": "Belt.MutableSet.String.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t, array) => unit" - }, - { - "id": "Belt.MutableSet.String.remove", - "kind": "value", - "name": "remove", - "docstrings": [], - "signature": "let remove: (t, value) => unit" - }, - { - "id": "Belt.MutableSet.String.removeCheck", - "kind": "value", - "name": "removeCheck", - "docstrings": [], - "signature": "let removeCheck: (t, value) => bool" - }, - { - "id": "Belt.MutableSet.String.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t, array) => unit" - }, - { - "id": "Belt.MutableSet.String.union", - "kind": "value", - "name": "union", - "docstrings": [], - "signature": "let union: (t, t) => t" - }, - { - "id": "Belt.MutableSet.String.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [], - "signature": "let intersect: (t, t) => t" - }, - { - "id": "Belt.MutableSet.String.diff", - "kind": "value", - "name": "diff", - "docstrings": [], - "signature": "let diff: (t, t) => t" - }, - { - "id": "Belt.MutableSet.String.subset", - "kind": "value", - "name": "subset", - "docstrings": [], - "signature": "let subset: (t, t) => bool" - }, - { - "id": "Belt.MutableSet.String.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [], - "signature": "let cmp: (t, t) => int" - }, - { - "id": "Belt.MutableSet.String.eq", - "kind": "value", - "name": "eq", - "docstrings": [], - "signature": "let eq: (t, t) => bool" - }, - { - "id": "Belt.MutableSet.String.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t, value => unit) => unit" - }, - { - "id": "Belt.MutableSet.String.forEach", - "kind": "value", - "name": "forEach", - "docstrings": ["In increasing order"], - "signature": "let forEach: (t, value => unit) => unit" - }, - { - "id": "Belt.MutableSet.String.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.MutableSet.String.reduce", - "kind": "value", - "name": "reduce", - "docstrings": ["Iterate in increasing order."], - "signature": "let reduce: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.MutableSet.String.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.String.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(p, s)` checks if all elements of the set satisfy the predicate `p`.\nOrder unspecified." - ], - "signature": "let every: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.String.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.String.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(p, s)` checks if at least one element of the set satisfies the predicate\n`p`. Oder unspecified." - ], - "signature": "let some: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.String.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t, value => bool) => t" - }, - { - "id": "Belt.MutableSet.String.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(s, p)` returns a fresh copy of the set of all elements in `s` that satisfy\npredicate `p`." - ], - "signature": "let keep: (t, value => bool) => t" - }, - { - "id": "Belt.MutableSet.String.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.MutableSet.String.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(s, p)` returns a fresh copy pair of sets `(s1, s2)`, where `s1` is\nthe set of all the elements of `s` that satisfy the predicate `p`, and `s2` is\nthe set of all the elements of `s` that do not satisfy `p`." - ], - "signature": "let partition: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.MutableSet.String.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t => int" - }, - { - "id": "Belt.MutableSet.String.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order with respect"], - "signature": "let toList: t => list" - }, - { - "id": "Belt.MutableSet.String.toArray", - "kind": "value", - "name": "toArray", - "docstrings": ["In increasing order with respect"], - "signature": "let toArray: t => array" - }, - { - "id": "Belt.MutableSet.String.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t => option" - }, - { - "id": "Belt.MutableSet.String.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t => Js.undefined" - }, - { - "id": "Belt.MutableSet.String.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t => option" - }, - { - "id": "Belt.MutableSet.String.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t => Js.undefined" - }, - { - "id": "Belt.MutableSet.String.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t, value) => option" - }, - { - "id": "Belt.MutableSet.String.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t, value) => Js.undefined" - }, - { - "id": "Belt.MutableSet.String.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t, value) => value" - }, - { - "id": "Belt.MutableSet.String.split", - "kind": "value", - "name": "split", - "docstrings": ["`split(s, key)` return a fresh copy of each"], - "signature": "let split: (t, value) => ((t, t), bool)" - }, - { - "id": "Belt.MutableSet.String.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t => unit" - } - ] - }, - "belt/mutableset/int": { - "id": "Belt.MutableSet.Int", - "name": "Int", - "docstrings": [ - "Specialized when key type is `int`, more efficient than the generic type", - "This module is [`Belt.MutableSet`]() specialized with key type to be a primitive type.\n\nIt is more efficient in general, the API is the same with [`Belt.MutableSet`]() except its key type is fixed,\nand identity is not needed(using the built-in one)\n\n**See** [`Belt.MutableSet`]()" - ], - "items": [ - { - "id": "Belt.MutableSet.Int.value", - "kind": "type", - "name": "value", - "docstrings": ["The type of the set elements."], - "signature": "type value = int" - }, - { - "id": "Belt.MutableSet.Int.t", - "kind": "type", - "name": "t", - "docstrings": ["The type of sets."], - "signature": "type t" - }, - { - "id": "Belt.MutableSet.Int.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: unit => t" - }, - { - "id": "Belt.MutableSet.Int.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array => t" - }, - { - "id": "Belt.MutableSet.Int.fromSortedArrayUnsafe", - "kind": "value", - "name": "fromSortedArrayUnsafe", - "docstrings": [], - "signature": "let fromSortedArrayUnsafe: array => t" - }, - { - "id": "Belt.MutableSet.Int.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Belt.MutableSet.Int.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t => bool" - }, - { - "id": "Belt.MutableSet.Int.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t, value) => bool" - }, - { - "id": "Belt.MutableSet.Int.add", - "kind": "value", - "name": "add", - "docstrings": [], - "signature": "let add: (t, value) => unit" - }, - { - "id": "Belt.MutableSet.Int.addCheck", - "kind": "value", - "name": "addCheck", - "docstrings": [], - "signature": "let addCheck: (t, value) => bool" - }, - { - "id": "Belt.MutableSet.Int.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t, array) => unit" - }, - { - "id": "Belt.MutableSet.Int.remove", - "kind": "value", - "name": "remove", - "docstrings": [], - "signature": "let remove: (t, value) => unit" - }, - { - "id": "Belt.MutableSet.Int.removeCheck", - "kind": "value", - "name": "removeCheck", - "docstrings": [], - "signature": "let removeCheck: (t, value) => bool" - }, - { - "id": "Belt.MutableSet.Int.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t, array) => unit" - }, - { - "id": "Belt.MutableSet.Int.union", - "kind": "value", - "name": "union", - "docstrings": [], - "signature": "let union: (t, t) => t" - }, - { - "id": "Belt.MutableSet.Int.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [], - "signature": "let intersect: (t, t) => t" - }, - { - "id": "Belt.MutableSet.Int.diff", - "kind": "value", - "name": "diff", - "docstrings": [], - "signature": "let diff: (t, t) => t" - }, - { - "id": "Belt.MutableSet.Int.subset", - "kind": "value", - "name": "subset", - "docstrings": [], - "signature": "let subset: (t, t) => bool" - }, - { - "id": "Belt.MutableSet.Int.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [], - "signature": "let cmp: (t, t) => int" - }, - { - "id": "Belt.MutableSet.Int.eq", - "kind": "value", - "name": "eq", - "docstrings": [], - "signature": "let eq: (t, t) => bool" - }, - { - "id": "Belt.MutableSet.Int.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t, value => unit) => unit" - }, - { - "id": "Belt.MutableSet.Int.forEach", - "kind": "value", - "name": "forEach", - "docstrings": ["In increasing order"], - "signature": "let forEach: (t, value => unit) => unit" - }, - { - "id": "Belt.MutableSet.Int.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.MutableSet.Int.reduce", - "kind": "value", - "name": "reduce", - "docstrings": ["Iterate in increasing order."], - "signature": "let reduce: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.MutableSet.Int.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.Int.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(p, s)` checks if all elements of the set satisfy the predicate `p`.\nOrder unspecified." - ], - "signature": "let every: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.Int.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.Int.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(p, s)` checks if at least one element of the set satisfies the predicate\n`p`. Oder unspecified." - ], - "signature": "let some: (t, value => bool) => bool" - }, - { - "id": "Belt.MutableSet.Int.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t, value => bool) => t" - }, - { - "id": "Belt.MutableSet.Int.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(s, p)` returns a fresh copy of the set of all elements in `s` that satisfy\npredicate `p`." - ], - "signature": "let keep: (t, value => bool) => t" - }, - { - "id": "Belt.MutableSet.Int.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.MutableSet.Int.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(s, p)` returns a fresh copy pair of sets `(s1, s2)`, where `s1` is\nthe set of all the elements of `s` that satisfy the predicate `p`, and `s2` is\nthe set of all the elements of `s` that do not satisfy `p`." - ], - "signature": "let partition: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.MutableSet.Int.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t => int" - }, - { - "id": "Belt.MutableSet.Int.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order with respect"], - "signature": "let toList: t => list" - }, - { - "id": "Belt.MutableSet.Int.toArray", - "kind": "value", - "name": "toArray", - "docstrings": ["In increasing order with respect"], - "signature": "let toArray: t => array" - }, - { - "id": "Belt.MutableSet.Int.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t => option" - }, - { - "id": "Belt.MutableSet.Int.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t => Js.undefined" - }, - { - "id": "Belt.MutableSet.Int.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t => option" - }, - { - "id": "Belt.MutableSet.Int.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t => Js.undefined" - }, - { - "id": "Belt.MutableSet.Int.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t, value) => option" - }, - { - "id": "Belt.MutableSet.Int.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t, value) => Js.undefined" - }, - { - "id": "Belt.MutableSet.Int.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t, value) => value" - }, - { - "id": "Belt.MutableSet.Int.split", - "kind": "value", - "name": "split", - "docstrings": ["`split(s, key)` return a fresh copy of each"], - "signature": "let split: (t, value) => ((t, t), bool)" - }, - { - "id": "Belt.MutableSet.Int.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t => unit" - } - ] - }, - "belt/map/dict": { - "id": "Belt.Map.Dict", - "name": "Dict", - "docstrings": [ - "This module separates identity from data, it is a bit more verbose but\nslightly more efficient due to the fact that there is no need to pack\nidentity and data back after each operation.\n\n**_Advanced usage only_**" - ], - "items": [ - { - "id": "Belt.Map.Dict.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'key, 'value, 'id>" - }, - { - "id": "Belt.Map.Dict.cmp", - "kind": "type", - "name": "cmp", - "docstrings": [], - "signature": "type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id>" - }, - { - "id": "Belt.Map.Dict.empty", - "kind": "value", - "name": "empty", - "docstrings": [], - "signature": "let empty: t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.Dict.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'k, 'v, 'id> => bool" - }, - { - "id": "Belt.Map.Dict.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => bool" - }, - { - "id": "Belt.Map.Dict.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (\n t<'k, 'v, 'id>,\n t<'k, 'v, 'id>,\n ~kcmp: cmp<'k, 'id>,\n ~vcmp: ('v, 'v) => int,\n) => int" - }, - { - "id": "Belt.Map.Dict.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [], - "signature": "let cmp: (\n t<'k, 'v, 'id>,\n t<'k, 'v, 'id>,\n ~kcmp: cmp<'k, 'id>,\n ~vcmp: ('v, 'v) => int,\n) => int" - }, - { - "id": "Belt.Map.Dict.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (\n t<'k, 'a, 'id>,\n t<'k, 'a, 'id>,\n ~kcmp: cmp<'k, 'id>,\n ~veq: ('a, 'a) => bool,\n) => bool" - }, - { - "id": "Belt.Map.Dict.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(m1, m2, cmp)` tests whether the maps `m1` and `m2` are equal, that is,\ncontain equal keys and associate them with equal data. `cmp` is the\nequality predicate used to compare the data associated with the keys." - ], - "signature": "let eq: (\n t<'k, 'a, 'id>,\n t<'k, 'a, 'id>,\n ~kcmp: cmp<'k, 'id>,\n ~veq: ('a, 'a) => bool,\n) => bool" - }, - { - "id": "Belt.Map.Dict.findFirstByU", - "kind": "value", - "name": "findFirstByU", - "docstrings": [], - "signature": "let findFirstByU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)>" - }, - { - "id": "Belt.Map.Dict.findFirstBy", - "kind": "value", - "name": "findFirstBy", - "docstrings": [ - "`findFirstBy(m, p)` uses function `f` to find the first key value pair to\nmatch predicate `p`.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Map.Dict.fromArray([(4, \"4\"), (1, \"1\"), (2, \"2\"), (3, \"3\")], ~cmp=IntCmp.cmp)\n\nBelt.Map.Dict.findFirstBy(s0, (k, _) => k == 4) == Some((4, \"4\"))\n```" - ], - "signature": "let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)>" - }, - { - "id": "Belt.Map.Dict.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit" - }, - { - "id": "Belt.Map.Dict.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the\nkey as first argument, and the associated value as second argument. The\nbindings are passed to `f` in increasing order with respect to the ordering\nover the type of the keys." - ], - "signature": "let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit" - }, - { - "id": "Belt.Map.Dict.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b" - }, - { - "id": "Belt.Map.Dict.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...)`, where `k1 ... kN` \nare the keys of all bindings in `m` (in increasing order), and `d1 ... dN` \nare the associated data." - ], - "signature": "let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b" - }, - { - "id": "Belt.Map.Dict.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.Map.Dict.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(m, p)` checks if all the bindings of the map satisfy the predicate\n`p`. Order unspecified" - ], - "signature": "let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.Map.Dict.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.Map.Dict.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(m, p)` checks if at least one binding of the map satisfy the\npredicate `p`. Order unspecified" - ], - "signature": "let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.Map.Dict.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'k, 'a, 'id> => int" - }, - { - "id": "Belt.Map.Dict.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order."], - "signature": "let toList: t<'k, 'a, 'id> => list<('k, 'a)>" - }, - { - "id": "Belt.Map.Dict.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t<'k, 'a, 'id> => array<('k, 'a)>" - }, - { - "id": "Belt.Map.Dict.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: (array<('k, 'a)>, ~cmp: cmp<'k, 'id>) => t<'k, 'a, 'id>" - }, - { - "id": "Belt.Map.Dict.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'k, 'a, 'id> => array<'k>" - }, - { - "id": "Belt.Map.Dict.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'k, 'a, 'id> => array<'a>" - }, - { - "id": "Belt.Map.Dict.minKey", - "kind": "value", - "name": "minKey", - "docstrings": [], - "signature": "let minKey: t<'k, 'a, 'b> => option<'k>" - }, - { - "id": "Belt.Map.Dict.minKeyUndefined", - "kind": "value", - "name": "minKeyUndefined", - "docstrings": [], - "signature": "let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>" - }, - { - "id": "Belt.Map.Dict.maxKey", - "kind": "value", - "name": "maxKey", - "docstrings": [], - "signature": "let maxKey: t<'k, 'a, 'b> => option<'k>" - }, - { - "id": "Belt.Map.Dict.maxKeyUndefined", - "kind": "value", - "name": "maxKeyUndefined", - "docstrings": [], - "signature": "let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>" - }, - { - "id": "Belt.Map.Dict.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t<'k, 'a, 'b> => option<('k, 'a)>" - }, - { - "id": "Belt.Map.Dict.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>" - }, - { - "id": "Belt.Map.Dict.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t<'k, 'a, 'b> => option<('k, 'a)>" - }, - { - "id": "Belt.Map.Dict.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>" - }, - { - "id": "Belt.Map.Dict.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => option<'a>" - }, - { - "id": "Belt.Map.Dict.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => Js.undefined<'a>" - }, - { - "id": "Belt.Map.Dict.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a, ~cmp: cmp<'k, 'id>) => 'a" - }, - { - "id": "Belt.Map.Dict.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a" - }, - { - "id": "Belt.Map.Dict.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": [], - "signature": "let checkInvariantInternal: t<'a, 'b, 'c> => unit" - }, - { - "id": "Belt.Map.Dict.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "`remove(m, x)` returns a map containing the same bindings as `m`, except\nfor `x` which is unbound in the returned map." - ], - "signature": "let remove: (t<'a, 'b, 'id>, 'a, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (\n t<'a, 'b, 'id>,\n array<'a>,\n ~cmp: cmp<'a, 'id>,\n) => t<'a, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(m, x, y)` returns a map containing the same bindings as `m`, plus a\nbinding of `x` to `y`. If `x` was already bound in `m`, its previous\nbinding disappears." - ], - "signature": "let set: (\n t<'a, 'b, 'id>,\n 'a,\n 'b,\n ~cmp: cmp<'a, 'id>,\n) => t<'a, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.updateU", - "kind": "value", - "name": "updateU", - "docstrings": [], - "signature": "let updateU: (\n t<'a, 'b, 'id>,\n 'a,\n option<'b> => option<'b>,\n ~cmp: cmp<'a, 'id>,\n) => t<'a, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.update", - "kind": "value", - "name": "update", - "docstrings": [], - "signature": "let update: (\n t<'a, 'b, 'id>,\n 'a,\n option<'b> => option<'b>,\n ~cmp: cmp<'a, 'id>,\n) => t<'a, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.mergeU", - "kind": "value", - "name": "mergeU", - "docstrings": [], - "signature": "let mergeU: (\n t<'a, 'b, 'id>,\n t<'a, 'c, 'id>,\n ('a, option<'b>, option<'c>) => option<'d>,\n ~cmp: cmp<'a, 'id>,\n) => t<'a, 'd, 'id>" - }, - { - "id": "Belt.Map.Dict.merge", - "kind": "value", - "name": "merge", - "docstrings": [ - "`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1`\nand of `m2`. The presence of each such binding, and the corresponding\nvalue, is determined with the function `f`." - ], - "signature": "let merge: (\n t<'a, 'b, 'id>,\n t<'a, 'c, 'id>,\n ('a, option<'b>, option<'c>) => option<'d>,\n ~cmp: cmp<'a, 'id>,\n) => t<'a, 'd, 'id>" - }, - { - "id": "Belt.Map.Dict.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (\n t<'a, 'b, 'id>,\n array<('a, 'b)>,\n ~cmp: cmp<'a, 'id>,\n) => t<'a, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id>" - }, - { - "id": "Belt.Map.Dict.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(m, p)` returns the map with all the bindings in `m` that satisfy\npredicate `p`." - ], - "signature": "let keep: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id>" - }, - { - "id": "Belt.Map.Dict.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (\n t<'k, 'a, 'id>,\n ('k, 'a) => bool,\n) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>)" - }, - { - "id": "Belt.Map.Dict.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains\nall the bindings of `s` that satisfy the predicate `p`, and `m2` is the map\nwith all the bindings of `s` that do not satisfy `p`." - ], - "signature": "let partition: (\n t<'k, 'a, 'id>,\n ('k, 'a) => bool,\n) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>)" - }, - { - "id": "Belt.Map.Dict.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with\nall the bindings of `m` whose key is strictly less than `x`; `r` is the map\nwith all the bindings of `m` whose key is strictly greater than `x`; `data`\nis `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v`\nto `x`." - ], - "signature": "let split: (\n t<'a, 'b, 'id>,\n 'a,\n ~cmp: cmp<'a, 'id>,\n) => ((t<'a, 'b, 'id>, t<'a, 'b, 'id>), option<'b>)" - }, - { - "id": "Belt.Map.Dict.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(m, f)` returns a map with same domain as `m`, where the associated\nvalue `a` of all bindings of `m` has been replaced by the result of the\napplication of `f` to `a`. The bindings are passed to `f` in increasing\norder with respect to the ordering over the type of the keys." - ], - "signature": "let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.mapWithKeyU", - "kind": "value", - "name": "mapWithKeyU", - "docstrings": [], - "signature": "let mapWithKeyU: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>" - }, - { - "id": "Belt.Map.Dict.mapWithKey", - "kind": "value", - "name": "mapWithKey", - "docstrings": [], - "signature": "let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>" - } - ] - }, - "belt/map/string": { - "id": "Belt.Map.String", - "name": "String", - "docstrings": [], - "items": [ - { - "id": "Belt.Map.String.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = string" - }, - { - "id": "Belt.Map.String.t", - "kind": "type", - "name": "t", - "docstrings": ["The type of maps from type `key` to type `'value`."], - "signature": "type t<'value>" - }, - { - "id": "Belt.Map.String.empty", - "kind": "value", - "name": "empty", - "docstrings": [], - "signature": "let empty: t<'v>" - }, - { - "id": "Belt.Map.String.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'v> => bool" - }, - { - "id": "Belt.Map.String.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'v>, key) => bool" - }, - { - "id": "Belt.Map.String.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'v>, t<'v>, ('v, 'v) => int) => int" - }, - { - "id": "Belt.Map.String.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [], - "signature": "let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int" - }, - { - "id": "Belt.Map.String.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'v>, t<'v>, ('v, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.String.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(m1, m2)` tests whether the maps `m1` and `m2` are\nequal, that is, contain equal keys and associate them with\nequal data." - ], - "signature": "let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.String.findFirstByU", - "kind": "value", - "name": "findFirstByU", - "docstrings": [], - "signature": "let findFirstByU: (t<'v>, (key, 'v) => bool) => option<(key, 'v)>" - }, - { - "id": "Belt.Map.String.findFirstBy", - "kind": "value", - "name": "findFirstBy", - "docstrings": [ - "`findFirstBy(m, p)` uses funcion `f` to find the first key value pair\nto match predicate `p`.\n\n```rescript\nlet s0 = fromArray(~id=module(IntCmp), [(4, \"4\"), (1, \"1\"), (2, \"2,\"(3, \"\"))])\nfindFirstBy(s0, (k, v) => k == 4) == option((4, \"4\"))\n```" - ], - "signature": "let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)>" - }, - { - "id": "Belt.Map.String.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'v>, (key, 'v) => unit) => unit" - }, - { - "id": "Belt.Map.String.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(m, f)` applies `f` to all bindings in map `m`.\n`f` receives the key as first argument, and the associated value\nas second argument. The bindings are passed to `f` in increasing\norder with respect to the ordering over the type of the keys." - ], - "signature": "let forEach: (t<'v>, (key, 'v) => unit) => unit" - }, - { - "id": "Belt.Map.String.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2" - }, - { - "id": "Belt.Map.String.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`,\nwhere `k1 ... kN` are the keys of all bindings in `m`\n(in increasing order), and `d1 ... dN` are the associated data." - ], - "signature": "let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2" - }, - { - "id": "Belt.Map.String.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.String.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`.\nOrder unspecified" - ], - "signature": "let every: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.String.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.String.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(m, p)` checks if at least one binding of the map satisfy the predicate\n`p`. Order unspecified" - ], - "signature": "let some: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.String.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'v> => int" - }, - { - "id": "Belt.Map.String.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order."], - "signature": "let toList: t<'v> => list<(key, 'v)>" - }, - { - "id": "Belt.Map.String.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t<'v> => array<(key, 'v)>" - }, - { - "id": "Belt.Map.String.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array<(key, 'v)> => t<'v>" - }, - { - "id": "Belt.Map.String.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'v> => array" - }, - { - "id": "Belt.Map.String.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'v> => array<'v>" - }, - { - "id": "Belt.Map.String.minKey", - "kind": "value", - "name": "minKey", - "docstrings": [], - "signature": "let minKey: t<'a> => option" - }, - { - "id": "Belt.Map.String.minKeyUndefined", - "kind": "value", - "name": "minKeyUndefined", - "docstrings": [], - "signature": "let minKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.Map.String.maxKey", - "kind": "value", - "name": "maxKey", - "docstrings": [], - "signature": "let maxKey: t<'a> => option" - }, - { - "id": "Belt.Map.String.maxKeyUndefined", - "kind": "value", - "name": "maxKeyUndefined", - "docstrings": [], - "signature": "let maxKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.Map.String.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t<'v> => option<(key, 'v)>" - }, - { - "id": "Belt.Map.String.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t<'v> => Js.undefined<(key, 'v)>" - }, - { - "id": "Belt.Map.String.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t<'v> => option<(key, 'v)>" - }, - { - "id": "Belt.Map.String.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t<'v> => Js.undefined<(key, 'v)>" - }, - { - "id": "Belt.Map.String.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'v>, key) => option<'v>" - }, - { - "id": "Belt.Map.String.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t<'v>, key) => Js.undefined<'v>" - }, - { - "id": "Belt.Map.String.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'v>, key, 'v) => 'v" - }, - { - "id": "Belt.Map.String.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t<'v>, key) => 'v" - }, - { - "id": "Belt.Map.String.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a> => unit" - }, - { - "id": "Belt.Map.String.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "`remove m x` returns a map containing the same bindings as\n `m`, except for `x` which is unbound in the returned map." - ], - "signature": "let remove: (t<'v>, key) => t<'v>" - }, - { - "id": "Belt.Map.String.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t<'v>, array) => t<'v>" - }, - { - "id": "Belt.Map.String.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(m, x, y)` returns a map containing the same bindings as\n`m`, plus a binding of `x` to `y`. If `x` was already bound\nin `m`, its previous binding disappears." - ], - "signature": "let set: (t<'v>, key, 'v) => t<'v>" - }, - { - "id": "Belt.Map.String.updateU", - "kind": "value", - "name": "updateU", - "docstrings": [], - "signature": "let updateU: (t<'v>, key, option<'v> => option<'v>) => t<'v>" - }, - { - "id": "Belt.Map.String.update", - "kind": "value", - "name": "update", - "docstrings": [], - "signature": "let update: (t<'v>, key, option<'v> => option<'v>) => t<'v>" - }, - { - "id": "Belt.Map.String.mergeU", - "kind": "value", - "name": "mergeU", - "docstrings": [], - "signature": "let mergeU: (\n t<'v>,\n t<'v2>,\n (key, option<'v>, option<'v2>) => option<'c>,\n) => t<'c>" - }, - { - "id": "Belt.Map.String.merge", - "kind": "value", - "name": "merge", - "docstrings": [ - "`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1`\nand of `m2`. The presence of each such binding, and the corresponding\nvalue, is determined with the function `f`." - ], - "signature": "let merge: (\n t<'v>,\n t<'v2>,\n (key, option<'v>, option<'v2>) => option<'c>,\n) => t<'c>" - }, - { - "id": "Belt.Map.String.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v>" - }, - { - "id": "Belt.Map.String.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'v>, (key, 'v) => bool) => t<'v>" - }, - { - "id": "Belt.Map.String.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate\n`p`." - ], - "signature": "let keep: (t<'v>, (key, 'v) => bool) => t<'v>" - }, - { - "id": "Belt.Map.String.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>)" - }, - { - "id": "Belt.Map.String.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the\nbindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the\nbindings of `s` that do not satisfy `p`." - ], - "signature": "let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>)" - }, - { - "id": "Belt.Map.String.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the\nbindings of `m` whose key is strictly less than `x`; `r` is the map with all the\nbindings of `m` whose key is strictly greater than `x`; `data` is `None` if `m`\ncontains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`." - ], - "signature": "let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>)" - }, - { - "id": "Belt.Map.String.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'v>, 'v => 'v2) => t<'v2>" - }, - { - "id": "Belt.Map.String.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(m, f)` returns a map with same domain as `m`, where the associated value `a`\nof all bindings of `m` has been replaced by the result of the application of `f`\nto `a`. The bindings are passed to `f` in increasing order with respect to the\nordering over the type of the keys." - ], - "signature": "let map: (t<'v>, 'v => 'v2) => t<'v2>" - }, - { - "id": "Belt.Map.String.mapWithKeyU", - "kind": "value", - "name": "mapWithKeyU", - "docstrings": [], - "signature": "let mapWithKeyU: (t<'v>, (key, 'v) => 'v2) => t<'v2>" - }, - { - "id": "Belt.Map.String.mapWithKey", - "kind": "value", - "name": "mapWithKey", - "docstrings": [], - "signature": "let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2>" - } - ] - }, - "belt/map/int": { - "id": "Belt.Map.Int", - "name": "Int", - "docstrings": [ - "## Examples\n\n```rescript\ntype t<'key, 'value, 'identity>\ntype id<'key, 'id> = Belt_Id.comparable<'key, 'id>\n```" - ], - "items": [ - { - "id": "Belt.Map.Int.key", - "kind": "type", - "name": "key", - "docstrings": [], - "signature": "type key = int" - }, - { - "id": "Belt.Map.Int.t", - "kind": "type", - "name": "t", - "docstrings": ["The type of maps from type `key` to type `'value`."], - "signature": "type t<'value>" - }, - { - "id": "Belt.Map.Int.empty", - "kind": "value", - "name": "empty", - "docstrings": [], - "signature": "let empty: t<'v>" - }, - { - "id": "Belt.Map.Int.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'v> => bool" - }, - { - "id": "Belt.Map.Int.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'v>, key) => bool" - }, - { - "id": "Belt.Map.Int.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'v>, t<'v>, ('v, 'v) => int) => int" - }, - { - "id": "Belt.Map.Int.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [], - "signature": "let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int" - }, - { - "id": "Belt.Map.Int.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'v>, t<'v>, ('v, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.Int.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(m1, m2)` tests whether the maps `m1` and `m2` are\nequal, that is, contain equal keys and associate them with\nequal data." - ], - "signature": "let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.Int.findFirstByU", - "kind": "value", - "name": "findFirstByU", - "docstrings": [], - "signature": "let findFirstByU: (t<'v>, (key, 'v) => bool) => option<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.findFirstBy", - "kind": "value", - "name": "findFirstBy", - "docstrings": [ - "`findFirstBy(m, p)` uses funcion `f` to find the first key value pair\nto match predicate `p`.\n\n```rescript\nlet s0 = fromArray(~id=module(IntCmp), [(4, \"4\"), (1, \"1\"), (2, \"2,\"(3, \"\"))])\nfindFirstBy(s0, (k, v) => k == 4) == option((4, \"4\"))\n```" - ], - "signature": "let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'v>, (key, 'v) => unit) => unit" - }, - { - "id": "Belt.Map.Int.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(m, f)` applies `f` to all bindings in map `m`.\n`f` receives the key as first argument, and the associated value\nas second argument. The bindings are passed to `f` in increasing\norder with respect to the ordering over the type of the keys." - ], - "signature": "let forEach: (t<'v>, (key, 'v) => unit) => unit" - }, - { - "id": "Belt.Map.Int.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2" - }, - { - "id": "Belt.Map.Int.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`,\nwhere `k1 ... kN` are the keys of all bindings in `m`\n(in increasing order), and `d1 ... dN` are the associated data." - ], - "signature": "let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2" - }, - { - "id": "Belt.Map.Int.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.Int.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`.\nOrder unspecified" - ], - "signature": "let every: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.Int.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.Int.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(m, p)` checks if at least one binding of the map satisfy the predicate\n`p`. Order unspecified" - ], - "signature": "let some: (t<'v>, (key, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.Int.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'v> => int" - }, - { - "id": "Belt.Map.Int.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order."], - "signature": "let toList: t<'v> => list<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t<'v> => array<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array<(key, 'v)> => t<'v>" - }, - { - "id": "Belt.Map.Int.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'v> => array" - }, - { - "id": "Belt.Map.Int.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'v> => array<'v>" - }, - { - "id": "Belt.Map.Int.minKey", - "kind": "value", - "name": "minKey", - "docstrings": [], - "signature": "let minKey: t<'a> => option" - }, - { - "id": "Belt.Map.Int.minKeyUndefined", - "kind": "value", - "name": "minKeyUndefined", - "docstrings": [], - "signature": "let minKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.Map.Int.maxKey", - "kind": "value", - "name": "maxKey", - "docstrings": [], - "signature": "let maxKey: t<'a> => option" - }, - { - "id": "Belt.Map.Int.maxKeyUndefined", - "kind": "value", - "name": "maxKeyUndefined", - "docstrings": [], - "signature": "let maxKeyUndefined: t<'a> => Js.undefined" - }, - { - "id": "Belt.Map.Int.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t<'v> => option<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t<'v> => Js.undefined<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t<'v> => option<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t<'v> => Js.undefined<(key, 'v)>" - }, - { - "id": "Belt.Map.Int.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'v>, key) => option<'v>" - }, - { - "id": "Belt.Map.Int.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t<'v>, key) => Js.undefined<'v>" - }, - { - "id": "Belt.Map.Int.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'v>, key, 'v) => 'v" - }, - { - "id": "Belt.Map.Int.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t<'v>, key) => 'v" - }, - { - "id": "Belt.Map.Int.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a> => unit" - }, - { - "id": "Belt.Map.Int.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "`remove m x` returns a map containing the same bindings as\n `m`, except for `x` which is unbound in the returned map." - ], - "signature": "let remove: (t<'v>, key) => t<'v>" - }, - { - "id": "Belt.Map.Int.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t<'v>, array) => t<'v>" - }, - { - "id": "Belt.Map.Int.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(m, x, y)` returns a map containing the same bindings as\n`m`, plus a binding of `x` to `y`. If `x` was already bound\nin `m`, its previous binding disappears." - ], - "signature": "let set: (t<'v>, key, 'v) => t<'v>" - }, - { - "id": "Belt.Map.Int.updateU", - "kind": "value", - "name": "updateU", - "docstrings": [], - "signature": "let updateU: (t<'v>, key, option<'v> => option<'v>) => t<'v>" - }, - { - "id": "Belt.Map.Int.update", - "kind": "value", - "name": "update", - "docstrings": [], - "signature": "let update: (t<'v>, key, option<'v> => option<'v>) => t<'v>" - }, - { - "id": "Belt.Map.Int.mergeU", - "kind": "value", - "name": "mergeU", - "docstrings": [], - "signature": "let mergeU: (\n t<'v>,\n t<'v2>,\n (key, option<'v>, option<'v2>) => option<'c>,\n) => t<'c>" - }, - { - "id": "Belt.Map.Int.merge", - "kind": "value", - "name": "merge", - "docstrings": [ - "`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1`\nand of `m2`. The presence of each such binding, and the corresponding\nvalue, is determined with the function `f`." - ], - "signature": "let merge: (\n t<'v>,\n t<'v2>,\n (key, option<'v>, option<'v2>) => option<'c>,\n) => t<'c>" - }, - { - "id": "Belt.Map.Int.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v>" - }, - { - "id": "Belt.Map.Int.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'v>, (key, 'v) => bool) => t<'v>" - }, - { - "id": "Belt.Map.Int.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate\n`p`." - ], - "signature": "let keep: (t<'v>, (key, 'v) => bool) => t<'v>" - }, - { - "id": "Belt.Map.Int.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>)" - }, - { - "id": "Belt.Map.Int.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the\nbindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the\nbindings of `s` that do not satisfy `p`." - ], - "signature": "let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>)" - }, - { - "id": "Belt.Map.Int.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the\nbindings of `m` whose key is strictly less than `x`; `r` is the map with all the\nbindings of `m` whose key is strictly greater than `x`; `data` is `None` if `m`\ncontains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`." - ], - "signature": "let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>)" - }, - { - "id": "Belt.Map.Int.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'v>, 'v => 'v2) => t<'v2>" - }, - { - "id": "Belt.Map.Int.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(m, f)` returns a map with same domain as `m`, where the associated value `a`\nof all bindings of `m` has been replaced by the result of the application of `f`\nto `a`. The bindings are passed to `f` in increasing order with respect to the\nordering over the type of the keys." - ], - "signature": "let map: (t<'v>, 'v => 'v2) => t<'v2>" - }, - { - "id": "Belt.Map.Int.mapWithKeyU", - "kind": "value", - "name": "mapWithKeyU", - "docstrings": [], - "signature": "let mapWithKeyU: (t<'v>, (key, 'v) => 'v2) => t<'v2>" - }, - { - "id": "Belt.Map.Int.mapWithKey", - "kind": "value", - "name": "mapWithKey", - "docstrings": [], - "signature": "let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2>" - } - ] - }, - "belt/set/dict": { - "id": "Belt.Set.Dict", - "name": "Dict", - "docstrings": [ - "This module separates identity from data, it is a bit more verbose but slightly\nmore efficient due to the fact that there is no need to pack identity and data back\nafter each operation", - "This module separates identity from data. It is a bit more verbose but slightly\nmore efficient due to the fact that there is no need to pack identity and data\nback after each operation." - ], - "items": [ - { - "id": "Belt.Set.Dict.t", - "kind": "type", - "name": "t", - "docstrings": [ - "`'value` is the element type\n\n`'identity` the identity of the collection" - ], - "signature": "type t<'value, 'identity>" - }, - { - "id": "Belt.Set.Dict.cmp", - "kind": "type", - "name": "cmp", - "docstrings": ["Type of compare function."], - "signature": "type cmp<'value, 'id> = Belt_Id.cmp<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.empty", - "kind": "value", - "name": "empty", - "docstrings": [ - "## Examples\n\n```rescript\nlet s0 = Belt.Set.Dict.empty\n```" - ], - "signature": "let empty: t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Creates new set from array of elements.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([1, 3, 2, 4], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.toArray /* [1, 2, 3, 4] */\n```" - ], - "signature": "let fromArray: (array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.fromSortedArrayUnsafe", - "kind": "value", - "name": "fromSortedArrayUnsafe", - "docstrings": [ - "The same as [fromArray][#fromarray] except it is after assuming the input array\nis already sorted." - ], - "signature": "let fromSortedArrayUnsafe: array<'value> => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [ - "Checks if set is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet empty = Belt.Set.Dict.fromArray([], ~cmp=IntCmp.cmp)\nlet notEmpty = Belt.Set.Dict.fromArray([1], ~cmp=IntCmp.cmp)\n\nBelt.Set.Dict.isEmpty(empty) /* true */\nBelt.Set.Dict.isEmpty(notEmpty) /* false */\n```" - ], - "signature": "let isEmpty: t<'a, 'b> => bool" - }, - { - "id": "Belt.Set.Dict.has", - "kind": "value", - "name": "has", - "docstrings": [ - "Checks if an element exists in the set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet set = Belt.Set.Dict.fromArray([1, 4, 2, 5], ~cmp=IntCmp.cmp)\n\nset->Belt.Set.Dict.has(3, ~cmp=IntCmp.cmp) /* false */\nset->Belt.Set.Dict.has(1, ~cmp=IntCmp.cmp) /* true */\n```" - ], - "signature": "let has: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => bool" - }, - { - "id": "Belt.Set.Dict.add", - "kind": "value", - "name": "add", - "docstrings": [ - "Adds element to set. If element existed in set, value is unchanged.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.empty\nlet s1 = s0->Belt.Set.Dict.add(1, ~cmp=IntCmp.cmp)\nlet s2 = s1->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp)\nlet s3 = s2->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp)\ns0->Belt.Set.Dict.toArray /* [] */\ns1->Belt.Set.Dict.toArray /* [1] */\ns2->Belt.Set.Dict.toArray /* [1, 2] */\ns3->Belt.Set.Dict.toArray /* [1,2 ] */\ns2 == s3 /* true */\n```" - ], - "signature": "let add: (\n t<'value, 'id>,\n 'value,\n ~cmp: cmp<'value, 'id>,\n) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [ - "Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet set = Belt.Set.Dict.empty\n\nlet newSet = set->Belt.Set.Dict.mergeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp)\nnewSet->Belt.Set.Dict.toArray /* [1, 2, 3, 4, 5] */\n```" - ], - "signature": "let mergeMany: (\n t<'value, 'id>,\n array<'value>,\n ~cmp: cmp<'value, 'id>,\n) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "Removes element from set. If element did not exist in set, value is unchanged.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([2, 3, 1, 4, 5], ~cmp=IntCmp.cmp)\nlet s1 = s0->Belt.Set.Dict.remove(1, ~cmp=IntCmp.cmp)\nlet s2 = s1->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp)\nlet s3 = s2->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp)\n\ns1->Belt.Set.Dict.toArray /* [2,3,4,5] */\ns2->Belt.Set.Dict.toArray /* [2,4,5] */\ns2 == s3 /* true */\n```" - ], - "signature": "let remove: (\n t<'value, 'id>,\n 'value,\n ~cmp: cmp<'value, 'id>,\n) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [ - "Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet set = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp)\n\nlet newSet = set->Belt.Set.Dict.removeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp)\nnewSet->Belt.Set.Dict.toArray /* [] */\n```" - ], - "signature": "let removeMany: (\n t<'value, 'id>,\n array<'value>,\n ~cmp: cmp<'value, 'id>,\n) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.union", - "kind": "value", - "name": "union", - "docstrings": [ - "Returns union of two sets.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp)\nlet s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp)\nlet union = Belt.Set.Dict.union(s0, s1, ~cmp=IntCmp.cmp)\nunion->Belt.Set.Dict.toArray /* [1,2,3,4,5,6] */\n```" - ], - "signature": "let union: (\n t<'value, 'id>,\n t<'value, 'id>,\n ~cmp: cmp<'value, 'id>,\n) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [ - "Returns intersection of two sets.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp)\nlet s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp)\nlet intersect = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp)\nintersect->Belt.Set.Dict.toArray /* [2,3,5] */\n```" - ], - "signature": "let intersect: (\n t<'value, 'id>,\n t<'value, 'id>,\n ~cmp: cmp<'value, 'id>,\n) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.diff", - "kind": "value", - "name": "diff", - "docstrings": [ - "Returns elements from first set, not existing in second set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp)\nlet s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp)\n\nlet diff1 = Belt.Set.Dict.diff(s0, s1, ~cmp=IntCmp.cmp)\nlet diff2 = Belt.Set.Dict.diff(s1, s0, ~cmp=IntCmp.cmp)\n\ndiff1->Belt.Set.Dict.toArray /* [6] */\ndiff2->Belt.Set.Dict.toArray /* [1,4] */\n```" - ], - "signature": "let diff: (\n t<'value, 'id>,\n t<'value, 'id>,\n ~cmp: cmp<'value, 'id>,\n) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.subset", - "kind": "value", - "name": "subset", - "docstrings": [ - "Checks if second set is subset of first set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp)\nlet s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp)\nlet s2 = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp)\nBelt.Set.Dict.subset(s2, s0, ~cmp=IntCmp.cmp) /* true */\nBelt.Set.Dict.subset(s2, s1, ~cmp=IntCmp.cmp) /* true */\nBelt.Set.Dict.subset(s1, s0, ~cmp=IntCmp.cmp) /* false */\n```" - ], - "signature": "let subset: (\n t<'value, 'id>,\n t<'value, 'id>,\n ~cmp: cmp<'value, 'id>,\n) => bool" - }, - { - "id": "Belt.Set.Dict.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "Total ordering between sets. Can be used as the ordering function for doing sets\nof sets. It compares size first and then iterates over each element following the\norder of elements." - ], - "signature": "let cmp: (\n t<'value, 'id>,\n t<'value, 'id>,\n ~cmp: cmp<'value, 'id>,\n) => int" - }, - { - "id": "Belt.Set.Dict.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "Checks if two sets are equal.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([5, 2, 3], ~cmp=IntCmp.cmp)\nlet s1 = Belt.Set.Dict.fromArray([3, 2, 5], ~cmp=IntCmp.cmp)\n\nBelt.Set.Dict.eq(s0, s1, ~cmp=IntCmp.cmp) /* true */\n```" - ], - "signature": "let eq: (\n t<'value, 'id>,\n t<'value, 'id>,\n ~cmp: cmp<'value, 'id>,\n) => bool" - }, - { - "id": "Belt.Set.Dict.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [ - "Same as [forEach](##forEach) but takes uncurried functon." - ], - "signature": "let forEachU: (t<'value, 'id>, 'value => unit) => unit" - }, - { - "id": "Belt.Set.Dict.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "Applies function `f` in turn to all elements of set in increasing order.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp)\nlet acc = ref(list{})\ns0->Belt.Set.Dict.forEach(x => acc := Belt.List.add(acc.contents, x))\nacc /* [6,5,3,2] */\n```" - ], - "signature": "let forEach: (t<'value, 'id>, 'value => unit) => unit" - }, - { - "id": "Belt.Set.Dict.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a" - }, - { - "id": "Belt.Set.Dict.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp)\ns0->Belt.Set.Dict.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */\n```" - ], - "signature": "let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a" - }, - { - "id": "Belt.Set.Dict.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.Dict.every", - "kind": "value", - "name": "every", - "docstrings": [ - "Checks if all elements of the set satisfy the predicate. Order unspecified.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isEven = x => mod(x, 2) == 0\n\nlet s0 = Belt.Set.Dict.fromArray([2, 4, 6, 8], ~cmp=IntCmp.cmp)\ns0->Belt.Set.Dict.every(isEven) /* true */\n```" - ], - "signature": "let every: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.Dict.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.Dict.some", - "kind": "value", - "name": "some", - "docstrings": [ - "Checks if at least one element of the set satisfies the predicate.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isOdd = x => mod(x, 2) != 0\n\nlet s0 = Belt.Set.Dict.fromArray([1, 2, 4, 6, 8], ~cmp=IntCmp.cmp)\ns0->Belt.Set.Dict.some(isOdd) /* true */\n```" - ], - "signature": "let some: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.Dict.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'value, 'id>, 'value => bool) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "Returns the set of all elements that satisfy the predicate.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isEven = x => mod(x, 2) == 0\n\nlet s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp)\nlet s1 = s0->Belt.Set.Dict.keep(isEven)\n\ns1->Belt.Set.Dict.toArray /* [2,4] */\n```" - ], - "signature": "let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id>" - }, - { - "id": "Belt.Set.Dict.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (\n t<'value, 'id>,\n 'value => bool,\n) => (t<'value, 'id>, t<'value, 'id>)" - }, - { - "id": "Belt.Set.Dict.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isOdd = x => mod(x, 2) != 0\n\nlet s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp)\nlet (s1, s2) = s0->Belt.Set.Dict.partition(isOdd)\n\ns1->Belt.Set.Dict.toArray /* [1,3,5] */\ns2->Belt.Set.Dict.toArray /* [2,4] */\n```" - ], - "signature": "let partition: (\n t<'value, 'id>,\n 'value => bool,\n) => (t<'value, 'id>, t<'value, 'id>)" - }, - { - "id": "Belt.Set.Dict.size", - "kind": "value", - "name": "size", - "docstrings": [ - "Returns size of the set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.size /* 4 */\n```" - ], - "signature": "let size: t<'value, 'id> => int" - }, - { - "id": "Belt.Set.Dict.toList", - "kind": "value", - "name": "toList", - "docstrings": [ - "Returns list of ordered set elements.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.toList /* [1,2,3,5] */\n```" - ], - "signature": "let toList: t<'value, 'id> => list<'value>" - }, - { - "id": "Belt.Set.Dict.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "Returns array of ordered set elements.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.toArray /* [1,2,3,5] */\n```" - ], - "signature": "let toArray: t<'value, 'id> => array<'value>" - }, - { - "id": "Belt.Set.Dict.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [ - "Returns minimum value of the collection. `None` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.empty\nlet s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.minimum /* None */\ns1->Belt.Set.Dict.minimum /* Some(1) */\n```" - ], - "signature": "let minimum: t<'value, 'id> => option<'value>" - }, - { - "id": "Belt.Set.Dict.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [ - "Returns minimum value of the collection. `undefined` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.empty\nlet s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.minUndefined /* undefined */\ns1->Belt.Set.Dict.minUndefined /* 1 */\n```" - ], - "signature": "let minUndefined: t<'value, 'id> => Js.undefined<'value>" - }, - { - "id": "Belt.Set.Dict.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [ - "Returns maximum value of the collection. `None` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.empty\nlet s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.maximum /* None */\ns1->Belt.Set.Dict.maximum /* Some(5) */\n```" - ], - "signature": "let maximum: t<'value, 'id> => option<'value>" - }, - { - "id": "Belt.Set.Dict.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [ - "Returns maximum value of the collection. `undefined` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.empty\nlet s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.maxUndefined /* undefined */\ns1->Belt.Set.Dict.maxUndefined /* 5 */\n```" - ], - "signature": "let maxUndefined: t<'value, 'id> => Js.undefined<'value>" - }, - { - "id": "Belt.Set.Dict.get", - "kind": "value", - "name": "get", - "docstrings": [ - "Returns the reference of the value which is equivalent to value using the comparator\nspecifiecd by this collection. Returns `None` if element does not exist.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp)\n\ns0->Belt.Set.Dict.get(3, ~cmp=IntCmp.cmp) /* Some(3) */\ns0->Belt.Set.Dict.get(20, ~cmp=IntCmp.cmp) /* None */\n```" - ], - "signature": "let get: (\n t<'value, 'id>,\n 'value,\n ~cmp: cmp<'value, 'id>,\n) => option<'value>" - }, - { - "id": "Belt.Set.Dict.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [ - "Same as [get](#get) but returns `undefined` when element does not exist." - ], - "signature": "let getUndefined: (\n t<'value, 'id>,\n 'value,\n ~cmp: cmp<'value, 'id>,\n) => Js.undefined<'value>" - }, - { - "id": "Belt.Set.Dict.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "Same as [get](#get) but raise when element does not exist." - ], - "signature": "let getExn: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => 'value" - }, - { - "id": "Belt.Set.Dict.split", - "kind": "value", - "name": "split", - "docstrings": [ - "Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp)\n\nlet ((smaller, larger), present) = s0->Belt.Set.Dict.split(3, ~cmp=IntCmp.cmp)\n\npresent /* true */\nsmaller->Belt.Set.Dict.toArray /* [1,2] */\nlarger->Belt.Set.Dict.toArray /* [4,5] */\n```" - ], - "signature": "let split: (\n t<'value, 'id>,\n 'value,\n ~cmp: cmp<'value, 'id>,\n) => ((t<'value, 'id>, t<'value, 'id>), bool)" - }, - { - "id": "Belt.Set.Dict.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a, 'b> => unit" - } - ] - }, - "belt/set/string": { - "id": "Belt.Set.String", - "name": "String", - "docstrings": [ - "Specialized when value type is `string`, more efficient than the generic type,\nits compare behavior is fixed using the built-in comparison", - "This module is [`Belt.Set`]() specialized with value type to be a primitive type.\n It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,\n and identity is not needed(using the built-in one)\n\n **See** [`Belt.Set`]()" - ], - "items": [ - { - "id": "Belt.Set.String.value", - "kind": "type", - "name": "value", - "docstrings": ["The type of the set elements."], - "signature": "type value = string" - }, - { - "id": "Belt.Set.String.t", - "kind": "type", - "name": "t", - "docstrings": ["The type of sets."], - "signature": "type t" - }, - { - "id": "Belt.Set.String.empty", - "kind": "value", - "name": "empty", - "docstrings": [], - "signature": "let empty: t" - }, - { - "id": "Belt.Set.String.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array => t" - }, - { - "id": "Belt.Set.String.fromSortedArrayUnsafe", - "kind": "value", - "name": "fromSortedArrayUnsafe", - "docstrings": [], - "signature": "let fromSortedArrayUnsafe: array => t" - }, - { - "id": "Belt.Set.String.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t => bool" - }, - { - "id": "Belt.Set.String.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t, value) => bool" - }, - { - "id": "Belt.Set.String.add", - "kind": "value", - "name": "add", - "docstrings": [ - "`add(s, x)` If `x` was already in `s`, `s` is returned unchanged." - ], - "signature": "let add: (t, value) => t" - }, - { - "id": "Belt.Set.String.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t, array) => t" - }, - { - "id": "Belt.Set.String.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "`remove(m, x)` If `x` was not in `m`, `m` is returned reference unchanged." - ], - "signature": "let remove: (t, value) => t" - }, - { - "id": "Belt.Set.String.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t, array) => t" - }, - { - "id": "Belt.Set.String.union", - "kind": "value", - "name": "union", - "docstrings": [], - "signature": "let union: (t, t) => t" - }, - { - "id": "Belt.Set.String.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [], - "signature": "let intersect: (t, t) => t" - }, - { - "id": "Belt.Set.String.diff", - "kind": "value", - "name": "diff", - "docstrings": [], - "signature": "let diff: (t, t) => t" - }, - { - "id": "Belt.Set.String.subset", - "kind": "value", - "name": "subset", - "docstrings": [ - "`subset(s1, s2)` tests whether the set `s1` is a subset of the set `s2`." - ], - "signature": "let subset: (t, t) => bool" - }, - { - "id": "Belt.Set.String.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "Total ordering between sets. Can be used as the ordering function for doing sets\nof sets." - ], - "signature": "let cmp: (t, t) => int" - }, - { - "id": "Belt.Set.String.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain\nequal elements." - ], - "signature": "let eq: (t, t) => bool" - }, - { - "id": "Belt.Set.String.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t, value => unit) => unit" - }, - { - "id": "Belt.Set.String.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(s, f)` applies `f` in turn to all elements of `s`. In increasing order" - ], - "signature": "let forEach: (t, value => unit) => unit" - }, - { - "id": "Belt.Set.String.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.Set.String.reduce", - "kind": "value", - "name": "reduce", - "docstrings": ["Iterate in increasing order."], - "signature": "let reduce: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.Set.String.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.String.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(p, s)` checks if all elements of the set satisfy the predicate `p`. Order\nunspecified." - ], - "signature": "let every: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.String.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.String.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(p, s)` checks if at least one element of the set satisfies the predicate\n`p`. Oder unspecified." - ], - "signature": "let some: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.String.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t, value => bool) => t" - }, - { - "id": "Belt.Set.String.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(p, s)` returns the set of all elements in `s` that satisfy predicate `p`." - ], - "signature": "let keep: (t, value => bool) => t" - }, - { - "id": "Belt.Set.String.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.Set.String.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(p, s)` returns a pair of sets `(s1, s2)`, where `s1` is the set of\nall the elements of `s` that satisfy the predicate `p`, and `s2` is the set of\nall the elements of `s` that do not satisfy `p`." - ], - "signature": "let partition: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.Set.String.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t => int" - }, - { - "id": "Belt.Set.String.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order"], - "signature": "let toList: t => list" - }, - { - "id": "Belt.Set.String.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t => array" - }, - { - "id": "Belt.Set.String.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t => option" - }, - { - "id": "Belt.Set.String.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t => Js.undefined" - }, - { - "id": "Belt.Set.String.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t => option" - }, - { - "id": "Belt.Set.String.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t => Js.undefined" - }, - { - "id": "Belt.Set.String.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t, value) => option" - }, - { - "id": "Belt.Set.String.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t, value) => Js.undefined" - }, - { - "id": "Belt.Set.String.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t, value) => value" - }, - { - "id": "Belt.Set.String.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(x, s)` returns a triple `(l, present, r)`, where `l` is the set of\nelements of `s` that are strictly less than `x`;`r` is the set of elements of\n`s` that are strictly greater than `x`; `present` is `false` if `s` contains no\nelement equal to `x`, or `true` if `s` contains an element equal to `x`." - ], - "signature": "let split: (t, value) => ((t, t), bool)" - }, - { - "id": "Belt.Set.String.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t => unit" - } - ] - }, - "belt/set/int": { - "id": "Belt.Set.Int", - "name": "Int", - "docstrings": [ - "Specialized when value type is `int`, more efficient than the generic type, its\ncompare behavior is fixed using the built-in comparison", - "This module is [`Belt.Set`]() specialized with value type to be a primitive type.\n It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,\n and identity is not needed(using the built-in one)\n\n **See** [`Belt.Set`]()" - ], - "items": [ - { - "id": "Belt.Set.Int.value", - "kind": "type", - "name": "value", - "docstrings": ["The type of the set elements."], - "signature": "type value = int" - }, - { - "id": "Belt.Set.Int.t", - "kind": "type", - "name": "t", - "docstrings": ["The type of sets."], - "signature": "type t" - }, - { - "id": "Belt.Set.Int.empty", - "kind": "value", - "name": "empty", - "docstrings": [], - "signature": "let empty: t" - }, - { - "id": "Belt.Set.Int.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: array => t" - }, - { - "id": "Belt.Set.Int.fromSortedArrayUnsafe", - "kind": "value", - "name": "fromSortedArrayUnsafe", - "docstrings": [], - "signature": "let fromSortedArrayUnsafe: array => t" - }, - { - "id": "Belt.Set.Int.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t => bool" - }, - { - "id": "Belt.Set.Int.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t, value) => bool" - }, - { - "id": "Belt.Set.Int.add", - "kind": "value", - "name": "add", - "docstrings": [ - "`add(s, x)` If `x` was already in `s`, `s` is returned unchanged." - ], - "signature": "let add: (t, value) => t" - }, - { - "id": "Belt.Set.Int.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t, array) => t" - }, - { - "id": "Belt.Set.Int.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "`remove(m, x)` If `x` was not in `m`, `m` is returned reference unchanged." - ], - "signature": "let remove: (t, value) => t" - }, - { - "id": "Belt.Set.Int.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t, array) => t" - }, - { - "id": "Belt.Set.Int.union", - "kind": "value", - "name": "union", - "docstrings": [], - "signature": "let union: (t, t) => t" - }, - { - "id": "Belt.Set.Int.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [], - "signature": "let intersect: (t, t) => t" - }, - { - "id": "Belt.Set.Int.diff", - "kind": "value", - "name": "diff", - "docstrings": [], - "signature": "let diff: (t, t) => t" - }, - { - "id": "Belt.Set.Int.subset", - "kind": "value", - "name": "subset", - "docstrings": [ - "`subset(s1, s2)` tests whether the set `s1` is a subset of the set `s2`." - ], - "signature": "let subset: (t, t) => bool" - }, - { - "id": "Belt.Set.Int.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "Total ordering between sets. Can be used as the ordering function for doing sets\nof sets." - ], - "signature": "let cmp: (t, t) => int" - }, - { - "id": "Belt.Set.Int.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain\nequal elements." - ], - "signature": "let eq: (t, t) => bool" - }, - { - "id": "Belt.Set.Int.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t, value => unit) => unit" - }, - { - "id": "Belt.Set.Int.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(s, f)` applies `f` in turn to all elements of `s`. In increasing order" - ], - "signature": "let forEach: (t, value => unit) => unit" - }, - { - "id": "Belt.Set.Int.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.Set.Int.reduce", - "kind": "value", - "name": "reduce", - "docstrings": ["Iterate in increasing order."], - "signature": "let reduce: (t, 'a, ('a, value) => 'a) => 'a" - }, - { - "id": "Belt.Set.Int.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.Int.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(p, s)` checks if all elements of the set satisfy the predicate `p`. Order\nunspecified." - ], - "signature": "let every: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.Int.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.Int.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(p, s)` checks if at least one element of the set satisfies the predicate\n`p`. Oder unspecified." - ], - "signature": "let some: (t, value => bool) => bool" - }, - { - "id": "Belt.Set.Int.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t, value => bool) => t" - }, - { - "id": "Belt.Set.Int.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(p, s)` returns the set of all elements in `s` that satisfy predicate `p`." - ], - "signature": "let keep: (t, value => bool) => t" - }, - { - "id": "Belt.Set.Int.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.Set.Int.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(p, s)` returns a pair of sets `(s1, s2)`, where `s1` is the set of\nall the elements of `s` that satisfy the predicate `p`, and `s2` is the set of\nall the elements of `s` that do not satisfy `p`." - ], - "signature": "let partition: (t, value => bool) => (t, t)" - }, - { - "id": "Belt.Set.Int.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t => int" - }, - { - "id": "Belt.Set.Int.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order"], - "signature": "let toList: t => list" - }, - { - "id": "Belt.Set.Int.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t => array" - }, - { - "id": "Belt.Set.Int.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t => option" - }, - { - "id": "Belt.Set.Int.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t => Js.undefined" - }, - { - "id": "Belt.Set.Int.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t => option" - }, - { - "id": "Belt.Set.Int.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t => Js.undefined" - }, - { - "id": "Belt.Set.Int.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t, value) => option" - }, - { - "id": "Belt.Set.Int.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t, value) => Js.undefined" - }, - { - "id": "Belt.Set.Int.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t, value) => value" - }, - { - "id": "Belt.Set.Int.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(x, s)` returns a triple `(l, present, r)`, where `l` is the set of\nelements of `s` that are strictly less than `x`;`r` is the set of elements of\n`s` that are strictly greater than `x`; `present` is `false` if `s` contains no\nelement equal to `x`, or `true` if `s` contains an element equal to `x`." - ], - "signature": "let split: (t, value) => ((t, t), bool)" - }, - { - "id": "Belt.Set.Int.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t => unit" - } - ] - }, - "belt/sortarray/string": { - "id": "Belt.SortArray.String", - "name": "String", - "docstrings": [ - "Specalized when key type is `string`, more efficient than the generic type", - "This is a specialized module for [`Belt_SortArray`](), the docs in that module also\napplies here, except the comparator is fixed and inlined" - ], - "items": [ - { - "id": "Belt.SortArray.String.element", - "kind": "type", - "name": "element", - "docstrings": [], - "signature": "type element = string" - }, - { - "id": "Belt.SortArray.String.strictlySortedLength", - "kind": "value", - "name": "strictlySortedLength", - "docstrings": [ - "The same as [`Belt_SortArray.strictlySortedLength`]() except the comparator is fixed\n\n**return** `+n` means increasing order `-n` means negative order" - ], - "signature": "let strictlySortedLength: array => int" - }, - { - "id": "Belt.SortArray.String.isSorted", - "kind": "value", - "name": "isSorted", - "docstrings": [ - "`sorted(xs)` return true if `xs` is in non strict increasing order" - ], - "signature": "let isSorted: array => bool" - }, - { - "id": "Belt.SortArray.String.stableSortInPlace", - "kind": "value", - "name": "stableSortInPlace", - "docstrings": [ - "The same as [`Belt_SortArray.stableSortInPlaceBy`]() except the comparator is fixed" - ], - "signature": "let stableSortInPlace: array => unit" - }, - { - "id": "Belt.SortArray.String.stableSort", - "kind": "value", - "name": "stableSort", - "docstrings": [ - "The same as [`Belt_SortArray.stableSortBy`]() except the comparator is fixed" - ], - "signature": "let stableSort: array => array" - }, - { - "id": "Belt.SortArray.String.binarySearch", - "kind": "value", - "name": "binarySearch", - "docstrings": [ - "If value is not found and value is less than one or more elements in array,\nthe negative number returned is the bitwise complement of the index of the first element\nthat is larger than value.\n\nIf value is not found and value is greater than all elements in array,\nthe negative number returned is the bitwise complement of\n(the index of the last element plus 1)\n\nfor example, if `key` is smaller than all elements return `-1` since `lnot (-1) = 0`\nif `key` is larger than all elements return `- (len + 1)` since `lnot (-(len+1)) = len`" - ], - "signature": "let binarySearch: (array, element) => int" - }, - { - "id": "Belt.SortArray.String.union", - "kind": "value", - "name": "union", - "docstrings": [ - "`union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp)` assume\n`src` and `src2` is strictly sorted. for equivalent elements, it is picked from\n`src` also assume that `dst` is large enough to store all elements" - ], - "signature": "let union: (\n array,\n int,\n int,\n array,\n int,\n int,\n array,\n int,\n) => int" - }, - { - "id": "Belt.SortArray.String.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [], - "signature": "let intersect: (\n array,\n int,\n int,\n array,\n int,\n int,\n array,\n int,\n) => int" - }, - { - "id": "Belt.SortArray.String.diff", - "kind": "value", - "name": "diff", - "docstrings": [], - "signature": "let diff: (\n array,\n int,\n int,\n array,\n int,\n int,\n array,\n int,\n) => int" - } - ] - }, - "belt/sortarray/int": { - "id": "Belt.SortArray.Int", - "name": "Int", - "docstrings": [ - "Specalized when key type is `int`, more efficient than the generic type", - "This is a specialized module for [`Belt_SortArray`](), the docs in that module also\napplies here, except the comparator is fixed and inlined" - ], - "items": [ - { - "id": "Belt.SortArray.Int.element", - "kind": "type", - "name": "element", - "docstrings": [], - "signature": "type element = int" - }, - { - "id": "Belt.SortArray.Int.strictlySortedLength", - "kind": "value", - "name": "strictlySortedLength", - "docstrings": [ - "The same as [`Belt_SortArray.strictlySortedLength`]() except the comparator is fixed\n\n**return** `+n` means increasing order `-n` means negative order" - ], - "signature": "let strictlySortedLength: array => int" - }, - { - "id": "Belt.SortArray.Int.isSorted", - "kind": "value", - "name": "isSorted", - "docstrings": [ - "`sorted(xs)` return true if `xs` is in non strict increasing order" - ], - "signature": "let isSorted: array => bool" - }, - { - "id": "Belt.SortArray.Int.stableSortInPlace", - "kind": "value", - "name": "stableSortInPlace", - "docstrings": [ - "The same as [`Belt_SortArray.stableSortInPlaceBy`]() except the comparator is fixed" - ], - "signature": "let stableSortInPlace: array => unit" - }, - { - "id": "Belt.SortArray.Int.stableSort", - "kind": "value", - "name": "stableSort", - "docstrings": [ - "The same as [`Belt_SortArray.stableSortBy`]() except the comparator is fixed" - ], - "signature": "let stableSort: array => array" - }, - { - "id": "Belt.SortArray.Int.binarySearch", - "kind": "value", - "name": "binarySearch", - "docstrings": [ - "If value is not found and value is less than one or more elements in array,\nthe negative number returned is the bitwise complement of the index of the first element\nthat is larger than value.\n\nIf value is not found and value is greater than all elements in array,\nthe negative number returned is the bitwise complement of\n(the index of the last element plus 1)\n\nfor example, if `key` is smaller than all elements return `-1` since `lnot (-1) = 0`\nif `key` is larger than all elements return `- (len + 1)` since `lnot (-(len+1)) = len`" - ], - "signature": "let binarySearch: (array, element) => int" - }, - { - "id": "Belt.SortArray.Int.union", - "kind": "value", - "name": "union", - "docstrings": [ - "`union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp)` assume\n`src` and `src2` is strictly sorted. for equivalent elements, it is picked from\n`src` also assume that `dst` is large enough to store all elements" - ], - "signature": "let union: (\n array,\n int,\n int,\n array,\n int,\n int,\n array,\n int,\n) => int" - }, - { - "id": "Belt.SortArray.Int.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [], - "signature": "let intersect: (\n array,\n int,\n int,\n array,\n int,\n int,\n array,\n int,\n) => int" - }, - { - "id": "Belt.SortArray.Int.diff", - "kind": "value", - "name": "diff", - "docstrings": [], - "signature": "let diff: (\n array,\n int,\n int,\n array,\n int,\n int,\n array,\n int,\n) => int" - } - ] - }, - "belt/id/makehashable": { - "id": "Belt.Id.MakeHashable", - "name": "MakeHashable", - "docstrings": [], - "items": [ - { - "id": "Belt.Id.MakeHashable.identity", - "kind": "type", - "name": "identity", - "docstrings": [], - "signature": "type identity" - }, - { - "id": "Belt.Id.MakeHashable.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = M.t" - }, - { - "id": "Belt.Id.MakeHashable.hash", - "kind": "value", - "name": "hash", - "docstrings": [], - "signature": "let hash: hash" - }, - { - "id": "Belt.Id.MakeHashable.eq", - "kind": "value", - "name": "eq", - "docstrings": [], - "signature": "let eq: eq" - } - ] - }, - "belt/id/makehashableu": { - "id": "Belt.Id.MakeHashableU", - "name": "MakeHashableU", - "docstrings": [], - "items": [ - { - "id": "Belt.Id.MakeHashableU.identity", - "kind": "type", - "name": "identity", - "docstrings": [], - "signature": "type identity" - }, - { - "id": "Belt.Id.MakeHashableU.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = M.t" - }, - { - "id": "Belt.Id.MakeHashableU.hash", - "kind": "value", - "name": "hash", - "docstrings": [], - "signature": "let hash: hash" - }, - { - "id": "Belt.Id.MakeHashableU.eq", - "kind": "value", - "name": "eq", - "docstrings": [], - "signature": "let eq: eq" - } - ] - }, - "belt/id/makecomparable": { - "id": "Belt.Id.MakeComparable", - "name": "MakeComparable", - "docstrings": [], - "items": [ - { - "id": "Belt.Id.MakeComparable.identity", - "kind": "type", - "name": "identity", - "docstrings": [], - "signature": "type identity" - }, - { - "id": "Belt.Id.MakeComparable.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = M.t" - }, - { - "id": "Belt.Id.MakeComparable.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [], - "signature": "let cmp: cmp" - } - ] - }, - "belt/id/makecomparableu": { - "id": "Belt.Id.MakeComparableU", - "name": "MakeComparableU", - "docstrings": [], - "items": [ - { - "id": "Belt.Id.MakeComparableU.identity", - "kind": "type", - "name": "identity", - "docstrings": [], - "signature": "type identity" - }, - { - "id": "Belt.Id.MakeComparableU.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = M.t" - }, - { - "id": "Belt.Id.MakeComparableU.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [], - "signature": "let cmp: cmp" - } - ] - }, - "belt/float": { - "id": "Belt.Float", - "name": "Float", - "docstrings": [ - "[`Belt.Float`]()\n\n Utilities for Float.", - "This module includes convenience methods for handling `float` types." - ], - "items": [ - { - "id": "Belt.Float.toInt", - "kind": "value", - "name": "toInt", - "docstrings": [ - "Converts a given `float` to an `int`.\n\n## Examples\n\n```rescript\nJs.log(Belt.Float.toInt(1.0) === 1) /* true */\n```" - ], - "signature": "let toInt: float => int" - }, - { - "id": "Belt.Float.fromInt", - "kind": "value", - "name": "fromInt", - "docstrings": [ - "Converts a given `int` to a `float`.\n\n## Examples\n\n```rescript\nJs.log(Belt.Float.fromInt(1) === 1.0) /* true */\n```" - ], - "signature": "let fromInt: int => float" - }, - { - "id": "Belt.Float.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "Converts a given `string` to a `float`. Returns `Some(float)` when the input is a number, `None` otherwise.\n\n## Examples\n\n```rescript\nJs.log(Belt.Float.fromString(\"1.0\") === Some(1.0)) /* true */\n```" - ], - "signature": "let fromString: string => option" - }, - { - "id": "Belt.Float.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Converts a given `float` to a `string`. Uses the JavaScript `String` constructor under the hood.\n\n## Examples\n\n```rescript\nJs.log(Belt.Float.toString(1.0) === \"1.0\") /* true */\n```" - ], - "signature": "let toString: float => string" - }, - { - "id": "Belt.Float.+", - "kind": "value", - "name": "+", - "docstrings": [ - "Addition of two `float` values.\nCan be opened in a module to avoid dot-notation (`+.`), however this yields a shadow warning (Warning number 44) in the default configuration.\n\n## Examples\n\n```rescript\nopen Belt.Float\nJs.log(2.0 + 2.0 === 4.0) /* true */\n```" - ], - "signature": "let +: (float, float) => float" - }, - { - "id": "Belt.Float.-", - "kind": "value", - "name": "-", - "docstrings": [ - "Subtraction of two `float` values.\nCan be opened in a module to avoid dot-notation (`-.`), however this yields a shadow warning (Warning number 44) in the default configuration.\n\n## Examples\n\n```rescript\nopen Belt.Float\nJs.log(2.0 - 1.0 === 1.0) /* true */\n```" - ], - "signature": "let -: (float, float) => float" - }, - { - "id": "Belt.Float.*", - "kind": "value", - "name": "*", - "docstrings": [ - "Multiplication of two `float` values.\nCan be opened in a module to avoid dot-notation (`*.`), however this yields a shadow warning (Warning number 44) in the default configuration.\n\n## Examples\n\n```rescript\nopen Belt.Float\nJs.log(2.0 * 2.0 === 4.0) /* true */\n```" - ], - "signature": "let *: (float, float) => float" - }, - { - "id": "Belt.Float./", - "kind": "value", - "name": "/", - "docstrings": [ - "Division of two `float` values.\nCan be opened in a module to avoid dot-notation (`/.`), however this yields a shadow warning (Warning number 44) in the default configuration.\n\n## Examples\n\n```rescript\nopen Belt.Float\nJs.log(4.0 / 2.0 === 2.0) /* true */\n```" - ], - "signature": "let /: (float, float) => float" - } - ] - }, - "belt/int": { - "id": "Belt.Int", - "name": "Int", - "docstrings": [ - "[`Belt.Int`]()\n\n Utilities for Int.", - "This module includes convenience methods for handling `int` types." - ], - "items": [ - { - "id": "Belt.Int.toFloat", - "kind": "value", - "name": "toFloat", - "docstrings": [ - "Converts a given `int` to a `float`.\n\n## Examples\n\n```rescript\nJs.log(Belt.Int.toFloat(1) === 1.0) /* true */\n```" - ], - "signature": "let toFloat: int => float" - }, - { - "id": "Belt.Int.fromFloat", - "kind": "value", - "name": "fromFloat", - "docstrings": [ - "Converts a given `float` to an `int`.\n\n## Examples\n\n```rescript\nJs.log(Belt.Int.fromFloat(1.0) === 1) /* true */\n```" - ], - "signature": "let fromFloat: float => int" - }, - { - "id": "Belt.Int.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "Converts a given `string` to an `int`. Returns `Some(int)` when the input is a number, `None` otherwise.\n\n## Examples\n\n```rescript\nJs.log(Belt.Int.fromString(\"1\") === Some(1)) /* true */\n```" - ], - "signature": "let fromString: string => option" - }, - { - "id": "Belt.Int.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood.\n\n## Examples\n\n```rescript\nJs.log(Belt.Int.toString(1) === \"1\") /* true */\n```" - ], - "signature": "let toString: int => string" - }, - { - "id": "Belt.Int.+", - "kind": "value", - "name": "+", - "docstrings": [ - "Addition of two `int` values. Same as the addition from `Pervasives`.\n\n## Examples\n\n```rescript\nopen Belt.Int\nJs.log(2 + 2 === 4) /* true */\n```" - ], - "signature": "let +: (int, int) => int" - }, - { - "id": "Belt.Int.-", - "kind": "value", - "name": "-", - "docstrings": [ - "Subtraction of two `int` values. Same as the subtraction from `Pervasives`.\n\n## Examples\n\n```rescript\nopen Belt.Int\nJs.log(2 - 1 === 1) /* true */\n```" - ], - "signature": "let -: (int, int) => int" - }, - { - "id": "Belt.Int.*", - "kind": "value", - "name": "*", - "docstrings": [ - "Multiplication of two `int` values. Same as the multiplication from `Pervasives`.\n\n## Examples\n\n```rescript\nopen Belt.Int\nJs.log(2 * 2 === 4) /* true */\n```" - ], - "signature": "let *: (int, int) => int" - }, - { - "id": "Belt.Int./", - "kind": "value", - "name": "/", - "docstrings": [ - "Division of two `int` values. Same as the division from `Pervasives`.\n\n## Examples\n\n```rescript\nopen Belt.Int\nJs.log(4 / 2 === 2); /* true */\n```" - ], - "signature": "let /: (int, int) => int" - } - ] - }, - "belt/result": { - "id": "Belt.Result", - "name": "Result", - "docstrings": [ - "[`Belt.Result`]()\n\n Utilities for result data type.", - "Result types are really useful to describe the result of a certain operation\nwithout relying on exceptions or `option` types.\n\nThis module gives you useful utilities to create and combine `Result` data." - ], - "items": [ - { - "id": "Belt.Result.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a, 'b> = result<'a, 'b> = Ok('a) | Error('b)" - }, - { - "id": "Belt.Result.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "`getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception\n\n## Examples\n\n```rescript\nBelt.Result.getExn(Belt.Result.Ok(42)) == 42\n\nBelt.Result.getExn(Belt.Result.Error(\"Invalid data\")) /* raises exception */\n```" - ], - "signature": "let getExn: t<'a, 'b> => 'a" - }, - { - "id": "Belt.Result.mapWithDefaultU", - "kind": "value", - "name": "mapWithDefaultU", - "docstrings": [], - "signature": "let mapWithDefaultU: (t<'a, 'c>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Belt.Result.mapWithDefault", - "kind": "value", - "name": "mapWithDefault", - "docstrings": [ - "`mapWithDefault(res, default, f)`: When res is `Ok(n)`, returns `f(n)`,\notherwise `default`.\n\n## Examples\n\n```rescript\nlet ok = Belt.Result.Ok(42)\nBelt.Result.mapWithDefault(ok, 0, (x) => x / 2) == 21\n\nlet error = Belt.Result.Error(\"Invalid data\")\nBelt.Result.mapWithDefault(error, 0, (x) => x / 2) == 0\n```" - ], - "signature": "let mapWithDefault: (t<'a, 'c>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Belt.Result.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'a, 'c>, 'a => 'b) => t<'b, 'c>" - }, - { - "id": "Belt.Result.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns an\nordinary value.\n\n## Examples\n\n```rescript\nlet f = (x) => sqrt(Belt.Int.toFloat(x))\n\nBelt.Result.map(Ok(64), f) == Ok(8.0)\n\nBelt.Result.map(Error(\"Invalid data\"), f) == Error(\"Invalid data\")\n```" - ], - "signature": "let map: (t<'a, 'c>, 'a => 'b) => t<'b, 'c>" - }, - { - "id": "Belt.Result.flatMapU", - "kind": "value", - "name": "flatMapU", - "docstrings": [], - "signature": "let flatMapU: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c>" - }, - { - "id": "Belt.Result.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "`flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns a\n`Belt.Result`.\n\n## Examples\n\n```rescript\nlet recip = (x) =>\n if (x !== 0.0) {\n Belt.Result.Ok(1.0 /. x)\n } else {\n Belt.Result.Error(\"Divide by zero\")\n }\n\nBelt.Result.flatMap(Ok(2.0), recip) == Ok(0.5)\n\nBelt.Result.flatMap(Ok(0.0), recip) == Error(\"Divide by zero\")\n\nBelt.Result.flatMap(Error(\"Already bad\"), recip) == Error(\"Already bad\")\n```" - ], - "signature": "let flatMap: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c>" - }, - { - "id": "Belt.Result.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [ - "`getWithDefault(res, defaultValue)`: If `res` is `Ok(n)`, returns `n`,\notherwise `default`\n\n## Examples\n\n```rescript\nBelt.Result.getWithDefault(Ok(42), 0) == 42\n\nBelt.Result.getWithDefault(Error(\"Invalid Data\"), 0) == 0\n```" - ], - "signature": "let getWithDefault: (t<'a, 'b>, 'a) => 'a" - }, - { - "id": "Belt.Result.isOk", - "kind": "value", - "name": "isOk", - "docstrings": [ - "`isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is\nthe `Error(e)` variant." - ], - "signature": "let isOk: t<'a, 'b> => bool" - }, - { - "id": "Belt.Result.isError", - "kind": "value", - "name": "isError", - "docstrings": [ - "`isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if\nit is the `Ok(n)` variant." - ], - "signature": "let isError: t<'a, 'b> => bool" - }, - { - "id": "Belt.Result.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Result.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(res1, res2, f)`: Determine if two `Belt.Result` variables are equal with\nrespect to an equality function. If `res1` and `res2` are of the form `Ok(n)`\nand `Ok(m)`, return the result of `f(n, m)`. If one of `res1` and `res2` are of\nthe form `Error(e)`, return false If both `res1` and `res2` are of the form\n`Error(e)`, return true\n\n## Examples\n\n```rescript\nlet good1 = Belt.Result.Ok(42)\n\nlet good2 = Belt.Result.Ok(32)\n\nlet bad1 = Belt.Result.Error(\"invalid\")\n\nlet bad2 = Belt.Result.Error(\"really invalid\")\n\nlet mod10equal = (a, b) => mod(a, 10) === mod(b, 10)\n\nBelt.Result.eq(good1, good2, mod10equal) == true\n\nBelt.Result.eq(good1, bad1, mod10equal) == false\n\nBelt.Result.eq(bad2, good2, mod10equal) == false\n\nBelt.Result.eq(bad1, bad2, mod10equal) == true\n```" - ], - "signature": "let eq: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Result.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => int) => int" - }, - { - "id": "Belt.Result.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "`cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a\ncomparison function. The comparison function returns -1 if the first variable\nis \"less than\" the second, 0 if the two variables are equal, and 1 if the first\nis \"greater than\" the second.\n\nIf `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of\n`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`,\nreturn -1 (nothing is less than something) If `res1` is of the form `Ok(n)` and\n`res2` of the form `Error(e)`, return 1 (something is greater than nothing) If\nboth `res1` and `res2` are of the form `Error(e)`, return 0 (equal)\n\n## Examples\n\n```rescript\nlet good1 = Belt.Result.Ok(59)\n\nlet good2 = Belt.Result.Ok(37)\n\nlet bad1 = Belt.Result.Error(\"invalid\")\n\nlet bad2 = Belt.Result.Error(\"really invalid\")\n\nlet mod10cmp = (a, b) => Pervasives.compare(mod(a, 10), mod(b, 10))\n\nBelt.Result.cmp(Ok(39), Ok(57), mod10cmp) == 1\n\nBelt.Result.cmp(Ok(57), Ok(39), mod10cmp) == (-1)\n\nBelt.Result.cmp(Ok(39), Error(\"y\"), mod10cmp) == 1\n\nBelt.Result.cmp(Error(\"x\"), Ok(57), mod10cmp) == (-1)\n\nBelt.Result.cmp(Error(\"x\"), Error(\"y\"), mod10cmp) == 0\n```" - ], - "signature": "let cmp: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => int) => int" - } - ] - }, - "belt/option": { - "id": "Belt.Option", - "name": "Option", - "docstrings": [ - "[`Belt.Option`]()\n\n Utilities for option data type.", - "In Belt we represent the existence and nonexistence of a value by wrapping it\nwith the `option` type. In order to make it a bit more convenient to work with\noption-types, Belt provides utility-functions for it.\n\nThe `option` type is a part of the ReScript standard library which is defined like this:\n\n## Examples\n\n```rescript\ntype option<'a> = None | Some('a)\n```\n\n```rescript\nlet someString: option = Some(\"hello\")\n```" - ], - "items": [ - { - "id": "Belt.Option.keepU", - "kind": "value", - "name": "keepU", - "docstrings": ["Uncurried version of `keep`"], - "signature": "let keepU: (option<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Belt.Option.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "If `optionValue` is `Some(value)` and `p(value) = true`, it returns `Some(value)`; otherwise returns `None`\n\n## Examples\n\n```rescript\nBelt.Option.keep(Some(10), x => x > 5) /* returns `Some(10)` */\nBelt.Option.keep(Some(4), x => x > 5) /* returns `None` */\nBelt.Option.keep(None, x => x > 5) /* returns `None` */\n```" - ], - "signature": "let keep: (option<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Belt.Option.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": ["Uncurried version of `forEach`"], - "signature": "let forEachU: (option<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.Option.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "If `optionValue` is `Some(value`), it calls `f(value)`; otherwise returns `()`\n\n## Examples\n\n```rescript\nBelt.Option.forEach(Some(\"thing\"), x => Js.log(x)) /* logs \"thing\" */\nBelt.Option.forEach(None, x => Js.log(x)) /* returns () */\n```" - ], - "signature": "let forEach: (option<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.Option.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "Raises an Error in case `None` is provided. Use with care.\n\n## Examples\n\n```rescript\nBelt.Option.getExn(Some(3)) /* 3 */\n\nBelt.Option.getExn(None) /* Raises an Error */\n```" - ], - "signature": "let getExn: option<'a> => 'a" - }, - { - "id": "Belt.Option.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(x)` returns `x`\n\nThis is an unsafe operation, it assumes `x` is neither `None`\nnor `Some(None(...)))`" - ], - "signature": "let getUnsafe: option<'a> => 'a" - }, - { - "id": "Belt.Option.mapWithDefaultU", - "kind": "value", - "name": "mapWithDefaultU", - "docstrings": ["Uncurried version of `mapWithDefault`"], - "signature": "let mapWithDefaultU: (option<'a>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Belt.Option.mapWithDefault", - "kind": "value", - "name": "mapWithDefault", - "docstrings": [ - "If `optionValue` is of `Some(value)`,\nthis function returns that value applied with `f`, in other words `f(value)`.\n\nIf `optionValue` is `None`, the default is returned.\n\n## Examples\n\n```rescript\nlet someValue = Some(3)\nsomeValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 8 */\n\nlet noneValue = None\nnoneValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 0 */\n```" - ], - "signature": "let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Belt.Option.mapU", - "kind": "value", - "name": "mapU", - "docstrings": ["Uncurried version of `map`"], - "signature": "let mapU: (option<'a>, 'a => 'b) => option<'b>" - }, - { - "id": "Belt.Option.map", - "kind": "value", - "name": "map", - "docstrings": [ - "If `optionValue` is `Some(value)` this returns `f(value)`, otherwise it returns `None`.\n\n## Examples\n\n```rescript\nBelt.Option.map(Some(3), x => x * x) /* Some(9) */\n\nBelt.Option.map(None, x => x * x) /* None */\n```" - ], - "signature": "let map: (option<'a>, 'a => 'b) => option<'b>" - }, - { - "id": "Belt.Option.flatMapU", - "kind": "value", - "name": "flatMapU", - "docstrings": ["Uncurried version of `flatMap`"], - "signature": "let flatMapU: (option<'a>, 'a => option<'b>) => option<'b>" - }, - { - "id": "Belt.Option.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "If `optionValue` is `Some(value)`, returns `f(value)`, otherwise returns\n`None`.
\nThe function `f` must have a return type of `option<'b>`.\n\n## Examples\n\n```rescript\nlet addIfAboveOne = value =>\n if (value > 1) {\n Some(value + 1)\n } else {\n None\n }\n\nBelt.Option.flatMap(Some(2), addIfAboveOne) /* Some(3) */\n\nBelt.Option.flatMap(Some(-4), addIfAboveOne) /* None */\n\nBelt.Option.flatMap(None, addIfAboveOne) /* None */\n```" - ], - "signature": "let flatMap: (option<'a>, 'a => option<'b>) => option<'b>" - }, - { - "id": "Belt.Option.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [ - "If `optionalValue` is `Some(value)`, returns `value`, otherwise default.\n\n## Examples\n\n```rescript\nBelt.Option.getWithDefault(None, \"Banana\") /* Banana */\n\nBelt.Option.getWithDefault(Some(\"Apple\"), \"Banana\") /* Apple */\n```\n\n```rescript\nlet greet = (firstName: option) =>\n \"Greetings \" ++ firstName->Belt.Option.getWithDefault(\"Anonymous\")\n\nSome(\"Jane\")->greet /* \"Greetings Jane\" */\n\nNone->greet /* \"Greetings Anonymous\" */\n```" - ], - "signature": "let getWithDefault: (option<'a>, 'a) => 'a" - }, - { - "id": "Belt.Option.orElse", - "kind": "value", - "name": "orElse", - "docstrings": [ - "`orElse(optionalValue, otherOptional)` if `optionalValue` is `Some(value)`,\nreturns `Some(value)`, otherwise `otherOptional`\n\n## Examples\n\n```rescript\nBelt.Option.orElse(Some(1812), Some(1066)) == Some(1812)\nBelt.Option.orElse(None, Some(1066)) == Some(1066)\nBelt.Option.orElse(None, None) == None\n```" - ], - "signature": "let orElse: (option<'a>, option<'a>) => option<'a>" - }, - { - "id": "Belt.Option.isSome", - "kind": "value", - "name": "isSome", - "docstrings": [ - "Returns `true` if the argument is `Some(value)`, `false` otherwise.\n\n## Examples\n\n```rescript\nBelt.Option.isSome(None) /* false */\n\nBelt.Option.isSome(Some(1)) /* true */\n```" - ], - "signature": "let isSome: option<'a> => bool" - }, - { - "id": "Belt.Option.isNone", - "kind": "value", - "name": "isNone", - "docstrings": [ - "Returns `true` if the argument is `None`, `false` otherwise.\n\n## Examples\n\n```rescript\nBelt.Option.isNone(None) /* true */\n\nBelt.Option.isNone(Some(1)) /* false */\n```" - ], - "signature": "let isNone: option<'a> => bool" - }, - { - "id": "Belt.Option.eqU", - "kind": "value", - "name": "eqU", - "docstrings": ["Uncurried version of `eq`"], - "signature": "let eqU: (option<'a>, option<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Option.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "Evaluates two optional values for equality with respect to a predicate\nfunction. If both `optValue1` and `optValue2` are `None`, returns `true`.\nIf one of the arguments is `Some(value)` and the other is `None`, returns\n`false`.\n\nIf arguments are `Some(value1)` and `Some(value2)`, returns the result of\n`predicate(value1, value2)`; the predicate function must return a bool.\n\n## Examples\n\n```rescript\nlet clockEqual = (a, b) => mod(a, 12) == mod(b, 12)\n\nopen Belt.Option\n\neq(Some(3), Some(15), clockEqual) /* true */\n\neq(Some(3), None, clockEqual) /* false */\n\neq(None, Some(3), clockEqual) /* false */\n\neq(None, None, clockEqual) /* true */\n```" - ], - "signature": "let eq: (option<'a>, option<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Option.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": ["Uncurried version of `cmp`"], - "signature": "let cmpU: (option<'a>, option<'b>, ('a, 'b) => int) => int" - }, - { - "id": "Belt.Option.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "`cmp(optValue1, optValue2, comparisonFunction)` compares two optional values\nwith respect to given `comparisonFunction`.\n\nIf both `optValue1` and `optValue2` are `None`, it returns `0`.\n\nIf the first argument is `Some(value1)` and the second is `None`, returns `1`\n(something is greater than nothing).\n\nIf the first argument is `None` and the second is `Some(value2)`, returns `-1`\n(nothing is less than something).\n\nIf the arguments are `Some(value1)` and `Some(value2)`, returns the result of\n`comparisonFunction(value1, value2)`; comparisonFunction takes two arguments\nand returns `-1` if the first argument is less than the second, `0` if the\narguments are equal, and `1` if the first argument is greater than the second.\n\n## Examples\n\n```rescript\nlet clockCompare = (a, b) => compare(mod(a, 12), mod(b, 12))\n\nopen Belt.Option\n\ncmp(Some(3), Some(15), clockCompare) /* 0 */\n\ncmp(Some(3), Some(14), clockCompare) /* 1 */\n\ncmp(Some(2), Some(15), clockCompare) /* (-1) */\n\ncmp(None, Some(15), clockCompare) /* (-1) */\n\ncmp(Some(14), None, clockCompare) /* 1 */\n\ncmp(None, None, clockCompare) /* 0 */\n```" - ], - "signature": "let cmp: (option<'a>, option<'b>, ('a, 'b) => int) => int" - } - ] - }, - "belt/hashmap": { - "id": "Belt.HashMap", - "name": "HashMap", - "docstrings": [ - "[`Belt.HashMap`]()\n\n The top level provides generic **mutable** hash map operations.\n\n It also has two specialized inner modules\n [`Belt.HashMap.Int`]() and [`Belt.HashMap.String`]()", - "A **mutable** Hash map which allows customized [`hash`]() behavior.\n\nAll data are parameterized by not its only type but also a unique identity in\nthe time of initialization, so that two _HashMaps of ints_ initialized with different\n_hash_ functions will have different type.\n\n## Examples\n\n```rescript\ntype t = int\nmodule I0 = unpack(Belt.Id.hashableU(~hash=(. a: t) => \"&\"(a, 0xff_ff), ~eq=(. a, b) => a == b))\nlet s0: t<_, string, _> = make(~hintSize=40, ~id=module(I0))\n\nmodule I1 = unpack(Belt.Id.hashableU(~hash=(. a: t) => \"&\"(a, 0xff), ~eq=(. a, b) => a == b))\nlet s1: t<_, string, _> = make(~hintSize=40, ~id=module(I1))\n```\n\nThe invariant must be held: for two elements who are _equal_,\ntheir hashed value should be the same\n\nHere the compiler would infer `s0` and `s1` having different type so that\nit would not mix.\n\n## Examples\n\n```rescript\nlet s0: t\nlet s1: t\n```\n\nWe can add elements to the collection:\n\n## Examples\n\n```rescript\nlet () = {\n add(s1, 0, \"3\")\n add(s1, 1, \"3\")\n}\n```\n\nSince this is an mutable data strucure, `s1` will contain two pairs." - ], - "items": [ - { - "id": "Belt.HashMap.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The type of hash tables from type `'key` to type `'value`." - ], - "signature": "type t<'key, 'value, 'id>" - }, - { - "id": "Belt.HashMap.id", - "kind": "type", - "name": "id", - "docstrings": ["The identity needed for making an empty hash map."], - "signature": "type id<'a, 'id> = Belt_Id.hashable<'a, 'id>" - }, - { - "id": "Belt.HashMap.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(~hintSize=10, ~id)` creates a new map by taking in the comparator and `hintSize`.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\n\nBelt.HashMap.set(hMap, 0, \"a\")\n```" - ], - "signature": "let make: (~hintSize: int, ~id: id<'key, 'id>) => t<'key, 'value, 'id>" - }, - { - "id": "Belt.HashMap.clear", - "kind": "value", - "name": "clear", - "docstrings": [ - "Clears a hash table.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet hMap = Belt.HashMap.fromArray([(1, \"1\")], ~id=module(IntHash))\nBelt.HashMap.clear(hMap)\nBelt.HashMap.isEmpty(hMap) == true\n```" - ], - "signature": "let clear: t<'key, 'value, 'id> => unit" - }, - { - "id": "Belt.HashMap.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [ - "`isEmpty(m)` checks whether a hash map is empty.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nBelt.HashMap.isEmpty(Belt.HashMap.fromArray([(1, \"1\")], ~id=module(IntHash))) == false\n```" - ], - "signature": "let isEmpty: t<'a, 'b, 'c> => bool" - }, - { - "id": "Belt.HashMap.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(hMap, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntHash))\n\nBelt.HashMap.set(s0, 2, \"3\")\n\nBelt.HashMap.valuesToArray(s0) == [\"1\", \"3\", \"3\"]\n```" - ], - "signature": "let set: (t<'key, 'value, 'id>, 'key, 'value) => unit" - }, - { - "id": "Belt.HashMap.copy", - "kind": "value", - "name": "copy", - "docstrings": [ - "Creates copy of a hash map.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntHash))\nlet s1 = Belt.HashMap.copy(s0)\n\nBelt.HashMap.set(s0, 2, \"3\")\n\nBelt.HashMap.get(s0, 2) != Belt.HashMap.get(s1, 2)\n```" - ], - "signature": "let copy: t<'key, 'value, 'id> => t<'key, 'value, 'id>" - }, - { - "id": "Belt.HashMap.get", - "kind": "value", - "name": "get", - "docstrings": [ - "Returns value bound under specific key. If values not exist returns `None`.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\n\nBelt.HashMap.get(s0, 1) == Some(\"value1\")\nBelt.HashMap.get(s0, 2) == None\n```" - ], - "signature": "let get: (t<'key, 'value, 'id>, 'key) => option<'value>" - }, - { - "id": "Belt.HashMap.has", - "kind": "value", - "name": "has", - "docstrings": [ - "Checks if `x` is bound in `tbl`.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\n\nBelt.HashMap.has(s0, 1) == true\nBelt.HashMap.has(s0, 2) == false\n```" - ], - "signature": "let has: (t<'key, 'value, 'id>, 'key) => bool" - }, - { - "id": "Belt.HashMap.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "If bound exists, removes it from the hash map.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.remove(s0, 1)\nBelt.HashMap.has(s0, 1) == false\n```" - ], - "signature": "let remove: (t<'key, 'value, 'id>, 'key) => unit" - }, - { - "id": "Belt.HashMap.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [ - "Same as [forEach](#forEach) but takes uncurried function." - ], - "signature": "let forEachU: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit" - }, - { - "id": "Belt.HashMap.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.forEach(s0, (key, value) => Js.log2(key, value))\n// prints (1, \"value1\")\n```" - ], - "signature": "let forEach: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit" - }, - { - "id": "Belt.HashMap.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c" - }, - { - "id": "Belt.HashMap.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`.\n\nThe order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.set(s0, 2, \"value2\")\n\nBelt.HashMap.reduce(s0, \"\", (acc, key, value) => acc ++ (\", \" ++ value)) == \"value1, value2\"\n```" - ], - "signature": "let reduce: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c" - }, - { - "id": "Belt.HashMap.keepMapInPlaceU", - "kind": "value", - "name": "keepMapInPlaceU", - "docstrings": [ - "Same as [keepMapInPlace](#keepMapInPlace) but takes uncurried function." - ], - "signature": "let keepMapInPlaceU: (\n t<'key, 'value, 'id>,\n ('key, 'value) => option<'value>,\n) => unit" - }, - { - "id": "Belt.HashMap.keepMapInPlace", - "kind": "value", - "name": "keepMapInPlace", - "docstrings": [ - "Filters out values for which function `f` returned `None`.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.set(s0, 2, \"value2\")\n\nBelt.HashMap.keepMapInPlace(s0, (key, value) => key == 1 ? None : Some(value))\n```" - ], - "signature": "let keepMapInPlace: (\n t<'key, 'value, 'id>,\n ('key, 'value) => option<'value>,\n) => unit" - }, - { - "id": "Belt.HashMap.size", - "kind": "value", - "name": "size", - "docstrings": [ - "`size(tbl)` returns the number of bindings in `tbl`. It takes constant time.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.set(s0, 2, \"value2\")\n\nBelt.HashMap.size(s0) == 2\n```" - ], - "signature": "let size: t<'a, 'b, 'c> => int" - }, - { - "id": "Belt.HashMap.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "Returns array of key value pairs.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.set(s0, 2, \"value2\")\n\nBelt.HashMap.toArray(s0) == [(1, \"value1\"), (2, \"value2\")]\n```" - ], - "signature": "let toArray: t<'key, 'value, 'id> => array<('key, 'value)>" - }, - { - "id": "Belt.HashMap.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [ - "Returns array of keys.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.set(s0, 2, \"value2\")\n\nBelt.HashMap.keysToArray(s0) == [1, 2]\n```" - ], - "signature": "let keysToArray: t<'key, 'a, 'b> => array<'key>" - }, - { - "id": "Belt.HashMap.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [ - "Returns array of values.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(s0, 1, \"value1\")\nBelt.HashMap.set(s0, 2, \"value2\")\n\nBelt.HashMap.valuesToArray(s0) == [\"value1\", \"value2\"]\n```" - ], - "signature": "let valuesToArray: t<'a, 'value, 'b> => array<'value>" - }, - { - "id": "Belt.HashMap.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Creates new hash map from array of pairs.\n\nReturns array of values.\n\n## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet s0 = Belt.HashMap.fromArray([(1, \"value1\"), (2, \"value2\")], ~id=module(IntHash))\nBelt.HashMap.toArray(s0) == [(1, \"value1\"), (2, \"value2\")]\n```" - ], - "signature": "let fromArray: (\n array<('key, 'value)>,\n ~id: id<'key, 'id>,\n) => t<'key, 'value, 'id>" - }, - { - "id": "Belt.HashMap.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [ - "## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\n\nlet hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.mergeMany(hMap, [(1, \"1\"), (2, \"2\")])\n```" - ], - "signature": "let mergeMany: (t<'key, 'value, 'id>, array<('key, 'value)>) => unit" - }, - { - "id": "Belt.HashMap.getBucketHistogram", - "kind": "value", - "name": "getBucketHistogram", - "docstrings": [ - "## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\nlet hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(hMap, 1, \"1\")\n\nBelt.HashMap.getBucketHistogram(hMap)\n```" - ], - "signature": "let getBucketHistogram: t<'a, 'b, 'c> => array" - }, - { - "id": "Belt.HashMap.logStats", - "kind": "value", - "name": "logStats", - "docstrings": [ - "## Examples\n\n```rescript\nmodule IntHash = Belt.Id.MakeHashable({\n type t = int\n let hash = a => a\n let eq = (a, b) => a == b\n})\nlet hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash))\nBelt.HashMap.set(hMap, 1, \"1\")\n\nBelt.HashMap.logStats(hMap)\n```" - ], - "signature": "let logStats: t<'a, 'b, 'c> => unit" - } - ] - }, - "belt/hashset": { - "id": "Belt.HashSet", - "name": "HashSet", - "docstrings": [ - "[`Belt.HashSet`]()\n\n The top level provides generic **mutable** hash set operations.\n\n It also has two specialized inner modules\n [`Belt.HashSet.Int`]() and [`Belt.HashSet.String`]()", - "A **mutable** Hash set which allows customized `hash` behavior.\n\nAll data are parameterized by not its only type but also a unique identity in\nthe time of initialization, so that two _HashSets of ints_ initialized with\ndifferent _hash_ functions will have different type.\n\n## Examples\n\n```rescript\nmodule I0 = unpack(\n Belt.Id.hashableU(\n ~hash=(. a: int) => land(a, 65535),\n ~eq=(. a, b) => a == b,\n )\n)\n\nlet s0 = Belt.HashSet.make(~id=module(I0), ~hintSize=40)\n\nmodule I1 = unpack(\n Belt.Id.hashableU(\n ~hash=(. a: int) => land(a, 255),\n ~eq=(. a, b) => a == b,\n )\n)\n\nlet s1 = Belt.HashSet.make(~id=module(I1), ~hintSize=40)\n\nBelt.HashSet.add(s1, 0)\nBelt.HashSet.add(s1, 1)\n```\n\nThe invariant must be held: for two elements who are equal, their hashed\nvalue should be the same.\n\nHere the compiler would infer `s0` and `s1` having different type so that it\nwould not mix.\n\n## Examples\n\n```rescript\nlet s0: Belt.HashSet.t\nlet s1: Belt.HashSet.t\n```\n\nWe can add elements to the collection (see last two lines in the example\nabove). Since this is an mutable data structure, `s1` will contain two pairs." - ], - "items": [ - { - "id": "Belt.HashSet.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a, 'id>" - }, - { - "id": "Belt.HashSet.id", - "kind": "type", - "name": "id", - "docstrings": ["The type of hash tables from type `'a` to type `'b`."], - "signature": "type id<'a, 'id> = Belt_Id.hashable<'a, 'id>" - }, - { - "id": "Belt.HashSet.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~hintSize: int, ~id: id<'a, 'id>) => t<'a, 'id>" - }, - { - "id": "Belt.HashSet.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t<'a, 'id> => unit" - }, - { - "id": "Belt.HashSet.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a, 'b> => bool" - }, - { - "id": "Belt.HashSet.add", - "kind": "value", - "name": "add", - "docstrings": [], - "signature": "let add: (t<'a, 'id>, 'a) => unit" - }, - { - "id": "Belt.HashSet.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t<'a, 'id> => t<'a, 'id>" - }, - { - "id": "Belt.HashSet.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'a, 'id>, 'a) => bool" - }, - { - "id": "Belt.HashSet.remove", - "kind": "value", - "name": "remove", - "docstrings": [], - "signature": "let remove: (t<'a, 'id>, 'a) => unit" - }, - { - "id": "Belt.HashSet.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'a, 'id>, 'a => unit) => unit" - }, - { - "id": "Belt.HashSet.forEach", - "kind": "value", - "name": "forEach", - "docstrings": ["Order unspecified."], - "signature": "let forEach: (t<'a, 'id>, 'a => unit) => unit" - }, - { - "id": "Belt.HashSet.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c" - }, - { - "id": "Belt.HashSet.reduce", - "kind": "value", - "name": "reduce", - "docstrings": ["Order unspecified."], - "signature": "let reduce: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c" - }, - { - "id": "Belt.HashSet.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'a, 'id> => int" - }, - { - "id": "Belt.HashSet.logStats", - "kind": "value", - "name": "logStats", - "docstrings": [], - "signature": "let logStats: t<'a, 'b> => unit" - }, - { - "id": "Belt.HashSet.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t<'a, 'id> => array<'a>" - }, - { - "id": "Belt.HashSet.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: (array<'a>, ~id: id<'a, 'id>) => t<'a, 'id>" - }, - { - "id": "Belt.HashSet.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t<'a, 'id>, array<'a>) => unit" - }, - { - "id": "Belt.HashSet.getBucketHistogram", - "kind": "value", - "name": "getBucketHistogram", - "docstrings": [], - "signature": "let getBucketHistogram: t<'a, 'b> => array" - } - ] - }, - "belt/mutablemap": { - "id": "Belt.MutableMap", - "name": "MutableMap", - "docstrings": [ - "[`Belt.MutableMap`]()\n\n The top level provides generic **mutable** map operations.\n\n It also has two specialized inner modules\n [`Belt.MutableMap.Int`]() and [`Belt.MutableMap.String`]()" - ], - "items": [ - { - "id": "Belt.MutableMap.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'k, 'v, 'id>" - }, - { - "id": "Belt.MutableMap.id", - "kind": "type", - "name": "id", - "docstrings": [], - "signature": "type id<'key, 'id> = Belt_Id.comparable<'key, 'id>" - }, - { - "id": "Belt.MutableMap.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~id: id<'k, 'id>) => t<'k, 'a, 'id>" - }, - { - "id": "Belt.MutableMap.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t<'a, 'b, 'c> => unit" - }, - { - "id": "Belt.MutableMap.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a, 'b, 'c> => bool" - }, - { - "id": "Belt.MutableMap.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'k, 'a, 'b>, 'k) => bool" - }, - { - "id": "Belt.MutableMap.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.MutableMap.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by\nkey, value pair." - ], - "signature": "let cmp: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.MutableMap.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(m1, m2, eqf)` tests whether the maps `m1` and `m2` are equal, that is,\ncontain equal keys and associate them with equal data. `eqf` is the\nequality predicate used to compare the data associated with the keys." - ], - "signature": "let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit" - }, - { - "id": "Belt.MutableMap.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(m, f)` applies f to all bindings in map `m`. `f` receives the `'k`\nas first argument, and the associated value as second argument. The\nbindings are passed to `f` in increasing order with respect to the ordering\nover the type of the keys." - ], - "signature": "let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit" - }, - { - "id": "Belt.MutableMap.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableMap.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ...\nkN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN`\nare the associated data." - ], - "signature": "let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableMap.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`." - ], - "signature": "let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`." - ], - "signature": "let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool" - }, - { - "id": "Belt.MutableMap.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'k, 'a, 'id> => int" - }, - { - "id": "Belt.MutableMap.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order."], - "signature": "let toList: t<'k, 'a, 'id> => list<('k, 'a)>" - }, - { - "id": "Belt.MutableMap.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [], - "signature": "let toArray: t<'k, 'a, 'id> => array<('k, 'a)>" - }, - { - "id": "Belt.MutableMap.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [], - "signature": "let fromArray: (array<('k, 'a)>, ~id: id<'k, 'id>) => t<'k, 'a, 'id>" - }, - { - "id": "Belt.MutableMap.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [], - "signature": "let keysToArray: t<'k, 'a, 'b> => array<'k>" - }, - { - "id": "Belt.MutableMap.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [], - "signature": "let valuesToArray: t<'b, 'a, 'c> => array<'a>" - }, - { - "id": "Belt.MutableMap.minKey", - "kind": "value", - "name": "minKey", - "docstrings": [], - "signature": "let minKey: t<'k, 'a, 'b> => option<'k>" - }, - { - "id": "Belt.MutableMap.minKeyUndefined", - "kind": "value", - "name": "minKeyUndefined", - "docstrings": [], - "signature": "let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>" - }, - { - "id": "Belt.MutableMap.maxKey", - "kind": "value", - "name": "maxKey", - "docstrings": [], - "signature": "let maxKey: t<'k, 'a, 'b> => option<'k>" - }, - { - "id": "Belt.MutableMap.maxKeyUndefined", - "kind": "value", - "name": "maxKeyUndefined", - "docstrings": [], - "signature": "let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>" - }, - { - "id": "Belt.MutableMap.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [], - "signature": "let minimum: t<'k, 'a, 'b> => option<('k, 'a)>" - }, - { - "id": "Belt.MutableMap.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [], - "signature": "let minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>" - }, - { - "id": "Belt.MutableMap.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [], - "signature": "let maximum: t<'k, 'a, 'b> => option<('k, 'a)>" - }, - { - "id": "Belt.MutableMap.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [], - "signature": "let maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>" - }, - { - "id": "Belt.MutableMap.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'k, 'a, 'id>, 'k) => option<'a>" - }, - { - "id": "Belt.MutableMap.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [], - "signature": "let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a>" - }, - { - "id": "Belt.MutableMap.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a" - }, - { - "id": "Belt.MutableMap.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: (t<'k, 'a, 'id>, 'k) => 'a" - }, - { - "id": "Belt.MutableMap.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["Raise when invariant is not held."], - "signature": "let checkInvariantInternal: t<'a, 'b, 'c> => unit" - }, - { - "id": "Belt.MutableMap.remove", - "kind": "value", - "name": "remove", - "docstrings": ["`remove(m, x)` do the in-place modification."], - "signature": "let remove: (t<'k, 'a, 'id>, 'k) => unit" - }, - { - "id": "Belt.MutableMap.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [], - "signature": "let removeMany: (t<'k, 'a, 'id>, array<'k>) => unit" - }, - { - "id": "Belt.MutableMap.set", - "kind": "value", - "name": "set", - "docstrings": ["`set(m, x, y)` do the in-place modification"], - "signature": "let set: (t<'k, 'a, 'id>, 'k, 'a) => unit" - }, - { - "id": "Belt.MutableMap.updateU", - "kind": "value", - "name": "updateU", - "docstrings": [], - "signature": "let updateU: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit" - }, - { - "id": "Belt.MutableMap.update", - "kind": "value", - "name": "update", - "docstrings": [], - "signature": "let update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit" - }, - { - "id": "Belt.MutableMap.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [], - "signature": "let mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unit" - }, - { - "id": "Belt.MutableMap.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>" - }, - { - "id": "Belt.MutableMap.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(m, f)` returns a map with same domain as `m`, where the associated\nvalue a of all bindings of `m` has been replaced by the result of the\napplication of `f` to `a`. The bindings are passed to `f` in increasing\norder with respect to the ordering over the type of the keys." - ], - "signature": "let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>" - }, - { - "id": "Belt.MutableMap.mapWithKeyU", - "kind": "value", - "name": "mapWithKeyU", - "docstrings": [], - "signature": "let mapWithKeyU: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>" - }, - { - "id": "Belt.MutableMap.mapWithKey", - "kind": "value", - "name": "mapWithKey", - "docstrings": [], - "signature": "let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>" - } - ] - }, - "belt/mutableset": { - "id": "Belt.MutableSet", - "name": "MutableSet", - "docstrings": [ - "[`Belt.MutableSet`]()\n\n The top level provides generic **mutable** set operations.\n\n It also has two specialized inner modules\n [`Belt.MutableSet.Int`]() and [`Belt.MutableSet.String`]()", - "A **mutable** sorted set module which allows customized compare behavior.\nThe implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map.\n\nIt also has two specialized inner modules [Belt.MutableSet.Int](mutable-set-int) and [Belt.MutableSet.String](mutable-set-string) - This module separates data from function which is more verbose but slightly more efficient\n\n## Examples\n\n```rescript\nmodule PairComparator = Belt.Id.MakeComparable({\n type t = (int, int)\n let cmp = ((a0, a1), (b0, b1)) =>\n switch Pervasives.compare(a0, b0) {\n | 0 => Pervasives.compare(a1, b1)\n | c => c\n }\n})\n\nlet mySet = Belt.MutableSet.make(~id=module(PairComparator))\nmySet->Belt.MutableSet.add((1, 2))\n```" - ], - "items": [ - { - "id": "Belt.MutableSet.t", - "kind": "type", - "name": "t", - "docstrings": [ - "`'value` is the element type\n\n`'identity` the identity of the collection" - ], - "signature": "type t<'value, 'identity>" - }, - { - "id": "Belt.MutableSet.id", - "kind": "type", - "name": "id", - "docstrings": ["The identity needed for making a set from scratch"], - "signature": "type id<'value, 'id> = Belt_Id.comparable<'value, 'id>" - }, - { - "id": "Belt.MutableSet.make", - "kind": "value", - "name": "make", - "docstrings": ["Creates a new set by taking in the comparator"], - "signature": "let make: (~id: id<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Creates new set from array of elements.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.toArray /* [1, 2, 3, 4] */\n```" - ], - "signature": "let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.fromSortedArrayUnsafe", - "kind": "value", - "name": "fromSortedArrayUnsafe", - "docstrings": [ - "The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted." - ], - "signature": "let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.copy", - "kind": "value", - "name": "copy", - "docstrings": [ - "Returns copy of a set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp))\n\nlet copied = s0->Belt.MutableSet.copy\ncopied->Belt.MutableSet.toArray /* [1, 2, 3, 4] */\n```" - ], - "signature": "let copy: t<'value, 'id> => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [ - "Checks if set is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet empty = Belt.MutableSet.fromArray([], ~id=module(IntCmp))\nlet notEmpty = Belt.MutableSet.fromArray([1], ~id=module(IntCmp))\n\nBelt.MutableSet.isEmpty(empty) /* true */\nBelt.MutableSet.isEmpty(notEmpty) /* false */\n```" - ], - "signature": "let isEmpty: t<'a, 'b> => bool" - }, - { - "id": "Belt.MutableSet.has", - "kind": "value", - "name": "has", - "docstrings": [ - "Checks if element exists in set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet set = Belt.MutableSet.fromArray([1, 4, 2, 5], ~id=module(IntCmp))\n\nset->Belt.MutableSet.has(3) /* false */\nset->Belt.MutableSet.has(1) /* true */\n```" - ], - "signature": "let has: (t<'value, 'id>, 'value) => bool" - }, - { - "id": "Belt.MutableSet.add", - "kind": "value", - "name": "add", - "docstrings": [ - "Adds element to set. If element existed in set, value is unchanged.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.make(~id=module(IntCmp))\ns0->Belt.MutableSet.add(1)\ns0->Belt.MutableSet.add(2)\ns0->Belt.MutableSet.add(2)\n\ns0->Belt.MutableSet.toArray /* [1, 2] */\n```" - ], - "signature": "let add: (t<'value, 'id>, 'value) => unit" - }, - { - "id": "Belt.MutableSet.addCheck", - "kind": "value", - "name": "addCheck", - "docstrings": [], - "signature": "let addCheck: (t<'value, 'id>, 'value) => bool" - }, - { - "id": "Belt.MutableSet.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [ - "Adds each element of array to set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet set = Belt.MutableSet.make(~id=module(IntCmp))\n\nset->Belt.MutableSet.mergeMany([5, 4, 3, 2, 1])\nset->Belt.MutableSet.toArray /* [1, 2, 3, 4, 5] */\n```" - ], - "signature": "let mergeMany: (t<'value, 'id>, array<'value>) => unit" - }, - { - "id": "Belt.MutableSet.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "Removes element from set. If element did not exist in set, value is unchanged.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([2, 3, 1, 4, 5], ~id=module(IntCmp))\ns0->Belt.MutableSet.remove(1)\ns0->Belt.MutableSet.remove(3)\ns0->Belt.MutableSet.remove(3)\n\ns0->Belt.MutableSet.toArray /* [2,4,5] */\n```" - ], - "signature": "let remove: (t<'value, 'id>, 'value) => unit" - }, - { - "id": "Belt.MutableSet.removeCheck", - "kind": "value", - "name": "removeCheck", - "docstrings": [], - "signature": "let removeCheck: (t<'value, 'id>, 'value) => bool" - }, - { - "id": "Belt.MutableSet.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [ - "Removes each element of array from set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet set = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp))\n\nset->Belt.MutableSet.removeMany([5, 4, 3, 2, 1])\nset->Belt.MutableSet.toArray /* [] */\n```" - ], - "signature": "let removeMany: (t<'value, 'id>, array<'value>) => unit" - }, - { - "id": "Belt.MutableSet.union", - "kind": "value", - "name": "union", - "docstrings": [ - "Returns union of two sets.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp))\nlet union = Belt.MutableSet.union(s0, s1)\nunion->Belt.MutableSet.toArray /* [1,2,3,4,5,6] */\n```" - ], - "signature": "let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [ - "Returns intersection of two sets.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp))\nlet intersect = Belt.MutableSet.intersect(s0, s1)\nintersect->Belt.MutableSet.toArray /* [2,3,5] */\n```" - ], - "signature": "let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.diff", - "kind": "value", - "name": "diff", - "docstrings": [ - "Returns elements from first set, not existing in second set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp))\nBelt.MutableSet.toArray(Belt.MutableSet.diff(s0, s1)) /* [6] */\nBelt.MutableSet.toArray(Belt.MutableSet.diff(s1, s0)) /* [1,4] */\n```" - ], - "signature": "let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.subset", - "kind": "value", - "name": "subset", - "docstrings": [ - "Checks if second set is subset of first set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp))\nlet s2 = Belt.MutableSet.intersect(s0, s1)\nBelt.MutableSet.subset(s2, s0) /* true */\nBelt.MutableSet.subset(s2, s1) /* true */\nBelt.MutableSet.subset(s1, s0) /* false */\n```" - ], - "signature": "let subset: (t<'value, 'id>, t<'value, 'id>) => bool" - }, - { - "id": "Belt.MutableSet.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "Total ordering between sets. Can be used as the ordering function for doing sets of sets.\nIt compares size first and then iterates over each element following the order of elements." - ], - "signature": "let cmp: (t<'value, 'id>, t<'value, 'id>) => int" - }, - { - "id": "Belt.MutableSet.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "Checks if two sets are equal.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([5, 2, 3], ~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([3, 2, 5], ~id=module(IntCmp))\n\nBelt.MutableSet.eq(s0, s1) /* true */\n```" - ], - "signature": "let eq: (t<'value, 'id>, t<'value, 'id>) => bool" - }, - { - "id": "Belt.MutableSet.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [ - "Same as `Belt.MutableSet.forEach` but takes uncurried functon." - ], - "signature": "let forEachU: (t<'value, 'id>, 'value => unit) => unit" - }, - { - "id": "Belt.MutableSet.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "Applies function `f` in turn to all elements of set in increasing order.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp))\nlet acc = ref(list{})\ns0->Belt.MutableSet.forEach(x => acc := Belt.List.add(acc.contents, x))\nacc /* [6,5,3,2] */\n```" - ], - "signature": "let forEach: (t<'value, 'id>, 'value => unit) => unit" - }, - { - "id": "Belt.MutableSet.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a" - }, - { - "id": "Belt.MutableSet.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp))\ns0->Belt.MutableSet.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */\n```" - ], - "signature": "let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a" - }, - { - "id": "Belt.MutableSet.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.MutableSet.every", - "kind": "value", - "name": "every", - "docstrings": [ - "Checks if all elements of the set satisfy the predicate. Order unspecified.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isEven = x => mod(x, 2) == 0\n\nlet s0 = Belt.MutableSet.fromArray([2, 4, 6, 8], ~id=module(IntCmp))\ns0->Belt.MutableSet.every(isEven) /* true */\n```" - ], - "signature": "let every: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.MutableSet.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.MutableSet.some", - "kind": "value", - "name": "some", - "docstrings": [ - "Checks if at least one element of the set satisfies the predicate.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isOdd = x => mod(x, 2) != 0\n\nlet s0 = Belt.MutableSet.fromArray([1, 2, 4, 6, 8], ~id=module(IntCmp))\ns0->Belt.MutableSet.some(isOdd) /* true */\n```" - ], - "signature": "let some: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.MutableSet.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'value, 'id>, 'value => bool) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "Returns the set of all elements that satisfy the predicate.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isEven = x => mod(x, 2) == 0\n\nlet s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp))\nlet s1 = s0->Belt.MutableSet.keep(isEven)\n\ns1->Belt.MutableSet.toArray /* [2, 4] */\n```" - ], - "signature": "let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id>" - }, - { - "id": "Belt.MutableSet.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (\n t<'value, 'id>,\n 'value => bool,\n) => (t<'value, 'id>, t<'value, 'id>)" - }, - { - "id": "Belt.MutableSet.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet isOdd = x => mod(x, 2) != 0\n\nlet s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp))\nlet (s1, s2) = s0->Belt.MutableSet.partition(isOdd)\n\ns1->Belt.MutableSet.toArray /* [1,3,5] */\ns2->Belt.MutableSet.toArray /* [2,4] */\n```" - ], - "signature": "let partition: (\n t<'value, 'id>,\n 'value => bool,\n) => (t<'value, 'id>, t<'value, 'id>)" - }, - { - "id": "Belt.MutableSet.size", - "kind": "value", - "name": "size", - "docstrings": [ - "Returns size of the set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.size /* 4 */\n```" - ], - "signature": "let size: t<'value, 'id> => int" - }, - { - "id": "Belt.MutableSet.toList", - "kind": "value", - "name": "toList", - "docstrings": [ - "Returns list of ordered set elements.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.toList /* [1,2,3,5] */\n```" - ], - "signature": "let toList: t<'value, 'id> => list<'value>" - }, - { - "id": "Belt.MutableSet.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "Returns array of ordered set elements.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.toArray /* [1,2,3,5] */\n```" - ], - "signature": "let toArray: t<'value, 'id> => array<'value>" - }, - { - "id": "Belt.MutableSet.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [ - "Returns minimum value of the collection. `None` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.make(~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.minimum /* None */\ns1->Belt.MutableSet.minimum /* Some(1) */\n```" - ], - "signature": "let minimum: t<'value, 'id> => option<'value>" - }, - { - "id": "Belt.MutableSet.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [ - "Returns minimum value of the collection. `undefined` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.make(~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.minUndefined /* undefined */\ns1->Belt.MutableSet.minUndefined /* 1 */\n```" - ], - "signature": "let minUndefined: t<'value, 'id> => Js.undefined<'value>" - }, - { - "id": "Belt.MutableSet.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [ - "Returns maximum value of the collection. `None` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.make(~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.maximum /* None */\ns1->Belt.MutableSet.maximum /* Some(5) */\n```" - ], - "signature": "let maximum: t<'value, 'id> => option<'value>" - }, - { - "id": "Belt.MutableSet.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [ - "Returns maximum value of the collection. `undefined` if collection is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.make(~id=module(IntCmp))\nlet s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.maxUndefined /* undefined */\ns1->Belt.MutableSet.maxUndefined /* 5 */\n```" - ], - "signature": "let maxUndefined: t<'value, 'id> => Js.undefined<'value>" - }, - { - "id": "Belt.MutableSet.get", - "kind": "value", - "name": "get", - "docstrings": [ - "Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp))\n\ns0->Belt.MutableSet.get(3) /* Some(3) */\ns0->Belt.MutableSet.get(20) /* None */\n```" - ], - "signature": "let get: (t<'value, 'id>, 'value) => option<'value>" - }, - { - "id": "Belt.MutableSet.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [ - "Same as `Belt.MutableSet.get` but returns `undefined` when element does not exist." - ], - "signature": "let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value>" - }, - { - "id": "Belt.MutableSet.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "Same as `Belt.MutableSet.get` but raise when element does not exist." - ], - "signature": "let getExn: (t<'value, 'id>, 'value) => 'value" - }, - { - "id": "Belt.MutableSet.split", - "kind": "value", - "name": "split", - "docstrings": [ - "Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n})\n\nlet s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp))\n\nlet ((smaller, larger), present) = s0->Belt.MutableSet.split(3)\n\npresent /* true */\nsmaller->Belt.MutableSet.toArray /* [1,2] */\nlarger->Belt.MutableSet.toArray /* [4,5] */\n```" - ], - "signature": "let split: (\n t<'value, 'id>,\n 'value,\n) => ((t<'value, 'id>, t<'value, 'id>), bool)" - }, - { - "id": "Belt.MutableSet.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a, 'b> => unit" - } - ] - }, - "belt/map": { - "id": "Belt.Map", - "name": "Map", - "docstrings": [ - "[`Belt.Map`](),\n\n The top level provides generic **immutable** map operations.\n\n It also has three specialized inner modules\n [`Belt.Map.Int`](), [`Belt.Map.String`]() and\n\n [`Belt.Map.Dict`](): This module separates data from function\n which is more verbose but slightly more efficient", - "The top level provides generic immutable map operations.\n\nIt also has three specialized inner modules `Belt.Map.Int`, `Belt.Map.String`\nand `Belt.Map.Dict`." - ], - "items": [ - { - "id": "Belt.Map.t", - "kind": "type", - "name": "t", - "docstrings": [ - "`'key` is the field type\n\n`'value` is the element type\n\n`'identity` the identity of the collection" - ], - "signature": "type t<'key, 'value, 'identity>" - }, - { - "id": "Belt.Map.id", - "kind": "type", - "name": "id", - "docstrings": ["The identity needed for making an empty map."], - "signature": "type id<'key, 'id> = Belt_Id.comparable<'key, 'id>" - }, - { - "id": "Belt.Map.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(~id)` creates a new map by taking in the comparator.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nlet m = Belt.Map.make(~id=module(IntCmp))\n\nBelt.Map.set(m, 0, \"a\")\n```" - ], - "signature": "let make: (~id: id<'k, 'id>) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [ - "`isEmpty(m)` checks whether a map m is empty.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.isEmpty(Belt.Map.fromArray([(1, \"1\")], ~id=module(IntCmp))) == false\n```" - ], - "signature": "let isEmpty: t<'a, 'b, 'c> => bool" - }, - { - "id": "Belt.Map.has", - "kind": "value", - "name": "has", - "docstrings": [ - "`has(m, k)` checks whether `m` has the key `k`.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.has(Belt.Map.fromArray([(1, \"1\")], ~id=module(IntCmp)), 1) == true\n```" - ], - "signature": "let has: (t<'k, 'v, 'id>, 'k) => bool" - }, - { - "id": "Belt.Map.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int" - }, - { - "id": "Belt.Map.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "`cmp(m0, m1, vcmp);`\n\nTotal ordering of map given total ordering of value function.\n\nIt will compare size first and each element following the order one by one." - ], - "signature": "let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int" - }, - { - "id": "Belt.Map.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "eq(m1, m2, veq)` tests whether the maps `m1` and `m2` are equal, that is,\ncontain equal keys and associate them with equal data. `veq` is the\nequality predicate used to compare the data associated with the keys." - ], - "signature": "let eq: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.findFirstByU", - "kind": "value", - "name": "findFirstByU", - "docstrings": [], - "signature": "let findFirstByU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)>" - }, - { - "id": "Belt.Map.findFirstBy", - "kind": "value", - "name": "findFirstBy", - "docstrings": [ - "`\nfindFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nlet s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, \"4\"), (1, \"1\"), (2, \"2\"), (3, \"\")])\n\nBelt.Map.findFirstBy(s0, (k, v) => k == 4) /* (4, \"4\") */\n```" - ], - "signature": "let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)>" - }, - { - "id": "Belt.Map.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit" - }, - { - "id": "Belt.Map.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the\n`'k` as first argument, and the associated value as second argument. The\nbindings are passed to `f` in increasing order with respect to the ordering\nover the type of the keys.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nlet s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, \"4\"), (1, \"1\"), (2, \"2\"), (3, \"\")])\n\nlet acc = ref(list{})\n\nBelt.Map.forEach(s0, (k, v) => acc := list{(k, v), ...acc.contents})\n\nacc.contents == list{(4, \"4\"), (3, \"3\"), (2, \"2\"), (1, \"1\")}\n```" - ], - "signature": "let forEach: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit" - }, - { - "id": "Belt.Map.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc" - }, - { - "id": "Belt.Map.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(m, a, f)` computes `(f(kN, dN) ... (f(k1, d1, a))...)`, where `k1\n... kN` are the keys of all bindings in m (in increasing order), and `d1\n... dN` are the associated data.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nlet s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, \"4\"), (1, \"1\"), (2, \"2\"), (3, \"3\")])\n\nBelt.Map.reduce(s0, list{}, (acc, k, v) => list{\n (k, v),\n ...acc,\n}) /* [(4, \"4\"), (3, \"3\"), (2, \"2\"), (1, \"1\"), 0] */\n```" - ], - "signature": "let reduce: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc" - }, - { - "id": "Belt.Map.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(m, p)` checks if all the bindings of the map satisfy the predicate\n`p`. Order unspecified" - ], - "signature": "let every: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(m, p)` checks if at least one binding of the map satisfy the predicate \n`p`. Order unspecified" - ], - "signature": "let some: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool" - }, - { - "id": "Belt.Map.size", - "kind": "value", - "name": "size", - "docstrings": [ - "`size(s)`\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.size(Belt.Map.fromArray([(2, \"2\"), (2, \"1\"), (3, \"3\")], ~id=module(IntCmp))) == 2\n```" - ], - "signature": "let size: t<'k, 'v, 'id> => int" - }, - { - "id": "Belt.Map.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "`toArray(s)`\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.toArray(Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp))) == [\n (1, \"1\"),\n (2, \"2\"),\n (3, \"3\"),\n ]\n```" - ], - "signature": "let toArray: t<'k, 'v, 'id> => array<('k, 'v)>" - }, - { - "id": "Belt.Map.toList", - "kind": "value", - "name": "toList", - "docstrings": ["In increasing order. See `Belt.Map.toArray`"], - "signature": "let toList: t<'k, 'v, 'id> => list<('k, 'v)>" - }, - { - "id": "Belt.Map.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray(kvs, ~id);`\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.toArray(Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp))) == [\n (1, \"1\"),\n (2, \"2\"),\n (3, \"3\"),\n ]\n```" - ], - "signature": "let fromArray: (array<('k, 'v)>, ~id: id<'k, 'id>) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [ - "`keysToArray(s);`\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.keysToArray(Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp))) == [\n 1,\n 2,\n 3,\n ]\n```" - ], - "signature": "let keysToArray: t<'k, 'v, 'id> => array<'k>" - }, - { - "id": "Belt.Map.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [ - "`valuesToArray(s);`\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.valuesToArray(\n Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp)),\n) == [\"1\", \"2\", \"3\"]\n```" - ], - "signature": "let valuesToArray: t<'k, 'v, 'id> => array<'v>" - }, - { - "id": "Belt.Map.minKey", - "kind": "value", - "name": "minKey", - "docstrings": [ - "`minKey(s)` returns the minimum key, None if not exist." - ], - "signature": "let minKey: t<'k, 'a, 'b> => option<'k>" - }, - { - "id": "Belt.Map.minKeyUndefined", - "kind": "value", - "name": "minKeyUndefined", - "docstrings": ["See `Belt.Map.minKey`"], - "signature": "let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>" - }, - { - "id": "Belt.Map.maxKey", - "kind": "value", - "name": "maxKey", - "docstrings": [ - "`maxKey(s)` returns the maximum key, None if not exist." - ], - "signature": "let maxKey: t<'k, 'a, 'b> => option<'k>" - }, - { - "id": "Belt.Map.maxKeyUndefined", - "kind": "value", - "name": "maxKeyUndefined", - "docstrings": ["See `Belt.Map.maxKey`"], - "signature": "let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>" - }, - { - "id": "Belt.Map.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [ - "`minimum(s)` returns the minimum key value pair, None if not exist." - ], - "signature": "let minimum: t<'k, 'v, 'a> => option<('k, 'v)>" - }, - { - "id": "Belt.Map.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": ["See `Belt.Map.minimum`"], - "signature": "let minUndefined: t<'k, 'v, 'a> => Js.undefined<('k, 'v)>" - }, - { - "id": "Belt.Map.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [ - "`maximum(s)` returns the maximum key value pair, None if not exist." - ], - "signature": "let maximum: t<'k, 'v, 'a> => option<('k, 'v)>" - }, - { - "id": "Belt.Map.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": ["See `Belt.Map.maximum`"], - "signature": "let maxUndefined: t<'k, 'v, 'a> => Js.undefined<('k, 'v)>" - }, - { - "id": "Belt.Map.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`get(s, k)`\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nBelt.Map.get(Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp)), 2) ==\n Some(\"2\")\n\nBelt.Map.get(Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp)), 2) == None\n```" - ], - "signature": "let get: (t<'k, 'v, 'id>, 'k) => option<'v>" - }, - { - "id": "Belt.Map.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [ - "See `Belt.Map.get`. Returns `undefined` when not found" - ], - "signature": "let getUndefined: (t<'k, 'v, 'id>, 'k) => Js.undefined<'v>" - }, - { - "id": "Belt.Map.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [ - "`getWithDefault(s, k, default)`\n\nSee `Belt.Map.get`\n\nReturns default when `k` is not found." - ], - "signature": "let getWithDefault: (t<'k, 'v, 'id>, 'k, 'v) => 'v" - }, - { - "id": "Belt.Map.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "`getExn(s, k)`\n\nSee `Belt.Map.getExn`\n\nraise when `k` not exist" - ], - "signature": "let getExn: (t<'k, 'v, 'id>, 'k) => 'v" - }, - { - "id": "Belt.Map.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "`remove(m, x)` when `x` is not in `m`, `m` is returned reference unchanged.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nlet s0 = Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp))\n\nlet s1 = Belt.Map.remove(s0, 1)\n\nlet s2 = Belt.Map.remove(s1, 1)\n\ns1 === s2\n\nBelt.Map.keysToArray(s1) == [2, 3]\n```" - ], - "signature": "let remove: (t<'k, 'v, 'id>, 'k) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [ - "`removeMany(s, xs)`\n\nRemoving each of `xs` to `s`, note unlike `Belt.Map.remove`, the reference\nof return value might be changed even if none in `xs` exists `s`." - ], - "signature": "let removeMany: (t<'k, 'v, 'id>, array<'k>) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(m, x, y)` returns a map containing the same bindings as `m`, with a\nnew binding of `x` to `y`. If `x` was already bound in `m`, its previous\nbinding disappears.\n\n## Examples\n\n```rescript\nmodule IntCmp = Belt.Id.MakeComparable({\n type t = int\n let cmp = (a, b) => Pervasives.compare(a, b)\n})\n\nlet s0 = Belt.Map.fromArray([(2, \"2\"), (1, \"1\"), (3, \"3\")], ~id=module(IntCmp))\n\nlet s1 = Belt.Map.set(s0, 2, \"3\")\n\nBelt.Map.valuesToArray(s1) == [\"1\", \"3\", \"3\"]\n```" - ], - "signature": "let set: (t<'k, 'v, 'id>, 'k, 'v) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.updateU", - "kind": "value", - "name": "updateU", - "docstrings": [], - "signature": "let updateU: (\n t<'k, 'v, 'id>,\n 'k,\n option<'v> => option<'v>,\n) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.update", - "kind": "value", - "name": "update", - "docstrings": [ - "`update(m, x, f)` returns a map containing the same bindings as `m`, except\nfor the binding of `x`. Depending on the value of `y` where `y` is\n`f(get(m, x))`, the binding of `x` is added, removed or updated. If `y` is\n`None`, the binding is removed if it exists; otherwise, if `y` is `Some(z)`\nthen `x` is associated to `z` in the resulting map." - ], - "signature": "let update: (\n t<'k, 'v, 'id>,\n 'k,\n option<'v> => option<'v>,\n) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [ - "`mergeMany(s, xs)`\n\nAdding each of `xs` to `s`, note unlike `add`, the reference of return\nvalue might be changed even if all values in `xs` exist `s`." - ], - "signature": "let mergeMany: (t<'k, 'v, 'id>, array<('k, 'v)>) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.mergeU", - "kind": "value", - "name": "mergeU", - "docstrings": [], - "signature": "let mergeU: (\n t<'k, 'v, 'id>,\n t<'k, 'v2, 'id>,\n ('k, option<'v>, option<'v2>) => option<'v3>,\n) => t<'k, 'v3, 'id>" - }, - { - "id": "Belt.Map.merge", - "kind": "value", - "name": "merge", - "docstrings": [ - "`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1`\nand of `m2`. The presence of each such binding, and the corresponding\nvalue, is determined with the function `f`." - ], - "signature": "let merge: (\n t<'k, 'v, 'id>,\n t<'k, 'v2, 'id>,\n ('k, option<'v>, option<'v2>) => option<'v3>,\n) => t<'k, 'v3, 'id>" - }, - { - "id": "Belt.Map.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(m, p)` returns the map with all the bindings in m that satisfy\npredicate `p`." - ], - "signature": "let keep: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (\n t<'k, 'v, 'id>,\n ('k, 'v) => bool,\n) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>)" - }, - { - "id": "Belt.Map.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains\nall the bindings of `s` that satisfy the predicate `p`, and `m2` is the map\nwith all the bindings of `s` that do not satisfy `p`." - ], - "signature": "let partition: (\n t<'k, 'v, 'id>,\n ('k, 'v) => bool,\n) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>)" - }, - { - "id": "Belt.Map.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(x, m)` returns a tuple `(l, r)`, data, where `l` is the map with all\nthe bindings of `m` whose 'k is strictly less than `x`; `r` is the map with\nall the bindings of m whose 'k is strictly greater than `x`; `data` is\n`None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to\n`x`." - ], - "signature": "let split: (\n t<'k, 'v, 'id>,\n 'k,\n) => ((t<'k, 'v, 'id>, t<'k, 'v, 'id>), option<'v>)" - }, - { - "id": "Belt.Map.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id>" - }, - { - "id": "Belt.Map.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(m, f) returns a map with same domain as`m`, where the associated\nvalue`a`of all bindings of`m`has been replaced by the result of the\napplication of`f`to`a`. The bindings are passed to`f` in increasing order\nwith respect to the ordering over the type of the keys." - ], - "signature": "let map: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id>" - }, - { - "id": "Belt.Map.mapWithKeyU", - "kind": "value", - "name": "mapWithKeyU", - "docstrings": [], - "signature": "let mapWithKeyU: (t<'k, 'v, 'id>, ('k, 'v) => 'v2) => t<'k, 'v2, 'id>" - }, - { - "id": "Belt.Map.mapWithKey", - "kind": "value", - "name": "mapWithKey", - "docstrings": [ - "`mapWithKey(m, f)`\n\nThe same as `Belt.Map.map` except that `f` is supplied with one more\nargument: the key." - ], - "signature": "let mapWithKey: (t<'k, 'v, 'id>, ('k, 'v) => 'v2) => t<'k, 'v2, 'id>" - }, - { - "id": "Belt.Map.getData", - "kind": "value", - "name": "getData", - "docstrings": [ - "`getData(s0)`\n\nAdvanced usage only\n\nReturns the raw data (detached from comparator), but its type is still\nmanifested, so that user can pass identity directly without boxing." - ], - "signature": "let getData: t<'k, 'v, 'id> => Belt_MapDict.t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.getId", - "kind": "value", - "name": "getId", - "docstrings": ["Advanced usage only. Returns the identity of s0."], - "signature": "let getId: t<'k, 'v, 'id> => id<'k, 'id>" - }, - { - "id": "Belt.Map.packIdData", - "kind": "value", - "name": "packIdData", - "docstrings": [ - "`packIdData(~id, ~data)`\n\nAdvanced usage only\n\nReturns the packed collection." - ], - "signature": "let packIdData: (\n ~id: id<'k, 'id>,\n ~data: Belt_MapDict.t<'k, 'v, 'id>,\n) => t<'k, 'v, 'id>" - }, - { - "id": "Belt.Map.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a, 'b, 'c> => unit" - } - ] - }, - "belt/set": { - "id": "Belt.Set", - "name": "Set", - "docstrings": [ - "[`Belt.Set`]()\n\n The top level provides generic **immutable** set operations.\n\n It also has three specialized inner modules\n [`Belt.Set.Int`](), [`Belt.Set.String`]() and\n\n [`Belt.Set.Dict`](): This module separates data from function\n which is more verbose but slightly more efficient", - "An _immutable_ sorted set module which allows customized _compare_ behavior.\n\nThe implementation uses balanced binary trees, and therefore searching\nand insertion take time logarithmic in the size of the map.\n\nFor more info on this module's usage of identity, `make` and others, please see\nthe top level documentation of Belt, **A special encoding for collection safety**.\n\n## Examples\n\n```rescript\nmodule PairComparator =\n Belt.Id.MakeComparable({\n type t = (int, int)\n let cmp = ((a0, a1), (b0, b1)) =>\n switch (Pervasives.compare(a0, b0)) {\n | 0 => Pervasives.compare(a1, b1)\n | c => c\n }\n })\n\nlet mySet = Belt.Set.make(~id=module(PairComparator))\nlet mySet2 = Belt.Set.add(mySet, (1, 2))\n```\n\n**Note:** This module's examples will assume a predeclared module for integers\ncalled `IntCmp`. It is declared like this:\n\n```rescript\nmodule IntCmp =\n Belt.Id.MakeComparable({\n type t = int\n let cmp = Pervasives.compare\n })\n```" - ], - "items": [ - { - "id": "Belt.Set.t", - "kind": "type", - "name": "t", - "docstrings": [ - "`'value` is the element type\n\n`'identity` the identity of the collection" - ], - "signature": "type t<'value, 'identity>" - }, - { - "id": "Belt.Set.id", - "kind": "type", - "name": "id", - "docstrings": ["The identity needed for making a set from scratch"], - "signature": "type id<'value, 'id> = Belt_Id.comparable<'value, 'id>" - }, - { - "id": "Belt.Set.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new set by taking in the comparator\n\n## Examples\n\n```rescript\nlet set = Belt.Set.make(~id=module(IntCmp))\n```" - ], - "signature": "let make: (~id: id<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Creates new set from array of elements.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([1, 3, 2, 4], ~id=module(IntCmp))\n\ns0->Belt.Set.toArray /* [1, 2, 3, 4] */\n```" - ], - "signature": "let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.fromSortedArrayUnsafe", - "kind": "value", - "name": "fromSortedArrayUnsafe", - "docstrings": [ - "The same as [fromArray][#fromarray] except it is after assuming the input array\nis already sorted." - ], - "signature": "let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [ - "Checks if set is empty.\n\n## Examples\n\n```rescript\nlet empty = Belt.Set.fromArray([], ~id=module(IntCmp))\nlet notEmpty = Belt.Set.fromArray([1],~id=module(IntCmp))\n\nBelt.Set.isEmpty(empty) /* true */\nBelt.Set.isEmpty(notEmpty) /* false */\n```" - ], - "signature": "let isEmpty: t<'a, 'b> => bool" - }, - { - "id": "Belt.Set.has", - "kind": "value", - "name": "has", - "docstrings": [ - "Checks if element exists in set.\n\n## Examples\n\n```rescript\nlet set = Belt.Set.fromArray([1, 4, 2, 5], ~id=module(IntCmp))\n\nset->Belt.Set.has(3) /* false */\nset->Belt.Set.has(1) /* true */\n```" - ], - "signature": "let has: (t<'value, 'id>, 'value) => bool" - }, - { - "id": "Belt.Set.add", - "kind": "value", - "name": "add", - "docstrings": [ - "Adds element to set. If element existed in set, value is unchanged.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.make(~id=module(IntCmp))\nlet s1 = s0->Belt.Set.add(1)\nlet s2 = s1->Belt.Set.add(2)\nlet s3 = s2->Belt.Set.add(2)\ns0->Belt.Set.toArray /* [] */\ns1->Belt.Set.toArray /* [1] */\ns2->Belt.Set.toArray /* [1, 2] */\ns3->Belt.Set.toArray /* [1,2 ] */\ns2 == s3 /* true */\n```" - ], - "signature": "let add: (t<'value, 'id>, 'value) => t<'value, 'id>" - }, - { - "id": "Belt.Set.mergeMany", - "kind": "value", - "name": "mergeMany", - "docstrings": [ - "Adds each element of array to set. Unlike `Belt.Set.add`](#add), the reference of return value might be changed even if all values in array already exist in set\n\n## Examples\n\n```rescript\nlet set = Belt.Set.make(~id=module(IntCmp))\n\nlet newSet = set->Belt.Set.mergeMany([5, 4, 3, 2, 1])\nnewSet->Belt.Set.toArray /* [1, 2, 3, 4, 5] */\n```" - ], - "signature": "let mergeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.remove", - "kind": "value", - "name": "remove", - "docstrings": [ - "Removes element from set. If element did not exist in set, value is unchanged.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([2,3,1,4,5], ~id=module(IntCmp))\nlet s1 = s0->Belt.Set.remove(1)\nlet s2 = s1->Belt.Set.remove(3)\nlet s3 = s2->Belt.Set.remove(3)\n\ns1->Belt.Set.toArray /* [2,3,4,5] */\ns2->Belt.Set.toArray /* [2,4,5] */\ns2 == s3 /* true */\n```" - ], - "signature": "let remove: (t<'value, 'id>, 'value) => t<'value, 'id>" - }, - { - "id": "Belt.Set.removeMany", - "kind": "value", - "name": "removeMany", - "docstrings": [ - "Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if none of values in array existed in set.\n\n## Examples\n\n```rescript\nlet set = Belt.Set.fromArray([1, 2, 3, 4],~id=module(IntCmp))\n\nlet newSet = set->Belt.Set.removeMany([5, 4, 3, 2, 1])\nnewSet->Belt.Set.toArray /* [] */\n```" - ], - "signature": "let removeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.union", - "kind": "value", - "name": "union", - "docstrings": [ - "Returns union of two sets.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp))\nlet union = Belt.Set.union(s0, s1)\nunion->Belt.Set.toArray /* [1,2,3,4,5,6] */\n```" - ], - "signature": "let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [ - "Returns intersection of two sets.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp))\nlet intersect = Belt.Set.intersect(s0, s1)\nintersect->Belt.Set.toArray /* [2,3,5] */\n```" - ], - "signature": "let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.diff", - "kind": "value", - "name": "diff", - "docstrings": [ - "Returns elements from first set, not existing in second set.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp))\nBelt.Set.toArray(Belt.Set.diff(s0, s1)) /* [6] */\nBelt.Set.toArray(Belt.Set.diff(s1,s0)) /* [1,4] */\n```" - ], - "signature": "let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id>" - }, - { - "id": "Belt.Set.subset", - "kind": "value", - "name": "subset", - "docstrings": [ - "Checks if second set is subset of first set.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp))\nlet s2 = Belt.Set.intersect(s0, s1)\nBelt.Set.subset(s2, s0) /* true */\nBelt.Set.subset(s2, s1) /* true */\nBelt.Set.subset(s1, s0) /* false */\n```" - ], - "signature": "let subset: (t<'value, 'id>, t<'value, 'id>) => bool" - }, - { - "id": "Belt.Set.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "Total ordering between sets. Can be used as the ordering function for doing sets\nof sets. It compares size first and then iterates over each element following\nthe order of elements." - ], - "signature": "let cmp: (t<'value, 'id>, t<'value, 'id>) => int" - }, - { - "id": "Belt.Set.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "Checks if two sets are equal.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([5,2,3], ~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([3,2,5], ~id=module(IntCmp))\n\nBelt.Set.eq(s0, s1) /* true */\n```" - ], - "signature": "let eq: (t<'value, 'id>, t<'value, 'id>) => bool" - }, - { - "id": "Belt.Set.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [ - "Same as [forEach](#forEach) but takes uncurried functon." - ], - "signature": "let forEachU: (t<'value, 'id>, 'value => unit) => unit" - }, - { - "id": "Belt.Set.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "Applies function `f` in turn to all elements of set in increasing order.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp))\nlet acc = ref(list{})\ns0->Belt.Set.forEach(x => {\n acc := Belt.List.add(acc.contents, x)\n})\nacc /* [6,5,3,2] */\n```" - ], - "signature": "let forEach: (t<'value, 'id>, 'value => unit) => unit" - }, - { - "id": "Belt.Set.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a" - }, - { - "id": "Belt.Set.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp))\ns0->Belt.Set.reduce(list{}, (acc, element) =>\n acc->Belt.List.add(element)\n) /* [6,5,3,2] */\n```" - ], - "signature": "let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a" - }, - { - "id": "Belt.Set.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.every", - "kind": "value", - "name": "every", - "docstrings": [ - "Checks if all elements of the set satisfy the predicate. Order unspecified.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nlet s0 = Belt.Set.fromArray([2,4,6,8], ~id=module(IntCmp))\ns0->Belt.Set.every(isEven) /* true */\n```" - ], - "signature": "let every: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.some", - "kind": "value", - "name": "some", - "docstrings": [ - "Checks if at least one element of the set satisfies the predicate.\n\n## Examples\n\n```rescript\nlet isOdd = x => mod(x, 2) != 0\n\nlet s0 = Belt.Set.fromArray([1,2,4,6,8], ~id=module(IntCmp))\ns0->Belt.Set.some(isOdd) /* true */\n```" - ], - "signature": "let some: (t<'value, 'id>, 'value => bool) => bool" - }, - { - "id": "Belt.Set.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'value, 'id>, 'value => bool) => t<'value, 'id>" - }, - { - "id": "Belt.Set.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "Returns the set of all elements that satisfy the predicate.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nlet s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp))\nlet s1 = s0->Belt.Set.keep(isEven)\n\ns1->Belt.Set.toArray /* [2,4] */\n```" - ], - "signature": "let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id>" - }, - { - "id": "Belt.Set.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (\n t<'value, 'id>,\n 'value => bool,\n) => (t<'value, 'id>, t<'value, 'id>)" - }, - { - "id": "Belt.Set.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate.\n\n## Examples\n\n```rescript\nlet isOdd = x => mod(x, 2) != 0\n\nlet s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp))\nlet (s1, s2) = s0->Belt.Set.partition(isOdd)\n\ns1->Belt.Set.toArray /* [1,3,5] */\ns2->Belt.Set.toArray /* [2,4] */\n```" - ], - "signature": "let partition: (\n t<'value, 'id>,\n 'value => bool,\n) => (t<'value, 'id>, t<'value, 'id>)" - }, - { - "id": "Belt.Set.size", - "kind": "value", - "name": "size", - "docstrings": [ - "Returns size of the set.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([1,2,3,4], ~id=module(IntCmp))\n\ns0->Belt.Set.size /* 4 */\n```" - ], - "signature": "let size: t<'value, 'id> => int" - }, - { - "id": "Belt.Set.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "Returns array of ordered set elements.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp))\n\ns0->Belt.Set.toArray /* [1,2,3,5] */\n```" - ], - "signature": "let toArray: t<'value, 'id> => array<'value>" - }, - { - "id": "Belt.Set.toList", - "kind": "value", - "name": "toList", - "docstrings": [ - "Returns list of ordered set elements.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp))\n\ns0->Belt.Set.toList /* [1,2,3,5] */\n```" - ], - "signature": "let toList: t<'value, 'id> => list<'value>" - }, - { - "id": "Belt.Set.minimum", - "kind": "value", - "name": "minimum", - "docstrings": [ - "Returns minimum value of the collection. `None` if collection is empty.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.make(~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp))\n\ns0->Belt.Set.minimum /* None */\ns1->Belt.Set.minimum /* Some(1) */\n```" - ], - "signature": "let minimum: t<'value, 'id> => option<'value>" - }, - { - "id": "Belt.Set.minUndefined", - "kind": "value", - "name": "minUndefined", - "docstrings": [ - "Returns minimum value of the collection. `undefined` if collection is empty.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.make(~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp))\n\ns0->Belt.Set.minUndefined /* undefined */\ns1->Belt.Set.minUndefined /* 1 */\n```" - ], - "signature": "let minUndefined: t<'value, 'id> => Js.undefined<'value>" - }, - { - "id": "Belt.Set.maximum", - "kind": "value", - "name": "maximum", - "docstrings": [ - "Returns maximum value of the collection. `None` if collection is empty.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.make(~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp))\n\ns0->Belt.Set.maximum /* None */\ns1->Belt.Set.maximum /* Some(5) */\n```" - ], - "signature": "let maximum: t<'value, 'id> => option<'value>" - }, - { - "id": "Belt.Set.maxUndefined", - "kind": "value", - "name": "maxUndefined", - "docstrings": [ - "Returns maximum value of the collection. `undefined` if collection is empty.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.make(~id=module(IntCmp))\nlet s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp))\n\ns0->Belt.Set.maxUndefined /* undefined */\ns1->Belt.Set.maxUndefined /* 5 */\n```" - ], - "signature": "let maxUndefined: t<'value, 'id> => Js.undefined<'value>" - }, - { - "id": "Belt.Set.get", - "kind": "value", - "name": "get", - "docstrings": [ - "Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp))\n\ns0->Belt.Set.get(3) /* Some(3) */\ns0->Belt.Set.get(20) /* None */\n```" - ], - "signature": "let get: (t<'value, 'id>, 'value) => option<'value>" - }, - { - "id": "Belt.Set.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [ - "Same as [get](#get) but returns `undefined` when element does not exist." - ], - "signature": "let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value>" - }, - { - "id": "Belt.Set.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "Same as [get](#get) but raise when element does not exist." - ], - "signature": "let getExn: (t<'value, 'id>, 'value) => 'value" - }, - { - "id": "Belt.Set.split", - "kind": "value", - "name": "split", - "docstrings": [ - "Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set.\n\n## Examples\n\n```rescript\nlet s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp))\n\nlet ((smaller, larger), present) = s0->Belt.Set.split(3)\n\npresent /* true */\nsmaller->Belt.Set.toArray /* [1,2] */\nlarger->Belt.Set.toArray /* [4,5] */\n\n```" - ], - "signature": "let split: (\n t<'value, 'id>,\n 'value,\n) => ((t<'value, 'id>, t<'value, 'id>), bool)" - }, - { - "id": "Belt.Set.checkInvariantInternal", - "kind": "value", - "name": "checkInvariantInternal", - "docstrings": ["**raise** when invariant is not held"], - "signature": "let checkInvariantInternal: t<'a, 'b> => unit" - }, - { - "id": "Belt.Set.getData", - "kind": "value", - "name": "getData", - "docstrings": [ - "**Advanced usage only**\n\nReturns the raw data (detached from comparator), but its type is still manifested,\nso that user can pass identity directly without boxing." - ], - "signature": "let getData: t<'value, 'id> => Belt_SetDict.t<'value, 'id>" - }, - { - "id": "Belt.Set.getId", - "kind": "value", - "name": "getId", - "docstrings": [ - "**Advanced usage only**\n\nReturns the identity of set." - ], - "signature": "let getId: t<'value, 'id> => id<'value, 'id>" - }, - { - "id": "Belt.Set.packIdData", - "kind": "value", - "name": "packIdData", - "docstrings": [ - "**Advanced usage only**\n\nReturns the packed collection." - ], - "signature": "let packIdData: (\n ~id: id<'value, 'id>,\n ~data: Belt_SetDict.t<'value, 'id>,\n) => t<'value, 'id>" - } - ] - }, - "belt/range": { - "id": "Belt.Range", - "name": "Range", - "docstrings": [ - "[`Belt.Range`]()\n\n Utilities for a closed range `(from, start)`", - "A small utility module to provide inclusive range operations for `[start, finish]`.\nInternally it is relying on loops instead of creating new arrays, which makes it\npretty performant and memory friendly." - ], - "items": [ - { - "id": "Belt.Range.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (int, int, int => unit) => unit" - }, - { - "id": "Belt.Range.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(start, finish, action)` equivalent to `Belt.Array.forEach(Belt.Array.range(start, finish), action))`\n\n## Examples\n\n```rescript\nBelt.Range.forEach(0, 4, (i) => Js.log(i))\n\n// Prints:\n// 0\n// 1\n// 2\n// 3\n// 4\n```" - ], - "signature": "let forEach: (int, int, int => unit) => unit" - }, - { - "id": "Belt.Range.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (int, int, int => bool) => bool" - }, - { - "id": "Belt.Range.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(start, finish, p)` equivalent to `Belt.Array.every(Belt.Array.range(start, finish), p)`\n## Examples\n\n```rescript\nBelt.Range.every(0, 4, (i) => i < 5) /* true */\n\nBelt.Range.every(0, 4, (i) => i < 4) /* false */\n```" - ], - "signature": "let every: (int, int, int => bool) => bool" - }, - { - "id": "Belt.Range.everyByU", - "kind": "value", - "name": "everyByU", - "docstrings": [], - "signature": "let everyByU: (int, int, ~step: int, int => bool) => bool" - }, - { - "id": "Belt.Range.everyBy", - "kind": "value", - "name": "everyBy", - "docstrings": [ - "`everyBy(start, finish, ~step, p)`. See `Belt.Array.rangeBy`, equivalent to\n`Belt.Array.every(Belt.Array.rangeBy(start, finish, ~step), p)`\n\n## Examples\n\n```rescript\nBelt.Range.everyBy(0, 4, ~step=1, (i) => mod(i, 2) === 0) /* false */\n\nBelt.Range.everyBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */\n```" - ], - "signature": "let everyBy: (int, int, ~step: int, int => bool) => bool" - }, - { - "id": "Belt.Range.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (int, int, int => bool) => bool" - }, - { - "id": "Belt.Range.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(start, finish, p)` equivalent to `Belt.Array.some(Belt.Array.range(start, finish), p)`\n\n## Examples\n\n```rescript\nBelt.Range.some(0, 4, (i) => i > 5) /* false */\n\nBelt.Range.some(0, 4, (i) => i > 2) /* true */\n```" - ], - "signature": "let some: (int, int, int => bool) => bool" - }, - { - "id": "Belt.Range.someByU", - "kind": "value", - "name": "someByU", - "docstrings": [], - "signature": "let someByU: (int, int, ~step: int, int => bool) => bool" - }, - { - "id": "Belt.Range.someBy", - "kind": "value", - "name": "someBy", - "docstrings": [ - "`someBy(start, finish, ~step, p)` See `Belt.Array.rangeBy`, equivalent to\n`Belt.Array.some(Belt.Array.rangeBy(start, finish, ~step), p)`\n\n## Examples\n\n```rescript\nBelt.Range.someBy(1, 5, ~step=2, (i) => mod(i, 2) === 0) /* false */\nBelt.Range.someBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */\n```" - ], - "signature": "let someBy: (int, int, ~step: int, int => bool) => bool" - } - ] - }, - "belt/list": { - "id": "Belt.List", - "name": "List", - "docstrings": [ - "[`Belt.List`]()\n\n Utilities for List data type", - "Collection functions for manipulating the `list` data structures, a singly-linked list.\n\n**Prefer Array** if you need any of the following:\n\n- Random access of element\n- Better interop with JavaScript\n- Better memory usage & performance." - ], - "items": [ - { - "id": "Belt.List.t", - "kind": "type", - "name": "t", - "docstrings": ["`'a t` is compatible with built-in `list` type"], - "signature": "type t<'a> = list<'a>" - }, - { - "id": "Belt.List.length", - "kind": "value", - "name": "length", - "docstrings": [ - "Returns the length of a list.\n\n## Examples\n\n```rescript\nBelt.List.length(list{1, 2, 3}) // 3\n```" - ], - "signature": "let length: t<'a> => int" - }, - { - "id": "Belt.List.size", - "kind": "value", - "name": "size", - "docstrings": ["See `Belt.List.length`"], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.List.head", - "kind": "value", - "name": "head", - "docstrings": [ - "Returns `Some(value)` where `value` is the first element in the list, or\n`None` if `someList` is an empty list.\n\n## Examples\n\n```rescript\nBelt.List.head(list{}) // None\nBelt.List.head(list{1, 2, 3}) // Some(1)\n```" - ], - "signature": "let head: t<'a> => option<'a>" - }, - { - "id": "Belt.List.headExn", - "kind": "value", - "name": "headExn", - "docstrings": [ - "Same as `Belt.List.head` but raises an exception if `someList` is empty. Use\nwith care.\n\n## Examples\n\n```rescript\nBelt.List.headExn(list{1, 2, 3}) // 1\n\nBelt.List.headExn(list{}) // Raises an Error\n```" - ], - "signature": "let headExn: t<'a> => 'a" - }, - { - "id": "Belt.List.tail", - "kind": "value", - "name": "tail", - "docstrings": [ - "Returns `None` if `someList` is empty, otherwise it returns `Some(tail)`\nwhere `tail` is everything except the first element of `someList`.\n\n## Examples\n\n```rescript\nBelt.List.tail(list{1, 2, 3}) // Some(list{2, 3})\n\nBelt.List.tail(list{}) // None\n```" - ], - "signature": "let tail: t<'a> => option>" - }, - { - "id": "Belt.List.tailExn", - "kind": "value", - "name": "tailExn", - "docstrings": [ - "Same as `Belt.List.tail` but raises an exception if `someList` is empty. Use\nwith care.\n\n## Examples\n\n```rescript\nBelt.List.tailExn(list{1, 2, 3}) // list{2, 3}\n\nBelt.List.tailExn(list{}) // Raises an Error\n```" - ], - "signature": "let tailExn: t<'a> => t<'a>" - }, - { - "id": "Belt.List.add", - "kind": "value", - "name": "add", - "docstrings": [ - "Adds `value` to the beginning of `someList`.\n\n## Examples\n\n```rescript\nBelt.List.add(list{2, 3}, 1) // list{1, 2, 3}\n\nBelt.List.add(list{\"World\", \"!\"}, \"Hello\") // list{\"Hello\", \"World\", \"!\"}\n```" - ], - "signature": "let add: (t<'a>, 'a) => t<'a>" - }, - { - "id": "Belt.List.get", - "kind": "value", - "name": "get", - "docstrings": [ - "Return the nth element in `someList`, or `None` if `index` is larger than the\nlength.\n\n## Examples\n\n```rescript\nlet abc = list{\"A\", \"B\", \"C\"}\n\nabc->Belt.List.get(1) // Some(\"B\")\n\nabc->Belt.List.get(4) // None\n```" - ], - "signature": "let get: (t<'a>, int) => option<'a>" - }, - { - "id": "Belt.List.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "Same as `Belt.List.get` but raises an exception if `index` is larger than the\nlength. Use with care.\n\n## Examples\n\n```rescript\nlet abc = list{\"A\", \"B\", \"C\"}\n\nabc->Belt.List.getExn(1) // \"B\"\n\nabc->Belt.List.getExn(4) // Raises an Error\n```" - ], - "signature": "let getExn: (t<'a>, int) => 'a" - }, - { - "id": "Belt.List.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Returns a list of length `numItems` with each element filled with value `v`. Returns an empty list if `numItems` is negative.\n\n## Examples\n\n```rescript\nBelt.List.make(3, 1) // list{1, 1, 1}\n```" - ], - "signature": "let make: (int, 'a) => t<'a>" - }, - { - "id": "Belt.List.makeByU", - "kind": "value", - "name": "makeByU", - "docstrings": ["Uncurried version of [makeBy](#makeBy)"], - "signature": "let makeByU: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.List.makeBy", - "kind": "value", - "name": "makeBy", - "docstrings": [ - "Return a list of length `numItems` with element `i` initialized with `f(i)`.\nReturns an empty list if `numItems` is negative.\n\n## Examples\n\n```rescript\nBelt.List.makeBy(5, i => i) // list{0, 1, 2, 3, 4}\n\nBelt.List.makeBy(5, i => i * i) // list{0, 1, 4, 9, 16}\n```" - ], - "signature": "let makeBy: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.List.shuffle", - "kind": "value", - "name": "shuffle", - "docstrings": [ - "Returns a new list in random order.\n\n## Examples\n\n```rescript\nBelt.List.shuffle(list{1, 2, 3}) // list{2, 1, 3}\n```" - ], - "signature": "let shuffle: t<'a> => t<'a>" - }, - { - "id": "Belt.List.drop", - "kind": "value", - "name": "drop", - "docstrings": [ - "Return a new list, dropping the first `n` elements. Returns `None` if `someList` has fewer than `n` elements.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->Belt.List.drop(2) // Some(list{3})\n\nlist{1, 2, 3}->Belt.List.drop(3) // Some(list{})\n\nlist{1, 2, 3}->Belt.List.drop(4) // None\n```" - ], - "signature": "let drop: (t<'a>, int) => option>" - }, - { - "id": "Belt.List.take", - "kind": "value", - "name": "take", - "docstrings": [ - "Returns a list with the first `n` elements from `someList`, or `None` if `someList` has fewer than `n` elements.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->Belt.List.take(1) // Some(list{1})\n\nlist{1, 2, 3}->Belt.List.take(2) // Some(list{1, 2})\n\nlist{1, 2, 3}->Belt.List.take(4) // None\n```" - ], - "signature": "let take: (t<'a>, int) => option>" - }, - { - "id": "Belt.List.splitAt", - "kind": "value", - "name": "splitAt", - "docstrings": [ - "Split the list `someList` at `index`. Returns `None` when the length of `someList` is less than `index`.\n\n## Examples\n\n```rescript\nlist{\"Hello\", \"World\"}->Belt.List.splitAt(1) // Some((list{\"Hello\"}, list{\"World\"}))\n\nlist{0, 1, 2, 3, 4}->Belt.List.splitAt(2) // Some((list{0, 1}, list{2, 3, 4}))\n```" - ], - "signature": "let splitAt: (t<'a>, int) => option<(list<'a>, list<'a>)>" - }, - { - "id": "Belt.List.concat", - "kind": "value", - "name": "concat", - "docstrings": [ - "Returns the list obtained by adding `secondList` after `firstList`.\n\n## Examples\n\n```rescript\nBelt.List.concat(list{1, 2, 3}, list{4, 5}) // list{1, 2, 3, 4, 5}\n```" - ], - "signature": "let concat: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Belt.List.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [ - "Returns the list obtained by concatenating all the lists in array `a`, in\norder.\n\n## Examples\n\n```rescript\nBelt.List.concatMany([list{1, 2, 3}, list{}, list{3}]) // list{1, 2, 3, 3}\n```" - ], - "signature": "let concatMany: array> => t<'a>" - }, - { - "id": "Belt.List.reverseConcat", - "kind": "value", - "name": "reverseConcat", - "docstrings": [ - "Equivalent to writing: `concat(reverse(firstList, secondList)`\n\n## Examples\n\n```rescript\nBelt.List.reverseConcat(list{1, 2}, list{3, 4}) // list{2, 1, 3, 4}\n```" - ], - "signature": "let reverseConcat: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Belt.List.flatten", - "kind": "value", - "name": "flatten", - "docstrings": [ - "Return the list obtained by concatenating all the lists in list `ls`, in order.\n\n## Examples\n\n```rescript\nBelt.List.flatten(list{list{1, 2, 3}, list{}, list{3}}) // list{1, 2, 3, 3}\n```" - ], - "signature": "let flatten: t> => t<'a>" - }, - { - "id": "Belt.List.mapU", - "kind": "value", - "name": "mapU", - "docstrings": ["Uncurried version of [map](#map)."], - "signature": "let mapU: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.List.map", - "kind": "value", - "name": "map", - "docstrings": [ - "Returns a new list with `f` applied to each element of `someList`.\n\n## Examples\n\n```rescript\nlist{1, 2}->Belt.List.map(x => x + 1) // list{3, 4}\n```" - ], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.List.zip", - "kind": "value", - "name": "zip", - "docstrings": [ - "Returns a list of pairs from the two lists with the length of the shorter list.\n\n## Examples\n\n```rescript\nBelt.List.zip(list{1, 2}, list{3, 4, 5}) // list{(1, 3), (2, 4)}\n```" - ], - "signature": "let zip: (t<'a>, t<'b>) => t<('a, 'b)>" - }, - { - "id": "Belt.List.zipByU", - "kind": "value", - "name": "zipByU", - "docstrings": ["Uncurried version of [zipBy](#zipBy)."], - "signature": "let zipByU: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c>" - }, - { - "id": "Belt.List.zipBy", - "kind": "value", - "name": "zipBy", - "docstrings": [ - "See [Belt.List.zip](#zip)\n\n## Examples\n\n```rescript\nBelt.List.zipBy(list{1, 2, 3}, list{4, 5}, (a, b) => 2 * a + b) // list{6, 9}\n```" - ], - "signature": "let zipBy: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c>" - }, - { - "id": "Belt.List.mapWithIndexU", - "kind": "value", - "name": "mapWithIndexU", - "docstrings": ["Uncurried version of [mapWithIndex](#mapWithIndex)."], - "signature": "let mapWithIndexU: (t<'a>, (int, 'a) => 'b) => t<'b>" - }, - { - "id": "Belt.List.mapWithIndex", - "kind": "value", - "name": "mapWithIndex", - "docstrings": [ - "Applies `f` to each element of `someList`.\nFunction `f` takes two arguments: the index starting from 0 and the element from `someList`, in that order.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->Belt.List.mapWithIndex((index, x) => index + x) // list{1, 3, 5}\n```" - ], - "signature": "let mapWithIndex: (t<'a>, (int, 'a) => 'b) => t<'b>" - }, - { - "id": "Belt.List.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Converts the given array to a list.\n\n## Examples\n\n```rescript\nBelt.List.fromArray([1, 2, 3]) // list{1, 2, 3}\n```" - ], - "signature": "let fromArray: array<'a> => t<'a>" - }, - { - "id": "Belt.List.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "Converts the given list to an array.\n\n## Examples\n\n```rescript\nBelt.List.toArray(list{1, 2, 3}) // [1, 2, 3]\n```" - ], - "signature": "let toArray: t<'a> => array<'a>" - }, - { - "id": "Belt.List.reverse", - "kind": "value", - "name": "reverse", - "docstrings": [ - "Returns a new list whose elements are those of `someList` in reversed order.\n\n## Examples\n\n```rescript\nBelt.List.reverse(list{1, 2, 3}) /* list{3, 2, 1} */\n```" - ], - "signature": "let reverse: t<'a> => t<'a>" - }, - { - "id": "Belt.List.mapReverseU", - "kind": "value", - "name": "mapReverseU", - "docstrings": ["Uncurried version of [mapReverse](#mapReverse)."], - "signature": "let mapReverseU: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.List.mapReverse", - "kind": "value", - "name": "mapReverse", - "docstrings": [ - "Equivalent to:\n\n```res\nmap(someList, f)->reverse\n```\n\n## Examples\n\n```rescript\nlist{3, 4, 5}->Belt.List.mapReverse(x => x * x) /* list{25, 16, 9} */\n```" - ], - "signature": "let mapReverse: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.List.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": ["Uncurried version of [forEach](#forEach)."], - "signature": "let forEachU: (t<'a>, 'a => 'b) => unit" - }, - { - "id": "Belt.List.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "Call `f` on each element of `someList` from the beginning to end.\n`f` returns `unit`, so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects.\n\n## Examples\n\n```rescript\nBelt.List.forEach(list{\"a\", \"b\", \"c\"}, x => Js.log(\"Item: \" ++ x))\n/*\n prints:\n Item: a\n Item: b\n Item: c\n*/\n```" - ], - "signature": "let forEach: (t<'a>, 'a => 'b) => unit" - }, - { - "id": "Belt.List.forEachWithIndexU", - "kind": "value", - "name": "forEachWithIndexU", - "docstrings": [ - "Uncurried version of [forEachWithIndex](#forEachWithIndex)." - ], - "signature": "let forEachWithIndexU: (t<'a>, (int, 'a) => 'b) => unit" - }, - { - "id": "Belt.List.forEachWithIndex", - "kind": "value", - "name": "forEachWithIndex", - "docstrings": [ - "Call `f` on each element of `someList` from beginning to end.\nFunction `f` takes two arguments: the index starting from 0 and the element from `someList`. `f` returns `unit`.\n\n## Examples\n\n```rescript\nBelt.List.forEachWithIndex(list{\"a\", \"b\", \"c\"}, (index, x) => {\n Js.log(\"Item \" ++ Belt.Int.toString(index) ++ \" is \" ++ x)\n})\n/*\n prints:\n Item 0 is a\n Item 1 is b\n Item 2 is cc\n*/\n```" - ], - "signature": "let forEachWithIndex: (t<'a>, (int, 'a) => 'b) => unit" - }, - { - "id": "Belt.List.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": ["Uncurried version of [reduce](#reduce)."], - "signature": "let reduceU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Belt.List.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "Applies `f` to each element of `someList` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue`. reduce returns the final value of the accumulator.\n\n## Examples\n\n```rescript\nlist{1, 2, 3, 4}->Belt.List.reduce(0, (a, b) => a + b) /* 10 */\n\n/* same as */\n\nlist{1, 2, 3, 4}->Belt.List.reduce(0, (acc, item) => acc + item) /* 10 */\n```" - ], - "signature": "let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Belt.List.reduceWithIndexU", - "kind": "value", - "name": "reduceWithIndexU", - "docstrings": [ - "Uncurried version of [reduceWithIndex](#reduceWithIndex)." - ], - "signature": "let reduceWithIndexU: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b" - }, - { - "id": "Belt.List.reduceWithIndex", - "kind": "value", - "name": "reduceWithIndex", - "docstrings": [ - "Applies `f` to each element of `someList` from beginning to end. Function `f` has three parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue` and the index of each element. `reduceWithIndex` returns the final value of the accumulator.\n\n## Examples\n\n```rescript\nlist{1, 2, 3, 4}->Belt.List.reduceWithIndex(0, (acc, item, index) => acc + item + index) /* 16 */\n```" - ], - "signature": "let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b" - }, - { - "id": "Belt.List.reduceReverseU", - "kind": "value", - "name": "reduceReverseU", - "docstrings": ["Uncurried version of [reduceReverse](#reduceReverse)."], - "signature": "let reduceReverseU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Belt.List.reduceReverse", - "kind": "value", - "name": "reduceReverse", - "docstrings": [ - "Works like [reduce](#reduce), except that function `f` is applied to each\nitem of `someList` from the last back to the first.\n\n## Examples\n\n```rescript\nlist{1, 2, 3, 4}->Belt.List.reduceReverse(0, (a, b) => a + b) /* 10 */\n\nlist{1, 2, 3, 4}->Belt.List.reduceReverse(10, (a, b) => a - b) /* 0 */\n\nlist{1, 2, 3, 4}->Belt.List.reduceReverse(list{}, Belt.List.add) // list{1, 2, 3, 4}\n```" - ], - "signature": "let reduceReverse: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Belt.List.mapReverse2U", - "kind": "value", - "name": "mapReverse2U", - "docstrings": ["Uncurried version of [mapReverse2](#mapReverse2)."], - "signature": "let mapReverse2U: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c>" - }, - { - "id": "Belt.List.mapReverse2", - "kind": "value", - "name": "mapReverse2", - "docstrings": [ - "Equivalent to: `zipBy(xs, ys, f)->reverse`\n\n## Examples\n\n```rescript\n\nBelt.List.mapReverse2(list{1, 2, 3}, list{1, 2}, (a, b) => a + b) // list{4, 2}\n```" - ], - "signature": "let mapReverse2: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c>" - }, - { - "id": "Belt.List.forEach2U", - "kind": "value", - "name": "forEach2U", - "docstrings": ["Uncurried version of [forEach2](#forEach2)."], - "signature": "let forEach2U: (t<'a>, t<'b>, ('a, 'b) => 'c) => unit" - }, - { - "id": "Belt.List.forEach2", - "kind": "value", - "name": "forEach2", - "docstrings": [ - "Stops at the length of the shorter list.\n\n## Examples\n\n```rescript\nBelt.List.forEach2(list{\"Z\", \"Y\"}, list{\"A\", \"B\", \"C\"}, (x, y) => Js.log2(x, y))\n\n/*\n prints:\n \"Z\" \"A\"\n \"Y\" \"B\"\n*/\n```" - ], - "signature": "let forEach2: (t<'a>, t<'b>, ('a, 'b) => 'c) => unit" - }, - { - "id": "Belt.List.reduce2U", - "kind": "value", - "name": "reduce2U", - "docstrings": ["Uncurried version of [reduce2](#reduce2)."], - "signature": "let reduce2U: (t<'b>, t<'c>, 'a, ('a, 'b, 'c) => 'a) => 'a" - }, - { - "id": "Belt.List.reduce2", - "kind": "value", - "name": "reduce2", - "docstrings": [ - "Applies `f` to each element of `firstList` and `secondList` from beginning to end. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of `initialValue`, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator.\n\n## Examples\n\n```rescript\nBelt.List.reduce2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* 0 + (1 * 1 + 4) + (2 * 2 + 5) */\n```" - ], - "signature": "let reduce2: (t<'b>, t<'c>, 'a, ('a, 'b, 'c) => 'a) => 'a" - }, - { - "id": "Belt.List.reduceReverse2U", - "kind": "value", - "name": "reduceReverse2U", - "docstrings": [ - "Uncurried version of [reduceReverse2](#reduceReverse2)." - ], - "signature": "let reduceReverse2U: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c" - }, - { - "id": "Belt.List.reduceReverse2", - "kind": "value", - "name": "reduceReverse2", - "docstrings": [ - "Applies `f` to each element of `firstList` and `secondList` from end to\nbeginning. Stops with the shorter list. Function `f` has three parameters: an\n“accumulator” which starts with a value of init, an item from `firstList`,\nand an item from `secondList`. `reduce2` returns the final value of the\naccumulator.\n\n## Examples\n\n```rescript\nBelt.List.reduceReverse2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* + (1 * 1 + 4) + (2 * 2 + 5) */\n```" - ], - "signature": "let reduceReverse2: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c" - }, - { - "id": "Belt.List.everyU", - "kind": "value", - "name": "everyU", - "docstrings": ["Uncurried version of [every](#every)."], - "signature": "let everyU: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.List.every", - "kind": "value", - "name": "every", - "docstrings": [ - "Returns `true` if all elements satisfy `pred`, where `pred` is a predicate: a function taking an element and returning a bool.\n\n## Examples\n\n```rescript\nlet isBelow10 = value => value < 10\n\nlist{1, 9, 8, 2}->Belt.List.every(isBelow10) /* true */\n\nlist{1, 99, 8, 2}->Belt.List.every(isBelow10) /* false */\n```" - ], - "signature": "let every: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.List.someU", - "kind": "value", - "name": "someU", - "docstrings": ["Uncurried version of [some](#some)."], - "signature": "let someU: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.List.some", - "kind": "value", - "name": "some", - "docstrings": [ - "Returns `true` if at least _one_ of the elements in `someList` satisfies\n`pred`, where `pred` is a predicate: a function taking an element and\nreturning a bool.\n\n## Examples\n\n```rescript\nlet isAbove100 = value => value > 100\n\nlist{101, 1, 2, 3}->Belt.List.some(isAbove100) /* true */\n\nlist{1, 2, 3, 4}->Belt.List.some(isAbove100) /* false */\n```" - ], - "signature": "let some: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.List.every2U", - "kind": "value", - "name": "every2U", - "docstrings": ["Uncurried version of [every2](#every2)."], - "signature": "let every2U: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.every2", - "kind": "value", - "name": "every2", - "docstrings": [ - "Returns `true` if predicate `pred(a, b)` is `true` for all pairs of elements\nup to the shorter length (i.e. `min(length(firstList), length(secondList))`)\n\n## Examples\n\n```rescript\nBelt.List.every2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */\n\nBelt.List.every2(list{}, list{1}, (a, b) => a > b) /* true */\n\nBelt.List.every2(list{2, 3}, list{1}, (a, b) => a > b) /* true */\n\nBelt.List.every2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* false */\n```" - ], - "signature": "let every2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.some2U", - "kind": "value", - "name": "some2U", - "docstrings": ["Uncurried version of [some2](#some2)."], - "signature": "let some2U: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.some2", - "kind": "value", - "name": "some2", - "docstrings": [ - "Returns `true` if predicate `pred(a, b)` is true for any pair of elements up\nto the shorter length (i.e. `min(length(firstList), length(secondList))`)\n\n## Examples\n\n```rescript\nBelt.List.some2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */\n\nBelt.List.some2(list{}, list{1}, (a, b) => a > b) /* false */\n\nBelt.List.some2(list{2, 3}, list{1}, (a, b) => a > b) /* true */\n\nBelt.List.some2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* true */\n```" - ], - "signature": "let some2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.cmpByLength", - "kind": "value", - "name": "cmpByLength", - "docstrings": [ - "Compare two lists solely by length. Returns `-1` if `length(firstList)` is\nless than `length(secondList)`, `0` if `length(firstList)` equals\n`length(secondList)`, and `1` if `length(firstList)` is greater than\n`length(secondList)`.\n\n## Examples\n\n```rescript\nBelt.List.cmpByLength(list{1, 2}, list{3, 4, 5, 6}) /* -1 */\n\nBelt.List.cmpByLength(list{1, 2, 3}, list{4, 5, 6}) /* = 0 */\n\nBelt.List.cmpByLength(list{1, 2, 3, 4}, list{5, 6}) /* = 1 */\n```" - ], - "signature": "let cmpByLength: (t<'a>, t<'a>) => int" - }, - { - "id": "Belt.List.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": ["Uncurried version of [cmp](#cmp)."], - "signature": "let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.List.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "Compare elements one by one `compareFn(a, b)`. `compareFn` returns a negative number if `a` is \"less than\" `b`, zero if `a` is \"equal to\" `b`, a positive number if `a` is \"greater than\" `b`.\n\nThe comparison returns the first non-zero result of `compareFn`, or zero if `compareFn` returns zero for all `a` and `b`.\n\nIf all items have compared equal, but `firstList` is exhausted first, return `-1`. (`firstList` is shorter).\nIf all items have compared equal, but `secondList` is exhausted first, return `1` (`firstList` is longer).\n\n## Examples\n\n```rescript\nBelt.List.cmp(list{3}, list{3, 7}, (a, b) => compare(a, b)) /* (-1) */\n\nBelt.List.cmp(list{5, 3}, list{5}, (a, b) => compare(a, b)) /* 1 */\n\nBelt.List.cmp(list{1, 3, 5}, list{1, 4, 2}, (a, b) => compare(a, b)) /* (-1) */\n\nBelt.List.cmp(list{1, 3, 5}, list{1, 2, 3}, (a, b) => compare(a, b)) /* 1 */\n\nBelt.List.cmp(list{1, 3, 5}, list{1, 3, 5}, (a, b) => compare(a, b)) /* 0 */\n```\n\n**Please note:** The total ordering of List is different from Array,\nfor Array, we compare the length first and, only if the lengths are equal, elements one by one.\nFor lists, we just compare elements one by one." - ], - "signature": "let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.List.eqU", - "kind": "value", - "name": "eqU", - "docstrings": ["Uncurried version of [eq](#eq)."], - "signature": "let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.List.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "Check equality of `firstList` and `secondList` using `eqElem` for equality on\nelements, where `eqElem` is a function that returns `true` if items `x` and\n`y` meet some criterion for equality, `false` otherwise. eq `false` if length\nof `firstList` and `secondList` are not the same.\n\n## Examples\n\n```rescript\nBelt.List.eq(list{1, 2, 3}, list{1, 2}, (a, b) => a == b) /* false */\n\nBelt.List.eq(list{1, 2}, list{1, 2}, (a, b) => a == b) /* true */\n\nBelt.List.eq(list{1, 2, 3}, list{(-1), (-2), (-3)}, (a, b) => abs(a) == abs(b)) /* true */\n```" - ], - "signature": "let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.List.hasU", - "kind": "value", - "name": "hasU", - "docstrings": ["Uncurried version of [has](#has)."], - "signature": "let hasU: (t<'a>, 'b, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.has", - "kind": "value", - "name": "has", - "docstrings": [ - "Returns `true` if the list contains at least one element for which\n`eqFunction(x)` returns true.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->Belt.List.has(2, (a, b) => a == b) /* true */\n\nlist{1, 2, 3}->Belt.List.has(4, (a, b) => a == b) /* false */\n\nlist{(-1), (-2), (-3)}->Belt.List.has(2, (a, b) => abs(a) == abs(b)) /* true */\n```" - ], - "signature": "let has: (t<'a>, 'b, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.getByU", - "kind": "value", - "name": "getByU", - "docstrings": ["Uncurried version of [getBy](#getBy)."], - "signature": "let getByU: (t<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Belt.List.getBy", - "kind": "value", - "name": "getBy", - "docstrings": [ - "Returns `Some(value)` for the first value in `someList` that satisfies the\npredicate function `pred`. Returns `None` if no element satisfies the function.\n\n## Examples\n\n```rescript\nBelt.List.getBy(list{1, 4, 3, 2}, x => x > 3) /* Some(4) */\n\nBelt.List.getBy(list{1, 4, 3, 2}, x => x > 4) /* None */\n```" - ], - "signature": "let getBy: (t<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Belt.List.keepU", - "kind": "value", - "name": "keepU", - "docstrings": ["Uncurried version of [keep](#keep)."], - "signature": "let keepU: (t<'a>, 'a => bool) => t<'a>" - }, - { - "id": "Belt.List.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "Returns a list of all elements in `someList` which satisfy the predicate function `pred`.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nBelt.List.keep(list{1, 2, 3, 4}, isEven) /* list{2, 4} */\n\nBelt.List.keep(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */\n```" - ], - "signature": "let keep: (t<'a>, 'a => bool) => t<'a>" - }, - { - "id": "Belt.List.filter", - "kind": "value", - "name": "filter", - "docstrings": [ - "Returns a list of all elements in `someList` which satisfy the predicate function `pred`.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nBelt.List.filter(list{1, 2, 3, 4}, isEven) /* list{2, 4} */\n\nBelt.List.filter(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */\n```" - ], - "signature": "let filter: (t<'a>, 'a => bool) => t<'a>", - "deprecated": "This function will soon be deprecated. Please, use `List.keep` instead." - }, - { - "id": "Belt.List.keepWithIndexU", - "kind": "value", - "name": "keepWithIndexU", - "docstrings": ["Uncurried version of [keepWithIndex](#keepWithIndex)."], - "signature": "let keepWithIndexU: (t<'a>, ('a, int) => bool) => t<'a>" - }, - { - "id": "Belt.List.keepWithIndex", - "kind": "value", - "name": "keepWithIndex", - "docstrings": [ - "Returns a list of all elements in `someList` which satisfy the predicate function `pred`.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nBelt.List.keepWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */\n```" - ], - "signature": "let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a>" - }, - { - "id": "Belt.List.filterWithIndex", - "kind": "value", - "name": "filterWithIndex", - "docstrings": [ - "Returns a list of all elements in `someList` which satisfy the predicate function `pred`.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nBelt.List.filterWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */\n```" - ], - "signature": "let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a>", - "deprecated": "This function will soon be deprecated. Please, use `List.keepWithIndex` \\\n instead." - }, - { - "id": "Belt.List.keepMapU", - "kind": "value", - "name": "keepMapU", - "docstrings": ["Uncurried version of [keepMap](#keepMap)."], - "signature": "let keepMapU: (t<'a>, 'a => option<'b>) => t<'b>" - }, - { - "id": "Belt.List.keepMap", - "kind": "value", - "name": "keepMap", - "docstrings": [ - "Applies `f` to each element of `someList`. If `f(x)` returns `Some(value)`, then `value` is _kept_ in the resulting list.\nIf `f(x)` returns `None`, the element is _not_ retained in the result.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nlist{1, 2, 3, 4}\n->Belt.List.keepMap(x =>\n if (isEven(x)) {\n Some(x)\n } else {\n None\n }\n ) /* list{2, 4} */\n\nlist{Some(1), Some(2), None}->Belt.List.keepMap(x => x) /* list{1, 2} */\n```" - ], - "signature": "let keepMap: (t<'a>, 'a => option<'b>) => t<'b>" - }, - { - "id": "Belt.List.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": ["Uncurried version of [partition](#partition)."], - "signature": "let partitionU: (t<'a>, 'a => bool) => (t<'a>, t<'a>)" - }, - { - "id": "Belt.List.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "Creates a pair of lists; the first list consists of all elements of `someList` that satisfy the predicate function `pred`; the second list consists of all elements of `someList` that _do not_ satisfy `pred.\n\nIn other words:\n\n```rescript\n(elementsThatSatisfies, elementsThatDoesNotSatisfy)\n```\n\n## Examples\n\n```rescript\nBelt.List.partition(list{1, 2, 3, 4}, x => x > 2) /* (list{3, 4}, list{1, 2}) */\n```" - ], - "signature": "let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>)" - }, - { - "id": "Belt.List.unzip", - "kind": "value", - "name": "unzip", - "docstrings": [ - "Takes a list of pairs and creates a pair of lists. The first list contains all the first items of the pairs; the second list contains all the second items.\n\n## Examples\n\n```rescript\nBelt.List.unzip(list{(1, 2), (3, 4)}) /* (list{1, 3}, list{2, 4}) */\n\nBelt.List.unzip(list{(\"H\", \"W\"), (\"e\", \"o\"), (\"l\", \"r\"), (\"l\", \"l\"), (\"o\", \"d\"), (\" \", \"!\")})\n/* (list{\"H\", \"e\", \"l\", \"l\", \"o\", \" \"}, list{\"W\", \"o\", \"r\", \"l\", \"d\", \"!\"}) */\n```" - ], - "signature": "let unzip: t<('a, 'b)> => (t<'a>, t<'b>)" - }, - { - "id": "Belt.List.getAssocU", - "kind": "value", - "name": "getAssocU", - "docstrings": ["Uncurried version of [getAssoc](#getAssoc)."], - "signature": "let getAssocU: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c>" - }, - { - "id": "Belt.List.getAssoc", - "kind": "value", - "name": "getAssoc", - "docstrings": [ - "Return the second element of a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`, or `None` if not found.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->Belt.List.getAssoc(3, (a, b) => a == b) /* Some(\"c\") */\n\nlist{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")}\n->Belt.List.getAssoc(15, (k, item) => k /* 15 */ == item /* 9, 5, 22 */)\n/* Some(\"afternoon\") */\n```" - ], - "signature": "let getAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c>" - }, - { - "id": "Belt.List.hasAssocU", - "kind": "value", - "name": "hasAssocU", - "docstrings": ["Uncurried version of [hasAssoc](#hasAssoc)."], - "signature": "let hasAssocU: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.hasAssoc", - "kind": "value", - "name": "hasAssoc", - "docstrings": [ - "Returns `true` if there is a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->Belt.List.hasAssoc(1, (a, b) => a == b) /* true */\n\nlist{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")}\n->Belt.List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */) /* false */\n```" - ], - "signature": "let hasAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.List.removeAssocU", - "kind": "value", - "name": "removeAssocU", - "docstrings": ["Uncurried version of [removeAssoc](#removeAssoc)."], - "signature": "let removeAssocU: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => t<('a, 'c)>" - }, - { - "id": "Belt.List.removeAssoc", - "kind": "value", - "name": "removeAssoc", - "docstrings": [ - "Return a list after removing the first pair whose first value is `k` per the equality predicate `eqFunction`; if not found, return a new list identical to `someList`.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->Belt.List.removeAssoc(1, (a, b) => a == b) /* list{(2, \"b\"), (3, \"c\")} */\n\nlist{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")}\n->Belt.List.removeAssoc(9, (k, item) => k /* 9 */ == item /* 9, 5, 22 */)\n/* list{(15, \"afternoon\"), (22, \"night\")} */\n```" - ], - "signature": "let removeAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => t<('a, 'c)>" - }, - { - "id": "Belt.List.setAssocU", - "kind": "value", - "name": "setAssocU", - "docstrings": ["Uncurried version of [setAssoc](#setAssoc)."], - "signature": "let setAssocU: (t<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => t<('a, 'c)>" - }, - { - "id": "Belt.List.setAssoc", - "kind": "value", - "name": "setAssoc", - "docstrings": [ - "If `k` exists in `someList` by satisfying the `eqFunction` predicate, return a new list with the key and value replaced by the new `k` and `v`; otherwise, return a new list with the pair `k`, `v` added to the head of `someList`.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->Belt.List.setAssoc(2, \"x\", (a, b) => a == b) /* list{(1, \"a\"), (2, \"x\"), (3, \"c\")} */\n\nlist{(1, \"a\"), (3, \"c\")}->Belt.List.setAssoc(2, \"b\", (a, b) => a == b) /* list{(2, \"b\"), (1, \"a\"), (3, \"c\")} */\n\nlist{(9, \"morning\"), (3, \"morning?!\"), (22, \"night\")}\n->Belt.List.setAssoc(15, \"afternoon\", (a, b) => mod(a, 12) == mod(b, 12))\n/* list{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")} */\n```\n\n**Please note**\n\nIn the last example, since: `15 mod 12` equals `3 mod 12`\n\nBoth the key _and_ the value are replaced in the list." - ], - "signature": "let setAssoc: (t<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => t<('a, 'c)>" - }, - { - "id": "Belt.List.sortU", - "kind": "value", - "name": "sortU", - "docstrings": ["Uncurried version of [sort](#sort)."], - "signature": "let sortU: (t<'a>, ('a, 'a) => int) => t<'a>" - }, - { - "id": "Belt.List.sort", - "kind": "value", - "name": "sort", - "docstrings": [ - "Returns a sorted list.\n\n## Examples\n\n```rescript\nBelt.List.sort(list{5, 4, 9, 3, 7}, (a, b) => a - b) // list{3, 4, 5, 7, 9}\n```" - ], - "signature": "let sort: (t<'a>, ('a, 'a) => int) => t<'a>" - } - ] - }, - "belt/mutablestack": { - "id": "Belt.MutableStack", - "name": "MutableStack", - "docstrings": [ - "[`Belt.MutableStack`]()\n\n An FILO(first in last out) stack data structure", - "First in last out stack. This module implements stacks, with in-place\nmodification." - ], - "items": [ - { - "id": "Belt.MutableStack.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a>" - }, - { - "id": "Belt.MutableStack.make", - "kind": "value", - "name": "make", - "docstrings": ["Returns a new stack, initially empty."], - "signature": "let make: unit => t<'a>" - }, - { - "id": "Belt.MutableStack.clear", - "kind": "value", - "name": "clear", - "docstrings": ["Discard all elements from the stack."], - "signature": "let clear: t<'a> => unit" - }, - { - "id": "Belt.MutableStack.copy", - "kind": "value", - "name": "copy", - "docstrings": ["`copy(x)` O(1) operation, return a new stack."], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Belt.MutableStack.push", - "kind": "value", - "name": "push", - "docstrings": [], - "signature": "let push: (t<'a>, 'a) => unit" - }, - { - "id": "Belt.MutableStack.popUndefined", - "kind": "value", - "name": "popUndefined", - "docstrings": [], - "signature": "let popUndefined: t<'a> => Js.undefined<'a>" - }, - { - "id": "Belt.MutableStack.pop", - "kind": "value", - "name": "pop", - "docstrings": [], - "signature": "let pop: t<'a> => option<'a>" - }, - { - "id": "Belt.MutableStack.topUndefined", - "kind": "value", - "name": "topUndefined", - "docstrings": [], - "signature": "let topUndefined: t<'a> => Js.undefined<'a>" - }, - { - "id": "Belt.MutableStack.top", - "kind": "value", - "name": "top", - "docstrings": [], - "signature": "let top: t<'a> => option<'a>" - }, - { - "id": "Belt.MutableStack.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a> => bool" - }, - { - "id": "Belt.MutableStack.size", - "kind": "value", - "name": "size", - "docstrings": [], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.MutableStack.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.MutableStack.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.MutableStack.dynamicPopIterU", - "kind": "value", - "name": "dynamicPopIterU", - "docstrings": [], - "signature": "let dynamicPopIterU: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.MutableStack.dynamicPopIter", - "kind": "value", - "name": "dynamicPopIter", - "docstrings": [ - "`dynamicPopIter(s, f)` apply `f` to each element of `s`. The item is poped\nbefore applying `f`, `s` will be empty after this opeartion. This function is\nuseful for worklist algorithm." - ], - "signature": "let dynamicPopIter: (t<'a>, 'a => unit) => unit" - } - ] - }, - "belt/mutablequeue": { - "id": "Belt.MutableQueue", - "name": "MutableQueue", - "docstrings": [ - "[`Belt.MutableQueue`]()\n\n An FIFO(first in first out) queue data structure", - "A FIFO (first in first out) queue data structure." - ], - "items": [ - { - "id": "Belt.MutableQueue.t", - "kind": "type", - "name": "t", - "docstrings": ["The type of queues containing elements of `type('a)`."], - "signature": "type t<'a>" - }, - { - "id": "Belt.MutableQueue.make", - "kind": "value", - "name": "make", - "docstrings": ["Returns a new queue, initially empty."], - "signature": "let make: unit => t<'a>" - }, - { - "id": "Belt.MutableQueue.clear", - "kind": "value", - "name": "clear", - "docstrings": ["Discard all elements from the queue."], - "signature": "let clear: t<'a> => unit" - }, - { - "id": "Belt.MutableQueue.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [ - "Returns `true` if the given queue is empty, `false` otherwise." - ], - "signature": "let isEmpty: t<'a> => bool" - }, - { - "id": "Belt.MutableQueue.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` a is equivalent to `Array.forEach(a, add(q, a));`" - ], - "signature": "let fromArray: array<'a> => t<'a>" - }, - { - "id": "Belt.MutableQueue.add", - "kind": "value", - "name": "add", - "docstrings": [ - "`add(q, x)` adds the element `x` at the end of the queue `q`." - ], - "signature": "let add: (t<'a>, 'a) => unit" - }, - { - "id": "Belt.MutableQueue.peek", - "kind": "value", - "name": "peek", - "docstrings": [ - "`peekOpt(q)` returns the first element in queue `q`, without removing it from the queue." - ], - "signature": "let peek: t<'a> => option<'a>" - }, - { - "id": "Belt.MutableQueue.peekUndefined", - "kind": "value", - "name": "peekUndefined", - "docstrings": ["`peekUndefined(q)` returns `undefined` if not found."], - "signature": "let peekUndefined: t<'a> => Js.undefined<'a>" - }, - { - "id": "Belt.MutableQueue.peekExn", - "kind": "value", - "name": "peekExn", - "docstrings": ["raise an exception if `q` is empty"], - "signature": "let peekExn: t<'a> => 'a" - }, - { - "id": "Belt.MutableQueue.pop", - "kind": "value", - "name": "pop", - "docstrings": [ - "`pop(q)` removes and returns the first element in queue `q`." - ], - "signature": "let pop: t<'a> => option<'a>" - }, - { - "id": "Belt.MutableQueue.popUndefined", - "kind": "value", - "name": "popUndefined", - "docstrings": [ - "`popUndefined(q)` removes and returns the first element in queue `q`. it will\nreturn `undefined` if it is already empty." - ], - "signature": "let popUndefined: t<'a> => Js.undefined<'a>" - }, - { - "id": "Belt.MutableQueue.popExn", - "kind": "value", - "name": "popExn", - "docstrings": ["`popExn(q)` raise an exception if q is empty."], - "signature": "let popExn: t<'a> => 'a" - }, - { - "id": "Belt.MutableQueue.copy", - "kind": "value", - "name": "copy", - "docstrings": ["`copy(q)` returns a fresh queue."], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Belt.MutableQueue.size", - "kind": "value", - "name": "size", - "docstrings": ["Returns the number of elements in a queue."], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.MutableQueue.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.MutableQueue.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Belt.MutableQueue.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.MutableQueue.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(q, f) applies`f`in turn to all elements of`q`, from the least\nrecently entered to the most recently entered. The queue itself is unchanged." - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.MutableQueue.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableQueue.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(q, accu, f)` is equivalent to `List.reduce(l, accu, f)`, where `l` is the\nlist of `q`'s elements. The queue remains unchanged." - ], - "signature": "let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Belt.MutableQueue.transfer", - "kind": "value", - "name": "transfer", - "docstrings": [ - "`transfer(q1, q2)` adds all of `q1`'s elements at the end of the queue `q2`,\nthen clears `q1`. It is equivalent to the sequence `forEach((x) => add(x, q2), q1)`;\nclear `q1`, but runs in constant time." - ], - "signature": "let transfer: (t<'a>, t<'a>) => unit" - }, - { - "id": "Belt.MutableQueue.toArray", - "kind": "value", - "name": "toArray", - "docstrings": ["First added will be in the beginning of the array."], - "signature": "let toArray: t<'a> => array<'a>" - } - ] - }, - "belt/sortarray": { - "id": "Belt.SortArray", - "name": "SortArray", - "docstrings": [ - "[`Belt.SortArray`]()\n\n The top level provides some generic sort related utilities.\n\n It also has two specialized inner modules\n [`Belt.SortArray.Int`]() and [`Belt.SortArray.String`]()", - "A module for Array sort relevant utiliites" - ], - "items": [ - { - "id": "Belt.SortArray.strictlySortedLengthU", - "kind": "value", - "name": "strictlySortedLengthU", - "docstrings": [], - "signature": "let strictlySortedLengthU: (array<'a>, ('a, 'a) => bool) => int" - }, - { - "id": "Belt.SortArray.strictlySortedLength", - "kind": "value", - "name": "strictlySortedLength", - "docstrings": [ - "`strictlySortedLenght(xs, cmp);` return `+n` means increasing order `-n` means negative order\n\n## Examples\n\n```rescript\nBelt.SortArray.strictlySortedLength([1, 2, 3, 4, 3], (x, y) => x < y) == 4\n\nBelt.SortArray.strictlySortedLength([], (x, y) => x < y) == 0\n\nBelt.SortArray.strictlySortedLength([1], (x, y) => x < y) == 1\n\nBelt.SortArray.strictlySortedLength([4, 3, 2, 1], (x, y) => x < y) == -4\n```" - ], - "signature": "let strictlySortedLength: (array<'a>, ('a, 'a) => bool) => int" - }, - { - "id": "Belt.SortArray.isSortedU", - "kind": "value", - "name": "isSortedU", - "docstrings": [], - "signature": "let isSortedU: (array<'a>, ('a, 'a) => int) => bool" - }, - { - "id": "Belt.SortArray.isSorted", - "kind": "value", - "name": "isSorted", - "docstrings": [ - "`isSorted(arr, cmp)`: Returns true if array is increasingly sorted (equal is okay)" - ], - "signature": "let isSorted: (array<'a>, ('a, 'a) => int) => bool" - }, - { - "id": "Belt.SortArray.stableSortInPlaceByU", - "kind": "value", - "name": "stableSortInPlaceByU", - "docstrings": [], - "signature": "let stableSortInPlaceByU: (array<'a>, ('a, 'a) => int) => unit" - }, - { - "id": "Belt.SortArray.stableSortInPlaceBy", - "kind": "value", - "name": "stableSortInPlaceBy", - "docstrings": [], - "signature": "let stableSortInPlaceBy: (array<'a>, ('a, 'a) => int) => unit" - }, - { - "id": "Belt.SortArray.stableSortByU", - "kind": "value", - "name": "stableSortByU", - "docstrings": [], - "signature": "let stableSortByU: (array<'a>, ('a, 'a) => int) => array<'a>" - }, - { - "id": "Belt.SortArray.stableSortBy", - "kind": "value", - "name": "stableSortBy", - "docstrings": [ - "`stableSortBy(xs, cmp)`: Returns a fresh array Sort `xs` in place using\ncomparator `cmp`, the stable means if the elements are equal, their order will\nbe preserved" - ], - "signature": "let stableSortBy: (array<'a>, ('a, 'a) => int) => array<'a>" - }, - { - "id": "Belt.SortArray.binarySearchByU", - "kind": "value", - "name": "binarySearchByU", - "docstrings": [], - "signature": "let binarySearchByU: (array<'a>, 'a, ('a, 'a) => int) => int" - }, - { - "id": "Belt.SortArray.binarySearchBy", - "kind": "value", - "name": "binarySearchBy", - "docstrings": [ - "If value is not found and value is less than one or more elements in array, the\nnegative number returned is the bitwise complement of the index of the first\nelement that is larger than value.\n\nIf value is not found and value is greater\nthan all elements in array, the negative number returned is the bitwise\ncomplement of (the index of the last element plus 1)for example, if `key` is\nsmaller than all elements return `-1` since `lnot(-1) == 0` if `key` is larger\nthan all elements return `lnot(-1) == 0` since `lnot(- (len + 1)) == len`\n\n## Examples\n\n```rescript\nBelt.SortArray.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 33, Pervasives.compare) == 4\n\nlnot(Belt.SortArray.binarySearchBy([1, 3, 5, 7], 4, Pervasives.compare)) == 2\n```" - ], - "signature": "let binarySearchBy: (array<'a>, 'a, ('a, 'a) => int) => int" - }, - { - "id": "Belt.SortArray.unionU", - "kind": "value", - "name": "unionU", - "docstrings": [], - "signature": "let unionU: (\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n ('a, 'a) => int,\n) => int" - }, - { - "id": "Belt.SortArray.union", - "kind": "value", - "name": "union", - "docstrings": [ - "`union src src1ofs src1len src2 src2ofs src2len dst dstofs cmp` assume `src` and\n`src2` is strictly sorted. for equivalent elements, it is picked from `src`\nalso assume that `dst` is large enough to store all elements" - ], - "signature": "let union: (\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n ('a, 'a) => int,\n) => int" - }, - { - "id": "Belt.SortArray.intersectU", - "kind": "value", - "name": "intersectU", - "docstrings": [], - "signature": "let intersectU: (\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n ('a, 'a) => int,\n) => int" - }, - { - "id": "Belt.SortArray.intersect", - "kind": "value", - "name": "intersect", - "docstrings": [ - "`union src src1ofs src1len src2 src2ofs src2len dst dstofs cmp`\n\n**return** the `offset` in the output array" - ], - "signature": "let intersect: (\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n ('a, 'a) => int,\n) => int" - }, - { - "id": "Belt.SortArray.diffU", - "kind": "value", - "name": "diffU", - "docstrings": [], - "signature": "let diffU: (\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n ('a, 'a) => int,\n) => int" - }, - { - "id": "Belt.SortArray.diff", - "kind": "value", - "name": "diff", - "docstrings": [], - "signature": "let diff: (\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n int,\n array<'a>,\n int,\n ('a, 'a) => int,\n) => int" - } - ] - }, - "belt/array": { - "id": "Belt.Array", - "name": "Array", - "docstrings": [ - "[`Belt.Array`]()\n\n **mutable array**: Utilities functions", - "Utilities for `Array` functions.\n\n### Note about index syntax\n\nCode like `arr[0]` does *not* compile to JavaScript `arr[0]`. Reason transforms\nthe `[]` index syntax into a function: `Array.get(arr, 0)`. By default, this\nuses the default standard library's `Array.get` function, which may raise an\nexception if the index isn't found. If you `open Belt`, it will use the\n`Belt.Array.get` function which returns options instead of raising exceptions. \n[See this for more information](../belt.mdx#array-access-runtime-safety)." - ], - "items": [ - { - "id": "Belt.Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = array<'a>" - }, - { - "id": "Belt.Array.length", - "kind": "value", - "name": "length", - "docstrings": [ - "Return the size of the array\n\n## Examples\n\n```rescript\n// Returns 1\nBelt.Array.length([\"test\"])\n```" - ], - "signature": "let length: t<'a> => int" - }, - { - "id": "Belt.Array.size", - "kind": "value", - "name": "size", - "docstrings": ["See [`Belt.Array.length`]()"], - "signature": "let size: t<'a> => int" - }, - { - "id": "Belt.Array.get", - "kind": "value", - "name": "get", - "docstrings": [ - "If `i <= 0 <= length(arr)` returns `Some(value)` where `value` is the item at index `i`.\nIf `i` is out of range returns `None`.\n\n## Examples\n\n```rescript\nBelt.Array.get([\"a\", \"b\", \"c\"], 0) == Some(\"a\")\nBelt.Array.get([\"a\", \"b\", \"c\"], 3) == None\nBelt.Array.get([\"a\", \"b\", \"c\"], -1) == None\n```" - ], - "signature": "let get: (t<'a>, int) => option<'a>" - }, - { - "id": "Belt.Array.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "Raise an exception if `i` is out of range.\nOtherwise return the value at index `i` in `arr`." - ], - "signature": "let getExn: (t<'a>, int) => 'a" - }, - { - "id": "Belt.Array.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(arr, i)`\n\n**Unsafe**\n\nno bounds checking; this would cause type error if `i` does not stay within range" - ], - "signature": "let getUnsafe: (t<'a>, int) => 'a" - }, - { - "id": "Belt.Array.getUndefined", - "kind": "value", - "name": "getUndefined", - "docstrings": [ - "`getUndefined(arr, i)`\n\nIt does the samething in the runtime as [`getUnsafe`]();\nit is _type safe_ since the return type still track whether it is\nin range or not" - ], - "signature": "let getUndefined: (t<'a>, int) => Js.undefined<'a>" - }, - { - "id": "Belt.Array.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(arr, n, x)` modifies `arr` in place; it replaces the nth element of `arr`\nwith `x`. Returning `false` means not updated due to out of range." - ], - "signature": "let set: (t<'a>, int, 'a) => bool" - }, - { - "id": "Belt.Array.setExn", - "kind": "value", - "name": "setExn", - "docstrings": [ - "`setExn(arr, i, x)` raise an exception if `i` is out of range." - ], - "signature": "let setExn: (t<'a>, int, 'a) => unit" - }, - { - "id": "Belt.Array.setUnsafe", - "kind": "value", - "name": "setUnsafe", - "docstrings": [], - "signature": "let setUnsafe: (t<'a>, int, 'a) => unit" - }, - { - "id": "Belt.Array.shuffleInPlace", - "kind": "value", - "name": "shuffleInPlace", - "docstrings": [ - "`shuffleInPlace(arr)` randomly re-orders the items in `arr`" - ], - "signature": "let shuffleInPlace: t<'a> => unit" - }, - { - "id": "Belt.Array.shuffle", - "kind": "value", - "name": "shuffle", - "docstrings": [ - "Returns a fresh array with items in original array randomly shuffled." - ], - "signature": "let shuffle: t<'a> => t<'a>" - }, - { - "id": "Belt.Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [ - "`reverseInPlace(arr)` reverses items in `arr` in place.\n\n## Examples\n\n```rescript\nlet arr = [10, 11, 12, 13, 14]\n\nlet () = Belt.Array.reverseInPlace(arr)\n\narr == [14, 13, 12, 11, 10]\n```" - ], - "signature": "let reverseInPlace: t<'a> => unit" - }, - { - "id": "Belt.Array.reverse", - "kind": "value", - "name": "reverse", - "docstrings": [ - "`reverse(arr)` returns a fresh array with items in arr in reverse order.\n\n## Examples\n\n```rescript\nBelt.Array.reverse([10, 11, 12, 13, 14]) == [14, 13, 12, 11, 10]\n```" - ], - "signature": "let reverse: t<'a> => t<'a>" - }, - { - "id": "Belt.Array.makeUninitialized", - "kind": "value", - "name": "makeUninitialized", - "docstrings": [ - "`makeUninitialized(n)` creates an array of length `n` filled with the undefined\nvalue. You must specify the type of data that will eventually fill the array.\n\n## Examples\n\n```rescript\nlet arr: array> = Belt.Array.makeUninitialized(5)\n\nBelt.Array.getExn(arr, 0) == Js.undefined\n```" - ], - "signature": "let makeUninitialized: int => array>" - }, - { - "id": "Belt.Array.makeUninitializedUnsafe", - "kind": "value", - "name": "makeUninitializedUnsafe", - "docstrings": [ - "**Unsafe**\n\n## Examples\n\n```rescript\nlet arr = Belt.Array.makeUninitializedUnsafe(5)\n\nJs.log(Belt.Array.getExn(arr, 0)) // undefined\n\nBelt.Array.setExn(arr, 0, \"example\")\n\nJs.log(Belt.Array.getExn(arr, 0) == \"example\")\n```" - ], - "signature": "let makeUninitializedUnsafe: int => t<'a>" - }, - { - "id": "Belt.Array.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(n, e)` return an array of size `n` filled with value `e`.\nReturns an empty array when `n` is negative." - ], - "signature": "let make: (int, 'a) => t<'a>" - }, - { - "id": "Belt.Array.range", - "kind": "value", - "name": "range", - "docstrings": [ - "`range(start, finish)` create an inclusive array.\n\n## Examples\n\n```rescript\nBelt.Array.range(0, 3) == [0, 1, 2, 3]\n\nBelt.Array.range(3, 0) == []\n\nBelt.Array.range(3, 3) == [3]\n```" - ], - "signature": "let range: (int, int) => array" - }, - { - "id": "Belt.Array.rangeBy", - "kind": "value", - "name": "rangeBy", - "docstrings": [ - "`rangeBy(start, finish, ~step)` returns empty array when step is 0 or negative.\nIt also return an empty array when `start > finish`.\n\n## Examples\n\n```rescript\nBelt.Array.rangeBy(0, 10, ~step=3) == [0, 3, 6, 9]\n\nBelt.Array.rangeBy(0, 12, ~step=3) == [0, 3, 6, 9, 12]\n\nBelt.Array.rangeBy(33, 0, ~step=1) == []\n\nBelt.Array.rangeBy(33, 0, ~step=-1) == []\n\nBelt.Array.rangeBy(3, 12, ~step=-1) == []\n\nBelt.Array.rangeBy(3, 3, ~step=0) == []\n\nBelt.Array.rangeBy(3, 3, ~step=1) == [3]\n```" - ], - "signature": "let rangeBy: (int, int, ~step: int) => array" - }, - { - "id": "Belt.Array.makeByU", - "kind": "value", - "name": "makeByU", - "docstrings": [], - "signature": "let makeByU: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.Array.makeBy", - "kind": "value", - "name": "makeBy", - "docstrings": [ - "`makeBy(n, f)` return an empty array when n is negative return an array of size\nn populated by `f(i)` start from `0` to `n - 1`.\n\n## Examples\n\n```rescript\nBelt.Array.makeBy(5, (i) => i) == [0, 1, 2, 3, 4]\n\nBelt.Array.makeBy(5, (i) => i * i) == [0, 1, 4, 9, 16]\n```" - ], - "signature": "let makeBy: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.Array.makeByAndShuffleU", - "kind": "value", - "name": "makeByAndShuffleU", - "docstrings": [], - "signature": "let makeByAndShuffleU: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.Array.makeByAndShuffle", - "kind": "value", - "name": "makeByAndShuffle", - "docstrings": ["Equivalent to `shuffle(makeBy(n, f))`"], - "signature": "let makeByAndShuffle: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.Array.zip", - "kind": "value", - "name": "zip", - "docstrings": [ - "`zip(a, b)` create an array of pairs from corresponding elements of a and b.\nStop with the shorter array.\n\n## Examples\n\n```rescript\nBelt.Array.zip([1, 2], [3, 4, 5]) == [(1, 3), (2, 4)]\n```" - ], - "signature": "let zip: (t<'a>, array<'b>) => array<('a, 'b)>" - }, - { - "id": "Belt.Array.zipByU", - "kind": "value", - "name": "zipByU", - "docstrings": [], - "signature": "let zipByU: (t<'a>, array<'b>, ('a, 'b) => 'c) => array<'c>" - }, - { - "id": "Belt.Array.zipBy", - "kind": "value", - "name": "zipBy", - "docstrings": [ - "`zipBy(xs, ys, f)` create an array by applying `f` to corresponding elements of\n`xs` and `ys`. Stops with shorter array.\n\nEquivalent to `map(zip(xs, ys), ((a, b)) => f(a, b))`\n\n## Examples\n\n```rescript\nBelt.Array.zipBy([1, 2, 3], [4, 5], (a, b) => 2 * a + b) == [6, 9]\n```" - ], - "signature": "let zipBy: (t<'a>, array<'b>, ('a, 'b) => 'c) => array<'c>" - }, - { - "id": "Belt.Array.unzip", - "kind": "value", - "name": "unzip", - "docstrings": [ - "`unzip(a)` takes an array of pairs and creates a pair of arrays. The first array\ncontains all the first items of the pairs; the second array contains all the\nsecond items.\n\n## Examples\n\n```rescript\nBelt.Array.unzip([(1, 2), (3, 4)]) == ([1, 3], [2, 4])\n\nBelt.Array.unzip([(1, 2), (3, 4), (5, 6), (7, 8)]) == ([1, 3, 5, 7], [2, 4, 6, 8])\n```" - ], - "signature": "let unzip: array<('a, 'b)> => (t<'a>, array<'b>)" - }, - { - "id": "Belt.Array.concat", - "kind": "value", - "name": "concat", - "docstrings": [ - "`concat(xs, ys)` returns a fresh array containing the concatenation of the arrays\n`v1` and `v2`, so even if `v1` or `v2` is empty; it can not be shared.\n\n## Examples\n\n```rescript\nBelt.Array.concat([1, 2, 3], [4, 5]) == [1, 2, 3, 4, 5]\n\nBelt.Array.concat([], [\"a\", \"b\", \"c\"]) == [\"a\", \"b\", \"c\"]\n```" - ], - "signature": "let concat: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Belt.Array.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [ - "`concatMany(xss)` returns a fresh array as the concatenation of `xss` (an array of arrays)\n\n## Examples\n\n```rescript\nBelt.Array.concatMany([[1, 2, 3], [4, 5, 6], [7, 8]]) == [1, 2, 3, 4, 5, 6, 7, 8]\n```" - ], - "signature": "let concatMany: array> => t<'a>" - }, - { - "id": "Belt.Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [ - "`slice(xs, offset, len)` creates a new array with the len elements of `xs`\nstarting at `offset` for `offset` can be negative;and is evaluated as\n`length(xs) - offset(slice, xs) - 1(1)` means get the last element as a\nsingleton array `slice(xs, ~-len, len)` will return a copy of the array if the\narray does not have enough data; `slice` extracts through the end of sequence.\n\nif `len` is negative; returns the empty array.\n\n## Examples\n\n```rescript\nBelt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=2, ~len=3) == [12, 13, 14]\n\nBelt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=-4, ~len=3) == [13, 14, 15]\n\nBelt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=4, ~len=9) == [14, 15, 16]\n```" - ], - "signature": "let slice: (t<'a>, ~offset: int, ~len: int) => t<'a>" - }, - { - "id": "Belt.Array.sliceToEnd", - "kind": "value", - "name": "sliceToEnd", - "docstrings": [ - "`sliceToEnd(xs, offset)` creates a new array with the elements of `xs` starting\nat `offset`\n\n`offset` can be negative; and is evaluated as `length(xs) - offset(sliceToEnd, xs) - 1`\nmeans get the last element as a singleton array\n\n`sliceToEnd(xs, 0)` will return a copy of the array\n\n## Examples\n\n```rescript\nBelt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], 2) == [12, 13, 14, 15, 16]\n\nBelt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], -4) == [13, 14, 15, 16]\n```" - ], - "signature": "let sliceToEnd: (t<'a>, int) => t<'a>" - }, - { - "id": "Belt.Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [ - "`copy(a)` returns a copy of `a`; that is; a fresh array containing the same\nelements as `a`." - ], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Belt.Array.fill", - "kind": "value", - "name": "fill", - "docstrings": [ - "`fill(arr, ~offset, ~len, x)` modifies `arr` in place, storing `x` in elements\nnumber `offset` to `offset + len - 1`. `offset` can be negative; and is evaluated\nas `length(arr - offset)`.\n\n`fill(arr, ~offset=-1, ~len=1)` means fill the last element, if the array does not have enough data; `fill` will ignore it\n\n## Examples\n\n```rescript\nlet arr = Belt.Array.makeBy(5, (i) => i)\n\nBelt.Array.fill(arr, ~offset=2, ~len=2, 9)\n\narr == [0, 1, 9, 9, 4]\n\nBelt.Array.fill(arr, ~offset=7, ~len=2, 8)\n\narr == [0, 1, 9, 9, 4]" - ], - "signature": "let fill: (t<'a>, ~offset: int, ~len: int, 'a) => unit" - }, - { - "id": "Belt.Array.blit", - "kind": "value", - "name": "blit", - "docstrings": [ - "`blit(~src=v1, ~srcOffset=o1, ~dst=v2, ~dstOffset=o2, ~len)` copies `len` elements\nfrom array `v1`;starting at element number `o1`;to array `v2`, starting at element\nnumber `o2`. It works correctly even if `v1` and `v2` are the same array and the\nsource and destination chunks overlap.\n\n`offset` can be negative; `-1` means `len - 1`; if `len + offset` is still negative;it will be set as 0\n\nFor each of the examples;presume that `v1 == [10, 11, 12, 13, 14, 15, 16, 17]` and `v2 == [20, 21, 22, 23, 24, 25, 26, 27]`. The result shown is the content of the destination array.\n\n## Examples\n\n```rescript\nlet v1 = [10, 11, 12, 13, 14, 15, 16, 17]\nlet v2 = [20, 21, 22, 23, 24, 25, 26, 27]\n\nBelt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v2, ~dstOffset=2, ~len=3)\nv2 == [20, 21, 14, 15, 16, 25, 26, 27]\n\nBelt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v1, ~dstOffset=2, ~len=3)\nv1 == [10, 11, 14, 15, 16, 15, 16, 17]\n```" - ], - "signature": "let blit: (\n ~src: t<'a>,\n ~srcOffset: int,\n ~dst: t<'a>,\n ~dstOffset: int,\n ~len: int,\n) => unit" - }, - { - "id": "Belt.Array.blitUnsafe", - "kind": "value", - "name": "blitUnsafe", - "docstrings": ["Unsafe blit without bounds checking."], - "signature": "let blitUnsafe: (\n ~src: t<'a>,\n ~srcOffset: int,\n ~dst: t<'a>,\n ~dstOffset: int,\n ~len: int,\n) => unit" - }, - { - "id": "Belt.Array.forEachU", - "kind": "value", - "name": "forEachU", - "docstrings": [], - "signature": "let forEachU: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(xs, f)`\n\nCall `f` on each element of `xs` from the beginning to end. `f` returns `unit`\nso no new array is created. Use `forEach` when you are primarily concerned with\nrepetitively creating side effects.\n\n## Examples\n\n```rescript\nBelt.Array.forEach([\"a\", \"b\", \"c\"], x => Js.log(\"Item: \" ++ x))\n\n/*\n prints:\n Item: a\n Item: b\n Item: c\n*/\nlet total = ref(0)\n\nBelt.Array.forEach([1, 2, 3, 4], x => total := total.contents + x)\n\ntotal.contents == 1 + 2 + 3 + 4\n```" - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Belt.Array.mapU", - "kind": "value", - "name": "mapU", - "docstrings": [], - "signature": "let mapU: (t<'a>, 'a => 'b) => array<'b>" - }, - { - "id": "Belt.Array.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(xs, f)` returns a new array by calling `f` for each element of `xs` from\nthe beginning to end.\n\n## Examples\n\n```rescript\nBelt.Array.map([1, 2], (x) => x + 1) == [3, 4]\n```" - ], - "signature": "let map: (t<'a>, 'a => 'b) => array<'b>" - }, - { - "id": "Belt.Array.flatMapU", - "kind": "value", - "name": "flatMapU", - "docstrings": [], - "signature": "let flatMapU: (t<'a>, 'a => array<'b>) => array<'b>" - }, - { - "id": "Belt.Array.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "`flatMap(xs, f)` returns a new array by calling `f` for each element of `xs` from\nthe beginning to end, concatenating the results.\n\n## Examples\n\n```rescript\nBelt.Array.flatMap([1, 2], x => [x + 10, x + 20]) == [11, 21, 12, 22]\n```" - ], - "signature": "let flatMap: (t<'a>, 'a => array<'b>) => array<'b>" - }, - { - "id": "Belt.Array.getByU", - "kind": "value", - "name": "getByU", - "docstrings": [], - "signature": "let getByU: (t<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Belt.Array.getBy", - "kind": "value", - "name": "getBy", - "docstrings": [ - "`getBy(xs, p)` returns `Some(value)` for the first value in `xs` that satisifies\nthe predicate function `p`; returns `None` if no element satisifies the function.\n\n## Examples\n\n```rescript\nBelt.Array.getBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(4)\nBelt.Array.getBy([15, 13, 11], (x) => mod(x, 2) == 0) == None\n```" - ], - "signature": "let getBy: (t<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Belt.Array.getIndexByU", - "kind": "value", - "name": "getIndexByU", - "docstrings": [], - "signature": "let getIndexByU: (t<'a>, 'a => bool) => option" - }, - { - "id": "Belt.Array.getIndexBy", - "kind": "value", - "name": "getIndexBy", - "docstrings": [ - "`getIndexBy(xs, p)` returns `Some(index)` for the first value in `xs` that\nsatisifies the predicate function `p`; returns `None` if no element satisifies\nthe function.\n\n## Examples\n\n```rescript\nBelt.Array.getIndexBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(1)\nBelt.Array.getIndexBy([15, 13, 11], (x) => mod(x, 2) == 0) == None\n```" - ], - "signature": "let getIndexBy: (t<'a>, 'a => bool) => option" - }, - { - "id": "Belt.Array.keepU", - "kind": "value", - "name": "keepU", - "docstrings": [], - "signature": "let keepU: (t<'a>, 'a => bool) => t<'a>" - }, - { - "id": "Belt.Array.keep", - "kind": "value", - "name": "keep", - "docstrings": [ - "`keep(xs, p)` returns a new array that keep all elements satisfy `p`." - ], - "signature": "let keep: (t<'a>, 'a => bool) => t<'a>" - }, - { - "id": "Belt.Array.keepWithIndexU", - "kind": "value", - "name": "keepWithIndexU", - "docstrings": [], - "signature": "let keepWithIndexU: (t<'a>, ('a, int) => bool) => t<'a>" - }, - { - "id": "Belt.Array.keepWithIndex", - "kind": "value", - "name": "keepWithIndex", - "docstrings": [ - "`keepWithIndex(xs, p)` returns a new array that keep all elements satisfy `p`.\n\n## Examples\n\n```rescript\nBelt.Array.keepWithIndex([1, 2, 3], (_x, i) => i == 1) == [2]\n```" - ], - "signature": "let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a>" - }, - { - "id": "Belt.Array.keepMapU", - "kind": "value", - "name": "keepMapU", - "docstrings": [], - "signature": "let keepMapU: (t<'a>, 'a => option<'b>) => array<'b>" - }, - { - "id": "Belt.Array.keepMap", - "kind": "value", - "name": "keepMap", - "docstrings": [ - "`keepMap(xs, p)` returns a new array that keep all elements that return a non\nNone applied `p`.\n\n## Examples\n\n```rescript\nBelt.Array.keepMap([1, 2, 3], x =>\n if mod(x, 2) == 0 {\n Some(x)\n } else {\n None\n }\n)\n== [2]\n```" - ], - "signature": "let keepMap: (t<'a>, 'a => option<'b>) => array<'b>" - }, - { - "id": "Belt.Array.forEachWithIndexU", - "kind": "value", - "name": "forEachWithIndexU", - "docstrings": [], - "signature": "let forEachWithIndexU: (t<'a>, (int, 'a) => unit) => unit" - }, - { - "id": "Belt.Array.forEachWithIndex", - "kind": "value", - "name": "forEachWithIndex", - "docstrings": [ - "`forEachWithIndex(xs, f)` same as `Belt.Array.forEach`, except that `f` is\nsupplied two arguments: the index starting from 0 and the element from `xs`.\n\n## Examples\n\n```rescript\nBelt.Array.forEachWithIndex([\"a\", \"b\", \"c\"], (i, x) => Js.log(\"Item \" ++ Belt.Int.toString(i) ++ \" is \" ++ x))\n\n/*\n prints:\n Item 0 is a\n Item 1 is b\n Item 2 is cc\n*/\nlet total = ref(0)\n\nBelt.Array.forEachWithIndex([10, 11, 12, 13], (i, x) => total := total.contents + x + i)\n\ntotal.contents == 0 + 10 + 1 + 11 + 2 + 12 + 3 + 13\n```" - ], - "signature": "let forEachWithIndex: (t<'a>, (int, 'a) => unit) => unit" - }, - { - "id": "Belt.Array.mapWithIndexU", - "kind": "value", - "name": "mapWithIndexU", - "docstrings": [], - "signature": "let mapWithIndexU: (t<'a>, (int, 'a) => 'b) => array<'b>" - }, - { - "id": "Belt.Array.mapWithIndex", - "kind": "value", - "name": "mapWithIndex", - "docstrings": [ - "`mapWithIndex(xs, f)` applies `f` to each element of `xs`. Function `f` takes\ntwo arguments: the index starting from 0 and the element from `xs`.\n\n## Examples\n\n```rescript\nBelt.Array.mapWithIndex([1, 2, 3], (i, x) => i + x) == [0 + 1, 1 + 2, 2 + 3]\n```" - ], - "signature": "let mapWithIndex: (t<'a>, (int, 'a) => 'b) => array<'b>" - }, - { - "id": "Belt.Array.partitionU", - "kind": "value", - "name": "partitionU", - "docstrings": [], - "signature": "let partitionU: (t<'a>, 'a => bool) => (t<'a>, t<'a>)" - }, - { - "id": "Belt.Array.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(f, a)` split array into tuple of two arrays based on predicate `f`;\nfirst of tuple where predicate cause true, second where predicate cause false\n\n## Examples\n\n```rescript\nBelt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) == 0) == ([2, 4], [1, 3, 5])\n\nBelt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) != 0) == ([1, 3, 5], [2, 4])\n```" - ], - "signature": "let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>)" - }, - { - "id": "Belt.Array.reduceU", - "kind": "value", - "name": "reduceU", - "docstrings": [], - "signature": "let reduceU: (array<'b>, 'a, ('a, 'b) => 'a) => 'a" - }, - { - "id": "Belt.Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(xs, init, f)` applies `f` to each element of `xs` from beginning to end.\nFunction `f` has two parameters: the item from the list and an “accumulator”;\nwhich starts with a value of `init`. `reduce` returns the final value of the\naccumulator.\n\n## Examples\n\n```rescript\nBelt.Array.reduce([2, 3, 4], 1, (a, b) => a + b) == 10\n\nBelt.Array.reduce([\"a\", \"b\", \"c\", \"d\"], \"\", (a, b) => a ++ b) == \"abcd\"\n```" - ], - "signature": "let reduce: (array<'b>, 'a, ('a, 'b) => 'a) => 'a" - }, - { - "id": "Belt.Array.reduceReverseU", - "kind": "value", - "name": "reduceReverseU", - "docstrings": [], - "signature": "let reduceReverseU: (array<'b>, 'a, ('a, 'b) => 'a) => 'a" - }, - { - "id": "Belt.Array.reduceReverse", - "kind": "value", - "name": "reduceReverse", - "docstrings": [ - "`reduceReverse(xs, init, f)` works like `Belt.Array.reduce` except that\nfunction `f` is applied to each item of `xs` from the last back to the first.\n\n## Examples\n\n```rescript\nBelt.Array.reduceReverse([\"a\", \"b\", \"c\", \"d\"], \"\", (a, b) => a ++ b) == \"dcba\"\n```" - ], - "signature": "let reduceReverse: (array<'b>, 'a, ('a, 'b) => 'a) => 'a" - }, - { - "id": "Belt.Array.reduceReverse2U", - "kind": "value", - "name": "reduceReverse2U", - "docstrings": [], - "signature": "let reduceReverse2U: (t<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c" - }, - { - "id": "Belt.Array.reduceReverse2", - "kind": "value", - "name": "reduceReverse2", - "docstrings": [ - "`reduceReverse2(xs, ys, init, f)` reduces two arrays xs and ys;taking items\nstarting at `min(length(xs), length(ys))` down to and including zero.\n\n## Examples\n\n```rescript\nBelt.Array.reduceReverse2([1, 2, 3], [1, 2], 0, (acc, x, y) => acc + x + y) == 6\n```" - ], - "signature": "let reduceReverse2: (t<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c" - }, - { - "id": "Belt.Array.reduceWithIndexU", - "kind": "value", - "name": "reduceWithIndexU", - "docstrings": [], - "signature": "let reduceWithIndexU: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b" - }, - { - "id": "Belt.Array.reduceWithIndex", - "kind": "value", - "name": "reduceWithIndex", - "docstrings": [ - "Applies `f` to each element of `xs` from beginning to end. Function `f` has\nthree parameters: the item from the array and an “accumulator”, which starts \nwith a value of `init` and the index of each element. `reduceWithIndex` returns\nthe final value of the accumulator.\n\n## Examples\n\n```rescript\nBelt.Array.reduceWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i) == 16\n```" - ], - "signature": "let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b" - }, - { - "id": "Belt.Array.joinWithU", - "kind": "value", - "name": "joinWithU", - "docstrings": [], - "signature": "let joinWithU: (t<'a>, string, 'a => string) => string" - }, - { - "id": "Belt.Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [ - "`joinWith(xs, sep, toString)`\n\nConcatenates all the elements of `xs` converted to string with `toString`, each\nseparated by `sep`, the string given as the second argument, into a single string.\nIf the array has only one element, then that element will be returned without \nusing the separator. If the array is empty, the empty string will be returned.\n\n## Examples\n\n```rescript\nBelt.Array.joinWith([0, 1], \", \", Js.Int.toString) == \"0, 1\"\nBelt.Array.joinWith([], \" \", Js.Int.toString) == \"\"\nBelt.Array.joinWith([1], \" \", Js.Int.toString) == \"1\"\n```" - ], - "signature": "let joinWith: (t<'a>, string, 'a => string) => string" - }, - { - "id": "Belt.Array.someU", - "kind": "value", - "name": "someU", - "docstrings": [], - "signature": "let someU: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.Array.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(xs, p)` returns true if at least one of the elements in `xs` satifies `p`;\nwhere `p` is a predicate: a function taking an element and returning a `bool`.\n\n## Examples\n\n```rescript\nBelt.Array.some([2, 3, 4], (x) => mod(x, 2) == 1) == true\n\nBelt.Array.some([(-1), (-3), (-5)], (x) => x > 0) == false\n```" - ], - "signature": "let some: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.Array.everyU", - "kind": "value", - "name": "everyU", - "docstrings": [], - "signature": "let everyU: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.Array.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(xs, p)` returns `true` if all elements satisfy `p`; where `p` is a\npredicate: a function taking an element and returning a `bool`.\n\n## Examples\n\n```rescript\nBelt.Array.every([1, 3, 5], (x) => mod(x, 2) == 1) == true\n\nBelt.Array.every([1, (-3), 5], (x) => x > 0) == false\n```" - ], - "signature": "let every: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Belt.Array.every2U", - "kind": "value", - "name": "every2U", - "docstrings": [], - "signature": "let every2U: (t<'a>, array<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Array.every2", - "kind": "value", - "name": "every2", - "docstrings": [ - "`every2(xs, ys, p)` returns true if `p(xi, yi)` is true for all pairs of\nelements up to the shorter length (i.e. `min(length(xs), length(ys))`)\n\n## Examples\n\n```rescript\nBelt.Array.every2([1, 2, 3], [0, 1], (a, b) => a > b) == true\n\nBelt.Array.every2([], [1], (x, y) => x > y) == true\n\nBelt.Array.every2([2, 3], [1], (x, y) => x > y) == true\n\nBelt.Array.every2([0, 1], [5, 0], (x, y) => x > y) == false\n```" - ], - "signature": "let every2: (t<'a>, array<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Array.some2U", - "kind": "value", - "name": "some2U", - "docstrings": [], - "signature": "let some2U: (t<'a>, array<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Array.some2", - "kind": "value", - "name": "some2", - "docstrings": [ - "`some2(xs, ys, p)` returns true if `p(xi, yi)` is true for any pair of elements\nup to the shorter length (i.e. `min(length(xs), length(ys))`)\n\n## Examples\n\n```rescript\nBelt.Array.some2([0, 2], [1, 0, 3], (a, b) => a > b) == true\n\nBelt.Array.some2([], [1], (x, y) => x > y) == false\n\nBelt.Array.some2([2, 3], [1, 4], (x, y) => x > y) == true\n```" - ], - "signature": "let some2: (t<'a>, array<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Belt.Array.cmpU", - "kind": "value", - "name": "cmpU", - "docstrings": [], - "signature": "let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.Array.cmp", - "kind": "value", - "name": "cmp", - "docstrings": [ - "`cmp(xs, ys, f)` compared by length if `length(xs) != length(ys)`; returning `-1`\nif `length(xs) < length(ys)` or 1 if `length(xs) > length(ys)`. Otherwise\ncompare one by one `f(x, y)`. `f` returns a negative number if `x` is “less than” `y`\nzero if `x` is “equal to” `y` a positive number if `x` is “greater than”\n`y`. The comparison returns the first non-zero result of `f`; or zero if `f`\nreturns zero for all `x` and `y`.\n\n## Examples\n\n```rescript\nBelt.Array.cmp([1, 3, 5], [1, 4, 2], (a, b) => compare(a, b)) == -1\n\nBelt.Array.cmp([1, 3, 5], [1, 2, 3], (a, b) => compare(a, b)) == 1\n\nBelt.Array.cmp([1, 3, 5], [1, 3, 5], (a, b) => compare(a, b)) == 0\n```" - ], - "signature": "let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int" - }, - { - "id": "Belt.Array.eqU", - "kind": "value", - "name": "eqU", - "docstrings": [], - "signature": "let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.Array.eq", - "kind": "value", - "name": "eq", - "docstrings": [ - "`eq(xs, ys)` return `false` if length is not the same otherwise compare items\none by one using `f(xi, yi)`; and return true if all results are true false otherwise\n\n## Examples\n\n```rescript\nBelt.Array.eq([1, 2, 3], [(-1), (-2), (-3)], (a, b) => abs(a) == abs(b)) == true\n```" - ], - "signature": "let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Belt.Array.truncateToLengthUnsafe", - "kind": "value", - "name": "truncateToLengthUnsafe", - "docstrings": [ - "Unsafe `truncateToLengthUnsafe(xs, n)` sets length of array `xs` to `n`. If `n`\nis greater than the length of `xs`; the extra elements are set to `Js.Null_undefined.null`.\nIf `n` is less than zero; raises a `RangeError`.\n\n## Examples\n\n```rescript\nlet arr = [\"ant\", \"bee\", \"cat\", \"dog\", \"elk\"]\n\nBelt.Array.truncateToLengthUnsafe(arr, 3)\n\narr == [\"ant\", \"bee\", \"cat\"]\n```" - ], - "signature": "let truncateToLengthUnsafe: (t<'a>, int) => unit" - }, - { - "id": "Belt.Array.initU", - "kind": "value", - "name": "initU", - "docstrings": [], - "signature": "let initU: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.Array.init", - "kind": "value", - "name": "init", - "docstrings": [], - "signature": "let init: (int, int => 'a) => t<'a>" - }, - { - "id": "Belt.Array.push", - "kind": "value", - "name": "push", - "docstrings": [ - "`arr->push(item)` pushes an element `item` into an array `arr`." - ], - "signature": "let push: (t<'a>, 'a) => unit" - } - ] - }, - "belt/id": { - "id": "Belt.Id", - "name": "Id", - "docstrings": [ - "[`Belt.Id`]()\n\n Provide utilities to create identified comparators or hashes for\n data structures used below.\n\n It create a unique identifier per module of\n functions so that different data structures with slightly different\n comparison functions won't mix", - "[`Belt.Id`]()\n\nProvide utiliites to create identified comparators or hashes for\ndata structures used below.\n\nIt create a unique identifer per module of functions so that different data structures with slightly different\ncomparison functions won't mix." - ], - "items": [ - { - "id": "Belt.Id.hash", - "kind": "type", - "name": "hash", - "docstrings": [ - "`('a, 'id) hash`\n\nIts runtime represenation is a `hash` function, but signed with a\ntype parameter, so that different hash functions type mismatch" - ], - "signature": "type hash<'a, 'id>" - }, - { - "id": "Belt.Id.eq", - "kind": "type", - "name": "eq", - "docstrings": [ - "`('a, 'id) eq`\n\nIts runtime represenation is an `eq` function, but signed with a\ntype parameter, so that different hash functions type mismatch" - ], - "signature": "type eq<'a, 'id>" - }, - { - "id": "Belt.Id.cmp", - "kind": "type", - "name": "cmp", - "docstrings": [ - "`('a,'id) cmp`\n\nIts runtime representation is a `cmp` function, but signed with a\ntype parameter, so that different hash functions type mismatch" - ], - "signature": "type cmp<'a, 'id>" - }, - { - "id": "Belt.Id.comparable", - "kind": "type", - "name": "comparable", - "docstrings": [ - "`('key, 'id) cmparable` is a module of functions, here it only includes `cmp`.\n\nUnlike normal functions, when created, it comes with a unique identity (guaranteed\nby the type system).\n\nIt can be created using function [`comparableU`]() or [`comparable`]().\n\nThe idea of a unique identity when created is that it makes sure two sets would type\nmismatch if they use different comparison function" - ], - "signature": "type comparable<'key, 'id> = module(Comparable\n with type identity = 'id\n with type t = 'key)" - }, - { - "id": "Belt.Id.comparableU", - "kind": "value", - "name": "comparableU", - "docstrings": [], - "signature": "let comparableU: (\n ~cmp: ('a, 'a) => int,\n) => module(Comparable with type t = 'a)" - }, - { - "id": "Belt.Id.comparable", - "kind": "value", - "name": "comparable", - "docstrings": [ - "## Examples\n\n```rescript\nmodule C = (\n val Belt.Id.comparable ~cmp:(compare : int -> int -> int)\n)\nlet m = Belt.Set.make(module C)\n```\nNote that the name of C can not be ignored" - ], - "signature": "let comparable: (\n ~cmp: ('a, 'a) => int,\n) => module(Comparable with type t = 'a)" - }, - { - "id": "Belt.Id.hashable", - "kind": "type", - "name": "hashable", - "docstrings": [ - "`('key, 'id) hashable` is a module of functions, here it only includes `hash`, `eq`.\n\nUnlike normal functions, when created, it comes with a unique identity (guaranteed\nby the type system).\n\nIt can be created using function [`hashableU`]() or [`hashable`]().\n\nThe idea of a unique identity when created is that it makes sure two hash sets would type\nmismatch if they use different comparison function" - ], - "signature": "type hashable<'key, 'id> = module(Hashable\n with type identity = 'id\n with type t = 'key)" - }, - { - "id": "Belt.Id.hashableU", - "kind": "value", - "name": "hashableU", - "docstrings": [], - "signature": "let hashableU: (\n ~hash: 'a => int,\n ~eq: ('a, 'a) => bool,\n) => module(Hashable with type t = 'a)" - }, - { - "id": "Belt.Id.hashable", - "kind": "value", - "name": "hashable", - "docstrings": [], - "signature": "let hashable: (\n ~hash: 'a => int,\n ~eq: ('a, 'a) => bool,\n) => module(Hashable with type t = 'a)" - }, - { - "id": "Belt.Id.getHashInternal", - "kind": "value", - "name": "getHashInternal", - "docstrings": [], - "signature": "let getHashInternal: hash<'a, 'id> => 'a => int" - }, - { - "id": "Belt.Id.getEqInternal", - "kind": "value", - "name": "getEqInternal", - "docstrings": [], - "signature": "let getEqInternal: eq<'a, 'id> => ('a, 'a) => bool" - }, - { - "id": "Belt.Id.getCmpInternal", - "kind": "value", - "name": "getCmpInternal", - "docstrings": [], - "signature": "let getCmpInternal: cmp<'a, 'id> => ('a, 'a) => int" - } - ] - } -} diff --git a/data/api/v11.0.0/core.json b/data/api/v11.0.0/core.json deleted file mode 100644 index fc8e00078..000000000 --- a/data/api/v11.0.0/core.json +++ /dev/null @@ -1,9894 +0,0 @@ -{ - "core": { - "id": "Core", - "name": "Core", - "docstrings": [], - "items": [ - { - "id": "Core.timeoutId", - "kind": "type", - "name": "timeoutId", - "docstrings": [ - "An `id` representing a timeout started via `setTimeout`.\n\nSee [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) on MDN." - ], - "signature": "type timeoutId = Js.Global.timeoutId" - }, - { - "id": "Core.setTimeout", - "kind": "value", - "name": "setTimeout", - "docstrings": [ - "`setTimeout(callback, durationInMilliseconds)` starts a timer that will execute `callback` after `durationInMilliseconds`.\n\nSee [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) on MDN.\n\n## Examples\n```rescript\n// Log to the console after 2 seconds (2000 milliseconds).\nlet timeoutId = setTimeout(() => {\n Console.log(\"This prints in 2 seconds.\")\n}, 2000)\n```" - ], - "signature": "let setTimeout: (unit => unit, int) => timeoutId" - }, - { - "id": "Core.setTimeoutFloat", - "kind": "value", - "name": "setTimeoutFloat", - "docstrings": [ - "`setTimeoutFloat(callback, durationInMilliseconds)` starts a timer that will execute `callback` after `durationInMilliseconds`.\n\nThe same as `setTimeout`, but allows you to pass a `float` instead of an `int` for the duration.\n\nSee [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) on MDN.\n\n## Examples\n```rescript\n// Log to the console after 2 seconds (2000 milliseconds).\nlet timeoutId = setTimeoutFloat(() => {\n Console.log(\"This prints in 2 seconds.\")\n}, 2000.)\n```" - ], - "signature": "let setTimeoutFloat: (unit => unit, float) => timeoutId" - }, - { - "id": "Core.clearTimeout", - "kind": "value", - "name": "clearTimeout", - "docstrings": [ - "`clearTimeout(timeoutId)` clears a scheduled timeout if it hasn't already executed.\n\nSee [`clearTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/clearTimeout) on MDN.\n\n## Examples\n```rescript\nlet timeoutId = setTimeout(() => {\n Console.log(\"This prints in 2 seconds.\")\n}, 2000)\n\n// Clearing the timeout right away, before 2 seconds has passed, means that the above callback logging to the console will never run.\nclearTimeout(timeoutId)\n```" - ], - "signature": "let clearTimeout: timeoutId => unit" - }, - { - "id": "Core.intervalId", - "kind": "type", - "name": "intervalId", - "docstrings": [ - "An `id` representing an interval started via `setInterval`.\n\nSee [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/setInterval) on MDN." - ], - "signature": "type intervalId = Js.Global.intervalId" - }, - { - "id": "Core.setInterval", - "kind": "value", - "name": "setInterval", - "docstrings": [ - "`setInterval(callback, intervalInMilliseconds)` starts an interval that will execute `callback` every `durationInMilliseconds` milliseconds.\n\nSee [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/setInterval) on MDN.\n\n## Examples\n```rescript\n// Log to the console ever 2 seconds (2000 milliseconds).\nlet intervalId = setInterval(() => {\n Console.log(\"This prints every 2 seconds.\")\n}, 2000)\n```" - ], - "signature": "let setInterval: (unit => unit, int) => intervalId" - }, - { - "id": "Core.setIntervalFloat", - "kind": "value", - "name": "setIntervalFloat", - "docstrings": [ - "`setIntervalFloat(callback, intervalInMilliseconds)` starts an interval that will execute `callback` every `durationInMilliseconds` milliseconds.\n\nThe same as `setInterval`, but allows you to pass a `float` instead of an `int` for the duration.\n\nSee [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/setInterval) on MDN.\n\n## Examples\n```rescript\n// Log to the console ever 2 seconds (2000 milliseconds).\nlet intervalId = setIntervalFloat(() => {\n Console.log(\"This prints every 2 seconds.\")\n}, 2000.)\n```" - ], - "signature": "let setIntervalFloat: (unit => unit, float) => intervalId" - }, - { - "id": "Core.clearInterval", - "kind": "value", - "name": "clearInterval", - "docstrings": [ - "`clearInterval(intervalId)` clears a scheduled interval.\n\nSee [`clearInterval`](https://developer.mozilla.org/en-US/docs/Web/API/clearInterval) on MDN.\n\n## Examples\n```rescript\nlet intervalId = setInterval(() => {\n Console.log(\"This prints in 2 seconds.\")\n}, 2000)\n\n// Stop the interval after 10 seconds\nlet timeoutId = setTimeout(() => {\n clearInterval(intervalId)\n}, 10000)\n```" - ], - "signature": "let clearInterval: intervalId => unit" - }, - { - "id": "Core.encodeURI", - "kind": "value", - "name": "encodeURI", - "docstrings": [ - "Encodes a URI by replacing characters in the provided string that aren't valid in a URL.\n\nThis is intended to operate on full URIs, so it encodes fewer characters than what `encodeURIComponent` does.\nIf you're looking to encode just parts of a URI, like a query parameter, prefer `encodeURIComponent`.\n\nSee [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) on MDN.\n\n## Examples\n```rescript\nConsole.log(encodeURI(\"https://rescript-lang.org?array=[someValue]\"))\n// Logs \"https://rescript-lang.org?array=%5BsomeValue%5D\" to the console.\n```" - ], - "signature": "let encodeURI: string => string" - }, - { - "id": "Core.decodeURI", - "kind": "value", - "name": "decodeURI", - "docstrings": [ - "Decodes a previously encoded URI back to a regular string.\n\nThis is intended to operate on full URIs, so it decodes fewer characters than what `decodeURIComponent` does.\nIf you're looking to decode just parts of a URI, like a query parameter, prefer `decodeURIComponent`.\n\nSee [`decodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI) on MDN.\n\n## Examples\n```rescript\nConsole.log(decodeURI(\"https://rescript-lang.org?array=%5BsomeValue%5D\"))\n// Logs \"https://rescript-lang.org?array=[someValue]\" to the console.\n```" - ], - "signature": "let decodeURI: string => string" - }, - { - "id": "Core.encodeURIComponent", - "kind": "value", - "name": "encodeURIComponent", - "docstrings": [ - "Encodes a string so it can be used as part of a URI.\n\nSee [`encodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) on MDN.\n\n## Examples\n```rescript\nConsole.log(encodeURIComponent(\"array=[someValue]\"))\n// Logs \"array%3D%5BsomeValue%5D\" to the console.\n```" - ], - "signature": "let encodeURIComponent: string => string" - }, - { - "id": "Core.decodeURIComponent", - "kind": "value", - "name": "decodeURIComponent", - "docstrings": [ - "Decodes a previously URI encoded string back to its original form.\n\nSee [`decodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) on MDN.\n\n## Examples\n```rescript\nConsole.log(decodeURIComponent(\"array%3D%5BsomeValue%5D\"))\n// Logs \"array=[someValue]\" to the console.\n```" - ], - "signature": "let decodeURIComponent: string => string" - }, - { - "id": "Core.window", - "kind": "value", - "name": "window", - "docstrings": [], - "signature": "let window: Dom.window" - }, - { - "id": "Core.document", - "kind": "value", - "name": "document", - "docstrings": [], - "signature": "let document: Dom.document" - }, - { - "id": "Core.globalThis", - "kind": "value", - "name": "globalThis", - "docstrings": [], - "signature": "let globalThis: {..}" - }, - { - "id": "Core.null", - "kind": "value", - "name": "null", - "docstrings": [], - "signature": "let null: Core__Nullable.t<'a>" - }, - { - "id": "Core.undefined", - "kind": "value", - "name": "undefined", - "docstrings": [], - "signature": "let undefined: Core__Nullable.t<'a>" - }, - { - "id": "Core.typeof", - "kind": "value", - "name": "typeof", - "docstrings": [], - "signature": "let typeof: 'a => Core__Type.t" - }, - { - "id": "Core.import", - "kind": "value", - "name": "import", - "docstrings": [ - "`import(value)` dynamically import a value or function from a ReScript\nmodule. The import call will return a `promise`, resolving to the dynamically loaded\nvalue.\n\n## Examples\n\n`Core__Array.res` file:\n\n```rescript\n@send external indexOf: (array<'a>, 'a) => int = \"indexOf\"\n\nlet indexOfOpt = (arr, item) =>\n switch arr->indexOf(item) {\n | -1 => None\n | index => Some(index)\n }\n```\nIn other file you can import the `indexOfOpt` value defined in `Core__Array.res`\n\n```rescript\nlet main = async () => {\n let indexOfOpt = await import(Core__Array.indexOfOpt)\n let index = indexOfOpt([1, 2], 2)\n Console.log(index)\n}\n```\n\nCompiles to:\n\n```javascript\nasync function main() {\n var add = await import(\"./Core__Array.mjs\").then(function(m) {\n return m.indexOfOpt;\n });\n var index = indexOfOpt([1, 2], 2);\n console.log(index);\n}\n```" - ], - "signature": "let import: 'a => promise<'a>" - }, - { - "id": "Core.null", - "kind": "type", - "name": "null", - "docstrings": [], - "signature": "type null<'a> = Js.null<'a>" - }, - { - "id": "Core.undefined", - "kind": "type", - "name": "undefined", - "docstrings": [], - "signature": "type undefined<'a> = Js.undefined<'a>" - }, - { - "id": "Core.nullable", - "kind": "type", - "name": "nullable", - "docstrings": [], - "signature": "type nullable<'a> = Js.nullable<'a>" - }, - { - "id": "Core.panic", - "kind": "value", - "name": "panic", - "docstrings": [], - "signature": "let panic: string => 'a" - } - ] - }, - "core/intl/numberformat/grouping": { - "id": "Core.Intl.NumberFormat.Grouping", - "name": "Grouping", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.NumberFormat.Grouping.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.NumberFormat.Grouping.parsed", - "kind": "type", - "name": "parsed", - "docstrings": [], - "signature": "type parsed = [#always | #auto | #bool(bool) | #min2]" - }, - { - "id": "Core.Intl.NumberFormat.Grouping.fromBool", - "kind": "value", - "name": "fromBool", - "docstrings": [], - "signature": "let fromBool: bool => t" - }, - { - "id": "Core.Intl.NumberFormat.Grouping.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [], - "signature": "let fromString: [#always | #auto | #min2] => t" - }, - { - "id": "Core.Intl.NumberFormat.Grouping.parseJsValue", - "kind": "value", - "name": "parseJsValue", - "docstrings": [], - "signature": "let parseJsValue: 'a => option<[> #always | #auto | #bool(bool) | #min2]>" - } - ] - }, - "core/intl/segments": { - "id": "Core.Intl.Segments", - "name": "Segments", - "docstrings": [ - "A Segments instance is an object that represents the segments of a specific string, subject to the locale and options of its constructing Intl.Segmenter instance.\nhttps://tc39.es/ecma402/#sec-segments-objects" - ], - "items": [ - { - "id": "Core.Intl.Segments.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.Segments.segmentData", - "kind": "type", - "name": "segmentData", - "docstrings": [], - "signature": "type segmentData = {\n segment: string,\n index: int,\n isWordLike: option,\n input: string,\n}" - }, - { - "id": "Core.Intl.Segments.containing", - "kind": "value", - "name": "containing", - "docstrings": [], - "signature": "let containing: t => segmentData" - }, - { - "id": "Core.Intl.Segments.containingWithIndex", - "kind": "value", - "name": "containingWithIndex", - "docstrings": [], - "signature": "let containingWithIndex: (t, int) => segmentData" - } - ] - }, - "core/intl/segmenter": { - "id": "Core.Intl.Segmenter", - "name": "Segmenter", - "docstrings": ["Not supported in Firefox"], - "items": [ - { - "id": "Core.Intl.Segmenter.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.Segmenter.granularity", - "kind": "type", - "name": "granularity", - "docstrings": [], - "signature": "type granularity = [#grapheme | #sentence | #word]" - }, - { - "id": "Core.Intl.Segmenter.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n localeMatcher?: Core__Intl__Common.localeMatcher,\n granularity?: granularity,\n}" - }, - { - "id": "Core.Intl.Segmenter.pluralCategories", - "kind": "type", - "name": "pluralCategories", - "docstrings": [], - "signature": "type pluralCategories = [\n | #few\n | #many\n | #one\n | #other\n | #two\n | #zero\n]" - }, - { - "id": "Core.Intl.Segmenter.resolvedOptions", - "kind": "type", - "name": "resolvedOptions", - "docstrings": [], - "signature": "type resolvedOptions = {\n locale: string,\n granularity: granularity,\n}" - }, - { - "id": "Core.Intl.Segmenter.supportedLocalesOptions", - "kind": "type", - "name": "supportedLocalesOptions", - "docstrings": [], - "signature": "type supportedLocalesOptions = {\n localeMatcher: Core__Intl__Common.localeMatcher,\n}" - }, - { - "id": "Core.Intl.Segmenter.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~locales: array=?, ~options: options=?) => t" - }, - { - "id": "Core.Intl.Segmenter.supportedLocalesOf", - "kind": "value", - "name": "supportedLocalesOf", - "docstrings": [], - "signature": "let supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t" - }, - { - "id": "Core.Intl.Segmenter.resolvedOptions", - "kind": "value", - "name": "resolvedOptions", - "docstrings": [], - "signature": "let resolvedOptions: t => resolvedOptions" - }, - { - "id": "Core.Intl.Segmenter.segment", - "kind": "value", - "name": "segment", - "docstrings": [], - "signature": "let segment: (t, string) => Core__Intl__Segments.t" - } - ] - }, - "core/intl/relativetimeformat": { - "id": "Core.Intl.RelativeTimeFormat", - "name": "RelativeTimeFormat", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.RelativeTimeFormat.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.RelativeTimeFormat.numeric", - "kind": "type", - "name": "numeric", - "docstrings": [], - "signature": "type numeric = [#always | #auto]" - }, - { - "id": "Core.Intl.RelativeTimeFormat.style", - "kind": "type", - "name": "style", - "docstrings": [], - "signature": "type style = [#long | #narrow | #short]" - }, - { - "id": "Core.Intl.RelativeTimeFormat.timeUnit", - "kind": "type", - "name": "timeUnit", - "docstrings": [], - "signature": "type timeUnit = [\n | #day\n | #hour\n | #minute\n | #month\n | #quarter\n | #second\n | #week\n | #year\n]" - }, - { - "id": "Core.Intl.RelativeTimeFormat.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n localeMatcher?: Core__Intl__Common.localeMatcher,\n numeric?: numeric,\n style?: style,\n}" - }, - { - "id": "Core.Intl.RelativeTimeFormat.supportedLocalesOptions", - "kind": "type", - "name": "supportedLocalesOptions", - "docstrings": [], - "signature": "type supportedLocalesOptions = {\n localeMatcher: Core__Intl__Common.localeMatcher,\n}" - }, - { - "id": "Core.Intl.RelativeTimeFormat.resolvedOptions", - "kind": "type", - "name": "resolvedOptions", - "docstrings": [], - "signature": "type resolvedOptions = {\n locale: string,\n numeric: numeric,\n style: style,\n numberingSystem: string,\n}" - }, - { - "id": "Core.Intl.RelativeTimeFormat.relativeTimePartComponent", - "kind": "type", - "name": "relativeTimePartComponent", - "docstrings": [], - "signature": "type relativeTimePartComponent = [#integer | #literal]" - }, - { - "id": "Core.Intl.RelativeTimeFormat.relativeTimePart", - "kind": "type", - "name": "relativeTimePart", - "docstrings": [], - "signature": "type relativeTimePart = {\n \\\"type\": relativeTimePartComponent,\n value: string,\n unit?: timeUnit,\n}" - }, - { - "id": "Core.Intl.RelativeTimeFormat.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~locales: array=?, ~options: options=?) => t" - }, - { - "id": "Core.Intl.RelativeTimeFormat.supportedLocalesOf", - "kind": "value", - "name": "supportedLocalesOf", - "docstrings": [], - "signature": "let supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t" - }, - { - "id": "Core.Intl.RelativeTimeFormat.resolvedOptions", - "kind": "value", - "name": "resolvedOptions", - "docstrings": [], - "signature": "let resolvedOptions: t => resolvedOptions" - }, - { - "id": "Core.Intl.RelativeTimeFormat.format", - "kind": "value", - "name": "format", - "docstrings": [], - "signature": "let format: (t, int, timeUnit) => string" - }, - { - "id": "Core.Intl.RelativeTimeFormat.formatToParts", - "kind": "value", - "name": "formatToParts", - "docstrings": [], - "signature": "let formatToParts: (t, int, timeUnit) => array" - } - ] - }, - "core/intl/pluralrules": { - "id": "Core.Intl.PluralRules", - "name": "PluralRules", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.PluralRules.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.PluralRules.localeType", - "kind": "type", - "name": "localeType", - "docstrings": [], - "signature": "type localeType = [#cardinal | #ordinal]" - }, - { - "id": "Core.Intl.PluralRules.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n localeMatcher?: Core__Intl__Common.localeMatcher,\n \\\"type\"?: localeType,\n minimumIntegerDigits?: Core__Intl__Common.oneTo21,\n minimumFractionDigits?: Core__Intl__Common.zeroTo20,\n maximumFractionDigits?: Core__Intl__Common.zeroTo20,\n minimumSignificantDigits?: Core__Intl__Common.oneTo21,\n maximumSignificantDigits?: Core__Intl__Common.oneTo21,\n}" - }, - { - "id": "Core.Intl.PluralRules.pluralCategories", - "kind": "type", - "name": "pluralCategories", - "docstrings": [], - "signature": "type pluralCategories = [\n | #few\n | #many\n | #one\n | #other\n | #two\n | #zero\n]" - }, - { - "id": "Core.Intl.PluralRules.resolvedOptions", - "kind": "type", - "name": "resolvedOptions", - "docstrings": [], - "signature": "type resolvedOptions = {\n locale: string,\n pluralCategories: array,\n \\\"type\": localeType,\n minimumIntegerDigits?: Core__Intl__Common.oneTo21,\n minimumFractionDigits?: Core__Intl__Common.zeroTo20,\n maximumFractionDigits?: Core__Intl__Common.zeroTo20,\n minimumSignificantDigits?: Core__Intl__Common.oneTo21,\n maximumSignificantDigits?: Core__Intl__Common.oneTo21,\n}" - }, - { - "id": "Core.Intl.PluralRules.supportedLocalesOptions", - "kind": "type", - "name": "supportedLocalesOptions", - "docstrings": [], - "signature": "type supportedLocalesOptions = {\n localeMatcher: Core__Intl__Common.localeMatcher,\n}" - }, - { - "id": "Core.Intl.PluralRules.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~locales: array=?, ~options: options=?) => t" - }, - { - "id": "Core.Intl.PluralRules.supportedLocalesOf", - "kind": "value", - "name": "supportedLocalesOf", - "docstrings": [], - "signature": "let supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t" - }, - { - "id": "Core.Intl.PluralRules.resolvedOptions", - "kind": "value", - "name": "resolvedOptions", - "docstrings": [], - "signature": "let resolvedOptions: t => resolvedOptions" - }, - { - "id": "Core.Intl.PluralRules.rule", - "kind": "type", - "name": "rule", - "docstrings": [], - "signature": "type rule = [#few | #many | #one | #other | #two | #zero]" - }, - { - "id": "Core.Intl.PluralRules.select", - "kind": "value", - "name": "select", - "docstrings": [], - "signature": "let select: (t, float) => rule" - }, - { - "id": "Core.Intl.PluralRules.selectInt", - "kind": "value", - "name": "selectInt", - "docstrings": [], - "signature": "let selectInt: (t, int) => rule" - }, - { - "id": "Core.Intl.PluralRules.selectBigInt", - "kind": "value", - "name": "selectBigInt", - "docstrings": [], - "signature": "let selectBigInt: (t, bigint) => rule" - }, - { - "id": "Core.Intl.PluralRules.selectRange", - "kind": "value", - "name": "selectRange", - "docstrings": [], - "signature": "let selectRange: (t, ~start: float, ~end: float) => rule" - }, - { - "id": "Core.Intl.PluralRules.selectRangeInt", - "kind": "value", - "name": "selectRangeInt", - "docstrings": [], - "signature": "let selectRangeInt: (t, ~start: int, ~end: int) => rule" - }, - { - "id": "Core.Intl.PluralRules.selectRangeBigInt", - "kind": "value", - "name": "selectRangeBigInt", - "docstrings": [], - "signature": "let selectRangeBigInt: (t, ~start: bigint, ~end: bigint) => rule" - } - ] - }, - "core/intl/numberformat": { - "id": "Core.Intl.NumberFormat", - "name": "NumberFormat", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.NumberFormat.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.NumberFormat.currency", - "kind": "type", - "name": "currency", - "docstrings": ["An ISO 4217 currency code. e.g. USD, EUR, CNY"], - "signature": "type currency = string" - }, - { - "id": "Core.Intl.NumberFormat.currencyDisplay", - "kind": "type", - "name": "currencyDisplay", - "docstrings": [], - "signature": "type currencyDisplay = [\n | #code\n | #name\n | #narrowSymbol\n | #symbol\n]" - }, - { - "id": "Core.Intl.NumberFormat.currencySign", - "kind": "type", - "name": "currencySign", - "docstrings": [], - "signature": "type currencySign = [#accounting | #standard]" - }, - { - "id": "Core.Intl.NumberFormat.notation", - "kind": "type", - "name": "notation", - "docstrings": [], - "signature": "type notation = [\n | #compact\n | #engineering\n | #scientific\n | #standard\n]" - }, - { - "id": "Core.Intl.NumberFormat.compactDisplay", - "kind": "type", - "name": "compactDisplay", - "docstrings": ["Used only when notation is #compact"], - "signature": "type compactDisplay = [#long | #short]" - }, - { - "id": "Core.Intl.NumberFormat.signDisplay", - "kind": "type", - "name": "signDisplay", - "docstrings": [], - "signature": "type signDisplay = [\n | #always\n | #auto\n | #exceptZero\n | #negative\n | #never\n]" - }, - { - "id": "Core.Intl.NumberFormat.style", - "kind": "type", - "name": "style", - "docstrings": [], - "signature": "type style = [#currency | #decimal | #percent | #unit]" - }, - { - "id": "Core.Intl.NumberFormat.unitSystem", - "kind": "type", - "name": "unitSystem", - "docstrings": [ - "Defined in https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-issanctionedsimpleunitidentifier\nOnly used when style is #unit" - ], - "signature": "type unitSystem = string" - }, - { - "id": "Core.Intl.NumberFormat.unitDisplay", - "kind": "type", - "name": "unitDisplay", - "docstrings": ["Only used when style is #unit"], - "signature": "type unitDisplay = [#long | #narrow | #short]" - }, - { - "id": "Core.Intl.NumberFormat.rounding", - "kind": "type", - "name": "rounding", - "docstrings": [], - "signature": "type rounding = [\n | #ceil\n | #expand\n | #floor\n | #halfCeil\n | #halfEven\n | #halfExpand\n | #halfFloor\n | #halfTrunc\n | #trunc\n]" - }, - { - "id": "Core.Intl.NumberFormat.roundingPriority", - "kind": "type", - "name": "roundingPriority", - "docstrings": [], - "signature": "type roundingPriority = [\n | #auto\n | #lessPrecision\n | #morePrecision\n]" - }, - { - "id": "Core.Intl.NumberFormat.roundingIncrement", - "kind": "type", - "name": "roundingIncrement", - "docstrings": [], - "signature": "type roundingIncrement = [\n | #1\n | #10\n | #100\n | #1000\n | #2\n | #20\n | #200\n | #2000\n | #25\n | #250\n | #2500\n | #5\n | #50\n | #500\n | #5000\n]" - }, - { - "id": "Core.Intl.NumberFormat.trailingZeroDisplay", - "kind": "type", - "name": "trailingZeroDisplay", - "docstrings": [], - "signature": "type trailingZeroDisplay = [\n | #auto\n | #lessPrecision\n | #stripIfInteger\n]" - }, - { - "id": "Core.Intl.NumberFormat.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n compactDisplay?: compactDisplay,\n numberingSystem?: Core__Intl__Common.numberingSystem,\n currency?: currency,\n currencyDisplay?: currencyDisplay,\n currencySign?: currencySign,\n localeMatcher?: Core__Intl__Common.localeMatcher,\n notation?: notation,\n signDisplay?: signDisplay,\n style?: style,\n unit?: unitSystem,\n unitDisplay?: unitDisplay,\n useGrouping?: Grouping.t,\n roundingMode?: rounding,\n roundingPriority?: roundingPriority,\n roundingIncrement?: roundingIncrement,\n trailingZeroDisplay?: trailingZeroDisplay,\n minimumIntegerDigits?: Core__Intl__Common.oneTo21,\n minimumFractionDigits?: Core__Intl__Common.zeroTo20,\n maximumFractionDigits?: Core__Intl__Common.zeroTo20,\n minimumSignificantDigits?: Core__Intl__Common.oneTo21,\n maximumSignificantDigits?: Core__Intl__Common.oneTo21,\n}" - }, - { - "id": "Core.Intl.NumberFormat.resolvedOptions", - "kind": "type", - "name": "resolvedOptions", - "docstrings": [], - "signature": "type resolvedOptions = {\n currency?: currency,\n currencyDisplay?: currencyDisplay,\n currencySign?: currencySign,\n compactDisplay?: compactDisplay,\n unit: unitSystem,\n unitDisplay: unitDisplay,\n roundingMode?: rounding,\n roundingPriority?: roundingPriority,\n roundingIncrement?: roundingIncrement,\n minimumIntegerDigits?: Core__Intl__Common.oneTo21,\n minimumFractionDigits?: Core__Intl__Common.zeroTo20,\n maximumFractionDigits?: Core__Intl__Common.zeroTo20,\n minimumSignificantDigits?: Core__Intl__Common.oneTo21,\n maximumSignificantDigits?: Core__Intl__Common.oneTo21,\n locale: string,\n notation: notation,\n numberingSystem: Core__Intl__Common.numberingSystem,\n signDisplay: signDisplay,\n style: style,\n useGrouping: Grouping.t,\n}" - }, - { - "id": "Core.Intl.NumberFormat.supportedLocalesOptions", - "kind": "type", - "name": "supportedLocalesOptions", - "docstrings": [], - "signature": "type supportedLocalesOptions = {\n localeMatcher: Core__Intl__Common.localeMatcher,\n}" - }, - { - "id": "Core.Intl.NumberFormat.numberFormatPartType", - "kind": "type", - "name": "numberFormatPartType", - "docstrings": [], - "signature": "type numberFormatPartType = [\n | #compact\n | #currency\n | #decimal\n | #exponentInteger\n | #exponentMinusSign\n | #exponentSeparator\n | #fraction\n | #group\n | #infinity\n | #integer\n | #literal\n | #minusSign\n | #nan\n | #percentSign\n | #plusSign\n | #unit\n | #unknown\n]" - }, - { - "id": "Core.Intl.NumberFormat.numberFormatPart", - "kind": "type", - "name": "numberFormatPart", - "docstrings": [], - "signature": "type numberFormatPart = {\n \\\"type\": numberFormatPartType,\n value: string,\n}" - }, - { - "id": "Core.Intl.NumberFormat.rangeSource", - "kind": "type", - "name": "rangeSource", - "docstrings": [], - "signature": "type rangeSource = [#endRange | #shared | #startRange]" - }, - { - "id": "Core.Intl.NumberFormat.numberFormatRangePart", - "kind": "type", - "name": "numberFormatRangePart", - "docstrings": [], - "signature": "type numberFormatRangePart = {\n \\\"type\": numberFormatPartType,\n value: string,\n source: rangeSource,\n}" - }, - { - "id": "Core.Intl.NumberFormat.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~locales: array=?, ~options: options=?) => t" - }, - { - "id": "Core.Intl.NumberFormat.supportedLocalesOf", - "kind": "value", - "name": "supportedLocalesOf", - "docstrings": [], - "signature": "let supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t" - }, - { - "id": "Core.Intl.NumberFormat.resolvedOptions", - "kind": "value", - "name": "resolvedOptions", - "docstrings": [], - "signature": "let resolvedOptions: t => resolvedOptions" - }, - { - "id": "Core.Intl.NumberFormat.format", - "kind": "value", - "name": "format", - "docstrings": [], - "signature": "let format: (t, float) => string" - }, - { - "id": "Core.Intl.NumberFormat.formatRange", - "kind": "value", - "name": "formatRange", - "docstrings": [], - "signature": "let formatRange: (t, ~start: float, ~end: float) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatToParts", - "kind": "value", - "name": "formatToParts", - "docstrings": [], - "signature": "let formatToParts: (t, float) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatRangeToParts", - "kind": "value", - "name": "formatRangeToParts", - "docstrings": [], - "signature": "let formatRangeToParts: (\n t,\n ~start: float,\n ~end: float,\n) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatInt", - "kind": "value", - "name": "formatInt", - "docstrings": [], - "signature": "let formatInt: (t, int) => string" - }, - { - "id": "Core.Intl.NumberFormat.formatIntRange", - "kind": "value", - "name": "formatIntRange", - "docstrings": [], - "signature": "let formatIntRange: (t, ~start: int, ~end: int) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatIntToParts", - "kind": "value", - "name": "formatIntToParts", - "docstrings": [], - "signature": "let formatIntToParts: (t, int) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatIntRangeToParts", - "kind": "value", - "name": "formatIntRangeToParts", - "docstrings": [], - "signature": "let formatIntRangeToParts: (t, ~start: int, ~end: int) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatBigInt", - "kind": "value", - "name": "formatBigInt", - "docstrings": [], - "signature": "let formatBigInt: (t, bigint) => string" - }, - { - "id": "Core.Intl.NumberFormat.formatBigIntRange", - "kind": "value", - "name": "formatBigIntRange", - "docstrings": [], - "signature": "let formatBigIntRange: (t, ~start: bigint, ~end: bigint) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatBigIntToParts", - "kind": "value", - "name": "formatBigIntToParts", - "docstrings": [], - "signature": "let formatBigIntToParts: (t, bigint) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatBigIntRangeToParts", - "kind": "value", - "name": "formatBigIntRangeToParts", - "docstrings": [], - "signature": "let formatBigIntRangeToParts: (t, ~start: bigint, ~end: bigint) => array" - }, - { - "id": "Core.Intl.NumberFormat.formatString", - "kind": "value", - "name": "formatString", - "docstrings": [], - "signature": "let formatString: (t, string) => string" - }, - { - "id": "Core.Intl.NumberFormat.formatStringToParts", - "kind": "value", - "name": "formatStringToParts", - "docstrings": [], - "signature": "let formatStringToParts: (t, string) => array" - } - ] - }, - "core/intl/locale": { - "id": "Core.Intl.Locale", - "name": "Locale", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.Locale.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.Locale.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n baseName?: string,\n calendar?: Core__Intl__Common.calendar,\n collation?: Core__Intl__Common.collation,\n hourCycle?: [#h11 | #h12 | #h23 | #h24],\n caseFirst?: [#\"false\" | #lower | #upper],\n numberingSystem?: Core__Intl__Common.numberingSystem,\n numeric?: bool,\n language?: string,\n script?: string,\n region?: string,\n}" - }, - { - "id": "Core.Intl.Locale.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (string, ~options: options=?) => t" - }, - { - "id": "Core.Intl.Locale.baseName", - "kind": "value", - "name": "baseName", - "docstrings": [], - "signature": "let baseName: t => string" - }, - { - "id": "Core.Intl.Locale.calendar", - "kind": "value", - "name": "calendar", - "docstrings": [], - "signature": "let calendar: t => option" - }, - { - "id": "Core.Intl.Locale.caseFirst", - "kind": "value", - "name": "caseFirst", - "docstrings": [], - "signature": "let caseFirst: t => option" - }, - { - "id": "Core.Intl.Locale.collation", - "kind": "value", - "name": "collation", - "docstrings": [], - "signature": "let collation: t => option" - }, - { - "id": "Core.Intl.Locale.hourCycle", - "kind": "value", - "name": "hourCycle", - "docstrings": [], - "signature": "let hourCycle: t => option" - }, - { - "id": "Core.Intl.Locale.language", - "kind": "value", - "name": "language", - "docstrings": [], - "signature": "let language: t => string" - }, - { - "id": "Core.Intl.Locale.numberingSystem", - "kind": "value", - "name": "numberingSystem", - "docstrings": [], - "signature": "let numberingSystem: t => option" - }, - { - "id": "Core.Intl.Locale.numeric", - "kind": "value", - "name": "numeric", - "docstrings": [], - "signature": "let numeric: t => bool" - }, - { - "id": "Core.Intl.Locale.region", - "kind": "value", - "name": "region", - "docstrings": [], - "signature": "let region: t => option" - }, - { - "id": "Core.Intl.Locale.script", - "kind": "value", - "name": "script", - "docstrings": [], - "signature": "let script: t => option" - }, - { - "id": "Core.Intl.Locale.maximize", - "kind": "value", - "name": "maximize", - "docstrings": [], - "signature": "let maximize: t => t" - }, - { - "id": "Core.Intl.Locale.minimize", - "kind": "value", - "name": "minimize", - "docstrings": [], - "signature": "let minimize: t => t" - } - ] - }, - "core/intl/listformat": { - "id": "Core.Intl.ListFormat", - "name": "ListFormat", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.ListFormat.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.ListFormat.listType", - "kind": "type", - "name": "listType", - "docstrings": [], - "signature": "type listType = [#conjunction | #disjunction | #unit]" - }, - { - "id": "Core.Intl.ListFormat.style", - "kind": "type", - "name": "style", - "docstrings": [], - "signature": "type style = [#long | #narrow | #short]" - }, - { - "id": "Core.Intl.ListFormat.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n localeMatcher?: Core__Intl__Common.localeMatcher,\n \\\"type\"?: listType,\n style?: style,\n}" - }, - { - "id": "Core.Intl.ListFormat.listPartComponentType", - "kind": "type", - "name": "listPartComponentType", - "docstrings": [], - "signature": "type listPartComponentType = [#element | #literal]" - }, - { - "id": "Core.Intl.ListFormat.listPart", - "kind": "type", - "name": "listPart", - "docstrings": [], - "signature": "type listPart = {\n \\\"type\": listPartComponentType,\n value: string,\n}" - }, - { - "id": "Core.Intl.ListFormat.resolvedOptions", - "kind": "type", - "name": "resolvedOptions", - "docstrings": [], - "signature": "type resolvedOptions = {\n locale: string,\n style: style,\n \\\"type\": listType,\n}" - }, - { - "id": "Core.Intl.ListFormat.supportedLocalesOptions", - "kind": "type", - "name": "supportedLocalesOptions", - "docstrings": [], - "signature": "type supportedLocalesOptions = {\n localeMatcher: Core__Intl__Common.localeMatcher,\n}" - }, - { - "id": "Core.Intl.ListFormat.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~locales: array=?, ~options: options=?) => t" - }, - { - "id": "Core.Intl.ListFormat.supportedLocalesOf", - "kind": "value", - "name": "supportedLocalesOf", - "docstrings": [], - "signature": "let supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t" - }, - { - "id": "Core.Intl.ListFormat.resolvedOptions", - "kind": "value", - "name": "resolvedOptions", - "docstrings": [], - "signature": "let resolvedOptions: t => resolvedOptions" - }, - { - "id": "Core.Intl.ListFormat.format", - "kind": "value", - "name": "format", - "docstrings": [], - "signature": "let format: (t, array) => string" - }, - { - "id": "Core.Intl.ListFormat.formatToParts", - "kind": "value", - "name": "formatToParts", - "docstrings": [], - "signature": "let formatToParts: (t, array) => array" - } - ] - }, - "core/intl/datetimeformat": { - "id": "Core.Intl.DateTimeFormat", - "name": "DateTimeFormat", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.DateTimeFormat.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.DateTimeFormat.dateStyle", - "kind": "type", - "name": "dateStyle", - "docstrings": [], - "signature": "type dateStyle = [#full | #long | #medium | #short]" - }, - { - "id": "Core.Intl.DateTimeFormat.timeStyle", - "kind": "type", - "name": "timeStyle", - "docstrings": [], - "signature": "type timeStyle = [#full | #long | #medium | #short]" - }, - { - "id": "Core.Intl.DateTimeFormat.dayPeriod", - "kind": "type", - "name": "dayPeriod", - "docstrings": [], - "signature": "type dayPeriod = [#long | #narrow | #short]" - }, - { - "id": "Core.Intl.DateTimeFormat.weekday", - "kind": "type", - "name": "weekday", - "docstrings": [], - "signature": "type weekday = [#long | #narrow | #short]" - }, - { - "id": "Core.Intl.DateTimeFormat.era", - "kind": "type", - "name": "era", - "docstrings": [], - "signature": "type era = [#long | #narrow | #short]" - }, - { - "id": "Core.Intl.DateTimeFormat.year", - "kind": "type", - "name": "year", - "docstrings": [], - "signature": "type year = [#\"2-digit\" | #numeric]" - }, - { - "id": "Core.Intl.DateTimeFormat.month", - "kind": "type", - "name": "month", - "docstrings": [], - "signature": "type month = [\n | #\"2-digit\"\n | #long\n | #narrow\n | #numeric\n | #short\n]" - }, - { - "id": "Core.Intl.DateTimeFormat.day", - "kind": "type", - "name": "day", - "docstrings": [], - "signature": "type day = [#\"2-digit\" | #numeric]" - }, - { - "id": "Core.Intl.DateTimeFormat.hour", - "kind": "type", - "name": "hour", - "docstrings": [], - "signature": "type hour = [#\"2-digit\" | #numeric]" - }, - { - "id": "Core.Intl.DateTimeFormat.minute", - "kind": "type", - "name": "minute", - "docstrings": [], - "signature": "type minute = [#\"2-digit\" | #numeric]" - }, - { - "id": "Core.Intl.DateTimeFormat.second", - "kind": "type", - "name": "second", - "docstrings": [], - "signature": "type second = [#\"2-digit\" | #numeric]" - }, - { - "id": "Core.Intl.DateTimeFormat.timeZoneName", - "kind": "type", - "name": "timeZoneName", - "docstrings": [ - "Firefox also supports IANA time zone names here\nNode v19+ supports \"shortOffset\", \"shortGeneric\", \"longOffset\", and \"longGeneric\"." - ], - "signature": "type timeZoneName = [\n | #long\n | #longGeneric\n | #longOffset\n | #short\n | #shortGeneric\n | #shortOffset\n]" - }, - { - "id": "Core.Intl.DateTimeFormat.hourCycle", - "kind": "type", - "name": "hourCycle", - "docstrings": [], - "signature": "type hourCycle = [#h11 | #h12 | #h23 | #h24]" - }, - { - "id": "Core.Intl.DateTimeFormat.formatMatcher", - "kind": "type", - "name": "formatMatcher", - "docstrings": [], - "signature": "type formatMatcher = [#basic | #\"best fit\"]" - }, - { - "id": "Core.Intl.DateTimeFormat.fractionalSecondDigits", - "kind": "type", - "name": "fractionalSecondDigits", - "docstrings": [], - "signature": "type fractionalSecondDigits = [#0 | #1 | #2 | #3]" - }, - { - "id": "Core.Intl.DateTimeFormat.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n dateStyle?: dateStyle,\n timeStyle?: timeStyle,\n calendar?: Core__Intl__Common.calendar,\n dayPeriod?: dayPeriod,\n numberingSystem?: Core__Intl__Common.numberingSystem,\n localeMatcher?: Core__Intl__Common.localeMatcher,\n timeZone?: string,\n hour12?: bool,\n hourCycle?: hourCycle,\n formatMatcher?: formatMatcher,\n weekday?: weekday,\n era?: era,\n year?: year,\n month?: month,\n day?: day,\n hour?: hour,\n minute?: minute,\n second?: second,\n fractionalSecondDigits?: fractionalSecondDigits,\n timeZoneName?: timeZoneName,\n}" - }, - { - "id": "Core.Intl.DateTimeFormat.resolvedOptions", - "kind": "type", - "name": "resolvedOptions", - "docstrings": [], - "signature": "type resolvedOptions = {\n dateStyle?: dateStyle,\n timeStyle?: timeStyle,\n weekday?: weekday,\n era?: era,\n year?: year,\n month?: month,\n day?: day,\n hour?: hour,\n minute?: minute,\n second?: second,\n fractionalSecondDigits?: fractionalSecondDigits,\n timeZoneName?: timeZoneName,\n calendar: Core__Intl__Common.calendar,\n hour12: bool,\n hourCycle: hourCycle,\n locale: string,\n numberingSystem: Core__Intl__Common.numberingSystem,\n timeZone: string,\n}" - }, - { - "id": "Core.Intl.DateTimeFormat.supportedLocalesOptions", - "kind": "type", - "name": "supportedLocalesOptions", - "docstrings": [], - "signature": "type supportedLocalesOptions = {\n localeMatcher: Core__Intl__Common.localeMatcher,\n}" - }, - { - "id": "Core.Intl.DateTimeFormat.dateTimeComponent", - "kind": "type", - "name": "dateTimeComponent", - "docstrings": [], - "signature": "type dateTimeComponent = [\n | #day\n | #dayPeriod\n | #era\n | #fractionalSecond\n | #hour\n | #literal\n | #minute\n | #month\n | #relatedYear\n | #second\n | #timeZone\n | #weekday\n | #year\n | #yearName\n]" - }, - { - "id": "Core.Intl.DateTimeFormat.dateTimePart", - "kind": "type", - "name": "dateTimePart", - "docstrings": [], - "signature": "type dateTimePart = {\n \\\"type\": dateTimeComponent,\n value: string,\n}" - }, - { - "id": "Core.Intl.DateTimeFormat.dateTimeRangeSource", - "kind": "type", - "name": "dateTimeRangeSource", - "docstrings": [], - "signature": "type dateTimeRangeSource = [\n | #endRange\n | #shared\n | #startRange\n]" - }, - { - "id": "Core.Intl.DateTimeFormat.dateTimeRangePart", - "kind": "type", - "name": "dateTimeRangePart", - "docstrings": [], - "signature": "type dateTimeRangePart = {\n \\\"type\": dateTimeComponent,\n value: string,\n source: dateTimeRangeSource,\n}" - }, - { - "id": "Core.Intl.DateTimeFormat.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~locales: array=?, ~options: options=?) => t" - }, - { - "id": "Core.Intl.DateTimeFormat.supportedLocalesOf", - "kind": "value", - "name": "supportedLocalesOf", - "docstrings": [], - "signature": "let supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t" - }, - { - "id": "Core.Intl.DateTimeFormat.resolvedOptions", - "kind": "value", - "name": "resolvedOptions", - "docstrings": [], - "signature": "let resolvedOptions: t => resolvedOptions" - }, - { - "id": "Core.Intl.DateTimeFormat.format", - "kind": "value", - "name": "format", - "docstrings": [], - "signature": "let format: (t, Core__Date.t) => string" - }, - { - "id": "Core.Intl.DateTimeFormat.formatToParts", - "kind": "value", - "name": "formatToParts", - "docstrings": [], - "signature": "let formatToParts: (t, Core__Date.t) => array" - }, - { - "id": "Core.Intl.DateTimeFormat.formatRange", - "kind": "value", - "name": "formatRange", - "docstrings": [], - "signature": "let formatRange: (\n t,\n ~startDate: Core__Date.t,\n ~endDate: Core__Date.t,\n) => string" - }, - { - "id": "Core.Intl.DateTimeFormat.formatRangeToParts", - "kind": "value", - "name": "formatRangeToParts", - "docstrings": [], - "signature": "let formatRangeToParts: (\n t,\n ~startDate: Core__Date.t,\n ~endDate: Core__Date.t,\n) => array" - } - ] - }, - "core/intl/collator": { - "id": "Core.Intl.Collator", - "name": "Collator", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.Collator.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.Intl.Collator.usage", - "kind": "type", - "name": "usage", - "docstrings": [], - "signature": "type usage = [#search | #sort]" - }, - { - "id": "Core.Intl.Collator.sensitivity", - "kind": "type", - "name": "sensitivity", - "docstrings": [], - "signature": "type sensitivity = [#accent | #base | #case | #variant]" - }, - { - "id": "Core.Intl.Collator.caseFirst", - "kind": "type", - "name": "caseFirst", - "docstrings": [], - "signature": "type caseFirst = [#\"false\" | #lower | #upper]" - }, - { - "id": "Core.Intl.Collator.options", - "kind": "type", - "name": "options", - "docstrings": [], - "signature": "type options = {\n localeMatcher?: Core__Intl__Common.localeMatcher,\n usage?: usage,\n sensitivity?: sensitivity,\n ignorePunctuation?: bool,\n numeric?: bool,\n caseFirst?: caseFirst,\n}" - }, - { - "id": "Core.Intl.Collator.resolvedOptions", - "kind": "type", - "name": "resolvedOptions", - "docstrings": [], - "signature": "type resolvedOptions = {\n locale: string,\n usage: usage,\n sensitivity: sensitivity,\n ignorePunctuation: bool,\n collation: [\n | #compat\n | #default\n | #dict\n | #emoji\n | #eor\n | #phonebk\n | #phonetic\n | #pinyin\n | #stroke\n | #trad\n | #unihan\n | #zhuyin\n ],\n numeric?: bool,\n caseFirst?: caseFirst,\n}" - }, - { - "id": "Core.Intl.Collator.supportedLocalesOptions", - "kind": "type", - "name": "supportedLocalesOptions", - "docstrings": [], - "signature": "type supportedLocalesOptions = {\n localeMatcher: Core__Intl__Common.localeMatcher,\n}" - }, - { - "id": "Core.Intl.Collator.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (~locales: array=?, ~options: options=?) => t" - }, - { - "id": "Core.Intl.Collator.supportedLocalesOf", - "kind": "value", - "name": "supportedLocalesOf", - "docstrings": [], - "signature": "let supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t" - }, - { - "id": "Core.Intl.Collator.resolvedOptions", - "kind": "value", - "name": "resolvedOptions", - "docstrings": [], - "signature": "let resolvedOptions: t => resolvedOptions" - }, - { - "id": "Core.Intl.Collator.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (t, string, string) => int" - } - ] - }, - "core/intl/common": { - "id": "Core.Intl.Common", - "name": "Common", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.Common.localeMatcher", - "kind": "type", - "name": "localeMatcher", - "docstrings": [], - "signature": "type localeMatcher = [#\"best fit\" | #lookup]" - }, - { - "id": "Core.Intl.Common.calendar", - "kind": "type", - "name": "calendar", - "docstrings": [], - "signature": "type calendar = [\n | #buddhist\n | #chinese\n | #coptic\n | #dangi\n | #ethioaa\n | #ethiopic\n | #gregory\n | #hebrew\n | #indian\n | #islamic\n | #\"islamic-civil\"\n | #\"islamic-rgsa\"\n | #\"islamic-tbla\"\n | #\"islamic-umalqura\"\n | #iso8601\n | #japanese\n | #persian\n | #roc\n]" - }, - { - "id": "Core.Intl.Common.collation", - "kind": "type", - "name": "collation", - "docstrings": [], - "signature": "type collation = [\n | #compat\n | #dict\n | #emoji\n | #eor\n | #phonebk\n | #phonetic\n | #pinyin\n | #stroke\n | #trad\n | #unihan\n | #zhuyin\n]" - }, - { - "id": "Core.Intl.Common.numberingSystem", - "kind": "type", - "name": "numberingSystem", - "docstrings": [], - "signature": "type numberingSystem = [\n | #adlm\n | #ahom\n | #arab\n | #arabext\n | #bali\n | #beng\n | #bhks\n | #brah\n | #cakm\n | #cham\n | #deva\n | #diak\n | #fullwide\n | #gong\n | #gonm\n | #gujr\n | #guru\n | #hanidec\n | #hmng\n | #hmnp\n | #java\n | #kali\n | #kawi\n | #khmr\n | #knda\n | #lana\n | #lanatham\n | #laoo\n | #latn\n | #lepc\n | #limb\n | #mathbold\n | #mathdbl\n | #mathmono\n | #mathsanb\n | #mathsans\n | #mlym\n | #modi\n | #mong\n | #mroo\n | #mtei\n | #mymr\n | #mymrshan\n | #mymrtlng\n | #nagm\n | #newa\n | #nkoo\n | #olck\n | #orya\n | #osma\n | #rohg\n | #saur\n | #segment\n | #shrd\n | #sind\n | #sinh\n | #sora\n | #sund\n | #takr\n | #talu\n | #tamldec\n | #telu\n | #thai\n | #tibt\n | #tirh\n | #tnsa\n | #vaii\n | #wara\n | #wcho\n]" - }, - { - "id": "Core.Intl.Common.oneTo21", - "kind": "type", - "name": "oneTo21", - "docstrings": [], - "signature": "type oneTo21 = [\n | #1\n | #10\n | #11\n | #12\n | #13\n | #14\n | #15\n | #16\n | #17\n | #18\n | #19\n | #2\n | #20\n | #21\n | #3\n | #4\n | #5\n | #6\n | #7\n | #8\n | #9\n]" - }, - { - "id": "Core.Intl.Common.zeroTo20", - "kind": "type", - "name": "zeroTo20", - "docstrings": [], - "signature": "type zeroTo20 = [\n | #0\n | #1\n | #10\n | #11\n | #12\n | #13\n | #14\n | #15\n | #16\n | #17\n | #18\n | #19\n | #2\n | #20\n | #3\n | #4\n | #5\n | #6\n | #7\n | #8\n | #9\n]" - } - ] - }, - "core/biguint64array/constants": { - "id": "Core.BigUint64Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.BigUint64Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/bigint64array/constants": { - "id": "Core.BigInt64Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.BigInt64Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/uint8clampedarray/constants": { - "id": "Core.Uint8ClampedArray.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Uint8ClampedArray.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/uint32array/constants": { - "id": "Core.Uint32Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Uint32Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/uint16array/constants": { - "id": "Core.Uint16Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Uint16Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/uint8array/constants": { - "id": "Core.Uint8Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Uint8Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/int32array/constants": { - "id": "Core.Int32Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Int32Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/int16array/constants": { - "id": "Core.Int16Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Int16Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/int8array/constants": { - "id": "Core.Int8Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Int8Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/float64array/constants": { - "id": "Core.Float64Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Float64Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/float32array/constants": { - "id": "Core.Float32Array.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Float32Array.Constants.bytesPerElement", - "kind": "value", - "name": "bytesPerElement", - "docstrings": [ - "`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)" - ], - "signature": "let bytesPerElement: int" - } - ] - }, - "core/json/decode": { - "id": "Core.JSON.Decode", - "name": "Decode", - "docstrings": [], - "items": [ - { - "id": "Core.JSON.Decode.bool", - "kind": "value", - "name": "bool", - "docstrings": [ - "Decodes a single JSON value. If the value is a bool, it will return `Some(bool)` - otherwise it will return `None`.\n\n ## Examples\n ```rescript\n JSON.parseExn(`true`)->JSON.Decode.bool\n // Some(true)\n\n JSON.parseExn(`\"hello world\"`)->JSON.Decode.bool\n // None\n ```" - ], - "signature": "let bool: t => option" - }, - { - "id": "Core.JSON.Decode.null", - "kind": "value", - "name": "null", - "docstrings": [ - "Decodes a single JSON value. If the value is null, it will return `Some(Null.t)` - otherwise it will return `None`.\n\n ## Examples\n ```rescript\n JSON.parseExn(`null`)->JSON.Decode.null\n // Some(null)\n\n JSON.parseExn(`\"hello world\"`)->JSON.Decode.null\n // None\n ```" - ], - "signature": "let null: t => option>" - }, - { - "id": "Core.JSON.Decode.string", - "kind": "value", - "name": "string", - "docstrings": [ - "Decodes a single JSON value. If the value is a string, it will return `Some(string)` - otherwise it will return `None`.\n\n ## Examples\n ```rescript\n JSON.parseExn(`\"hello world\"`)->JSON.Decode.string\n // Some(\"hello world\")\n\n JSON.parseExn(`42`)->JSON.Decode.string\n // None \n ```" - ], - "signature": "let string: t => option" - }, - { - "id": "Core.JSON.Decode.float", - "kind": "value", - "name": "float", - "docstrings": [ - "Decodes a single JSON value. If the value is a float, it will return `Some(float)` - otherwise it will return `None`.\n\n ## Examples\n ```rescript\n JSON.parseExn(`42.0`)->JSON.Decode.float\n // Some(42.0)\n\n JSON.parseExn(`\"hello world\"`)->JSON.Decode.float\n // None\n ```" - ], - "signature": "let float: t => option" - }, - { - "id": "Core.JSON.Decode.object", - "kind": "value", - "name": "object", - "docstrings": [ - "Decodes a single JSON value. If the value is an object, it will return `Some(Dict.t)` - otherwise it will return `None`.\n\n ## Examples\n ```rescript\n JSON.parseExn(`{\"foo\":\"bar\"}`)->JSON.Decode.object\n // Some({ foo: 'bar' })\n\n JSON.parseExn(`\"hello world\"`)->JSON.Decode.object\n // None\n ```" - ], - "signature": "let object: t => option>" - }, - { - "id": "Core.JSON.Decode.array", - "kind": "value", - "name": "array", - "docstrings": [ - "Decodes a single JSON value. If the value is an array, it will return `Some(array)` - otherwise it will return `None`.\n\n ## Examples\n ```rescript\n JSON.parseExn(`[\"foo\", \"bar\"]`)->JSON.Decode.array\n // Some([ 'foo', 'bar' ])\n\n JSON.parseExn(`\"hello world\"`)->JSON.Decode.array\n // None\n ```" - ], - "signature": "let array: t => option>" - } - ] - }, - "core/json/encode": { - "id": "Core.JSON.Encode", - "name": "Encode", - "docstrings": [], - "items": [ - { - "id": "Core.JSON.Encode.bool", - "kind": "value", - "name": "bool", - "docstrings": [ - "Returns a boolean as a JSON object.\n\n ## Examples\n ```rescript\n JSON.Encode.bool(true)\n ```" - ], - "signature": "let bool: bool => t" - }, - { - "id": "Core.JSON.Encode.null", - "kind": "value", - "name": "null", - "docstrings": [ - "Returns null as a JSON object.\n\n ## Examples\n ```rescript\n JSON.Encode.null\n ```" - ], - "signature": "let null: t" - }, - { - "id": "Core.JSON.Encode.string", - "kind": "value", - "name": "string", - "docstrings": [ - "Returns a string as a JSON object.\n\n ## Examples\n ```rescript\n JSON.Encode.string(\"hello world\")\n ```" - ], - "signature": "let string: string => t" - }, - { - "id": "Core.JSON.Encode.int", - "kind": "value", - "name": "int", - "docstrings": [ - "Returns an int as a JSON object.\n\n ## Examples\n ```rescript\n JSON.Encode.int(42)\n ```" - ], - "signature": "let int: int => t" - }, - { - "id": "Core.JSON.Encode.float", - "kind": "value", - "name": "float", - "docstrings": [ - "Returns a float as a JSON object.\n\n ## Examples\n ```rescript\n JSON.Encode.float(42.0)\n ```" - ], - "signature": "let float: float => t" - }, - { - "id": "Core.JSON.Encode.object", - "kind": "value", - "name": "object", - "docstrings": [ - "Returns a dict as a JSON object.\n\n ## Examples\n ```rescript\n let dict = Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n ])\n\n JSON.Encode.object(dict)\n ```" - ], - "signature": "let object: Core__Dict.t => t" - }, - { - "id": "Core.JSON.Encode.array", - "kind": "value", - "name": "array", - "docstrings": [ - "Returns an array as a JSON object.\n\n ## Examples\n ```rescript\n let array = [JSON.Encode.string(\"hello world\"), JSON.Encode.int(42)]\n\n JSON.Encode.array(array)\n ```" - ], - "signature": "let array: array => t" - } - ] - }, - "core/json/classify": { - "id": "Core.JSON.Classify", - "name": "Classify", - "docstrings": [], - "items": [ - { - "id": "Core.JSON.Classify.t", - "kind": "type", - "name": "t", - "docstrings": ["A type representing a JavaScript type."], - "signature": "type t =\n | Bool(bool)\n | Null\n | String(string)\n | Number(float)\n | Object(Core__Dict.t)\n | Array(array)" - }, - { - "id": "Core.JSON.Classify.classify", - "kind": "value", - "name": "classify", - "docstrings": [ - "Returns the JSON type of any value.\n\n ## Examples\n ```rescript\n JSON.Classify.classify(\"hello world\")\n // String(\"hello world\")\n\n JSON.Classify.classify(42)\n // Number(42)\n ```" - ], - "signature": "let classify: 'a => t" - } - ] - }, - "core/type/classify": { - "id": "Core.Type.Classify", - "name": "Classify", - "docstrings": [], - "items": [ - { - "id": "Core.Type.Classify.function", - "kind": "type", - "name": "function", - "docstrings": [ - "An abstract type representing a JavaScript function.\n\n See [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) on MDN." - ], - "signature": "type function" - }, - { - "id": "Core.Type.Classify.object", - "kind": "type", - "name": "object", - "docstrings": [ - "An abstract type representing a JavaScript object.\n\n See [`object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) on MDN." - ], - "signature": "type object" - }, - { - "id": "Core.Type.Classify.t", - "kind": "type", - "name": "t", - "docstrings": ["The type representing a classified JavaScript value."], - "signature": "type t =\n | Bool(bool)\n | Null\n | Undefined\n | String(string)\n | Number(float)\n | Object(object)\n | Function(function)\n | Symbol(Core__Symbol.t)\n | BigInt(bigint)" - }, - { - "id": "Core.Type.Classify.classify", - "kind": "value", - "name": "classify", - "docstrings": [ - "`classify(anyValue)`\nClassifies a JavaScript value.\n\n## Examples\n```rescript\nswitch %raw(`null`)->Type.Classify.classify {\n| Null => Console.log(\"Yup, that's null.\")\n| _ => Console.log(\"This doesn't actually appear to be null...\")\n}\n```" - ], - "signature": "let classify: 'a => t" - } - ] - }, - "core/regexp/result": { - "id": "Core.RegExp.Result", - "name": "Result", - "docstrings": [], - "items": [ - { - "id": "Core.RegExp.Result.t", - "kind": "type", - "name": "t", - "docstrings": ["Type representing the result of a `RegExp` execution."], - "signature": "type t = array>" - }, - { - "id": "Core.RegExp.Result.fullMatch", - "kind": "value", - "name": "fullMatch", - "docstrings": [ - "`fullMatch(regExpResult)` returns the full string that matched in this result.\n\n ## Examples\n ```rescript\n // Match the first two words separated by a space\n let regexp = RegExp.fromString(\"(\\\\w+) (\\\\w+)\")\n\n switch regexp->RegExp.exec(\"ReScript is pretty cool, right?\") {\n | None => Console.log(\"Nope, no match...\")\n | Some(result) => Console.log(result->RegExp.Result.fullMatch) // Prints the full string that matched, \"ReScript is\"\n }\n ```" - ], - "signature": "let fullMatch: t => string" - }, - { - "id": "Core.RegExp.Result.matches", - "kind": "value", - "name": "matches", - "docstrings": [ - "`matches(regExpResult)` returns all matches for `regExpResult`.\n\n ## Examples\n ```rescript\n // Match the first two words separated by a space\n let regexp = RegExp.fromString(\"(\\\\w+) (\\\\w+)\")\n\n // This below will log \"ReScript\" and \"is\" to the console.\n switch regexp->RegExp.exec(\"ReScript is pretty cool, right?\") {\n | None => Console.log(\"Nope, no match...\")\n | Some(result) => switch result->RegExp.Result.matches {\n | [firstWord, secondWord] => Console.log2(firstWord, secondWord)\n | _ => Console.log(\"Didn't find exactly two words...\")\n }\n }\n ```" - ], - "signature": "let matches: t => array" - }, - { - "id": "Core.RegExp.Result.index", - "kind": "value", - "name": "index", - "docstrings": [], - "signature": "let index: t => int" - }, - { - "id": "Core.RegExp.Result.input", - "kind": "value", - "name": "input", - "docstrings": [ - "`input(regExpResult)` returns the full input string that was passed to what produced the `RegExp.Result.t`.\n\n ## Examples\n ```rescript\n // Match the first two words separated by a space\n let regexp = RegExp.fromString(\"(\\\\w+) (\\\\w+)\")\n\n // This below will log the full input string \"ReScript is pretty cool, right?\" to the console.\n switch regexp->RegExp.exec(\"ReScript is pretty cool, right?\") {\n | None => Console.log(\"Nope, no match...\")\n | Some(result) => Console.log(result->RegExp.Result.input)\n }\n ```" - ], - "signature": "let input: t => string" - } - ] - }, - "core/math/int": { - "id": "Core.Math.Int", - "name": "Int", - "docstrings": ["Provide Math utilities for `int`"], - "items": [ - { - "id": "Core.Math.Int.abs", - "kind": "value", - "name": "abs", - "docstrings": [ - "`abs(v)` returns absolute value of `v`.\n See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.abs(-2) // 2\n Math.Int.abs(3) // 3\n ```" - ], - "signature": "let abs: int => int" - }, - { - "id": "Core.Math.Int.clz32", - "kind": "value", - "name": "clz32", - "docstrings": [ - "`clz32(v)` returns the number of leading zero bits of the argument's 32 bit\n int representation.\n See [`Math.clz32`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32) on MDN.\n\n ## Examples\n\n ```rescript\n // 00000000000000000000000000000001\n Math.Int.clz32(1) // 31\n // 00000000000000000000000000000100\n Math.Int.clz32(4) // 29\n ```" - ], - "signature": "let clz32: int => int" - }, - { - "id": "Core.Math.Int.imul", - "kind": "value", - "name": "imul", - "docstrings": [ - "`imul(a, b)` returns 32-bit integer multiplication. Use this only when you\n need to optimize performance of multiplication of numbers stored as 32-bit\n integers.\n See [`Math.imul`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.imul(3, 4) // 12\n Math.Int.imul(-5, 12) // 60\n ```" - ], - "signature": "let imul: (int, int) => int" - }, - { - "id": "Core.Math.Int.min", - "kind": "value", - "name": "min", - "docstrings": [ - "`min(a, b)` returns the minimum of its two integer arguments.\n See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.min(1, 2) // 1\n Math.Int.min(-1, -2) // -2\n ```" - ], - "signature": "let min: (int, int) => int" - }, - { - "id": "Core.Math.Int.minMany", - "kind": "value", - "name": "minMany", - "docstrings": [ - "`minMany(arr)` returns the minimum of the integers in the given array `arr`.\n Returns `Infinity` if `arr` is empty.\n See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.minMany([1, 2]) // 1\n Math.Int.minMany([-1, -2]) // -2\n Math.Int.minMany([])->Int.toFloat->Float.isFinite // false\n ```" - ], - "signature": "let minMany: array => int" - }, - { - "id": "Core.Math.Int.max", - "kind": "value", - "name": "max", - "docstrings": [ - "`max(a, b)` returns the maximum of its two integer arguments.\n See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.max(1, 2) // 2\n Math.Int.max(-1, -2) // -1\n ```" - ], - "signature": "let max: (int, int) => int" - }, - { - "id": "Core.Math.Int.maxMany", - "kind": "value", - "name": "maxMany", - "docstrings": [ - "`maxMany(arr)` returns the maximum of the integers in the given array `arr`.\n Returns `Infinity` if `arr` is empty.\n See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.maxMany([1, 2]) // 2\n Math.Int.maxMany([-1, -2]) // -1\n Math.Int.maxMany([])->Int.toFloat->Float.isFinite // false\n ```" - ], - "signature": "let maxMany: array => int" - }, - { - "id": "Core.Math.Int.pow", - "kind": "value", - "name": "pow", - "docstrings": [ - "`pow(a, ~exp)` raises the given base `a` to the given exponent `exp`.\n See [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.pow(2, ~exp=4) // 16\n Math.Int.pow(3, ~exp=4) // 81\n ```" - ], - "signature": "let pow: (int, ~exp: int) => int" - }, - { - "id": "Core.Math.Int.sign", - "kind": "value", - "name": "sign", - "docstrings": [ - "`sign(v)` returns the sign of its integer argument: `-1` if negative, `0` if\n zero, `1` if positive.\n See [`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.sign(3) // 1\n Math.Int.sign(-3) // 1\n Math.Int.sign(0) // 0\n ```" - ], - "signature": "let sign: int => int" - }, - { - "id": "Core.Math.Int.floor", - "kind": "value", - "name": "floor", - "docstrings": [ - "floor(v) returns the largest `int` less than or equal to the argument; \n See [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)\n on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.floor(3.7) == 3\n Math.Int.floor(3.0) == 3\n Math.Int.floor(-3.1) == -4\n ```" - ], - "signature": "let floor: float => int" - }, - { - "id": "Core.Math.Int.ceil", - "kind": "value", - "name": "ceil", - "docstrings": [ - "ceil(v) returns the smallest `int` greater than or equal to the argument;\n See [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)\n on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.ceil(3.7) == 4\n Math.Int.ceil(3.0) == 3\n Math.Int.ceil(-3.1) == -3\n ```" - ], - "signature": "let ceil: float => int" - }, - { - "id": "Core.Math.Int.random", - "kind": "value", - "name": "random", - "docstrings": [ - "`random(minVal, maxVal)` returns a random integer number in the half-closed interval [minVal, maxVal).\n See [`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)\n on MDN.\n\n ## Examples\n\n ```rescript\n Math.Int.random(2, 5) == 4\n Math.Int.random(505, 2000) == 1276\n Math.Int.random(-7, -2) == -4\n ```" - ], - "signature": "let random: (int, int) => int" - } - ] - }, - "core/math/constants": { - "id": "Core.Math.Constants", - "name": "Constants", - "docstrings": ["Mathematical Constants"], - "items": [ - { - "id": "Core.Math.Constants.e", - "kind": "value", - "name": "e", - "docstrings": [ - "`Math.Constants.e` returns Euler's number, ≈ 2.718281828459045.\n See [`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.e\n ```" - ], - "signature": "let e: float" - }, - { - "id": "Core.Math.Constants.ln2", - "kind": "value", - "name": "ln2", - "docstrings": [ - "`Math.Constants.ln2` returns Natural logarithm of 2, ≈ 0.6931471805599453.\n See [`Math.LN2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.ln2\n ```" - ], - "signature": "let ln2: float" - }, - { - "id": "Core.Math.Constants.ln10", - "kind": "value", - "name": "ln10", - "docstrings": [ - "`Math.Constants.ln10` returns Natural logarithm of 10, ≈ 2.302585092994046.\n See [`Math.LN10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.ln10\n ```" - ], - "signature": "let ln10: float" - }, - { - "id": "Core.Math.Constants.log2e", - "kind": "value", - "name": "log2e", - "docstrings": [ - "`Math.Constants.log2e` returns Base 2 logarithm of E, ≈ 1.4426950408889634.\n See [`Math.LOG2E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.log2e\n ```" - ], - "signature": "let log2e: float" - }, - { - "id": "Core.Math.Constants.log10e", - "kind": "value", - "name": "log10e", - "docstrings": [ - "`Math.Constants.log10e` returns Base 10 logarithm of E, ≈ 0.4342944819032518.\n See [`Math.LOG10E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.log10e\n ```" - ], - "signature": "let log10e: float" - }, - { - "id": "Core.Math.Constants.pi", - "kind": "value", - "name": "pi", - "docstrings": [ - "`Math.Constants.pi` returns Pi - ratio of the circumference to the diameter\n of a circle, ≈ 3.141592653589793.\n See [`Math.PI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.pi\n ```" - ], - "signature": "let pi: float" - }, - { - "id": "Core.Math.Constants.sqrt1_2", - "kind": "value", - "name": "sqrt1_2", - "docstrings": [ - "`Math.Constants.sqrt1_2` returns Square root of 1/2, ≈ 0.7071067811865476.\n See [`Math.SQRT1_2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.sqrt1_2\n ```" - ], - "signature": "let sqrt1_2: float" - }, - { - "id": "Core.Math.Constants.sqrt2", - "kind": "value", - "name": "sqrt2", - "docstrings": [ - "`Math.Constants.e` returns Absolute value for integer argument.\n See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN.\n\n ## Examples\n\n ```rescript\n Math.Constants.sqrt2\n ```" - ], - "signature": "let sqrt2: float" - } - ] - }, - "core/int/constants": { - "id": "Core.Int.Constants", - "name": "Constants", - "docstrings": [], - "items": [ - { - "id": "Core.Int.Constants.minValue", - "kind": "value", - "name": "minValue", - "docstrings": [ - "The smallest positive number represented in JavaScript.\n See [`Number.MIN_VALUE`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)\n on MDN.\n\n ## Examples\n\n ```rescript\n Console.log(Int.Constants.minValue)\n ```" - ], - "signature": "let minValue: int" - }, - { - "id": "Core.Int.Constants.maxValue", - "kind": "value", - "name": "maxValue", - "docstrings": [ - "The largest positive number represented in JavaScript.\n See [`Number.MAX_VALUE`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)\n on MDN.\n\n ## Examples\n\n ```rescript\n Console.log(Int.Constants.maxValue)\n ```" - ], - "signature": "let maxValue: int" - } - ] - }, - "core/float/constants": { - "id": "Core.Float.Constants", - "name": "Constants", - "docstrings": ["Float constants."], - "items": [ - { - "id": "Core.Float.Constants.nan", - "kind": "value", - "name": "nan", - "docstrings": [ - "The special value \"Not a Number\"\n See [`NaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) on MDN.\n\n ## Examples\n\n ```rescript\n Float.Constants.nan\n ```" - ], - "signature": "let nan: float" - }, - { - "id": "Core.Float.Constants.epsilon", - "kind": "value", - "name": "epsilon", - "docstrings": [ - "Represents the difference between 1 and the smallest floating point number greater than 1.\n See [`Number.EPSILON`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON) on MDN.\n\n ## Examples\n\n ```rescript\n Float.Constants.epsilon\n ```" - ], - "signature": "let epsilon: float" - }, - { - "id": "Core.Float.Constants.positiveInfinity", - "kind": "value", - "name": "positiveInfinity", - "docstrings": [ - "The positive Infinity value\n See [`Number.POSITIVE_INFINITY`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY) on MDN.\n\n ## Examples\n\n ```rescript\n Float.Constants.positiveInfinity\n ```" - ], - "signature": "let positiveInfinity: float" - }, - { - "id": "Core.Float.Constants.negativeInfinity", - "kind": "value", - "name": "negativeInfinity", - "docstrings": [ - "The negative Infinity value\n See [`Number.NEGATIVE_INFINITY`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY) on MDN.\n\n ## Examples\n\n ```rescript\n Float.Constants.negativeInfinity\n ```" - ], - "signature": "let negativeInfinity: float" - }, - { - "id": "Core.Float.Constants.minValue", - "kind": "value", - "name": "minValue", - "docstrings": [ - "The smallest positive numeric value representable in JavaScript.\n See [`Number.MIN_VALUE`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE) on MDN.\n\n ## Examples\n\n ```rescript\n Float.Constants.minValue\n ```" - ], - "signature": "let minValue: float" - }, - { - "id": "Core.Float.Constants.maxValue", - "kind": "value", - "name": "maxValue", - "docstrings": [ - "The maximum positive numeric value representable in JavaScript.\n See [`Number.MAX_VALUE`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE) on MDN.\n\n ## Examples\n\n ```rescript\n Float.Constants.minValue\n ```" - ], - "signature": "let maxValue: float" - } - ] - }, - "core/error/urierror": { - "id": "Core.Error.URIError", - "name": "URIError", - "docstrings": [], - "items": [ - { - "id": "Core.Error.URIError.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new `URIError` with the provided `message`.\n\n See [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) on MDN." - ], - "signature": "let make: string => t" - } - ] - }, - "core/error/typeerror": { - "id": "Core.Error.TypeError", - "name": "TypeError", - "docstrings": [], - "items": [ - { - "id": "Core.Error.TypeError.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new `TypeError` with the provided `message`.\n\n See [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) on MDN." - ], - "signature": "let make: string => t" - } - ] - }, - "core/error/syntaxerror": { - "id": "Core.Error.SyntaxError", - "name": "SyntaxError", - "docstrings": [], - "items": [ - { - "id": "Core.Error.SyntaxError.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new `SyntaxError` with the provided `message`.\n\n See [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) on MDN." - ], - "signature": "let make: string => t" - } - ] - }, - "core/error/referenceerror": { - "id": "Core.Error.ReferenceError", - "name": "ReferenceError", - "docstrings": [], - "items": [ - { - "id": "Core.Error.ReferenceError.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new `ReferenceError` with the provided `message`.\n\n See [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) on MDN." - ], - "signature": "let make: string => t" - } - ] - }, - "core/error/rangeerror": { - "id": "Core.Error.RangeError", - "name": "RangeError", - "docstrings": [], - "items": [ - { - "id": "Core.Error.RangeError.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new `RangeError` with the provided `message`.\n\n See [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) on MDN." - ], - "signature": "let make: string => t" - } - ] - }, - "core/error/evalerror": { - "id": "Core.Error.EvalError", - "name": "EvalError", - "docstrings": [], - "items": [ - { - "id": "Core.Error.EvalError.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new `EvalError` with the provided `message`.\n\n See [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) on MDN." - ], - "signature": "let make: string => t" - } - ] - }, - "core/date/utc": { - "id": "Core.Date.UTC", - "name": "UTC", - "docstrings": [], - "items": [ - { - "id": "Core.Date.UTC.makeWithYM", - "kind": "value", - "name": "makeWithYM", - "docstrings": [ - "Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC).\n Be aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\n Months are 0-indexed (0 = January, 11 = December).\n Values, which are out of range, will be carried over to the next bigger unit (s. example).\n\n ## Examples\n ```rescript\n Date.UTC.makeWithYM(~year=2023, ~month=0)\n // 1672531200000\n\n Date.UTC.makeWithYM(~year=2023, ~month=11)\n // 1701388800000\n\n Date.UTC.makeWithYM(~year=2023, ~month=12)\n // 1704067200000\n\n Date.UTC.makeWithYM(~year=2023, ~month=-1)\n // 1669852800000\n ```" - ], - "signature": "let makeWithYM: (~year: int, ~month: int) => msSinceEpoch" - }, - { - "id": "Core.Date.UTC.makeWithYMD", - "kind": "value", - "name": "makeWithYMD", - "docstrings": [ - "Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC).\n Be aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\n Months are 0-indexed (0 = January, 11 = December).\n Values, which are out of range, will be carried over to the next bigger unit (s. example).\n\n ## Examples\n ```rescript\n Date.UTC.makeWithYMD(~year=2023, ~month=1, ~date=20)\n // 1676851200000\n\n Date.UTC.makeWithYMD(~year=2023, ~month=1, ~date=-1)\n // 1675036800000\n\n Date.UTC.makeWithYMD(~year=2023, ~month=1, ~date=29)\n // 1677628800000\n ```" - ], - "signature": "let makeWithYMD: (~year: int, ~month: int, ~date: int) => msSinceEpoch" - }, - { - "id": "Core.Date.UTC.makeWithYMDH", - "kind": "value", - "name": "makeWithYMDH", - "docstrings": [ - "Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC).\n Be aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\n Months are 0-indexed (0 = January, 11 = December).\n Values, which are out of range, will be carried over to the next bigger unit (s. example).\n\n ## Examples\n ```rescript\n Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=16)\n // 1676908800000\n\n Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=24)\n // 1676937600000\n\n Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=-1)\n // 1676847600000\n ```" - ], - "signature": "let makeWithYMDH: (\n ~year: int,\n ~month: int,\n ~date: int,\n ~hours: int,\n) => msSinceEpoch" - }, - { - "id": "Core.Date.UTC.makeWithYMDHM", - "kind": "value", - "name": "makeWithYMDHM", - "docstrings": [ - "Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC).\n Be aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\n Months are 0-indexed (0 = January, 11 = December).\n Values, which are out of range, will be carried over to the next bigger unit (s. example).\n\n ## Examples\n ```rescript\n Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40)\n // 1676911200000\n\n Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=60)\n // 1676912400000\n\n Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=-1)\n // 1676908740000\n ```" - ], - "signature": "let makeWithYMDHM: (\n ~year: int,\n ~month: int,\n ~date: int,\n ~hours: int,\n ~minutes: int,\n) => msSinceEpoch" - }, - { - "id": "Core.Date.UTC.makeWithYMDHMS", - "kind": "value", - "name": "makeWithYMDHMS", - "docstrings": [ - "Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC).\n Be aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\n Months are 0-indexed (0 = January, 11 = December).\n Values, which are out of range, will be carried over to the next bigger unit (s. example).\n\n ## Examples\n ```rescript\n Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0)\n // 1676911200000\n\n Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=60)\n // 1676911260000\n\n Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=-1)\n // 1676911199000\n ```" - ], - "signature": "let makeWithYMDHMS: (\n ~year: int,\n ~month: int,\n ~date: int,\n ~hours: int,\n ~minutes: int,\n ~seconds: int,\n) => msSinceEpoch" - }, - { - "id": "Core.Date.UTC.makeWithYMDHMSM", - "kind": "value", - "name": "makeWithYMDHMSM", - "docstrings": [ - "Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC).\n Be aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\n Months are 0-indexed (0 = January, 11 = December).\n Values, which are out of range, will be carried over to the next bigger unit (s. example).\n\n ## Examples\n ```rescript\n Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=0)->Console.log\n // 1676911200000\n\n Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=1000)->Console.log\n // 1676911201000\n\n Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=-1)->Console.log\n // 1676911199999\n ```" - ], - "signature": "let makeWithYMDHMSM: (\n ~year: int,\n ~month: int,\n ~date: int,\n ~hours: int,\n ~minutes: int,\n ~seconds: int,\n ~milliseconds: int,\n) => msSinceEpoch" - } - ] - }, - "core/result": { - "id": "Core.Result", - "name": "Result", - "docstrings": [], - "items": [ - { - "id": "Core.Result.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "Result types are really useful to describe the result of a certain operation\n without relying on exceptions or `option` types.\n\n This module gives you useful utilities to create and combine `Result` data." - ], - "signature": "let getExn: result<'a, 'b> => 'a" - }, - { - "id": "Core.Result.mapOr", - "kind": "value", - "name": "mapOr", - "docstrings": [ - "`mapOr(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, otherwise `default`.\n\n## Examples\n\n```rescript\nlet ok = Ok(42)\nResult.mapOr(ok, 0, (x) => x / 2) == 21\n\nlet error = Error(\"Invalid data\")\nResult.mapOr(error, 0, (x) => x / 2) == 0\n```" - ], - "signature": "let mapOr: (result<'a, 'c>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Core.Result.mapWithDefault", - "kind": "value", - "name": "mapWithDefault", - "docstrings": [], - "signature": "let mapWithDefault: (result<'a, 'c>, 'b, 'a => 'b) => 'b", - "deprecated": "Use mapOr instead" - }, - { - "id": "Core.Result.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns an\nordinary value.\n\n## Examples\n\n```rescript\nlet f = (x) => sqrt(Int.toFloat(x))\n\nResult.map(Ok(64), f) == Ok(8.0)\n\nResult.map(Error(\"Invalid data\"), f) == Error(\"Invalid data\")\n```" - ], - "signature": "let map: (result<'a, 'c>, 'a => 'b) => result<'b, 'c>" - }, - { - "id": "Core.Result.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "`flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns a\n`Result`.\n\n## Examples\n\n```rescript\nlet recip = (x) =>\n if (x !== 0.0) {\n Ok(1.0 /. x)\n } else {\n Error(\"Divide by zero\")\n }\n\nResult.flatMap(Ok(2.0), recip) == Ok(0.5)\n\nResult.flatMap(Ok(0.0), recip) == Error(\"Divide by zero\")\n\nResult.flatMap(Error(\"Already bad\"), recip) == Error(\"Already bad\")\n```" - ], - "signature": "let flatMap: (result<'a, 'c>, 'a => result<'b, 'c>) => result<'b, 'c>" - }, - { - "id": "Core.Result.getOr", - "kind": "value", - "name": "getOr", - "docstrings": [ - "`getOr(res, defaultValue)`: If `res` is `Ok(n)`, returns `n`, otherwise `default`\n\n## Examples\n\n```rescript\nResult.getOr(Ok(42), 0) == 42\n\nResult.getOr(Error(\"Invalid Data\"), 0) == 0\n```" - ], - "signature": "let getOr: (result<'a, 'b>, 'a) => 'a" - }, - { - "id": "Core.Result.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (result<'a, 'b>, 'a) => 'a", - "deprecated": "Use getOr instead" - }, - { - "id": "Core.Result.isOk", - "kind": "value", - "name": "isOk", - "docstrings": [ - "`isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is the `Error(e)` variant." - ], - "signature": "let isOk: result<'a, 'b> => bool" - }, - { - "id": "Core.Result.isError", - "kind": "value", - "name": "isError", - "docstrings": [ - "`isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if it is the `Ok(n)` variant." - ], - "signature": "let isError: result<'a, 'b> => bool" - }, - { - "id": "Core.Result.equal", - "kind": "value", - "name": "equal", - "docstrings": [ - "`equal(res1, res2, f)`: Determine if two `Result` variables are equal with\nrespect to an equality function. If `res1` and `res2` are of the form `Ok(n)`\nand `Ok(m)`, return the result of `f(n, m)`. If one of `res1` and `res2` are of\nthe form `Error(e)`, return false If both `res1` and `res2` are of the form\n`Error(e)`, return true\n\n## Examples\n\n```rescript\nlet good1 = Ok(42)\n\nlet good2 = Ok(32)\n\nlet bad1 = Error(\"invalid\")\n\nlet bad2 = Error(\"really invalid\")\n\nlet mod10equal = (a, b) => mod(a, 10) === mod(b, 10)\n\nResult.equal(good1, good2, mod10equal) == true\n\nResult.equal(good1, bad1, mod10equal) == false\n\nResult.equal(bad2, good2, mod10equal) == false\n\nResult.equal(bad1, bad2, mod10equal) == true\n```" - ], - "signature": "let equal: (result<'a, 'c>, result<'b, 'd>, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.Result.compare", - "kind": "value", - "name": "compare", - "docstrings": [ - "`compare(res1, res2, f)`: Compare two `Result` variables with respect to a\ncomparison function. The comparison function returns -1. if the first variable\nis \"less than\" the second, 0. if the two variables are equal, and 1. if the first\nis \"greater than\" the second.\n\nIf `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of\n`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`,\nreturn -1. (nothing is less than something) If `res1` is of the form `Ok(n)` and\n`res2` of the form `Error(e)`, return 1. (something is greater than nothing) If\nboth `res1` and `res2` are of the form `Error(e)`, return 0. (equal)\n\n## Examples\n\n```rescript\nlet good1 = Ok(59)\n\nlet good2 = Ok(37)\n\nlet bad1 = Error(\"invalid\")\n\nlet bad2 = Error(\"really invalid\")\n\nlet mod10cmp = (a, b) => Int.compare(mod(a, 10), mod(b, 10))\n\nResult.compare(Ok(39), Ok(57), mod10cmp) == 1.\n\nResult.compare(Ok(57), Ok(39), mod10cmp) == (-1.)\n\nResult.compare(Ok(39), Error(\"y\"), mod10cmp) == 1.\n\nResult.compare(Error(\"x\"), Ok(57), mod10cmp) == (-1.)\n\nResult.compare(Error(\"x\"), Error(\"y\"), mod10cmp) == 0.\n```" - ], - "signature": "let compare: (\n result<'a, 'c>,\n result<'b, 'd>,\n ('a, 'b) => Core__Ordering.t,\n) => Core__Ordering.t" - }, - { - "id": "Core.Result.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(res, f)` runs the provided function `f` on the `Ok` value. If `res` is `Error`, nothing happens.\n\n## Examples\n\n```rescript\nResult.forEach(Ok(3), Console.log) // Logs \"3\", returns ()\nResult.forEach(Error(\"x\"), Console.log) // Does nothing, returns ()\n```" - ], - "signature": "let forEach: (result<'a, 'b>, 'a => unit) => unit" - }, - { - "id": "Core.Result.mapError", - "kind": "value", - "name": "mapError", - "docstrings": [ - "`mapError(r, f)` generates a new `result` by applying the function `f` to the `Error` value. If the source is `Ok`, return it as-is.\n\n## Examples\n\n```rescript\nlet format = n => `Error code: ${n->Int.toString}`\nResult.mapError(Error(14), format) // Error(\"Error code: 14\")\nResult.mapError(Ok(\"abc\"), format) // Ok(\"abc\")\n```" - ], - "signature": "let mapError: (result<'a, 'b>, 'b => 'c) => result<'a, 'c>" - } - ] - }, - "core/list": { - "id": "Core.List", - "name": "List", - "docstrings": [], - "items": [ - { - "id": "Core.List.t", - "kind": "type", - "name": "t", - "docstrings": [ - "Collection functions for manipulating the `list` data structures, a singly-linked list.\n\n**Prefer Array** if you need any of the following:\n\n- Random access of element\n- Better interop with JavaScript\n- Better memory usage & performance." - ], - "signature": "type t<'a> = list<'a>" - }, - { - "id": "Core.List.length", - "kind": "value", - "name": "length", - "docstrings": [ - "`length(list)` returns the length of `list`.\n\n## Examples\n\n```rescript\nList.length(list{1, 2, 3}) // 3\n```" - ], - "signature": "let length: t<'a> => int" - }, - { - "id": "Core.List.size", - "kind": "value", - "name": "size", - "docstrings": [ - "`size(list)`. See [`length`](#length)\n\n## Examples\n\n```rescript\nList.size(list{1, 2, 3}) // 3\n```" - ], - "signature": "let size: t<'a> => int" - }, - { - "id": "Core.List.head", - "kind": "value", - "name": "head", - "docstrings": [ - "`head(list)` returns `Some(value)` where `value` is the first element in the\nlist, or `None` if `list` is an empty list.\n\n## Examples\n\n```rescript\nList.head(list{}) // None\nList.head(list{1, 2, 3}) // Some(1)\n```" - ], - "signature": "let head: t<'a> => option<'a>" - }, - { - "id": "Core.List.headExn", - "kind": "value", - "name": "headExn", - "docstrings": [ - "`headExn(list)` same as [`head`](#head).\n\n## Examples\n\n```rescript\nList.headExn(list{1, 2, 3}) // 1\n\nList.headExn(list{}) // Raises an Error\n```\n\n## Exceptions\n\n- Raises an Error if list is empty." - ], - "signature": "let headExn: t<'a> => 'a" - }, - { - "id": "Core.List.tail", - "kind": "value", - "name": "tail", - "docstrings": [ - "`tail(list)` returns `None` if `list` is empty, otherwise it returns `Some(tail)`\nwhere `tail` is everything except the first element of `list`.\n\n## Examples\n\n```rescript\nList.tail(list{1, 2, 3}) // Some(list{2, 3})\n\nList.tail(list{}) // None\n```" - ], - "signature": "let tail: t<'a> => option>" - }, - { - "id": "Core.List.tailExn", - "kind": "value", - "name": "tailExn", - "docstrings": [ - "`tailExn(list)` same as [`tail`](#tail).\n\n## Examples\n\n```rescript\nList.tailExn(list{1, 2, 3}) // list{2, 3}\n\nList.tailExn(list{}) // Raises an Error\n```\n\n## Exceptions\n\n- Raises an Error if list is empty." - ], - "signature": "let tailExn: t<'a> => t<'a>" - }, - { - "id": "Core.List.add", - "kind": "value", - "name": "add", - "docstrings": [ - "`add(list, value)` adds a `value` to the beginning of list `list`.\n\n## Examples\n\n```rescript\nList.add(list{2, 3}, 1) // list{1, 2, 3}\n\nList.add(list{\"World\", \"!\"}, \"Hello\") // list{\"Hello\", \"World\", \"!\"}\n```" - ], - "signature": "let add: (t<'a>, 'a) => t<'a>" - }, - { - "id": "Core.List.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`get(list, index)` return the `index` element in `list`, or `None` if `index`\nis larger than the length of list `list`.\n\n## Examples\n\n```rescript\nlet abc = list{\"A\", \"B\", \"C\"}\n\nabc->List.get(1) // Some(\"B\")\n\nabc->List.get(4) // None\n```" - ], - "signature": "let get: (t<'a>, int) => option<'a>" - }, - { - "id": "Core.List.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "`getExn(list, index)` same as [`get`](#get).\n\n## Examples\n\n```rescript\nlet abc = list{\"A\", \"B\", \"C\"}\n\nabc->List.getExn(1) // \"B\"\n\nabc->List.getExn(4) // Raises an Error\n```\n\n## Exceptions\n\n- Raises an Error if `index` is larger than the length of list." - ], - "signature": "let getExn: (t<'a>, int) => 'a" - }, - { - "id": "Core.List.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(length, value)` returns a list of length `length` with each element filled\nwith `value`. Returns an empty list if `value` is negative.\n\n## Examples\n\n```rescript\nList.make(~length=3, 1) // list{1, 1, 1}\n```" - ], - "signature": "let make: (~length: int, 'a) => t<'a>" - }, - { - "id": "Core.List.fromInitializer", - "kind": "value", - "name": "fromInitializer", - "docstrings": [ - "`makeBy(length, f)` return a list of length `length` with element initialized\nwith `f`. Returns an empty list if `length` is negative.\n\n## Examples\n\n```rescript\nList.fromInitializer(~length=5, i => i) // list{0, 1, 2, 3, 4}\n\nList.fromInitializer(~length=5, i => i * i) // list{0, 1, 4, 9, 16}\n```" - ], - "signature": "let fromInitializer: (~length: int, int => 'a) => t<'a>" - }, - { - "id": "Core.List.toShuffled", - "kind": "value", - "name": "toShuffled", - "docstrings": [ - "`toShuffled(list)` returns a new list in random order.\n\n## Examples\n\n```rescript\nList.toShuffled(list{1, 2, 3}) // list{2, 1, 3}\n```" - ], - "signature": "let toShuffled: t<'a> => t<'a>" - }, - { - "id": "Core.List.drop", - "kind": "value", - "name": "drop", - "docstrings": [ - "`drop(list, value)` return a new list, dropping the first `value` element.\nReturns `None` if `list` has fewer than `value` elements.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->List.drop(2) // Some(list{3})\n\nlist{1, 2, 3}->List.drop(3) // Some(list{})\n\nlist{1, 2, 3}->List.drop(4) // None\n```" - ], - "signature": "let drop: (t<'a>, int) => option>" - }, - { - "id": "Core.List.take", - "kind": "value", - "name": "take", - "docstrings": [ - "`take(list, value)` returns a list with the first `value` elements from `list`,\nor `None` if `list` has fewer than `value` elements.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->List.take(1) // Some(list{1})\n\nlist{1, 2, 3}->List.take(2) // Some(list{1, 2})\n\nlist{1, 2, 3}->List.take(4) // None\n```" - ], - "signature": "let take: (t<'a>, int) => option>" - }, - { - "id": "Core.List.splitAt", - "kind": "value", - "name": "splitAt", - "docstrings": [ - "`splitAt(list, n)` split the list `list` at `n`. Returns `None` when the length\nof `list` is less than `n`.\n\n## Examples\n\n```rescript\nlist{\"Hello\", \"World\"}->List.splitAt(1) // Some((list{\"Hello\"}, list{\"World\"}))\n\nlist{0, 1, 2, 3, 4}->List.splitAt(2) // Some((list{0, 1}, list{2, 3, 4}))\n```" - ], - "signature": "let splitAt: (t<'a>, int) => option<(list<'a>, list<'a>)>" - }, - { - "id": "Core.List.concat", - "kind": "value", - "name": "concat", - "docstrings": [ - "`concat(list1, list2)` returns the list obtained by adding `list1` after `list2`.\n\n## Examples\n\n```rescript\nList.concat(list{1, 2, 3}, list{4, 5}) // list{1, 2, 3, 4, 5}\n```" - ], - "signature": "let concat: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Core.List.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [ - "`concatMany(arr)` returns the list obtained by concatenating all the lists in\narray `arr`, in order.\n\n## Examples\n\n```rescript\nList.concatMany([list{1, 2, 3}, list{}, list{3}]) // list{1, 2, 3, 3}\n```" - ], - "signature": "let concatMany: array> => t<'a>" - }, - { - "id": "Core.List.reverseConcat", - "kind": "value", - "name": "reverseConcat", - "docstrings": [ - "`reverseConcat(list1, list2)` is equivalent to writing: `concat(reverse(list1, list2)`\n\n## Examples\n\n```rescript\nList.reverseConcat(list{1, 2}, list{3, 4}) // list{2, 1, 3, 4}\n```" - ], - "signature": "let reverseConcat: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Core.List.flat", - "kind": "value", - "name": "flat", - "docstrings": [ - "`flat(list)` return the list obtained by concatenating all the lists in\n`list`, in order.\n\n## Examples\n\n```rescript\nList.flat(list{list{1, 2, 3}, list{}, list{3}}) // list{1, 2, 3, 3}\n```" - ], - "signature": "let flat: t> => t<'a>" - }, - { - "id": "Core.List.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(list, f)` returns a new list with `f` applied to each element of `list`.\n\n## Examples\n\n```rescript\nlist{1, 2}->List.map(x => x + 1) // list{3, 4}\n```" - ], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Core.List.zip", - "kind": "value", - "name": "zip", - "docstrings": [ - "`zip(list1, list2)` returns a list of pairs from the two lists with the length\nof the shorter list.\n\n## Examples\n\n```rescript\nList.zip(list{1, 2}, list{3, 4, 5}) // list{(1, 3), (2, 4)}\n```" - ], - "signature": "let zip: (t<'a>, t<'b>) => t<('a, 'b)>" - }, - { - "id": "Core.List.zipBy", - "kind": "value", - "name": "zipBy", - "docstrings": [ - "`zipBy(list1, list2, f)`. See [`zip`](#zip)\n\n## Examples\n\n```rescript\nList.zipBy(list{1, 2, 3}, list{4, 5}, (a, b) => 2 * a + b) // list{6, 9}\n```" - ], - "signature": "let zipBy: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c>" - }, - { - "id": "Core.List.mapWithIndex", - "kind": "value", - "name": "mapWithIndex", - "docstrings": [ - "`mapWithIndex(list, f)` applies `f` to each element of `list`. Function `f`\ntakes two arguments: the index starting from 0 and the element from `list`, in\nthat order.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->List.mapWithIndex((x, index) => index + x) // list{1, 3, 5}\n```" - ], - "signature": "let mapWithIndex: (t<'a>, ('a, int) => 'b) => t<'b>" - }, - { - "id": "Core.List.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray(arr)` converts the given array `arr` to a list.\n\n## Examples\n\n```rescript\nList.fromArray([1, 2, 3]) // list{1, 2, 3}\n```" - ], - "signature": "let fromArray: array<'a> => t<'a>" - }, - { - "id": "Core.List.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "`toArray(list)` converts the given list `list` to an array.\n\n## Examples\n\n```rescript\nList.toArray(list{1, 2, 3}) // [1, 2, 3]\n```" - ], - "signature": "let toArray: t<'a> => array<'a>" - }, - { - "id": "Core.List.reverse", - "kind": "value", - "name": "reverse", - "docstrings": [ - "`reverse(list)` returns a new list whose elements are those of `list` in\nreversed order.\n\n## Examples\n\n```rescript\nList.reverse(list{1, 2, 3}) // list{3, 2, 1}\n```" - ], - "signature": "let reverse: t<'a> => t<'a>" - }, - { - "id": "Core.List.mapReverse", - "kind": "value", - "name": "mapReverse", - "docstrings": [ - "`mapReverse(list, f)` is equivalent to `map` function.\n\n## Examples\n\n```rescript\nlet f = x => x * x\nlet l = list{3, 4, 5}\n\nlet withMap = List.map(l, f)->List.reverse\nlet withMapReverse = l->List.mapReverse(f)\n\nConsole.log(withMap == withMapReverse) // true\n```" - ], - "signature": "let mapReverse: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Core.List.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(list, f)` call `f` on each element of `list` from the beginning to end.\n`f` returns `unit`, so no new array is created. Use `forEach` when you are primarily\nconcerned with repetitively creating side effects.\n\n## Examples\n\n```rescript\nList.forEach(list{\"a\", \"b\", \"c\"}, x => Console.log(\"Item: \" ++ x))\n/*\n prints:\n Item: a\n Item: b\n Item: c\n*/\n```" - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Core.List.forEachWithIndex", - "kind": "value", - "name": "forEachWithIndex", - "docstrings": [ - "`forEachWithIndex(list, f, index)` call `f` on each element of `list` from beginning\nto end. Function `f` takes two arguments: the `index` starting from 0 and the\nelement from `list`. `f` returns `unit`.\n\n## Examples\n\n```rescript\nList.forEachWithIndex(list{\"a\", \"b\", \"c\"}, (x, index) => {\n Console.log(\"Item \" ++ Int.toString(index) ++ \" is \" ++ x)\n})\n/*\n prints:\n Item 0 is a\n Item 1 is b\n Item 2 is cc\n*/\n```" - ], - "signature": "let forEachWithIndex: (t<'a>, ('a, int) => unit) => unit" - }, - { - "id": "Core.List.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(list, initialValue, f)` applies `f` to each element of `list` from\nbeginning to end. Function `f` has two parameters: the item from the list and\nan \"accumulator\", which starts with a value of `initialValue`. `reduce` returns\nthe final value of the accumulator.\n\n## Examples\n\n```rescript\nlist{1, 2, 3, 4}->List.reduce(0, (a, b) => a + b) // 10\n\n// same as\n\nlist{1, 2, 3, 4}->List.reduce(0, (acc, item) => acc + item) // 10\n```" - ], - "signature": "let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Core.List.reduceWithIndex", - "kind": "value", - "name": "reduceWithIndex", - "docstrings": [ - "`reduceWithIndex(list, initialValue, f)` applies `f` to each element of `list`\nfrom beginning to end. Function `f` has three parameters: the item from the list\nand an \"accumulator\", which starts with a value of `initialValue` and the index\nof each element. `reduceWithIndex` returns the final value of the accumulator.\n\n## Examples\n\n```rescript\nlist{1, 2, 3, 4}->List.reduceWithIndex(0, (acc, item, index) => acc + item + index) // 16\n```" - ], - "signature": "let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b" - }, - { - "id": "Core.List.reduceReverse", - "kind": "value", - "name": "reduceReverse", - "docstrings": [ - "`reduceReverse(list, initialValue, f)` works like `reduce`, except that\nfunction `f` is applied to each item of `list` from the last back to the first.\n\n## Examples\n\n```rescript\nlist{1, 2, 3, 4}->List.reduceReverse(0, (a, b) => a + b) // 10\n\nlist{1, 2, 3, 4}->List.reduceReverse(10, (a, b) => a - b) // 0\n\nlist{1, 2, 3, 4}->List.reduceReverse(list{}, List.add) // list{1, 2, 3, 4}\n```" - ], - "signature": "let reduceReverse: (t<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Core.List.mapReverse2", - "kind": "value", - "name": "mapReverse2", - "docstrings": [ - "`mapReverse2(list1, list2, f)` is equivalent to `List.zipBy(list1, list2, f)->List.reverse`.\n\n## Examples\n\n```rescript\nList.mapReverse2(list{1, 2, 3}, list{1, 2}, (a, b) => a + b) // list{4, 2}\n```" - ], - "signature": "let mapReverse2: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c>" - }, - { - "id": "Core.List.forEach2", - "kind": "value", - "name": "forEach2", - "docstrings": [ - "`forEach2(list1, list2, f)` is similar to `forEach`, but accepts two lists and\nstops at the length of the shorter list.\n\n## Examples\n\n```rescript\nList.forEach2(list{\"Z\", \"Y\"}, list{\"A\", \"B\", \"C\"}, (x, y) => Console.log2(x, y))\n\n/*\n prints:\n \"Z\" \"A\"\n \"Y\" \"B\"\n*/\n```" - ], - "signature": "let forEach2: (t<'a>, t<'b>, ('a, 'b) => 'c) => unit" - }, - { - "id": "Core.List.reduce2", - "kind": "value", - "name": "reduce2", - "docstrings": [ - "`reduce2(list1, list2, initialValue, f)` applies `f` to each element of `list1`\nand `list2` from beginning to end. Stops with the shorter list. Function `f` has\nthree parameters: an accumulator which starts with a value of `initialValue`, an\nitem from `l1`, and an item from `l2`. `reduce2` returns the final value of the\naccumulator.\n\n## Examples\n\n```rescript\nList.reduce2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) // 0 + (1 * 1 + 4) + (2 * 2 + 5)\n```" - ], - "signature": "let reduce2: (t<'b>, t<'c>, 'a, ('a, 'b, 'c) => 'a) => 'a" - }, - { - "id": "Core.List.reduceReverse2", - "kind": "value", - "name": "reduceReverse2", - "docstrings": [ - "`reduceReverse2(list1, list2, initialValue, f)` applies `f` to each element of\n`list1` and `list2`from end to beginning. Stops with the shorter list. Function\n`f` has three parameters: an accumulator which starts with a value of\n`initialValue`, an item from `l1`, and an item from `l2`. `reduce2` returns the\nfinal value of the accumulator.\n\n## Examples\n\n```rescript\nList.reduceReverse2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) // + (1 * 1 + 4) + (2 * 2 + 5)\n```" - ], - "signature": "let reduceReverse2: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c" - }, - { - "id": "Core.List.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(list, f)` returns `true` if all elements in `list` satisfy `f`, where `f`\nis a predicate: a function taking an element and returning a bool.\n\n## Examples\n\n```rescript\nlet isBelow10 = value => value < 10\n\nlist{1, 9, 8, 2}->List.every(isBelow10) // true\n\nlist{1, 99, 8, 2}->List.every(isBelow10) // false\n```" - ], - "signature": "let every: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Core.List.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(list, f)` returns `true` if at least _one_ of the elements in `list`\nsatisfies `f`, where `f` is a predicate: a function taking an element and\nreturning a bool.\n\n## Examples\n\n```rescript\nlet isAbove100 = value => value > 100\n\nlist{101, 1, 2, 3}->List.some(isAbove100) // true\n\nlist{1, 2, 3, 4}->List.some(isAbove100) // false\n```" - ], - "signature": "let some: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Core.List.every2", - "kind": "value", - "name": "every2", - "docstrings": [ - "`every2(list1, list2, f)` returns `true` if predicate `f` is `true` for all\npairs of elements up to the shorter length (i.e. `min(length(list1), length(list2))`)\n\n## Examples\n\n```rescript\nList.every2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) // true\n\nList.every2(list{}, list{1}, (a, b) => a > b) // true\n\nList.every2(list{2, 3}, list{1}, (a, b) => a > b) // true\n\nList.every2(list{0, 1}, list{5, 0}, (a, b) => a > b) // false\n```" - ], - "signature": "let every2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.List.some2", - "kind": "value", - "name": "some2", - "docstrings": [ - "`some2(list1, list2, f)` returns `true` if predicate `f` is `true` for any pair\nof elements up to the shorter length (i.e. `min(length(list1), length(list2))`)\n\n## Examples\n\n```rescript\nList.some2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) // true\n\nList.some2(list{}, list{1}, (a, b) => a > b) // false\n\nList.some2(list{2, 3}, list{1}, (a, b) => a > b) // true\n\nList.some2(list{0, 1}, list{5, 0}, (a, b) => a > b) // true\n```" - ], - "signature": "let some2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.List.compareLength", - "kind": "value", - "name": "compareLength", - "docstrings": [ - "`compareLength(list1, list2)` compare two lists solely by length. Returns `-1.` if\n`length(list1)` is less than `length(list2)`, `0.` if `length(list1)` equals\n`length(list2)`, and `1.` if `length(list1)` is greater than `length(list2)`.\n\n## Examples\n\n```rescript\nList.compareLength(list{1, 2}, list{3, 4, 5, 6}) // -1.\n\nList.compareLength(list{1, 2, 3}, list{4, 5, 6}) // 0.\n\nList.compareLength(list{1, 2, 3, 4}, list{5, 6}) // 1.\n```" - ], - "signature": "let compareLength: (t<'a>, t<'a>) => Core__Ordering.t" - }, - { - "id": "Core.List.compare", - "kind": "value", - "name": "compare", - "docstrings": [ - "`compare(list1, list2, f)` compare elements one by one `f`. `f` returns a negative\nnumber if `list1` is \"less than\" `list2`, zero if `list1` is \"equal to\" `list2`,\na positive number if `list1` is \"greater than\" `list2`.\n\nThe comparison returns the first non-zero result of `f`, or zero if `f` returns\nzero for all `list1` and `list2`.\n\n- If all items have compared equal, but `list1` is exhausted first, return `-1.`. (`list1` is shorter).\n- If all items have compared equal, but `list2` is exhausted first, return `1.` (`list1` is longer).\n\n## Examples\n\n```rescript\nList.compare(list{3}, list{3, 7}, (a, b) => Int.compare(a, b)) // -1.\nList.compare(list{5, 3}, list{5}, (a, b) => Int.compare(a, b)) // 1.\nList.compare(list{1, 3, 5}, list{1, 4, 2}, (a, b) => Int.compare(a, b)) // -1.\nList.compare(list{1, 3, 5}, list{1, 2, 3}, (a, b) => Int.compare(a, b)) // 1.\nList.compare(list{1, 3, 5}, list{1, 3, 5}, (a, b) => Int.compare(a, b)) // 0.\n```\n\n**Please note:** The total ordering of List is different from Array,\nfor Array, we compare the length first and, only if the lengths are equal, elements one by one.\nFor lists, we just compare elements one by one." - ], - "signature": "let compare: (\n t<'a>,\n t<'a>,\n ('a, 'a) => Core__Ordering.t,\n) => Core__Ordering.t" - }, - { - "id": "Core.List.equal", - "kind": "value", - "name": "equal", - "docstrings": [ - "`equal(list1, list2, f)` check equality of `list2` and `list2` using `f` for\nequality on elements, where `f` is a function that returns `true` if items `x` and\n`y` meet some criterion for equality, `false` otherwise. equal `false` if length\nof `list1` and `list2` are not the same.\n\n## Examples\n\n```rescript\nList.equal(list{1, 2, 3}, list{1, 2}, (a, b) => a == b) // false\n\nList.equal(list{1, 2}, list{1, 2}, (a, b) => a == b) // true\n\nList.equal(list{1, 2, 3}, list{(-1), (-2), (-3)}, (a, b) => abs(a) == abs(b)) // true\n```" - ], - "signature": "let equal: (t<'a>, t<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Core.List.has", - "kind": "value", - "name": "has", - "docstrings": [ - "`has(list, element, f)` returns `true` if the list contains at least one\n`element` for which `f` returns `true'.\n\n## Examples\n\n```rescript\nlist{1, 2, 3}->List.has(2, (a, b) => a == b) // true\n\nlist{1, 2, 3}->List.has(4, (a, b) => a == b) // false\n\nlist{(-1), (-2), (-3)}->List.has(2, (a, b) => abs(a) == abs(b)) // true\n```" - ], - "signature": "let has: (t<'a>, 'b, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.List.find", - "kind": "value", - "name": "find", - "docstrings": [ - "`find(list, f)` returns `Some(value)` for the first value in `list` that\nsatisfies the predicate function `f`. Returns `None` if no element satisfies\nthe function.\n\n## Examples\n\n```rescript\nList.find(list{1, 4, 3, 2}, x => x > 3) // Some(4)\n\nList.find(list{1, 4, 3, 2}, x => x > 4) // None\n```" - ], - "signature": "let find: (t<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Core.List.filter", - "kind": "value", - "name": "filter", - "docstrings": [ - "`filter(list, f)` returns a list of all elements in `list` which satisfy the\npredicate function `f`.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nList.filter(list{1, 2, 3, 4}, isEven) // list{2, 4}\n\nList.filter(list{None, Some(2), Some(3), None}, Option.isSome) // list{Some(2), Some(3)}\n```" - ], - "signature": "let filter: (t<'a>, 'a => bool) => t<'a>" - }, - { - "id": "Core.List.filterWithIndex", - "kind": "value", - "name": "filterWithIndex", - "docstrings": [ - "`filterWithIndex(list, f)` returns a list of all elements in `list` which\nsatisfy the predicate function `f`.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nList.filterWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) // list{1, 3}\n```" - ], - "signature": "let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a>" - }, - { - "id": "Core.List.filterMap", - "kind": "value", - "name": "filterMap", - "docstrings": [ - "`filterMap(list, f)` applies `f` to each element of `list`. If `f` returns\n`Some(value)`, then `value` is _kept_ in the resulting list. If `f` returns\n`None`, the element is _not_ retained in the result.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nlist{1, 2, 3, 4}\n->List.filterMap(x =>\n if (isEven(x)) {\n Some(x)\n } else {\n None\n }\n ) // list{2, 4}\n\nlist{Some(1), Some(2), None}->List.filterMap(x => x) // list{1, 2}\n```" - ], - "signature": "let filterMap: (t<'a>, 'a => option<'b>) => t<'b>" - }, - { - "id": "Core.List.partition", - "kind": "value", - "name": "partition", - "docstrings": [ - "`partition(list, f)` creates a pair of lists; the first list consists of all\nelements of `list` that satisfy the predicate function `f`, the second list\nconsists of all elements of `list` that _do not_ satisfy `f`.\n\n## Examples\n\n```rescript\n// (elementsThatSatisfies, elementsThatDoesNotSatisfy)\n\nList.partition(list{1, 2, 3, 4}, x => x > 2) // (list{3, 4}, list{1, 2})\n```" - ], - "signature": "let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>)" - }, - { - "id": "Core.List.unzip", - "kind": "value", - "name": "unzip", - "docstrings": [ - "`unzip(list)` takes a list of pairs and creates a pair of lists. The first list\ncontains all the first items of the pairs, the second list contains all the\nsecond items.\n\n## Examples\n\n```rescript\nList.unzip(list{(1, 2), (3, 4)}) // (list{1, 3}, list{2, 4})\n\nList.unzip(list{(\"H\", \"W\"), (\"e\", \"o\"), (\"l\", \"r\"), (\"l\", \"l\"), (\"o\", \"d\"), (\" \", \"!\")})\n// (list{\"H\", \"e\", \"l\", \"l\", \"o\", \" \"}, list{\"W\", \"o\", \"r\", \"l\", \"d\", \"!\"})\n```" - ], - "signature": "let unzip: t<('a, 'b)> => (t<'a>, t<'b>)" - }, - { - "id": "Core.List.getAssoc", - "kind": "value", - "name": "getAssoc", - "docstrings": [ - "`getAssoc(list, k, f)` return the second element of a pair in `list` where\nthe first element equals `k` as per the predicate function `f`, or `None` if\nnot found.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->List.getAssoc(3, (a, b) => a == b) // Some(\"c\")\n\nlist{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")}\n->List.getAssoc(15, (k, item) => k /* 15 */ == item /* 9, 5, 22 */)\n// Some(\"afternoon\")\n```" - ], - "signature": "let getAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c>" - }, - { - "id": "Core.List.hasAssoc", - "kind": "value", - "name": "hasAssoc", - "docstrings": [ - "`hasAssoc(list, k, f)` returns `true` if there is a pair in `list` where the\nfirst element equals `k` as per the predicate function `f`.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->List.hasAssoc(1, (a, b) => a == b) // true\n\nlist{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")}\n->List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */) // false\n```" - ], - "signature": "let hasAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.List.removeAssoc", - "kind": "value", - "name": "removeAssoc", - "docstrings": [ - "`removeAssoc(list, k, f)` return a list after removing the first pair whose\nfirst value is `k` per the equality predicate `f`, if not found, return a new\nlist identical to `list`.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->List.removeAssoc(1, (a, b) => a == b) // list{(2, \"b\"), (3, \"c\")}\n\nlist{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")}\n->List.removeAssoc(9, (k, item) => k /* 9 */ == item /* 9, 5, 22 */)\n// list{(15, \"afternoon\"), (22, \"night\")}\n```" - ], - "signature": "let removeAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => t<('a, 'c)>" - }, - { - "id": "Core.List.setAssoc", - "kind": "value", - "name": "setAssoc", - "docstrings": [ - "`setAssoc(list, k, v, f)`. If `k` exists in `list` by satisfying the `f`\npredicate, return a new list with the key and value replaced by the new `k` and\n`v`, otherwise, return a new list with the pair `k`, `v` added to the head of\n`list`.\n\n## Examples\n\n```rescript\nlist{(1, \"a\"), (2, \"b\"), (3, \"c\")}->List.setAssoc(2, \"x\", (a, b) => a == b) // list{(1, \"a\"), (2, \"x\"), (3, \"c\")}\n\nlist{(1, \"a\"), (3, \"c\")}->List.setAssoc(2, \"b\", (a, b) => a == b) // list{(2, \"b\"), (1, \"a\"), (3, \"c\")}\n\nlist{(9, \"morning\"), (3, \"morning?!\"), (22, \"night\")}\n->List.setAssoc(15, \"afternoon\", (a, b) => mod(a, 12) == mod(b, 12))\n// list{(9, \"morning\"), (15, \"afternoon\"), (22, \"night\")}\n```\n\n**Please note**: In the last example, since: `15 mod 12` equals `3 mod 12`. Both\nthe key _and_ the value are replaced in the list." - ], - "signature": "let setAssoc: (t<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => t<('a, 'c)>" - }, - { - "id": "Core.List.sort", - "kind": "value", - "name": "sort", - "docstrings": [ - "`sort(list, f)` returns a sorted list.\n\n## Examples\n\n```rescript\nList.sort(list{5, 4, 9, 3, 7}, Int.compare) // list{3, 4, 5, 7, 9}\n```" - ], - "signature": "let sort: (t<'a>, ('a, 'a) => Core__Ordering.t) => t<'a>" - } - ] - }, - "core/option": { - "id": "Core.Option", - "name": "Option", - "docstrings": [ - "We represent the existence and nonexistence of a value by wrapping it with\nthe `option` type. In order to make it a bit more convenient to work with\noption-types, we provide utility-functions for it.\n\nThe `option` type is a part of the ReScript standard library which is defined\nlike this:\n\n```rescript\ntype option<'a> = None | Some('a)\n```\n\n```rescript\nlet someString: option = Some(\"hello\")\n```" - ], - "items": [ - { - "id": "Core.Option.filter", - "kind": "value", - "name": "filter", - "docstrings": [ - "`filter(opt, f)` applies `f` to `opt`, if `f` returns `true`, then it returns `Some(value)`, otherwise returns `None`.\n\n## Examples\n\n```rescript\nOption.filter(Some(10), x => x > 5) // Some(10)\nOption.filter(Some(4), x => x > 5) // None\nOption.filter(None, x => x > 5) // None\n```" - ], - "signature": "let filter: (option<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Core.Option.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(opt, f)` call `f` on `opt`. if `opt` is `Some(value)`, then if calls\n`f`, otherwise returns `unit`.\n\n## Examples\n\n```rescript\nOption.forEach(Some(\"thing\"), x => Console.log(x)) // logs \"thing\"\nOption.forEach(None, x => Console.log(x)) // returns ()\n```" - ], - "signature": "let forEach: (option<'a>, 'a => unit) => unit" - }, - { - "id": "Core.Option.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "`getExn(opt, ~message=?)` returns `value` if `opt` is `Some(value)`, otherwise raises an exception with the message provided, or a generic message if no message was provided.\n\n```rescript\nOption.getExn(Some(3)) // 3\nOption.getExn(None) /* Raises an Error */\nOption.getExn(None, ~message=\"was None!\") /* Raises an Error with the message \"was None!\" */\n```\n\n## Exceptions\n\n- Raises an error if `opt` is `None`" - ], - "signature": "let getExn: (option<'a>, ~message: string=?) => 'a" - }, - { - "id": "Core.Option.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(opt)` returns `value` if `opt` is `Some(value)`, otherwise `undefined`.\n\n## Examples\n\n```rescript\nOption.getUnsafe(Some(3)) == 3\nOption.getUnsafe(None: option) // Returns `undefined`, which is not a valid `int`\n```\n\n## Notes\n\n- This is an unsafe operation. It assumes `value` is not `None`, and may cause undefined behaviour if it is." - ], - "signature": "let getUnsafe: option<'a> => 'a" - }, - { - "id": "Core.Option.mapOr", - "kind": "value", - "name": "mapOr", - "docstrings": [ - "`mapOr(opt, default, f)` returns `f(value)` if `opt` is `Some(value)`, otherwise `default`.\n\n## Examples\n\n```rescript\nlet someValue = Some(3)\nsomeValue->Option.mapOr(0, x => x + 5) // 8\n\nlet noneValue = None\nnoneValue->Option.mapOr(0, x => x + 5) // 0\n```" - ], - "signature": "let mapOr: (option<'a>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Core.Option.mapWithDefault", - "kind": "value", - "name": "mapWithDefault", - "docstrings": [], - "signature": "let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b", - "deprecated": "Use mapOr instead" - }, - { - "id": "Core.Option.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(opt, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `None`.\n\n## Examples\n\n```rescript\nOption.map(Some(3), x => x * x) // Some(9)\nOption.map(None, x => x * x) // None\n```" - ], - "signature": "let map: (option<'a>, 'a => 'b) => option<'b>" - }, - { - "id": "Core.Option.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "`flatMap(opt, f)` returns `f(value)` if `opt` is `Some(value)`, otherwise `None`.\n\n## Examples\n\n```rescript\nlet addIfAboveOne = value =>\n if (value > 1) {\n Some(value + 1)\n } else {\n None\n }\n\nOption.flatMap(Some(2), addIfAboveOne) // Some(3)\nOption.flatMap(Some(-4), addIfAboveOne) // None\nOption.flatMap(None, addIfAboveOne) // None\n```" - ], - "signature": "let flatMap: (option<'a>, 'a => option<'b>) => option<'b>" - }, - { - "id": "Core.Option.getOr", - "kind": "value", - "name": "getOr", - "docstrings": [ - "`getOr(opt, default)` returns `value` if `opt` is `Some(value)`, otherwise `default`.\n\n## Examples\n\n```rescript\nOption.getOr(None, \"Banana\") // Banana\nOption.getOr(Some(\"Apple\"), \"Banana\") // Apple\n\nlet greet = (firstName: option) =>\n \"Greetings \" ++ firstName->Option.getOr(\"Anonymous\")\n\nSome(\"Jane\")->greet // \"Greetings Jane\"\nNone->greet // \"Greetings Anonymous\"\n```" - ], - "signature": "let getOr: (option<'a>, 'a) => 'a" - }, - { - "id": "Core.Option.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (option<'a>, 'a) => 'a", - "deprecated": "Use getOr instead" - }, - { - "id": "Core.Option.orElse", - "kind": "value", - "name": "orElse", - "docstrings": [ - "`orElse(opt1, opt2)` returns `opt2` if `opt1` is `None`, otherwise `opt1`.\n\n## Examples\n\n```rescript\nOption.orElse(Some(1812), Some(1066)) == Some(1812)\nOption.orElse(None, Some(1066)) == Some(1066)\nOption.orElse(None, None) == None\n```" - ], - "signature": "let orElse: (option<'a>, option<'a>) => option<'a>" - }, - { - "id": "Core.Option.isSome", - "kind": "value", - "name": "isSome", - "docstrings": [ - "`isSome(opt)` returns `true` if `opt` is `Some(value)`, otherwise returns `false`.\n\n## Examples\n\n```rescript\nOption.isSome(None) // false\nOption.isSome(Some(1)) // true\n```" - ], - "signature": "let isSome: option<'a> => bool" - }, - { - "id": "Core.Option.isNone", - "kind": "value", - "name": "isNone", - "docstrings": [ - "`isNone(opt)` returns `true` if `opt` is `None`, false otherwise.\n\n## Examples\n\n```rescript\nOption.isNone(None) // true\nOption.isNone(Some(1)) // false\n```" - ], - "signature": "let isNone: option<'a> => bool" - }, - { - "id": "Core.Option.equal", - "kind": "value", - "name": "equal", - "docstrings": [ - "`equal(opt1, opt2, f)` evaluates two optional values for equality with respect to a predicate function `f`. If both `opt1` and `opt2` are `None`, returns `true`.\nIf one of the arguments is `Some(value)` and the other is `None`, returns\n`false`.\nIf arguments are `Some(value1)` and `Some(value2)`, returns the result of\n`f(value1, value2)`, the predicate function `f` must return a bool.\n\n## Examples\n\n```rescript\nlet clockEqual = (a, b) => mod(a, 12) == mod(b, 12)\n\nopen Option\n\nequal(Some(3), Some(15), clockEqual) // true\nequal(Some(3), None, clockEqual) // false\nequal(None, Some(3), clockEqual) // false\nequal(None, None, clockEqual) // true\n```" - ], - "signature": "let equal: (option<'a>, option<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.Option.compare", - "kind": "value", - "name": "compare", - "docstrings": [ - "`compare(opt1, opt2, f)` compares two optional values with respect to given `f`.\n\nIf both `opt1` and `opt2` are `None`, it returns `0.`. If the first argument is `Some(value1)` and the second is `None`, returns `1.` (something is greater than nothing).\n\nIf the first argument is `None` and the second is `Some(value2)`, returns `-1.`\n(nothing is less than something).\n\nIf the arguments are `Some(value1)` and `Some(value2)`, returns the result of\n`f(value1, value2)`, `f` takes two arguments and returns `-1.` if the first\nargument is less than the second, `0.` if the arguments are equal, and `1.` if\nthe first argument is greater than the second.\n\n## Examples\n\n```rescript\nlet clockCompare = (a, b) => Int.compare(mod(a, 12), mod(b, 12))\n\nOption.compare(Some(3), Some(15), clockCompare) // 0.\nOption.compare(Some(3), Some(14), clockCompare) // 1.\nOption.compare(Some(2), Some(15), clockCompare) // (-1.)\nOption.compare(None, Some(15), clockCompare) // (-1.)\nOption.compare(Some(14), None, clockCompare) // 1.\nOption.compare(None, None, clockCompare) // 0.\n```" - ], - "signature": "let compare: (\n option<'a>,\n option<'b>,\n ('a, 'b) => Core__Ordering.t,\n) => Core__Ordering.t" - } - ] - }, - "core/exn": { - "id": "Core.Exn", - "name": "Exn", - "docstrings": [], - "items": [] - }, - "core/intl": { - "id": "Core.Intl", - "name": "Intl", - "docstrings": [], - "items": [ - { - "id": "Core.Intl.getCanonicalLocalesExn", - "kind": "value", - "name": "getCanonicalLocalesExn", - "docstrings": ["@throws RangeError"], - "signature": "let getCanonicalLocalesExn: string => array" - }, - { - "id": "Core.Intl.getCanonicalLocalesManyExn", - "kind": "value", - "name": "getCanonicalLocalesManyExn", - "docstrings": ["@throws RangeError"], - "signature": "let getCanonicalLocalesManyExn: array => array" - }, - { - "id": "Core.Intl.supportedValuesOfExn", - "kind": "value", - "name": "supportedValuesOfExn", - "docstrings": ["@throws RangeError"], - "signature": "let supportedValuesOfExn: string => array" - } - ] - }, - "core/biguint64array": { - "id": "Core.BigUint64Array", - "name": "BigUint64Array", - "docstrings": [], - "items": [ - { - "id": "Core.BigUint64Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `BigUint64Array` typed array represents an array of 64-bit unsigned integers in platform byte order. See [BigUint64Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.BigUint64Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `BigUint64Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.BigUint64Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `BigUint64Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.BigUint64Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `BigUint64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.BigUint64Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `BigUint64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.BigUint64Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `BigUint64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.BigUint64Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `BigUint64Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.BigUint64Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `BigUint64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t" - } - ] - }, - "core/bigint64array": { - "id": "Core.BigInt64Array", - "name": "BigInt64Array", - "docstrings": [], - "items": [ - { - "id": "Core.BigInt64Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `BigInt64Array` typed array represents an array of 64-bit signed integers in platform byte order. See [BigInt64Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.BigInt64Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `BigInt64Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.BigInt64Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `BigInt64Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.BigInt64Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `BigInt64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.BigInt64Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `BigInt64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.BigInt64Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `BigInt64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.BigInt64Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `BigInt64Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.BigInt64Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `BigInt64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t" - } - ] - }, - "core/uint8clampedarray": { - "id": "Core.Uint8ClampedArray", - "name": "Uint8ClampedArray", - "docstrings": [], - "items": [ - { - "id": "Core.Uint8ClampedArray.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Uint8ClampedArray` typed array represents an array of 8-bit unsigned integers clamped to 0-255. See [Uint8ClampedArray on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Uint8ClampedArray.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Uint8ClampedArray` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Uint8ClampedArray.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Uint8ClampedArray` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Uint8ClampedArray.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Uint8ClampedArray` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Uint8ClampedArray.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Uint8ClampedArray` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Uint8ClampedArray.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Uint8ClampedArray` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Uint8ClampedArray.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Uint8ClampedArray` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Uint8ClampedArray.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Uint8ClampedArray` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t" - } - ] - }, - "core/uint32array": { - "id": "Core.Uint32Array", - "name": "Uint32Array", - "docstrings": [], - "items": [ - { - "id": "Core.Uint32Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Uint32Array` typed array represents an array of 32-bit unsigned integers in platform byte order. See [Uint32Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Uint32Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Uint32Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Uint32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Uint32Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Uint32Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Uint32Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Uint32Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Uint32Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Uint32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Uint32Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Uint32Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Uint32Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Uint32Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Uint32Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t" - } - ] - }, - "core/uint16array": { - "id": "Core.Uint16Array", - "name": "Uint16Array", - "docstrings": [], - "items": [ - { - "id": "Core.Uint16Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Uint16Array` typed array represents an array of 16-bit unsigned integers in platform byte order. See [Uint16Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Uint16Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Uint16Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Uint16Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Uint16Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Uint16Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Uint16Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Uint16Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Uint16Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Uint16Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Uint16Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Uint16Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Uint16Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Uint16Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Uint16Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t" - } - ] - }, - "core/uint8array": { - "id": "Core.Uint8Array", - "name": "Uint8Array", - "docstrings": [], - "items": [ - { - "id": "Core.Uint8Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Uint8Array` typed array represents an array of 8-bit unsigned integers. See [Uint8Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Uint8Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Uint8Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Uint8Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Uint8Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Uint8Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Uint8Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Uint8Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Uint8Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Uint8Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Uint8Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Uint8Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Uint8Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Uint8Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Uint8Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t" - } - ] - }, - "core/int32array": { - "id": "Core.Int32Array", - "name": "Int32Array", - "docstrings": [], - "items": [ - { - "id": "Core.Int32Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Int32Array` typed array represents an array of twos-complemenet 32-bit signed integers in platform byte order. See [Int32Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Int32Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Int32Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Int32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Int32Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Int32Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Int32Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Int32Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Int32Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Int32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Int32Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Int32Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Int32Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Int32Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Int32Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t" - } - ] - }, - "core/int16array": { - "id": "Core.Int16Array", - "name": "Int16Array", - "docstrings": [], - "items": [ - { - "id": "Core.Int16Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Int16Array` typed array represents an array of twos-complement 16-bit signed integers in platform byte order. See [Int16Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Int16Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Int16Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Int16Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Int16Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Int16Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Int16Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Int16Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Int16Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Int16Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Int16Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Int16Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Int16Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Int16Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Int16Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t" - } - ] - }, - "core/int8array": { - "id": "Core.Int8Array", - "name": "Int8Array", - "docstrings": [], - "items": [ - { - "id": "Core.Int8Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Int8Array` typed array represents an array of twos-complement 8-bit signed integers. See [Int8Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Int8Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Int8Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Int8Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Int8Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Int8Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Int8Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Int8Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Int8Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Int8Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Int8Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Int8Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Int8Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Int8Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Int8Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t" - } - ] - }, - "core/float64array": { - "id": "Core.Float64Array", - "name": "Float64Array", - "docstrings": [], - "items": [ - { - "id": "Core.Float64Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Float64Array` typed array represents an array of 64-bit floating point numbers in platform byte order. See [Float64Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Float64Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Float64Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Float64Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Float64Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Float64Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Float64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Float64Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Float64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Float64Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Float64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Float64Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Float64Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Float64Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Float64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t" - } - ] - }, - "core/float32array": { - "id": "Core.Float32Array", - "name": "Float32Array", - "docstrings": [], - "items": [ - { - "id": "Core.Float32Array.t", - "kind": "type", - "name": "t", - "docstrings": [ - "The `Float32Array` typed array represents an array of 32-bit floating point numbers in platform byte order. See [Float32Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array)" - ], - "signature": "type t = Core__TypedArray.t" - }, - { - "id": "Core.Float32Array.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray` creates a `Float32Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array)" - ], - "signature": "let fromArray: array => t" - }, - { - "id": "Core.Float32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [ - "`fromBuffer` creates a `Float32Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.Float32Array.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [ - "`fromBufferToEnd` creates a `Float32Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.Float32Array.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [ - "`fromBufferWithRange` creates a `Float32Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.Float32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [ - "`fromLength` creates a zero-initialized `Float32Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array)\n\n**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds." - ], - "signature": "let fromLength: int => t" - }, - { - "id": "Core.Float32Array.fromArrayLikeOrIterable", - "kind": "value", - "name": "fromArrayLikeOrIterable", - "docstrings": [ - "`fromArrayLikeOrIterable` creates a `Float32Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterable: 'a => t" - }, - { - "id": "Core.Float32Array.fromArrayLikeOrIterableWithMap", - "kind": "value", - "name": "fromArrayLikeOrIterableWithMap", - "docstrings": [ - "`fromArrayLikeOrIterableWithMap` creates a `Float32Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)" - ], - "signature": "let fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t" - } - ] - }, - "core/typedarray": { - "id": "Core.TypedArray", - "name": "TypedArray", - "docstrings": [], - "items": [ - { - "id": "Core.TypedArray.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a>" - }, - { - "id": "Core.TypedArray.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'a>, int) => option<'a>" - }, - { - "id": "Core.TypedArray.set", - "kind": "value", - "name": "set", - "docstrings": [], - "signature": "let set: (t<'a>, int, 'a) => unit" - }, - { - "id": "Core.TypedArray.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t<'a> => Core__ArrayBuffer.t" - }, - { - "id": "Core.TypedArray.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t<'a> => int" - }, - { - "id": "Core.TypedArray.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t<'a> => int" - }, - { - "id": "Core.TypedArray.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t<'a>, array<'a>) => unit" - }, - { - "id": "Core.TypedArray.setArrayFrom", - "kind": "value", - "name": "setArrayFrom", - "docstrings": [], - "signature": "let setArrayFrom: (t<'a>, array<'a>, int) => unit" - }, - { - "id": "Core.TypedArray.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t<'a> => int" - }, - { - "id": "Core.TypedArray.copyAllWithin", - "kind": "value", - "name": "copyAllWithin", - "docstrings": [], - "signature": "let copyAllWithin: (t<'a>, ~target: int) => array<'a>" - }, - { - "id": "Core.TypedArray.copyWithinToEnd", - "kind": "value", - "name": "copyWithinToEnd", - "docstrings": [], - "signature": "let copyWithinToEnd: (t<'a>, ~target: int, ~start: int) => array<'a>" - }, - { - "id": "Core.TypedArray.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t<'a>, ~target: int, ~start: int, ~end: int) => array<'a>" - }, - { - "id": "Core.TypedArray.fillAll", - "kind": "value", - "name": "fillAll", - "docstrings": [], - "signature": "let fillAll: (t<'a>, 'a) => t<'a>" - }, - { - "id": "Core.TypedArray.fillToEnd", - "kind": "value", - "name": "fillToEnd", - "docstrings": [], - "signature": "let fillToEnd: (t<'a>, 'a, ~start: int) => t<'a>" - }, - { - "id": "Core.TypedArray.fill", - "kind": "value", - "name": "fill", - "docstrings": [], - "signature": "let fill: (t<'a>, 'a, ~start: int, ~end: int) => t<'a>" - }, - { - "id": "Core.TypedArray.reverse", - "kind": "value", - "name": "reverse", - "docstrings": [], - "signature": "let reverse: t<'a> => unit" - }, - { - "id": "Core.TypedArray.toReversed", - "kind": "value", - "name": "toReversed", - "docstrings": [], - "signature": "let toReversed: t<'a> => t<'a>" - }, - { - "id": "Core.TypedArray.sort", - "kind": "value", - "name": "sort", - "docstrings": [], - "signature": "let sort: (t<'a>, ('a, 'a) => Core__Ordering.t) => unit" - }, - { - "id": "Core.TypedArray.toSorted", - "kind": "value", - "name": "toSorted", - "docstrings": [], - "signature": "let toSorted: (t<'a>, ('a, 'a) => Core__Ordering.t) => t<'a>" - }, - { - "id": "Core.TypedArray.with", - "kind": "value", - "name": "with", - "docstrings": [], - "signature": "let with: (t<'a>, int, 'a) => t<'a>" - }, - { - "id": "Core.TypedArray.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t<'a>, 'a) => bool" - }, - { - "id": "Core.TypedArray.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t<'a>, 'a) => int" - }, - { - "id": "Core.TypedArray.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t<'a>, 'a, int) => int" - }, - { - "id": "Core.TypedArray.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t<'a>, string) => string" - }, - { - "id": "Core.TypedArray.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t<'a>, 'a) => int" - }, - { - "id": "Core.TypedArray.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t<'a>, 'a, int) => int" - }, - { - "id": "Core.TypedArray.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (t<'a>, ~start: int, ~end: int) => t<'a>" - }, - { - "id": "Core.TypedArray.sliceToEnd", - "kind": "value", - "name": "sliceToEnd", - "docstrings": [], - "signature": "let sliceToEnd: (t<'a>, ~start: int) => t<'a>" - }, - { - "id": "Core.TypedArray.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Core.TypedArray.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (t<'a>, ~start: int, ~end: int) => t<'a>" - }, - { - "id": "Core.TypedArray.subarrayToEnd", - "kind": "value", - "name": "subarrayToEnd", - "docstrings": [], - "signature": "let subarrayToEnd: (t<'a>, ~start: int) => t<'a>" - }, - { - "id": "Core.TypedArray.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t<'a> => string" - }, - { - "id": "Core.TypedArray.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t<'a> => string" - }, - { - "id": "Core.TypedArray.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Core.TypedArray.everyWithIndex", - "kind": "value", - "name": "everyWithIndex", - "docstrings": [], - "signature": "let everyWithIndex: (t<'a>, ('a, int) => bool) => bool" - }, - { - "id": "Core.TypedArray.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t<'a>, 'a => bool) => t<'a>" - }, - { - "id": "Core.TypedArray.filterWithIndex", - "kind": "value", - "name": "filterWithIndex", - "docstrings": [], - "signature": "let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a>" - }, - { - "id": "Core.TypedArray.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Core.TypedArray.findWithIndex", - "kind": "value", - "name": "findWithIndex", - "docstrings": [], - "signature": "let findWithIndex: (t<'a>, ('a, int) => bool) => option<'a>" - }, - { - "id": "Core.TypedArray.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t<'a>, 'a => bool) => int" - }, - { - "id": "Core.TypedArray.findIndexWithIndex", - "kind": "value", - "name": "findIndexWithIndex", - "docstrings": [], - "signature": "let findIndexWithIndex: (t<'a>, ('a, int) => bool) => int" - }, - { - "id": "Core.TypedArray.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Core.TypedArray.forEachWithIndex", - "kind": "value", - "name": "forEachWithIndex", - "docstrings": [], - "signature": "let forEachWithIndex: (t<'a>, ('a, int) => unit) => unit" - }, - { - "id": "Core.TypedArray.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Core.TypedArray.mapWithIndex", - "kind": "value", - "name": "mapWithIndex", - "docstrings": [], - "signature": "let mapWithIndex: (t<'a>, ('a, int) => 'b) => t<'b>" - }, - { - "id": "Core.TypedArray.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b" - }, - { - "id": "Core.TypedArray.reduceWithIndex", - "kind": "value", - "name": "reduceWithIndex", - "docstrings": [], - "signature": "let reduceWithIndex: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b" - }, - { - "id": "Core.TypedArray.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b" - }, - { - "id": "Core.TypedArray.reduceRightWithIndex", - "kind": "value", - "name": "reduceRightWithIndex", - "docstrings": [], - "signature": "let reduceRightWithIndex: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b" - }, - { - "id": "Core.TypedArray.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Core.TypedArray.someWithIndex", - "kind": "value", - "name": "someWithIndex", - "docstrings": [], - "signature": "let someWithIndex: (t<'a>, ('a, int) => bool) => bool" - } - ] - }, - "core/arraybuffer": { - "id": "Core.ArrayBuffer", - "name": "ArrayBuffer", - "docstrings": [], - "items": [ - { - "id": "Core.ArrayBuffer.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = Js.TypedArray2.ArrayBuffer.t" - }, - { - "id": "Core.ArrayBuffer.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: int => t" - }, - { - "id": "Core.ArrayBuffer.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Core.ArrayBuffer.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (t, ~start: int, ~end: int) => t" - }, - { - "id": "Core.ArrayBuffer.sliceToEnd", - "kind": "value", - "name": "sliceToEnd", - "docstrings": [], - "signature": "let sliceToEnd: (t, ~start: int) => t" - } - ] - }, - "core/weakset": { - "id": "Core.WeakSet", - "name": "WeakSet", - "docstrings": [], - "items": [ - { - "id": "Core.WeakSet.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = Js.WeakSet.t<'a>" - }, - { - "id": "Core.WeakSet.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: unit => t<'a>" - }, - { - "id": "Core.WeakSet.add", - "kind": "value", - "name": "add", - "docstrings": [], - "signature": "let add: (t<'a>, 'a) => t<'a>" - }, - { - "id": "Core.WeakSet.delete", - "kind": "value", - "name": "delete", - "docstrings": [], - "signature": "let delete: (t<'a>, 'a) => bool" - }, - { - "id": "Core.WeakSet.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'a>, 'a) => bool" - } - ] - }, - "core/set": { - "id": "Core.Set", - "name": "Set", - "docstrings": [ - "Bindings to the mutable JavaScript `Set`.\n\nSee [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) on MDN." - ], - "items": [ - { - "id": "Core.Set.t", - "kind": "type", - "name": "t", - "docstrings": ["Type representing an instance of `Set`."], - "signature": "type t<'a> = Js.Set.t<'a>" - }, - { - "id": "Core.Set.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new, mutable JavaScript `Set`. A `Set` is a collection of unique values.\n\nSee [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) on MDN.\n\n\n\n## Examples\n```rescript\n// You can annotate the type of your set if you want to\nlet mySet: Set.t = Set.make()\n\n// Or you can let ReScript infer what's in your Set\nlet set = Set.make()\nset->Set.add(\"Fine name\") // Inferred as Set.t\n```\n\n## Alternatives\nA JavaScript `Set` is mutable. If you're looking for an immutable alternative, check out `Belt.Set`." - ], - "signature": "let make: unit => t<'a>" - }, - { - "id": "Core.Set.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Turns an array of values into a Set. Meaning only unique values are preserved.\n\n## Examples\n```rescript\ntype languages = ReScript | JavaScript | TypeScript\nlet languageRank = [ReScript, JavaScript, TypeScript]\n\nlet set = Set.fromArray(languageRank) // Set.t\n\nswitch set->Set.has(ReScript) {\n| true => Console.log(\"Yay, ReScript is in there!\")\n| false => Console.log(\"Uh-oh, something is _terribly_ wrong with this program... abort.\")\n}\n```" - ], - "signature": "let fromArray: array<'a> => t<'a>" - }, - { - "id": "Core.Set.fromIterator", - "kind": "value", - "name": "fromIterator", - "docstrings": [ - "Turns an iterator into a `Set`.\n\n## Examples\n```rescript\n// Let's pretend we have an interator\n@val external someIterator: Iterator.t = \"someIterator\"\n\nlet set = Set.fromIterator(someIterator) // Set.t\n```" - ], - "signature": "let fromIterator: Core__Iterator.t<'a> => t<'a>" - }, - { - "id": "Core.Set.size", - "kind": "value", - "name": "size", - "docstrings": [ - "Returns the size, the number of unique values, of the set.\n\n## Examples\n```rescript\nlet set = Set.make()\n\nset->Set.add(\"someValue\")\nset->Set.add(\"someValue\")\nset->Set.add(\"someValue2\")\n\nlet size = set->Set.size // 2\n```" - ], - "signature": "let size: t<'a> => int" - }, - { - "id": "Core.Set.clear", - "kind": "value", - "name": "clear", - "docstrings": [ - "Clears all entries in the set.\n\n## Examples\n```rescript\nlet set = Set.make()\n\nset->Set.add(\"someKey\")\nset->Set.size // 1\n\nset->Set.clear\nset->Set.size // 0\n```" - ], - "signature": "let clear: t<'a> => unit" - }, - { - "id": "Core.Set.add", - "kind": "value", - "name": "add", - "docstrings": [ - "Adds a new value to the set.\n\n## Examples\n```rescript\nlet set = Set.make()\nset->Set.add(\"someValue\")\n```" - ], - "signature": "let add: (t<'a>, 'a) => unit" - }, - { - "id": "Core.Set.delete", - "kind": "value", - "name": "delete", - "docstrings": [ - "Deletes the provided `value` from the set. Returns a `bool` for whether the value existed, and was deleted.\n\n## Examples\n```rescript\nlet set = Set.make()\nset->Set.add(\"someValue\")\nlet didDeleteValue = set->Set.delete(\"someValue\")\nConsole.log(didDeleteValue) // Logs `true` to the console, becuase the set had the value, so it was successfully deleted\n\nlet didDeleteValue = set->Set.delete(\"someNonExistantKey\")\nConsole.log(didDeleteValue) // Logs `false` to the console, becuase the value did not exist in the set\n```" - ], - "signature": "let delete: (t<'a>, 'a) => bool" - }, - { - "id": "Core.Set.has", - "kind": "value", - "name": "has", - "docstrings": [ - "Checks whether the set has a specific value.\n\n## Examples\n```rescript\nlet set = Set.make()\nset->Set.add(\"someValue\")\n\nswitch set->Set.has(\"someValue\") {\n| false => Console.log(\"Nope, didn't have it.\")\n| true => Console.log(\"Yay, we have the value!\")\n}\n```" - ], - "signature": "let has: (t<'a>, 'a) => bool" - }, - { - "id": "Core.Set.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "Iterates through all values of the set.\n\n## Examples\n```rescript\nlet set = Set.make()\nset->Set.add(\"someValue\")\nset->Set.add(\"someValue2\")\n\nset->Set.forEach(value => {\n Console.log(value)\n})\n```" - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Core.Set.values", - "kind": "value", - "name": "values", - "docstrings": [ - "Returns an iterator that holds all values of the set.\n\n## Examples\n```rescript\nlet set = Set.make()\nset->Set.add(\"someValue\")\nset->Set.add(\"anotherValue\")\n\nlet values = set->Set.values\n\n// Logs the first value\nConsole.log(Iterator.next(values).value)\n\n// You can also turn the iterator into an array.\n// Remember that an iterator consumes values. We'll need a fresh values iterator to get an array of all values, since we consumed a value via `next` above already.\nConsole.log(set->Set.values->Iterator.toArray)\n```" - ], - "signature": "let values: t<'a> => Core__Iterator.t<'a>" - } - ] - }, - "core/weakmap": { - "id": "Core.WeakMap", - "name": "WeakMap", - "docstrings": [], - "items": [ - { - "id": "Core.WeakMap.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'k, 'v> = Js.WeakMap.t<'k, 'v>" - }, - { - "id": "Core.WeakMap.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: unit => t<'k, 'v>" - }, - { - "id": "Core.WeakMap.get", - "kind": "value", - "name": "get", - "docstrings": [], - "signature": "let get: (t<'k, 'v>, 'k) => option<'v>" - }, - { - "id": "Core.WeakMap.has", - "kind": "value", - "name": "has", - "docstrings": [], - "signature": "let has: (t<'k, 'v>, 'k) => bool" - }, - { - "id": "Core.WeakMap.set", - "kind": "value", - "name": "set", - "docstrings": [], - "signature": "let set: (t<'k, 'v>, 'k, 'v) => t<'k, 'v>" - }, - { - "id": "Core.WeakMap.delete", - "kind": "value", - "name": "delete", - "docstrings": [], - "signature": "let delete: (t<'k, 'v>, 'k) => bool" - } - ] - }, - "core/map": { - "id": "Core.Map", - "name": "Map", - "docstrings": [ - "Bindings to the mutable JavaScript `Map`.\n\nSee [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) on MDN." - ], - "items": [ - { - "id": "Core.Map.t", - "kind": "type", - "name": "t", - "docstrings": ["Type representing an instance of `Map`."], - "signature": "type t<'k, 'v> = Js.Map.t<'k, 'v>" - }, - { - "id": "Core.Map.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new, mutable JavaScript `Map`. A `Map` can have any values as both keys and values.\n\nSee [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) on MDN.\n\n\n\n## Examples\n```rescript\n`make()`\n// You can annotate the type of your map if you want to\nlet myMap: Map.t = Map.make()\n\n// Or you can let ReScript infer what's in your map\nlet map = Map.make()\nmap->Map.set(\"lang\", \"ReScript\") // Inferred as Map.t\n```\n\n## Alternatives\nA JavaScript `Map` is mutable. If you're looking for an immutable alternative, check out`Belt.Map`." - ], - "signature": "let make: unit => t<'k, 'v>" - }, - { - "id": "Core.Map.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Turns an array of key/value pairs into a Map.\n\n## Examples\n```rescript\ntype languages = ReScript | JavaScript | TypeScript\nlet languageRank = [(ReScript, 1), (JavaScript, 2), (TypeScript, 3)]\n\nlet map = Map.fromArray(languageRank) // Map.t\n\nswitch map->Map.get(ReScript) {\n| Some(1) => Console.log(\"Yay, ReScript is #1!\")\n| _ => Console.log(\"Uh-oh, something is _terribly_ wrong with this program... abort.\")\n}\n```" - ], - "signature": "let fromArray: array<('k, 'v)> => t<'k, 'v>" - }, - { - "id": "Core.Map.fromIterator", - "kind": "value", - "name": "fromIterator", - "docstrings": [ - "Turns an iterator in the shape of `('key, 'value)` into a `Map`.\n\n## Examples\n```rescript\n// Let's pretend we have an interator in the correct shape\n@val external someIterator: Iterator.t<(string, int)> = \"someIterator\"\n\nlet map = Map.fromIterator(someIterator) // Map.t\n```" - ], - "signature": "let fromIterator: Core__Iterator.t<('k, 'v)> => t<'k, 'v>" - }, - { - "id": "Core.Map.size", - "kind": "value", - "name": "size", - "docstrings": [ - "Returns the size, the number of key/value pairs, of the map.\n\n## Examples\n```rescript\nlet map = Map.make()\n\nmap->Map.set(\"someKey\", \"someValue\")\n\nlet size = map->Map.size // 1\n```" - ], - "signature": "let size: t<'k, 'v> => int" - }, - { - "id": "Core.Map.clear", - "kind": "value", - "name": "clear", - "docstrings": [ - "Clears all entries in the map.\n\n## Examples\n```rescript\nlet map = Map.make()\n\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.size // 1\n\nmap->Map.clear\nmap->Map.size // 0\n```" - ], - "signature": "let clear: t<'k, 'v> => unit" - }, - { - "id": "Core.Map.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "Iterates through all values of the map.\n\n> Please note that this is *without the keys*, just the values. If you need the key as well, use `Map.forEachWithKey`.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\nmap->Map.forEach(value => {\n Console.log(value)\n})\n```" - ], - "signature": "let forEach: (t<'k, 'v>, 'v => unit) => unit" - }, - { - "id": "Core.Map.forEachWithKey", - "kind": "value", - "name": "forEachWithKey", - "docstrings": [ - "Iterates through all values of the map, including the key for each value.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\nmap->Map.forEachWithKey((value, key) => {\n Console.log2(value, key)\n})\n```" - ], - "signature": "let forEachWithKey: (t<'k, 'v>, ('v, 'k) => unit) => unit" - }, - { - "id": "Core.Map.get", - "kind": "value", - "name": "get", - "docstrings": [ - "Returns the value for a key, if a value exists at that key.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\n\nswitch map->Map.get(\"someKey\") {\n| None => Console.log(\"Nope, didn't have it.\")\n| Some(value) => Console.log2(\"Yay, had the value, and it's:\", value)\n}\n```" - ], - "signature": "let get: (t<'k, 'v>, 'k) => option<'v>" - }, - { - "id": "Core.Map.has", - "kind": "value", - "name": "has", - "docstrings": [ - "Checks whether the map has a specific key.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\n\nswitch map->Map.has(\"someKey\") {\n| false => Console.log(\"Nope, didn't have it.\")\n| true => Console.log(\"Yay, we have the value!\")\n}\n```" - ], - "signature": "let has: (t<'k, 'v>, 'k) => bool" - }, - { - "id": "Core.Map.set", - "kind": "value", - "name": "set", - "docstrings": [ - "Sets the provided `value` to the provided `key`.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\n```" - ], - "signature": "let set: (t<'k, 'v>, 'k, 'v) => unit" - }, - { - "id": "Core.Map.delete", - "kind": "value", - "name": "delete", - "docstrings": [ - "Deletes the provided `key` and its value from the map. Returns a `bool` for whether the key existed, and was deleted.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nlet didDeleteKey = map->Map.delete(\"someKey\")\nConsole.log(didDeleteKey) // Logs `true` to the console, becuase the map had the key, so it was successfully deleted\n\nlet didDeleteKey = map->Map.delete(\"someNonExistantKey\")\nConsole.log(didDeleteKey) // Logs `false` to the console, becuase the key did not exist\n```" - ], - "signature": "let delete: (t<'k, 'v>, 'k) => bool" - }, - { - "id": "Core.Map.keys", - "kind": "value", - "name": "keys", - "docstrings": [ - "Returns an iterator that holds all keys of the map.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"anotherKey\", \"anotherValue\")\n\nlet keys = map->Map.keys\n\n// Logs the first key\nConsole.log(Iterator.next(keys).value)\n\n// You can also turn the iterator into an array.\n// Remember that an iterator consumes values. We'll need a fresh keys iterator to get an array of all keys, since we consumed a value via `next` above already.\nConsole.log(map->Map.keys->Iterator.toArray)\n```" - ], - "signature": "let keys: t<'k, 'v> => Core__Iterator.t<'k>" - }, - { - "id": "Core.Map.values", - "kind": "value", - "name": "values", - "docstrings": [ - "Returns an iterator that holds all values of the map.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"anotherKey\", \"anotherValue\")\n\nlet values = map->Map.values\n\n// Logs the first value\nConsole.log(Iterator.next(values).value)\n\n// You can also turn the iterator into an array.\n// Remember that an iterator consumes values. We'll need a fresh values iterator to get an array of all values, since we consumed a value via `next` above already.\nConsole.log(map->Map.values->Iterator.toArray)\n```" - ], - "signature": "let values: t<'k, 'v> => Core__Iterator.t<'v>" - }, - { - "id": "Core.Map.entries", - "kind": "value", - "name": "entries", - "docstrings": [ - "Returns an iterator that holds all entries of the map.\nAn entry is represented as a tuple of `('key, 'value)`,\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"anotherKey\", \"anotherValue\")\n\nlet entries = map->Map.entries\n\n// Logs the first value\nConsole.log(Iterator.next(entries).value)\n\n// You can also turn the iterator into an array.\n// Remember that an iterator consumes entries. We'll need a fresh entries iterator to get an array of all entries, since we consumed a value via `next` above already.\nConsole.log(map->Map.entries->Iterator.toArray)\n```" - ], - "signature": "let entries: t<'k, 'v> => Core__Iterator.t<('k, 'v)>" - } - ] - }, - "core/asynciterator": { - "id": "Core.AsyncIterator", - "name": "AsyncIterator", - "docstrings": [ - "Bindings to async iterators, a way to do async iteration in JavaScript.\n\nSee [async iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols) on MDN." - ], - "items": [ - { - "id": "Core.AsyncIterator.t", - "kind": "type", - "name": "t", - "docstrings": ["The type representing an async iterator."], - "signature": "type t<'a>" - }, - { - "id": "Core.AsyncIterator.value", - "kind": "type", - "name": "value", - "docstrings": [], - "signature": "type value<'a> = {done: bool, value: option<'a>}" - }, - { - "id": "Core.AsyncIterator.next", - "kind": "value", - "name": "next", - "docstrings": [ - "`next(asyncIterator)`\n\nReturns the next value of the iterator, if any.\n\nSee [async iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols) on MDN.\n\n## Examples\n- A simple example, getting the next value:\n```rescript\n@val external asyncIterator: AsyncIterator.t = \"someAsyncIterator\"\nlet {AsyncIterator.done, value} = await asyncIterator->AsyncIterator.next\n```\n\n- Complete example, including looping over all values:\n```rescript\n// Let's pretend we get an async iterator returning ints from somewhere.\n@val external asyncIterator: AsyncIterator.t = \"someAsyncIterator\"\n\n\nlet processMyAsyncIterator = async () => {\n // ReScript doesn't have `for ... of` loops, but it's easy to mimic using a while loop.\n let break = ref(false)\n\n while !break.contents {\n // Await the next iterator value\n let {value, done} = await asyncIterator->AsyncIterator.next\n\n // Exit the while loop if the iterator says it's done\n break := done\n\n // This will log the (int) value of the current async iteration, if a value was returned.\n Console.log(value)\n }\n}\n```" - ], - "signature": "let next: t<'a> => promise>" - }, - { - "id": "Core.AsyncIterator.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(iterator, fn)` consumes all values in the async iterator and runs the callback `fn` for each value.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\n// Let's pretend we get an async iterator returning ints from somewhere.\n@val external asyncIterator: AsyncIterator.t = \"someAsyncIterator\"\n\nawait asyncIterator->AsyncIterator.forEach(value =>\n switch value {\n | Some(value) if value > 10 => Console.log(\"More than 10!\")\n | _ => ()\n }\n)\n```" - ], - "signature": "let forEach: (t<'a>, option<'a> => unit) => promise" - } - ] - }, - "core/iterator": { - "id": "Core.Iterator", - "name": "Iterator", - "docstrings": [ - "Bindings to JavaScript iterators.\n\nSee [`iterator protocols`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN." - ], - "items": [ - { - "id": "Core.Iterator.t", - "kind": "type", - "name": "t", - "docstrings": ["The type representing an iterator."], - "signature": "type t<'a>" - }, - { - "id": "Core.Iterator.value", - "kind": "type", - "name": "value", - "docstrings": ["The current value of an iterator."], - "signature": "type value<'a> = {done: bool, value: option<'a>}" - }, - { - "id": "Core.Iterator.next", - "kind": "value", - "name": "next", - "docstrings": [ - "Returns the next value of the iterator, if any.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\n@val external someIterator: Iterator.t = \"someIterator\"\n\n// Pulls out the next value of the iterator\nlet {Iterator.done, value} = someIterator->Iterator.next\n```" - ], - "signature": "let next: t<'a> => value<'a>" - }, - { - "id": "Core.Iterator.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "Turns an iterator into an array of the remaining values.\nRemember that each invocation of `next` of an iterator consumes a value. `Iterator.toArray` will consume all remaining values of the iterator and return them in an array to you.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\n// `Map.keys` returns all keys of the map as an iterator.\nlet mapKeysAsArray = map->Map.keys->Iterator.toArray\n\nConsole.log(mapKeysAsArray) // Logs [\"someKey\", \"someKey2\"] to the console.\n```" - ], - "signature": "let toArray: t<'a> => array<'a>" - }, - { - "id": "Core.Iterator.toArrayWithMapper", - "kind": "value", - "name": "toArrayWithMapper", - "docstrings": [ - "`toArray(iterator)` turns `iterator` into an array of its remaining values, applying the provided mapper function on each item.\nRemember that each invocation of `next` of an iterator consumes a value. `Iterator.toArrayWithMapper` will consume all remaining values of the iterator and return them in an array to you.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\n// `Map.keys` returns all keys of the map as an iterator.\nlet mapKeysAsArray = map\n ->Map.keys\n ->Iterator.toArrayWithMapper(key => key->String.length)\n\nConsole.log(mapKeysAsArray) // Logs [7, 8] to the console.\n```" - ], - "signature": "let toArrayWithMapper: (t<'a>, 'a => 'b) => array<'b>" - }, - { - "id": "Core.Iterator.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(iterator, fn)` consumes all values in the iterator and runs the callback `fn` for each value.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\n@val external someIterator: Iterator.t = \"someIterator\"\n\nsomeIterator->Iterator.forEach(value =>\n switch value {\n | Some(value) if value > 10 => Console.log(\"More than 10!\")\n | _ => ()\n }\n)\n```" - ], - "signature": "let forEach: (t<'a>, option<'a> => unit) => unit" - } - ] - }, - "core/json": { - "id": "Core.JSON", - "name": "JSON", - "docstrings": ["Functions for interacting with JSON."], - "items": [ - { - "id": "Core.JSON.t", - "kind": "type", - "name": "t", - "docstrings": ["A type representing a JSON object."], - "signature": "type t = Js.Json.t =\n | Boolean(bool)\n | Null\n | String(string)\n | Number(float)\n | Object(Core__Dict.t)\n | Array(array)" - }, - { - "id": "Core.JSON.replacer", - "kind": "type", - "name": "replacer", - "docstrings": [], - "signature": "type replacer =\n | Keys(array)\n | Replacer((string, t) => t)" - }, - { - "id": "Core.JSON.parseExn", - "kind": "value", - "name": "parseExn", - "docstrings": [ - "`parseExn(string, ~reviver=?)` \n\nParses a JSON string or throws a JavaScript exception (SyntaxError), if the string isn't valid.\nThe reviver describes how the value should be transformed. It is a function which receives a key and a value.\nIt returns a JSON type.\n\n## Examples\n```rescript\ntry {\n let _ = JSON.parseExn(`{\"foo\":\"bar\",\"hello\":\"world\"}`)\n // { foo: 'bar', hello: 'world' }\n\n let _ = JSON.parseExn(\"\")\n // error\n} catch {\n| Exn.Error(_) => Console.log(\"error\")\n}\n\nlet reviver = (_, value: JSON.t) =>\n switch value {\n | String(string) => string->String.toUpperCase->JSON.Encode.string\n | Number(number) => (number *. 2.0)->JSON.Encode.float\n | _ => value\n }\n\nlet jsonString = `{\"hello\":\"world\",\"someNumber\":21}`\n\ntry {\n JSON.parseExn(jsonString, ~reviver)->Console.log\n // { hello: 'WORLD', someNumber: 42 }\n\n JSON.parseExn(\"\", ~reviver)->Console.log\n // error\n} catch {\n| Exn.Error(_) => Console.log(\"error\")\n}\n```\n\n## Exceptions \n\n- Raises a SyntaxError (Exn.t) if the string isn't valid JSON." - ], - "signature": "let parseExn: (string, ~reviver: (string, t) => t=?) => t" - }, - { - "id": "Core.JSON.parseExnWithReviver", - "kind": "value", - "name": "parseExnWithReviver", - "docstrings": [ - "`parseExnWithReviver(string, reviver)` \n\nParses a JSON string or throws a JavaScript exception (SyntaxError), if the string isn't valid.\nThe reviver describes how the value should be transformed. It is a function which receives a key and a value.\nIt returns a JSON type.\n\n## Examples\n```rescript\nlet reviver = (_, value: JSON.t) =>\n switch value {\n | String(string) => string->String.toUpperCase->JSON.Encode.string\n | Number(number) => (number *. 2.0)->JSON.Encode.float\n | _ => value\n }\n\nlet jsonString = `{\"hello\":\"world\",\"someNumber\":21}`\n\ntry {\n JSON.parseExnWithReviver(jsonString, reviver)->Console.log\n // { hello: 'WORLD', someNumber: 42 }\n\n JSON.parseExnWithReviver(\"\", reviver)->Console.log\n // error\n} catch {\n| Exn.Error(_) => Console.log(\"error\")\n}\n```\n\n## Exceptions \n\n- Raises a SyntaxError if the string isn't valid JSON." - ], - "signature": "let parseExnWithReviver: (string, (string, t) => t) => t", - "deprecated": "Use `parseExn` with optional parameter instead" - }, - { - "id": "Core.JSON.stringify", - "kind": "value", - "name": "stringify", - "docstrings": [ - "`stringify(json, ~replacer=?, ~space=?)` \n\nConverts a JSON object to a JSON string.\nThe replacer describes how the value should be transformed. It is a function which receives a key and a value,\nor an array of keys which should be included in the output.\nIf you want to stringify any type, use `JSON.stringifyAny` instead.\n\n## Examples\n```rescript\nlet json =\n Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n ])->JSON.Encode.object\n\nJSON.stringify(json)\n// {\"foo\":\"bar\",\"hello\":\"world\",\"someNumber\":42}\n\nJSON.stringify(json, ~space=2)\n// {\n// \"foo\": \"bar\",\n// \"hello\": \"world\",\n// \"someNumber\": 42\n// }\n\nJSON.stringify(json, ~replacer=Keys([\"foo\", \"someNumber\"]))\n// {\"foo\":\"bar\",\"someNumber\":42}\n\nlet replacer = JSON.Replacer((_, value) => {\n let decodedValue = value->JSON.Decode.string\n\n switch decodedValue {\n | Some(string) => string->String.toUpperCase->JSON.Encode.string\n | None => value\n }\n})\n\nJSON.stringify(json, ~replacer)\n// {\"foo\":\"BAR\",\"hello\":\"WORLD\",\"someNumber\":42}\n```" - ], - "signature": "let stringify: (t, ~replacer: replacer=?, ~space: int=?) => string" - }, - { - "id": "Core.JSON.stringifyWithIndent", - "kind": "value", - "name": "stringifyWithIndent", - "docstrings": [ - "`stringifyWithIndent(json, indentation)` \n\nConverts a JSON object to a JSON string. The output will be indented.\nIf you want to stringify any type, use `JSON.stringifyAnyWithIndent` instead.\n\n## Examples\n```rescript\nlet json =\n Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n ])->JSON.Encode.object\n\nJSON.stringifyWithIndent(json, 2)\n// {\n// \"foo\": \"bar\",\n// \"hello\": \"world\",\n// \"someNumber\": 42\n// }\n```" - ], - "signature": "let stringifyWithIndent: (t, int) => string", - "deprecated": "Use `stringify` with optional parameter instead" - }, - { - "id": "Core.JSON.stringifyWithReplacer", - "kind": "value", - "name": "stringifyWithReplacer", - "docstrings": [ - "`stringifyWithReplacer(json, replacer)` \n\nConverts a JSON object to a JSON string.\nThe replacer describes how the value should be transformed. It is a function which receives a key and a value.\nIf you want to stringify any type, use `JSON.stringifyAnyWithReplacer` instead.\n\n## Examples\n```rescript\nlet json =\n Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n ])->JSON.Encode.object\n\nlet replacer = (_, value) => {\n let decodedValue = value->JSON.Decode.string\n\n switch decodedValue {\n | Some(string) => string->String.toUpperCase->JSON.Encode.string\n | None => value\n }\n}\n\nJSON.stringifyWithReplacer(json, replacer)\n// {\"foo\":\"BAR\",\"hello\":\"WORLD\",\"someNumber\":42}\n```" - ], - "signature": "let stringifyWithReplacer: (t, (string, t) => t) => string", - "deprecated": "Use `stringify` with optional parameter instead" - }, - { - "id": "Core.JSON.stringifyWithReplacerAndIndent", - "kind": "value", - "name": "stringifyWithReplacerAndIndent", - "docstrings": [ - "`stringifyWithReplacerAndIndent(json, replacer, indentation)`\n\nConverts a JSON object to a JSON string. The output will be indented.\nThe replacer describes how the value should be transformed. It is a function which receives a key and a value.\nIf you want to stringify any type, use `JSON.stringifyAnyWithReplacerAndIndent` instead.\n\n## Examples\n```rescript\nlet json =\n Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n ])->JSON.Encode.object\n\nlet replacer = (_, value) => {\n let decodedValue = value->JSON.Decode.string\n\n switch decodedValue {\n | Some(string) => string->String.toUpperCase->JSON.Encode.string\n | None => value\n }\n}\n\nJSON.stringifyWithReplacerAndIndent(json, replacer, 2)\n// {\n// \"foo\": \"BAR\",\n// \"hello\": \"WORLD\",\n// \"someNumber\": 42\n// }\n```" - ], - "signature": "let stringifyWithReplacerAndIndent: (t, (string, t) => t, int) => string", - "deprecated": "Use `stringify` with optional parameters instead" - }, - { - "id": "Core.JSON.stringifyWithFilter", - "kind": "value", - "name": "stringifyWithFilter", - "docstrings": [ - "`stringifyWithFilter(json, filter)` \n\nConverts a JSON object to a JSON string.\nThe filter is an array of keys, which should be included in the output.\nIf you want to stringify any type, use `JSON.stringifyAnyWithFilter` instead.\n\n## Examples\n```rescript\nlet json =\n Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n ])->JSON.Encode.object\n\nJSON.stringifyWithFilter(json, [\"foo\", \"someNumber\"])\n// {\"foo\":\"bar\",\"someNumber\":42}\n```" - ], - "signature": "let stringifyWithFilter: (t, array) => string", - "deprecated": "Use `stringify` with optional parameter instead" - }, - { - "id": "Core.JSON.stringifyWithFilterAndIndent", - "kind": "value", - "name": "stringifyWithFilterAndIndent", - "docstrings": [ - "`stringifyWithFilterAndIndent(json, filter, indentation)` \n\nConverts a JSON object to a JSON string. The output will be indented.\nThe filter is an array of keys, which should be included in the output.\nIf you want to stringify any type, use `JSON.stringifyAnyWithFilterAndIndent` instead.\n\n## Examples\n```rescript\nlet json =\n Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n ])->JSON.Encode.object\n\nJSON.stringifyWithFilterAndIndent(json, [\"foo\", \"someNumber\"], 2)\n// {\n// \"foo\": \"bar\",\n// \"someNumber\": 42\n// }\n```" - ], - "signature": "let stringifyWithFilterAndIndent: (t, array, int) => string", - "deprecated": "Use `stringify` with optional parameters instead" - }, - { - "id": "Core.JSON.stringifyAny", - "kind": "value", - "name": "stringifyAny", - "docstrings": [ - "`stringifyAny(any, ~replacer=?, ~space=?)` \n\nConverts any type to a JSON string.\nThe replacer describes how the value should be transformed. It is a function which receives a key and a value.\nStringifying a function or `undefined` will return `None`.\nIf the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError).\nIf you want to stringify a JSON object, use `JSON.stringify` instead.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n])\n\nJSON.stringifyAny(dict)\n// {\"foo\":\"bar\",\"hello\":\"world\",\"someNumber\":42}\n\nJSON.stringifyAny(dict, ~space=2)\n// {\n// \"foo\": \"bar\",\n// \"hello\": \"world\",\n// \"someNumber\": 42\n// }\n\nJSON.stringifyAny(dict, ~replacer=Keys([\"foo\", \"someNumber\"]))\n// {\"foo\":\"bar\",\"someNumber\":42}\n\nlet replacer = JSON.Replacer((_, value) => {\n let decodedValue = value->JSON.Decode.string\n\n switch decodedValue {\n | Some(string) => string->String.toUpperCase->JSON.Encode.string\n | None => value\n }\n})\n\nJSON.stringifyAny(dict, ~replacer)\n// {\"foo\":\"BAR\",\"hello\":\"WORLD\",\"someNumber\":42}\n\nJSON.stringifyAny(() => \"hello world\")\n// None\n\nBigInt.fromInt(0)->JSON.stringifyAny\n// exception\n```\n\n## Exceptions \n\n- Raises a TypeError if the value contains circular references.\n- Raises a TypeError if the value contains `BigInt`s." - ], - "signature": "let stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option" - }, - { - "id": "Core.JSON.stringifyAnyWithIndent", - "kind": "value", - "name": "stringifyAnyWithIndent", - "docstrings": [ - "`stringifyAnyWithIndent(any, indentation)` \n\nConverts any type to a JSON string. The output will be indented.\nStringifying a function or `undefined` will return `None`.\nIf the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError).\nIf you want to stringify a JSON object, use `JSON.stringifyWithIndent` instead.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n])\n\nJSON.stringifyAnyWithIndent(dict, 2)\n// {\n// \"foo\": \"bar\",\n// \"hello\": \"world\",\n// \"someNumber\": 42\n// }\n\nJSON.stringifyAny(() => \"hello world\")\n// None\n\nBigInt.fromInt(0)->JSON.stringifyAny\n// exception\n```\n\n## Exceptions \n\n- Raises a TypeError if the value contains circular references.\n- Raises a TypeError if the value contains `BigInt`s." - ], - "signature": "let stringifyAnyWithIndent: ('a, int) => option", - "deprecated": "Use `stringifyAny` with optional parameter instead" - }, - { - "id": "Core.JSON.stringifyAnyWithReplacer", - "kind": "value", - "name": "stringifyAnyWithReplacer", - "docstrings": [ - "`stringifyAnyWithReplacer(json, replacer)`\n\nConverts any type to a JSON string.\nThe replacer describes how the value should be transformed. It is a function which receives a key and a value.\nStringifying a function or `undefined` will return `None`.\nIf the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError).\nIf you want to stringify a JSON object, use `JSON.stringifyWithReplacer` instead.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n])\n\nlet replacer = (_, value) => {\n let decodedValue = value->JSON.Decode.string\n\n switch decodedValue {\n | Some(string) => string->String.toUpperCase->JSON.Encode.string\n | None => value\n }\n}\n\nJSON.stringifyAnyWithReplacer(dict, replacer)\n// {\"foo\":\"BAR\",\"hello\":\"WORLD\",\"someNumber\":42}\n\nJSON.stringifyAny(() => \"hello world\")\n// None\n\nBigInt.fromInt(0)->JSON.stringifyAny\n// exception\n```\n\n## Exceptions \n\n- Raises a TypeError if the value contains circular references.\n- Raises a TypeError if the value contains `BigInt`s." - ], - "signature": "let stringifyAnyWithReplacer: ('a, (string, t) => t) => option", - "deprecated": "Use `stringifyAny` with optional parameter instead" - }, - { - "id": "Core.JSON.stringifyAnyWithReplacerAndIndent", - "kind": "value", - "name": "stringifyAnyWithReplacerAndIndent", - "docstrings": [ - "`stringifyAnyWithReplacerAndIndent(json, replacer, indentation)` \n\nConverts any type to a JSON string. The output will be indented.\nThe replacer describes how the value should be transformed. It is a function which receives a key and a value.\nStringifying a function or `undefined` will return `None`.\nIf the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError).\nIf you want to stringify a JSON object, use `JSON.stringifyWithReplacerAndIndent` instead.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n])\n\nlet replacer = (_, value) => {\n let decodedValue = value->JSON.Decode.string\n\n switch decodedValue {\n | Some(string) => string->String.toUpperCase->JSON.Encode.string\n | None => value\n }\n}\n\nJSON.stringifyAnyWithReplacerAndIndent(dict, replacer, 2)\n// {\n// \"foo\": \"BAR\",\n// \"hello\": \"WORLD\",\n// \"someNumber\": 42\n// }\n\nJSON.stringifyAny(() => \"hello world\")\n// None\n\nBigInt.fromInt(0)->JSON.stringifyAny\n// exception\n```\n\n## Exceptions \n\n- Raises a TypeError if the value contains circular references.\n- Raises a TypeError if the value contains `BigInt`s." - ], - "signature": "let stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option", - "deprecated": "Use `stringifyAny` with optional parameters instead" - }, - { - "id": "Core.JSON.stringifyAnyWithFilter", - "kind": "value", - "name": "stringifyAnyWithFilter", - "docstrings": [ - "`stringifyAnyWithFilter(json, filter)` \n\nConverts any type to a JSON string.\nThe filter is an array of keys, which should be included in the output.\nStringifying a function or `undefined` will return `None`.\nIf the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError).\nIf you want to stringify a JSON object, use `JSON.stringifyWithFilter` instead.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n])\n\nJSON.stringifyAnyWithFilter(dict, [\"foo\", \"someNumber\"])\n// {\"foo\": \"bar\",\"someNumber\": 42}\n\nJSON.stringifyAny(() => \"hello world\")\n// None\n\nBigInt.fromInt(0)->JSON.stringifyAny\n// exception\n```\n\n## Exceptions \n\n- Raises a TypeError if the value contains circular references.\n- Raises a TypeError if the value contains `BigInt`s." - ], - "signature": "let stringifyAnyWithFilter: ('a, array) => string", - "deprecated": "Use `stringifyAny` with optional parameter instead" - }, - { - "id": "Core.JSON.stringifyAnyWithFilterAndIndent", - "kind": "value", - "name": "stringifyAnyWithFilterAndIndent", - "docstrings": [ - "`stringifyAnyWithFilterAndIndent(json, filter, indentation)` \n\nConverts any type to a JSON string. The output will be indented.\nThe filter is an array of keys, which should be included in the output.\nStringifying a function or `undefined` will return `None`.\nIf the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError).\nIf you want to stringify a JSON object, use `JSON.stringifyWithFilterAndIndent` instead.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([\n (\"foo\", JSON.Encode.string(\"bar\")),\n (\"hello\", JSON.Encode.string(\"world\")),\n (\"someNumber\", JSON.Encode.int(42)),\n])\n\nJSON.stringifyAnyWithFilterAndIndent(dict, [\"foo\", \"someNumber\"], 2)\n// {\n// \"foo\": \"bar\",\n// \"someNumber\": 42\n// }\n\nJSON.stringifyAny(() => \"hello world\")\n// None\n\nBigInt.fromInt(0)->JSON.stringifyAny\n// exception\n```\n\n## Exceptions \n\n- Raises a TypeError if the value contains circular references.\n- Raises a TypeError if the value contains `BigInt`s." - ], - "signature": "let stringifyAnyWithFilterAndIndent: ('a, array, int) => string", - "deprecated": "Use `stringifyAny` with optional parameters instead" - } - ] - }, - "core/type": { - "id": "Core.Type", - "name": "Type", - "docstrings": [ - "Utilities for classifying the type of JavaScript values at runtime." - ], - "items": [ - { - "id": "Core.Type.t", - "kind": "type", - "name": "t", - "docstrings": ["The possible types of JavaScript values."], - "signature": "type t = [\n | #bigint\n | #boolean\n | #function\n | #number\n | #object\n | #string\n | #symbol\n | #undefined\n]" - }, - { - "id": "Core.Type.typeof", - "kind": "value", - "name": "typeof", - "docstrings": [ - "`typeof(someValue)`\n\nReturns the underlying JavaScript type of any runtime value.\n\nSee [`typeof`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) on MDN.\n\n## Examples\n```rescript\nConsole.log(Type.typeof(\"Hello\")) // Logs \"string\" to the console.\n\nlet someVariable = true\n\nswitch someVariable->Type.typeof {\n| #boolean => Console.log(\"This is a bool, yay!\")\n| _ => Console.log(\"Oh, not a bool sadly...\")\n}\n```" - ], - "signature": "let typeof: 'a => t" - } - ] - }, - "core/symbol": { - "id": "Core.Symbol", - "name": "Symbol", - "docstrings": [], - "items": [ - { - "id": "Core.Symbol.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = Js.Types.symbol" - }, - { - "id": "Core.Symbol.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: string => t" - }, - { - "id": "Core.Symbol.getFor", - "kind": "value", - "name": "getFor", - "docstrings": [], - "signature": "let getFor: string => t" - }, - { - "id": "Core.Symbol.keyFor", - "kind": "value", - "name": "keyFor", - "docstrings": [], - "signature": "let keyFor: t => option" - }, - { - "id": "Core.Symbol.asyncIterator", - "kind": "value", - "name": "asyncIterator", - "docstrings": [], - "signature": "let asyncIterator: t" - }, - { - "id": "Core.Symbol.hasInstance", - "kind": "value", - "name": "hasInstance", - "docstrings": [], - "signature": "let hasInstance: t" - }, - { - "id": "Core.Symbol.isConcatSpreadable", - "kind": "value", - "name": "isConcatSpreadable", - "docstrings": [], - "signature": "let isConcatSpreadable: t" - }, - { - "id": "Core.Symbol.iterator", - "kind": "value", - "name": "iterator", - "docstrings": [], - "signature": "let iterator: t" - }, - { - "id": "Core.Symbol.match", - "kind": "value", - "name": "match", - "docstrings": [], - "signature": "let match: t" - }, - { - "id": "Core.Symbol.matchAll", - "kind": "value", - "name": "matchAll", - "docstrings": [], - "signature": "let matchAll: t" - }, - { - "id": "Core.Symbol.replace", - "kind": "value", - "name": "replace", - "docstrings": [], - "signature": "let replace: t" - }, - { - "id": "Core.Symbol.search", - "kind": "value", - "name": "search", - "docstrings": [], - "signature": "let search: t" - }, - { - "id": "Core.Symbol.species", - "kind": "value", - "name": "species", - "docstrings": [], - "signature": "let species: t" - }, - { - "id": "Core.Symbol.split", - "kind": "value", - "name": "split", - "docstrings": [], - "signature": "let split: t" - }, - { - "id": "Core.Symbol.toPrimitive", - "kind": "value", - "name": "toPrimitive", - "docstrings": [], - "signature": "let toPrimitive: t" - }, - { - "id": "Core.Symbol.toStringTag", - "kind": "value", - "name": "toStringTag", - "docstrings": [], - "signature": "let toStringTag: t" - }, - { - "id": "Core.Symbol.unscopables", - "kind": "value", - "name": "unscopables", - "docstrings": [], - "signature": "let unscopables: t" - } - ] - }, - "core/string": { - "id": "Core.String", - "name": "String", - "docstrings": [ - "Functions for interacting with JavaScript strings.\nSee: [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)." - ], - "items": [ - { - "id": "Core.String.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(value)` converts the given value to a `string`.\n\n## Examples\n\n```rescript\nString.make(3.5) == \"3.5\"\nString.make([1, 2, 3]) == \"1,2,3\"\n```" - ], - "signature": "let make: 'a => string" - }, - { - "id": "Core.String.fromCharCode", - "kind": "value", - "name": "fromCharCode", - "docstrings": [ - "`fromCharCode(n)` creates a `string` containing the character corresponding to\nthat number, `n` ranges from 0 to 65535. If out of range, the lower 16 bits of\nthe value are used. Thus, `fromCharCode(0x1F63A)` gives the same result as\n`fromCharCode(0xF63A)`.\nSee [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) on MDN.\n\n## Examples\n\n```rescript\nString.fromCharCode(65) == \"A\"\nString.fromCharCode(0x3c8) == `ψ`\nString.fromCharCode(0xd55c) == `한`\nString.fromCharCode(-64568) == `ψ`\n```" - ], - "signature": "let fromCharCode: int => string" - }, - { - "id": "Core.String.fromCharCodeMany", - "kind": "value", - "name": "fromCharCodeMany", - "docstrings": [ - "`fromCharCodeMany([n1, n2, n3])` creates a `string` from the characters\ncorresponding to the given numbers, using the same rules as `fromCharCode`.\nSee [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) on MDN.\n\n## Examples\n\n```rescript\nString.fromCharCodeMany([189, 43, 190, 61]) == \"½+¾=\"\nString.fromCharCodeMany([65, 66, 67]) == \"ABC\"\n```" - ], - "signature": "let fromCharCodeMany: array => string" - }, - { - "id": "Core.String.fromCodePoint", - "kind": "value", - "name": "fromCodePoint", - "docstrings": [ - "`fromCodePoint(n)` creates a `string` containing the character corresponding to\nthat numeric code point.\nSee [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN.\n\n## Examples\n\n```rescript\nString.fromCodePoint(65) == \"A\"\nString.fromCodePoint(0x3c8) == `ψ`\nString.fromCodePoint(0xd55c) == `한`\nString.fromCodePoint(0x1f63a) == `😺`\n```\n\n## Exceptions\n\n- `RangeError`: If the number is not a valid code point, like `fromCharCode(-5)`." - ], - "signature": "let fromCodePoint: int => string" - }, - { - "id": "Core.String.fromCodePointMany", - "kind": "value", - "name": "fromCodePointMany", - "docstrings": [ - "`fromCodePointMany([n1, n2, n3])` creates a `string` from the characters\ncorresponding to the given code point numbers, using the same rules as\n`fromCodePoint`.\nSee [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN.\n\n## Examples\n\n```rescript\nString.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺`\n```\n\n## Exceptions\n\n- `RangeError`: If one of the number is not a valid code point, like\n`fromCharCode([1, -5])`." - ], - "signature": "let fromCodePointMany: array => string" - }, - { - "id": "Core.String.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (string, string) => bool" - }, - { - "id": "Core.String.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (string, string) => Core__Ordering.t" - }, - { - "id": "Core.String.length", - "kind": "value", - "name": "length", - "docstrings": [ - "`length(str)` returns the length of the given `string`.\nSee [`String.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) on MDN.\n\n## Examples\n\n```rescript\nString.length(\"abcd\") == 4\n```" - ], - "signature": "let length: string => int" - }, - { - "id": "Core.String.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`get(str, index)` returns an `option` at the given `index` number. If\n`index` is out of range, this function returns `None`.\n\n## Examples\n\n```rescript\nString.get(\"ReScript\", 0) == Some(\"R\")\nString.get(\"Hello\", 4) == Some(\"o\")\nString.get(`JS`, 4) == None\n```" - ], - "signature": "let get: (string, int) => option" - }, - { - "id": "Core.String.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(str, index)` returns an `string` at the given `index` number.\n\nThis is _unsafe_, meaning it will return `undefined` value if `index` does not exist in `string`.\n\nUse `String.getUnsafe` only when you are sure the `index` exists.\n## Examples\n\n```rescript\nString.getUnsafe(\"ReScript\", 0) == \"R\"\nString.getUnsafe(\"Hello\", 4) == \"o\"\n```" - ], - "signature": "let getUnsafe: (string, int) => string" - }, - { - "id": "Core.String.charAt", - "kind": "value", - "name": "charAt", - "docstrings": [ - "`charAt(str, index)` gets the character at `index` within string `str`. If\n`index` is negative or greater than the length of `str`, it returns the empty\nstring. If the string contains characters outside the range \\u0000-\\uffff, it\nwill return the first 16-bit value at that position in the string.\nSee [`String.charAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt) on MDN.\n\n## Examples\n\n```rescript\nString.charAt(\"ReScript\", 0) == \"R\"\nString.charAt(\"Hello\", 12) == \"\"\nString.charAt(`JS`, 5) == \"\"\n```" - ], - "signature": "let charAt: (string, int) => string" - }, - { - "id": "Core.String.charCodeAt", - "kind": "value", - "name": "charCodeAt", - "docstrings": [ - "`charCodeAt(str, index)` returns the character code at position `index` in\nstring `str` the result is in the range 0-65535, unlike `codePointAt`, so it\nwill not work correctly for characters with code points greater than or equal\nto 0x10000. The return type is `float` because this function returns NaN if\n`index` is less than zero or greater than the length of the string.\nSee [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) on MDN.\n\n## Examples\n\n```rescript\nString.charCodeAt(`😺`, 0) == 0xd83d->Int.toFloat\nString.codePointAt(`😺`, 0) == Some(0x1f63a)\n```" - ], - "signature": "let charCodeAt: (string, int) => float" - }, - { - "id": "Core.String.codePointAt", - "kind": "value", - "name": "codePointAt", - "docstrings": [ - "`codePointAt(str, index)` returns the code point at position `index` within\nstring `str` as a `Some(value)`. The return value handles code points greater\nthan or equal to 0x10000. If there is no code point at the given position, the\nfunction returns `None`.\nSee [`String.codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) on MDN.\n\n## Examples\n\n```rescript\nString.codePointAt(`¿😺?`, 1) == Some(0x1f63a)\nString.codePointAt(\"abc\", 5) == None\n```" - ], - "signature": "let codePointAt: (string, int) => option" - }, - { - "id": "Core.String.concat", - "kind": "value", - "name": "concat", - "docstrings": [ - "`concat(original, append)` returns a new `string` with `append` added after\n`original`.\nSee [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat) on MDN.\n\n## Examples\n\n```rescript\nString.concat(\"cow\", \"bell\") == \"cowbell\"\nString.concat(\"Re\", \"Script\") == \"ReScript\"\n```" - ], - "signature": "let concat: (string, string) => string" - }, - { - "id": "Core.String.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [ - "`concatMany(original, arr)` returns a new `string` consisting of each item of an\narray of strings added to the `original` string.\nSee [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat) on MDN.\n\n## Examples\n\n```rescript\nString.concatMany(\"1st\", [\"2nd\", \"3rd\", \"4th\"]) == \"1st2nd3rd4th\"\n```" - ], - "signature": "let concatMany: (string, array) => string" - }, - { - "id": "Core.String.endsWith", - "kind": "value", - "name": "endsWith", - "docstrings": [ - "`endsWith(str, substr)` returns `true` if the `str` ends with `substr`, `false`\notherwise.\nSee [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith) on MDN.\n\n## Examples\n\n```rescript\nString.endsWith(\"BuckleScript\", \"Script\") == true\nString.endsWith(\"BuckleShoes\", \"Script\") == false\n```" - ], - "signature": "let endsWith: (string, string) => bool" - }, - { - "id": "Core.String.endsWithFrom", - "kind": "value", - "name": "endsWithFrom", - "docstrings": [ - "`endsWithFrom(str, ending, len)` returns `true` if the first len characters of\n`str` end with `ending`, `false` otherwise. If `len` is greater than or equal\nto the length of `str`, then it works like `endsWith`.\nSee [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith) on MDN.\n\n## Examples\n\n```rescript\nString.endsWithFrom(\"abcd\", \"cd\", 4) == true\nString.endsWithFrom(\"abcde\", \"cd\", 3) == false\nString.endsWithFrom(\"abcde\", \"cde\", 99) == true\nString.endsWithFrom(\"example.dat\", \"ple\", 7) == true\n```" - ], - "signature": "let endsWithFrom: (string, string, int) => bool" - }, - { - "id": "Core.String.includes", - "kind": "value", - "name": "includes", - "docstrings": [ - "`includes(str, searchValue)` returns `true` if `searchValue` is found anywhere\nwithin `str`, `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includes(\"programmer\", \"gram\") == true\nString.includes(\"programmer\", \"er\") == true\nString.includes(\"programmer\", \"pro\") == true\nString.includes(\"programmer.dat\", \"xyz\") == false\n```" - ], - "signature": "let includes: (string, string) => bool" - }, - { - "id": "Core.String.includesFrom", - "kind": "value", - "name": "includesFrom", - "docstrings": [ - "`includesFrom(str, searchValue, start)` returns `true` if `searchValue` is found\nanywhere within `str` starting at character number `start` (where 0 is the\nfirst character), `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includesFrom(\"programmer\", \"gram\", 1) == true\nString.includesFrom(\"programmer\", \"gram\", 4) == false\nString.includesFrom(`대한민국`, `한`, 1) == true\n```" - ], - "signature": "let includesFrom: (string, string, int) => bool" - }, - { - "id": "Core.String.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [ - "`indexOf(str, searchValue)` returns the position at which `searchValue` was\nfirst found within `str`, or `-1` if `searchValue` is not in `str`.\nSee [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) on MDN.\n\n## Examples\n\n```rescript\nString.indexOf(\"bookseller\", \"ok\") == 2\nString.indexOf(\"bookseller\", \"sell\") == 4\nString.indexOf(\"beekeeper\", \"ee\") == 1\nString.indexOf(\"bookseller\", \"xyz\") == -1\n```" - ], - "signature": "let indexOf: (string, string) => int" - }, - { - "id": "Core.String.indexOfOpt", - "kind": "value", - "name": "indexOfOpt", - "docstrings": [ - "`indexOfOpt(str, searchValue)`. Like `indexOf`, but return an `option`.\n\n## Examples\n\n```rescript\nString.indexOfOpt(\"bookseller\", \"ok\") == Some(2)\nString.indexOfOpt(\"bookseller\", \"xyz\") == None\n```" - ], - "signature": "let indexOfOpt: (string, string) => option" - }, - { - "id": "Core.String.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [ - "`indexOfFrom(str, searchValue, start)` returns the position at which\n`searchValue` was found within `str` starting at character position `start`, or\n`-1` if `searchValue` is not found in that portion of `str`. The return value is\nrelative to the beginning of the string, no matter where the search started\nfrom.\nSee [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) on MDN.\n\n## Examples\n\n```rescript\nString.indexOfFrom(\"bookseller\", \"ok\", 1) == 2\nString.indexOfFrom(\"bookseller\", \"sell\", 2) == 4\nString.indexOfFrom(\"bookseller\", \"sell\", 5) == -1\n```" - ], - "signature": "let indexOfFrom: (string, string, int) => int" - }, - { - "id": "Core.String.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [ - "`lastIndexOf(str, searchValue)` returns the position of the last occurrence of\n`searchValue` within `str`, searching backwards from the end of the string.\nReturns `-1` if `searchValue` is not in `str`. The return value is always\nrelative to the beginning of the string.\nSee [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf) on MDN.\n\n## Examples\n\n```rescript\nString.lastIndexOf(\"bookseller\", \"ok\") == 2\nString.lastIndexOf(\"beekeeper\", \"ee\") == 4\nString.lastIndexOf(\"abcdefg\", \"xyz\") == -1\n```" - ], - "signature": "let lastIndexOf: (string, string) => int" - }, - { - "id": "Core.String.lastIndexOfOpt", - "kind": "value", - "name": "lastIndexOfOpt", - "docstrings": [ - "`lastIndexOfOpt(str, searchValue)`. Like `lastIndexOfOpt`, but return an\n`option`.\n\n## Examples\n\n```rescript\nString.lastIndexOfOpt(\"bookseller\", \"ok\") == Some(2)\nString.lastIndexOfOpt(\"beekeeper\", \"ee\") == Some(4)\nString.lastIndexOfOpt(\"abcdefg\", \"xyz\") == None\n```" - ], - "signature": "let lastIndexOfOpt: (string, string) => option" - }, - { - "id": "Core.String.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [ - "`lastIndexOfFrom(str, searchValue, start)` returns the position of the last\noccurrence of `searchValue` within `str`, searching backwards from the given\nstart position. Returns `-1` if `searchValue` is not in `str`. The return value\nis always relative to the beginning of the string.\nSee [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf) on MDN.\n\n## Examples\n\n```rescript\nString.lastIndexOfFrom(\"bookseller\", \"ok\", 6) == 2\nString.lastIndexOfFrom(\"beekeeper\", \"ee\", 8) == 4\nString.lastIndexOfFrom(\"beekeeper\", \"ee\", 3) == 1\nString.lastIndexOfFrom(\"abcdefg\", \"xyz\", 4) == -1\n```" - ], - "signature": "let lastIndexOfFrom: (string, string, int) => int" - }, - { - "id": "Core.String.match", - "kind": "value", - "name": "match", - "docstrings": [ - "`match(str, regexp)` matches a `string` against the given `regexp`. If there is\nno match, it returns `None`. For regular expressions without the g modifier, if\nthere is a match, the return value is `Some(array)` where the array contains:\n- The entire matched string\n- Any capture groups if the regexp had parentheses\nFor regular expressions with the g modifier, a matched expression returns\n`Some(array)` with all the matched substrings and no capture groups.\nSee [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) on MDN.\n\n## Examples\n\n```rescript\nString.match(\"The better bats\", %re(\"/b[aeiou]t/\")) == Some([Some(\"bet\")])\nString.match(\"The better bats\", %re(\"/b[aeiou]t/g\")) == Some([Some(\"bet\"), Some(\"bat\")])\nString.match(\"Today is 2018-04-05.\", %re(\"/(\\d+)-(\\d+)-(\\d+)/\")) ==\n Some([Some(\"2018-04-05\"), Some(\"2018\"), Some(\"04\"), Some(\"05\")])\nString.match(\"The optional example\", %re(\"/(foo)?(example)/\")) == Some([Some(\"example\"), None, Some(\"example\")])\nString.match(\"The large container.\", %re(\"/b[aeiou]g/\")) == None\n```" - ], - "signature": "let match: (string, Core__RegExp.t) => option" - }, - { - "id": "Core.String.normalize", - "kind": "value", - "name": "normalize", - "docstrings": [ - "`normalize(str)` returns the normalized Unicode string using Normalization Form\nCanonical (NFC) Composition. Consider the character ã, which can be represented\nas the single codepoint \\u00e3 or the combination of a lower case letter A\n\\u0061 and a combining tilde \\u0303. Normalization ensures that both can be\nstored in an equivalent binary representation.\nSee [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) on MDN.\nSee also [Unicode technical report #15](https://unicode.org/reports/tr15/) for details.\n\n## Examples\n\n```rescript\nlet string1 = \"\\uFB00\"\nlet string2 = \"\\u0066\\u0066\"\nConsole.log(string1 === string2) // false\n\nlet normalizeString1 = String.normalize(string1)\nlet normalizeString2 = String.normalize(string2)\nassert(normalizeString1 === normalizeString2)\n```" - ], - "signature": "let normalize: string => string" - }, - { - "id": "Core.String.normalizeForm", - "kind": "type", - "name": "normalizeForm", - "docstrings": [ - "`normalizeByForm(str, form)` returns the normalized Unicode string using the\nspecified form of normalization, which may be one of:\n- \"NFC\" — Normalization Form Canonical Composition.\n- \"NFD\" — Normalization Form Canonical Decomposition.\n- \"NFKC\" — Normalization Form Compatibility Composition.\n- \"NFKD\" — Normalization Form Compatibility Decomposition.\nSee [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) on MDN.\nSee also [Unicode technical report #15](https://unicode.org/reports/tr15/) for\ndetails.\n\n## Examples\n\n```rescript\nlet string1 = \"\\uFB00\"\nlet string2 = \"\\u0066\\u0066\"\nConsole.log(string1 == string2) // false\n\nlet normalizeString1 = String.normalizeByForm(string1, #NFKD)\nlet normalizeString2 = String.normalizeByForm(string2, #NFKD)\nConsole.log(normalizeString1 == normalizeString2) // true\n```" - ], - "signature": "type normalizeForm = [#NFC | #NFD | #NFKC | #NFKD]" - }, - { - "id": "Core.String.normalizeByForm", - "kind": "value", - "name": "normalizeByForm", - "docstrings": [], - "signature": "let normalizeByForm: (string, normalizeForm) => string" - }, - { - "id": "Core.String.repeat", - "kind": "value", - "name": "repeat", - "docstrings": [ - "`repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`.\nSee [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN.\n\n## Examples\n\n```rescript\nString.repeat(\"ha\", 3) == \"hahaha\"\nString.repeat(\"empty\", 0) == \"\"\n```\n\n## Exceptions\n\n- `RangeError`: if `n` is negative." - ], - "signature": "let repeat: (string, int) => string" - }, - { - "id": "Core.String.replace", - "kind": "value", - "name": "replace", - "docstrings": [ - "`replace(str, substr, newSubstr)` returns a new `string` which is\nidentical to `str` except with the first matching instance of `substr` replaced\nby `newSubstr`. `substr` is treated as a verbatim string to match, not a\nregular expression.\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN.\n\n## Examples\n\n```rescript\nString.replace(\"old string\", \"old\", \"new\") == \"new string\"\nString.replace(\"the cat and the dog\", \"the\", \"this\") == \"this cat and the dog\"\n```" - ], - "signature": "let replace: (string, string, string) => string" - }, - { - "id": "Core.String.replaceRegExp", - "kind": "value", - "name": "replaceRegExp", - "docstrings": [ - "`replaceRegExp(str, regex, replacement)` returns a new `string` where\noccurrences matching regex have been replaced by `replacement`.\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN.\n\n## Examples\n\n```rescript\nString.replaceRegExp(\"vowels be gone\", %re(\"/[aeiou]/g\"), \"x\") == \"vxwxls bx gxnx\"\nString.replaceRegExp(\"Juan Fulano\", %re(\"/(\\w+) (\\w+)/\"), \"$2, $1\") == \"Fulano, Juan\"\n```" - ], - "signature": "let replaceRegExp: (string, Core__RegExp.t, string) => string" - }, - { - "id": "Core.String.replaceAll", - "kind": "value", - "name": "replaceAll", - "docstrings": [ - "`replaceAll(str, substr, newSubstr)` returns a new `string` which is\nidentical to `str` except with all matching instances of `substr` replaced\nby `newSubstr`. `substr` is treated as a verbatim string to match, not a\nregular expression.\nSee [`String.replaceAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll) on MDN.\n\n## Examples\n\n```rescript\nString.replaceAll(\"old old string\", \"old\", \"new\") == \"new new string\"\nString.replaceAll(\"the cat and the dog\", \"the\", \"this\") == \"this cat and this dog\"\n```" - ], - "signature": "let replaceAll: (string, string, string) => string" - }, - { - "id": "Core.String.replaceAllRegExp", - "kind": "value", - "name": "replaceAllRegExp", - "docstrings": [ - "`replaceAllRegExp(str, regex, replacement)` returns a new `string` where\nall occurrences matching regex have been replaced by `replacement`.\nThe pattern must include the global (`g`) flag or a runtime TypeError will be thrown.\nSee [`String.replaceAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll) on MDN.\n\n## Examples\n\n```rescript\nString.replaceAllRegExp(\"vowels be gone\", %re(\"/[aeiou]/g\"), \"x\") == \"vxwxls bx gxnx\"\nString.replaceAllRegExp(\"aabbcc\", %re(\"/b/g\"), \".\") == \"aa..cc\"\n```" - ], - "signature": "let replaceAllRegExp: (string, Core__RegExp.t, string) => string" - }, - { - "id": "Core.String.unsafeReplaceRegExpBy0", - "kind": "value", - "name": "unsafeReplaceRegExpBy0", - "docstrings": [ - "`unsafeReplaceRegExpBy0(str, regex, f)` returns a new `string` with some or all\nmatches of a pattern with no capturing parentheses replaced by the value\nreturned from the given function. The function receives as its parameters the\nmatched string, the offset at which the match begins, and the whole string being\nmatched.\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN.\n\n## Examples\n\n```rescript\nlet str = \"beautiful vowels\"\nlet re = %re(\"/[aeiou]/g\")\nlet matchFn = (~match, ~offset as _, ~input as _) => String.toUpperCase(match)\nString.unsafeReplaceRegExpBy0(str, re, matchFn) == \"bEAUtIfUl vOwEls\"\n```" - ], - "signature": "let unsafeReplaceRegExpBy0: (\n string,\n Core__RegExp.t,\n (~match: string, ~offset: int, ~input: string) => string,\n) => string" - }, - { - "id": "Core.String.unsafeReplaceRegExpBy1", - "kind": "value", - "name": "unsafeReplaceRegExpBy1", - "docstrings": [ - "`unsafeReplaceRegExpBy1(str, regexp, f)`. Like `unsafeReplaceRegExpBy0`, but `f`\nhas `group1` parameter.\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN.\n\n## Examples\n\n```rescript\nlet str = \"Jony is 40\"\nlet re = %re(\"/(Jony is )\\d+/g\")\nlet matchFn = (~match as _, ~group1, ~offset as _, ~input as _) => {\n group1 ++ \"41\"\n}\nString.unsafeReplaceRegExpBy1(str, re, matchFn) == \"Jony is 41\"\n```" - ], - "signature": "let unsafeReplaceRegExpBy1: (\n string,\n Core__RegExp.t,\n (\n ~match: string,\n ~group1: string,\n ~offset: int,\n ~input: string,\n ) => string,\n) => string" - }, - { - "id": "Core.String.unsafeReplaceRegExpBy2", - "kind": "value", - "name": "unsafeReplaceRegExpBy2", - "docstrings": [ - "`unsafeReplaceRegExpBy2(str, regexp, f)`. Like `unsafeReplaceRegExpBy1`, but `f`\nhas two group parameters.\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN.\n\n## Examples\n\n```rescript\nlet str = \"7 times 6\"\nlet re = %re(\"/(\\d+) times (\\d+)/\")\nlet matchFn = (~match as _, ~group1, ~group2, ~offset as _, ~input as _) => {\n switch (Int.fromString(group1), Int.fromString(group2)) {\n | (Some(x), Some(y)) => Int.toString(x * y)\n | _ => \"???\"\n }\n}\nString.unsafeReplaceRegExpBy2(str, re, matchFn) == \"42\"\n```" - ], - "signature": "let unsafeReplaceRegExpBy2: (\n string,\n Core__RegExp.t,\n (\n ~match: string,\n ~group1: string,\n ~group2: string,\n ~offset: int,\n ~input: string,\n ) => string,\n) => string" - }, - { - "id": "Core.String.unsafeReplaceRegExpBy3", - "kind": "value", - "name": "unsafeReplaceRegExpBy3", - "docstrings": [ - "`unsafeReplaceRegExpBy3(str, regexp, f)`. Like `unsafeReplaceRegExpBy1`, but `f`\nhas three group parameters.\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN." - ], - "signature": "let unsafeReplaceRegExpBy3: (\n string,\n Core__RegExp.t,\n (\n ~match: string,\n ~group1: string,\n ~group2: string,\n ~group3: string,\n ~offset: int,\n ~input: string,\n ) => string,\n) => string" - }, - { - "id": "Core.String.search", - "kind": "value", - "name": "search", - "docstrings": [ - "`search(str, regexp)` returns the starting position of the first match of\n`regexp` in the given `str`, or -1 if there is no match.\nSee [`String.search`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search) on MDN.\n\n## Examples\n\n```rescript\nString.search(\"testing 1 2 3\", %re(\"/\\d+/\")) == 8\nString.search(\"no numbers\", %re(\"/\\d+/\")) == -1\n```" - ], - "signature": "let search: (string, Core__RegExp.t) => int" - }, - { - "id": "Core.String.searchOpt", - "kind": "value", - "name": "searchOpt", - "docstrings": [ - "`searchOpt(str, regexp)`. Like `search`, but return an `option`.\n\n## Examples\n\n```rescript\nString.searchOpt(\"testing 1 2 3\", %re(\"/\\d+/\")) == Some(8)\nString.searchOpt(\"no numbers\", %re(\"/\\d+/\")) == None\n```" - ], - "signature": "let searchOpt: (string, Core__RegExp.t) => option" - }, - { - "id": "Core.String.slice", - "kind": "value", - "name": "slice", - "docstrings": [ - "`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n`length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n`length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\nSee [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\n```" - ], - "signature": "let slice: (string, ~start: int, ~end: int) => string" - }, - { - "id": "Core.String.sliceToEnd", - "kind": "value", - "name": "sliceToEnd", - "docstrings": [ - "`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\nSee [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```" - ], - "signature": "let sliceToEnd: (string, ~start: int) => string" - }, - { - "id": "Core.String.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(str, delimiter)` splits the given `str` at every occurrence of\n`delimiter` and returns an array of the resulting substrings.\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) on MDN.\n\n## Examples\n\n```rescript\nString.split(\"2018-01-02\", \"-\") == [\"2018\", \"01\", \"02\"]\nString.split(\"a,b,,c\", \",\") == [\"a\", \"b\", \"\", \"c\"]\nString.split(\"good::bad as great::awful\", \"::\") == [\"good\", \"bad as great\", \"awful\"]\nString.split(\"has-no-delimiter\", \";\") == [\"has-no-delimiter\"]\n```" - ], - "signature": "let split: (string, string) => array" - }, - { - "id": "Core.String.splitAtMost", - "kind": "value", - "name": "splitAtMost", - "docstrings": [ - "`splitAtMost(str, delimiter, ~limit)` splits the given `str` at every\noccurrence of `delimiter` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings,\nthe array will contain all the substrings.\n\n## Examples\n\n```rescript\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=3) == [\"ant\", \"bee\", \"cat\"]\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=0) == []\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=9) == [\"ant\", \"bee\", \"cat\", \"dog\", \"elk\"]\n```" - ], - "signature": "let splitAtMost: (string, string, ~limit: int) => array" - }, - { - "id": "Core.String.splitByRegExp", - "kind": "value", - "name": "splitByRegExp", - "docstrings": [ - "`splitByRegExp(str, regexp)` splits the given `str` at every occurrence of\n`regexp` and returns an array of the resulting substrings.\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) on MDN.\n\n## Examples\n\n```rescript\nString.splitByRegExp(\"Jan,Feb,Mar\", %re(\"/,/\")) == [Some(\"Jan\"), Some(\"Feb\"), Some(\"Mar\")]\n```" - ], - "signature": "let splitByRegExp: (string, Core__RegExp.t) => array>" - }, - { - "id": "Core.String.splitByRegExpAtMost", - "kind": "value", - "name": "splitByRegExpAtMost", - "docstrings": [ - "`splitByRegExpAtMost(str, regexp, ~limit)` splits the given `str` at every\noccurrence of `regexp` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings, the\narray will contain all the substrings.\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) on MDN.\n\n## Examples\n\n```rescript\nString.splitByRegExpAtMost(\"Hello World. How are you doing?\", %re(\"/ /\"), ~limit=3) == [\n Some(\"Hello\"),\n Some(\"World.\"),\n Some(\"How\"),\n]\n```" - ], - "signature": "let splitByRegExpAtMost: (\n string,\n Core__RegExp.t,\n ~limit: int,\n) => array>" - }, - { - "id": "Core.String.startsWith", - "kind": "value", - "name": "startsWith", - "docstrings": [ - "`startsWith(str, substr)` returns `true` if the `str` starts with `substr`,\n`false` otherwise.\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) on MDN.\n\n## Examples\n\n```rescript\nString.startsWith(\"BuckleScript\", \"Buckle\") == true\nString.startsWith(\"BuckleScript\", \"\") == true\nString.startsWith(\"JavaScript\", \"Buckle\") == false\n```" - ], - "signature": "let startsWith: (string, string) => bool" - }, - { - "id": "Core.String.startsWithFrom", - "kind": "value", - "name": "startsWithFrom", - "docstrings": [ - "`startsWithFrom(str, substr, n)` returns `true` if the `str` starts\nwith `substr` starting at position `n`, `false` otherwise. If `n` is negative,\nthe search starts at the beginning of `str`.\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) on MDN.\n\n## Examples\n\n```rescript\nString.startsWithFrom(\"BuckleScript\", \"kle\", 3) == true\nString.startsWithFrom(\"BuckleScript\", \"\", 3) == true\nString.startsWithFrom(\"JavaScript\", \"Buckle\", 2) == false\n```" - ], - "signature": "let startsWithFrom: (string, string, int) => bool" - }, - { - "id": "Core.String.substring", - "kind": "value", - "name": "substring", - "docstrings": [ - "`substring(str, ~start, ~end)` returns characters `start` up to but not\nincluding end from `str`.\n- If `start` is less than zero, it is treated as zero.\n- If `end` is zero or negative, the empty string is returned.\n- If `start` is greater than `end`, the `start` and `end` points are swapped.\nSee [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substring(\"playground\", ~start=3, ~end=6) == \"ygr\"\nString.substring(\"playground\", ~start=6, ~end=3) == \"ygr\"\nString.substring(\"playground\", ~start=4, ~end=12) == \"ground\"\n```" - ], - "signature": "let substring: (string, ~start: int, ~end: int) => string" - }, - { - "id": "Core.String.substringToEnd", - "kind": "value", - "name": "substringToEnd", - "docstrings": [ - "`substringToEnd(str, ~start)` returns the substring of `str` from position\n`start` to the end.\n- If `start` is less than or equal to zero, the entire string is returned.\n- If `start` is greater than or equal to the length of `str`, the empty string\nis returned.\nSee [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substringToEnd(\"playground\", ~start=4) == \"ground\"\nString.substringToEnd(\"playground\", ~start=-3) == \"playground\"\nString.substringToEnd(\"playground\", ~start=12) == \"\"\n```" - ], - "signature": "let substringToEnd: (string, ~start: int) => string" - }, - { - "id": "Core.String.toLowerCase", - "kind": "value", - "name": "toLowerCase", - "docstrings": [ - "`toLowerCase(str)` converts `str` to lower case using the locale-insensitive\ncase mappings in the Unicode Character Database. Notice that the conversion can\ngive different results depending upon context, for example with the Greek\nletter sigma, which has two different lower case forms, one when it is the last\ncharacter in a string and another when it is not.\nSee [`String.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase) on MDN.\n\n## Examples\n\n```rescript\nString.toLowerCase(\"ABC\") == \"abc\"\nString.toLowerCase(`ΣΠ`) == `σπ`\nString.toLowerCase(`ΠΣ`) == `πς`\n```" - ], - "signature": "let toLowerCase: string => string" - }, - { - "id": "Core.String.toLocaleLowerCase", - "kind": "value", - "name": "toLocaleLowerCase", - "docstrings": [ - "`toLocaleLowerCase(str)` converts `str` to lower case using the current locale.\nSee [`String.toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase) on MDN." - ], - "signature": "let toLocaleLowerCase: string => string" - }, - { - "id": "Core.String.toUpperCase", - "kind": "value", - "name": "toUpperCase", - "docstrings": [ - "`toUpperCase(str)` converts `str` to upper case using the locale-insensitive\ncase mappings in the Unicode Character Database. Notice that the conversion can\nexpand the number of letters in the result, for example the German ß\ncapitalizes to two Ses in a row.\nSee [`String.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase) on MDN.\n\n## Examples\n\n```rescript\nString.toUpperCase(\"abc\") == \"ABC\"\nString.toUpperCase(`Straße`) == `STRASSE`\nString.toUpperCase(`πς`) == `ΠΣ`\n```" - ], - "signature": "let toUpperCase: string => string" - }, - { - "id": "Core.String.toLocaleUpperCase", - "kind": "value", - "name": "toLocaleUpperCase", - "docstrings": [ - "`toLocaleUpperCase(str)` converts `str` to upper case using the current locale.\nSee [`String.toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase) on MDN." - ], - "signature": "let toLocaleUpperCase: string => string" - }, - { - "id": "Core.String.trim", - "kind": "value", - "name": "trim", - "docstrings": [ - "`trim(str)` returns a string that is `str` with whitespace stripped from both\nends. Internal whitespace is not removed.\nSee [`String.trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) on MDN.\n\n## Examples\n\n```rescript\nString.trim(\" abc def \") == \"abc def\"\nString.trim(\"\\n\\r\\t abc def \\n\\n\\t\\r \") == \"abc def\"\n```" - ], - "signature": "let trim: string => string" - }, - { - "id": "Core.String.trimStart", - "kind": "value", - "name": "trimStart", - "docstrings": [ - "`trimStart(str)` returns a string that is `str` with whitespace stripped from\nthe beginning of a string. Internal whitespace is not removed.\nSee [`String.trimStart`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart) on MDN.\n\n## Examples\n\n```rescript\nString.trimStart(\" Hello world! \") == \"Hello world! \"\nString.trimStart(\" Hello world! \") == \"Hello world! \"\n```" - ], - "signature": "let trimStart: string => string" - }, - { - "id": "Core.String.trimEnd", - "kind": "value", - "name": "trimEnd", - "docstrings": [ - "`trinEnd(str)` returns a string that is `str` with whitespace stripped from the\nend of a string. Internal whitespace is not removed.\nSee [`String.trimEnd`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd) on MDN.\n\n## Examples\n\n```rescript\nString.trimEnd(\" Hello world! \") == \" Hello world!\"\nString.trimEnd(\" Hello world! \") == \" Hello world!\"\n```" - ], - "signature": "let trimEnd: string => string" - }, - { - "id": "Core.String.padStart", - "kind": "value", - "name": "padStart", - "docstrings": [ - "`padStart(str, n, padStr)` returns a string that has been padded with `padStr`\n(multiple times, if needed) until the resulting string reaches the given `n`\nlength. The padding is applied from the start of the current string.\nSee [`String.padStart`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart) on MDN.\n\n## Examples\n\n```rescript\nString.padStart(\"abc\", 5, \" \") == \" abc\"\nString.padStart(\"abc\", 6, \"123465\") == \"123abc\"\n```" - ], - "signature": "let padStart: (string, int, string) => string" - }, - { - "id": "Core.String.padEnd", - "kind": "value", - "name": "padEnd", - "docstrings": [ - "`padEnd(str, n, padStr)` returns a string that has been padded with `padStr`\n(multiple times, if needed) until the resulting string reaches the given `n`\nlength. The padding is applied from the end of the current string.\nSee [`String.padEnd`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd) on MDN.\n\n## Examples\n\n```rescript\nString.padEnd(\"Hello\", 10, \".\") == \"Hello.....\"\nString.padEnd(\"abc\", 1, \"\") == \"abc\"\n```" - ], - "signature": "let padEnd: (string, int, string) => string" - }, - { - "id": "Core.String.getSymbol", - "kind": "value", - "name": "getSymbol", - "docstrings": [], - "signature": "let getSymbol: (string, Core__Symbol.t) => option<'a>" - }, - { - "id": "Core.String.getSymbolUnsafe", - "kind": "value", - "name": "getSymbolUnsafe", - "docstrings": [], - "signature": "let getSymbolUnsafe: (string, Core__Symbol.t) => 'a" - }, - { - "id": "Core.String.setSymbol", - "kind": "value", - "name": "setSymbol", - "docstrings": [], - "signature": "let setSymbol: (string, Core__Symbol.t, 'a) => unit" - }, - { - "id": "Core.String.localeCompare", - "kind": "value", - "name": "localeCompare", - "docstrings": [ - "`localeCompare(referenceStr, compareStr)` returns a float than indicatings\nwhether a reference string comes before or after, or is the same as the given\nstring in sort order. If `referenceStr` occurs before `compareStr` positive if\nthe `referenceStr` occurs after `compareStr`, `0` if they are equivalent.\nDo not rely on exact return values of `-1` or `1`\nSee [`String.localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare) on MDN.\n\n## Examples\n\n```rescript\nString.localeCompare(\"a\", \"c\") < 0.0 == true\nString.localeCompare(\"a\", \"a\") == 0.0\n```" - ], - "signature": "let localeCompare: (string, string) => float" - } - ] - }, - "core/regexp": { - "id": "Core.RegExp", - "name": "RegExp", - "docstrings": [ - "Functions for handling RegExp's in ReScript.\n\nSee [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) on MDN." - ], - "items": [ - { - "id": "Core.RegExp.t", - "kind": "type", - "name": "t", - "docstrings": ["Type representing an instantiated `RegExp`."], - "signature": "type t = Js.Re.t" - }, - { - "id": "Core.RegExp.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "`fromString(string)` creates a `RegExp.t` from the provided string. This can then be used to match on strings using `RegExp.exec`.\n\nSee [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) on MDN.\n\n## Examples\n```rescript\n// Match the first word in a sentence\nlet regexp = RegExp.fromString(\"\\\\w+\")\n\nswitch regexp->RegExp.exec(\"ReScript is pretty cool, right?\") {\n| None => Console.log(\"Nope, no match...\")\n| Some(result) => Console.log(result->RegExp.Result.fullMatch) // Prints \"ReScript\"\n}\n```" - ], - "signature": "let fromString: string => t" - }, - { - "id": "Core.RegExp.fromStringWithFlags", - "kind": "value", - "name": "fromStringWithFlags", - "docstrings": [ - "`fromStringWithFlags(string)` creates a `RegExp.t` from the provided string, using the provided `flags`. This can then be used to match on strings using `RegExp.exec`.\n\nSee [`RegExp parameters`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp#parameters) on MDN.\n\n## Examples\n```rescript\n// Match the first word in a sentence\nlet regexp = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\n\nswitch regexp->RegExp.exec(\"ReScript is pretty cool, right?\") {\n| None => Console.log(\"Nope, no match...\")\n| Some(result) => Console.log(result->RegExp.Result.fullMatch) // Prints \"ReScript\"\n}\n```" - ], - "signature": "let fromStringWithFlags: (string, ~flags: string) => t" - }, - { - "id": "Core.RegExp.test", - "kind": "value", - "name": "test", - "docstrings": [ - "`test(regexp, string)` tests whether the provided `regexp` matches on the provided string.\n\nSee [`RegExp.test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) on MDN.\n\n## Examples\n```rescript\n// Match the first word in a sentence\nlet regexp = RegExp.fromString(\"\\\\w+\")\n\nif regexp->RegExp.test(\"ReScript is cool!\") {\n Console.log(\"Yay, there's a word in there.\")\n}\n```" - ], - "signature": "let test: (t, string) => bool" - }, - { - "id": "Core.RegExp.exec", - "kind": "value", - "name": "exec", - "docstrings": [ - "`exec(regexp, string)` executes the provided regexp on the provided string, optionally returning a `RegExp.Result.t` if the regexp matches on the string.\n\nSee [`RegExp.exec`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) on MDN.\n\n## Examples\n```rescript\n// Match the first word in a sentence\nlet regexp = RegExp.fromString(\"\\\\w+\")\n\nswitch regexp->RegExp.exec(\"ReScript is pretty cool, right?\") {\n| None => Console.log(\"Nope, no match...\")\n| Some(result) => Console.log(result->RegExp.Result.fullMatch) // Prints \"ReScript\"\n}\n```" - ], - "signature": "let exec: (t, string) => option" - }, - { - "id": "Core.RegExp.lastIndex", - "kind": "value", - "name": "lastIndex", - "docstrings": [ - "`lastIndex(regexp)` returns the index the next match will start from.\n\nSee [`RegExp.lastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) on MDN.\n\n## Examples\n```rescript\n// Match the first word in a sentence\nlet regexp = RegExp.fromString(\"\\\\w+\")\nlet someStr = \"Many words here.\"\n\nConsole.log(regexp->RegExp.lastIndex) // Logs `0` to the console\n\nregexp->RegExp.exec(someStr)->ignore\n\nConsole.log(regexp->RegExp.lastIndex) // Logs `4` to the console\n```" - ], - "signature": "let lastIndex: t => int" - }, - { - "id": "Core.RegExp.setLastIndex", - "kind": "value", - "name": "setLastIndex", - "docstrings": [ - "`setLastIndex(regexp, index)` set the index the next match will start from.\n\nSee [`RegExp.lastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) on MDN.\n\n## Examples\n```rescript\n// Match the first word in a sentence\nlet regexp = RegExp.fromString(\"\\\\w+\")\nlet someStr = \"Many words here.\"\n\nregexp->RegExp.setLastIndex(4)\nregexp->RegExp.exec(someStr)->ignore\n\nConsole.log(regexp->RegExp.lastIndex) // Logs `10` to the console\n```" - ], - "signature": "let setLastIndex: (t, int) => unit" - }, - { - "id": "Core.RegExp.ignoreCase", - "kind": "value", - "name": "ignoreCase", - "docstrings": [ - "`ignoreCase(regexp)` returns whether the ignore case (`i`) flag is set on this `RegExp`.\n\nSee [`RegExp.ignoreCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.ignoreCase) // Logs `false`, since `i` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"i\")\nConsole.log(regexp2->RegExp.ignoreCase) // Logs `true`, since `i` is set\n```" - ], - "signature": "let ignoreCase: t => bool" - }, - { - "id": "Core.RegExp.global", - "kind": "value", - "name": "global", - "docstrings": [ - "`global(regexp)` returns whether the global (`g`) flag is set on this `RegExp`.\n\nSee [`RegExp.global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.global) // Logs `true`, since `g` is set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"i\")\nConsole.log(regexp2->RegExp.global) // Logs `false`, since `g` is not set\n```" - ], - "signature": "let global: t => bool" - }, - { - "id": "Core.RegExp.multiline", - "kind": "value", - "name": "multiline", - "docstrings": [ - "`multiline(regexp)` returns whether the multiline (`m`) flag is set on this `RegExp`.\n\nSee [`RegExp.multiline`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.multiline) // Logs `false`, since `m` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"mi\")\nConsole.log(regexp2->RegExp.multiline) // Logs `true`, since `m` is set\n```" - ], - "signature": "let multiline: t => bool" - }, - { - "id": "Core.RegExp.source", - "kind": "value", - "name": "source", - "docstrings": [ - "`source(regexp)` returns the source text for this `RegExp`, without the two forward slashes (if present), and without any set flags.\n\nSee [`RegExp.source`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source) on MDN.\n\n## Examples\n```rescript\nlet regexp = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp->RegExp.source) // Logs `\\w+`, the source text of the `RegExp`\n```" - ], - "signature": "let source: t => string" - }, - { - "id": "Core.RegExp.sticky", - "kind": "value", - "name": "sticky", - "docstrings": [ - "`sticky(regexp)` returns whether the sticky (`y`) flag is set on this `RegExp`.\n\nSee [`RegExp.sticky`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.unicode) // Logs `false`, since `y` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"my\")\nConsole.log(regexp2->RegExp.unicode) // Logs `true`, since `y` is set\n```" - ], - "signature": "let sticky: t => bool" - }, - { - "id": "Core.RegExp.unicode", - "kind": "value", - "name": "unicode", - "docstrings": [ - "`unicode(regexp)` returns whether the unicode (`y`) flag is set on this `RegExp`.\n\nSee [`RegExp.unicode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.unicode) // Logs `false`, since `u` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"mu\")\nConsole.log(regexp2->RegExp.unicode) // Logs `true`, since `u` is set\n```" - ], - "signature": "let unicode: t => bool" - } - ] - }, - "core/promise": { - "id": "Core.Promise", - "name": "Promise", - "docstrings": [ - "Functions for interacting with JavaScript Promise.\nSee: [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)." - ], - "items": [ - { - "id": "Core.Promise.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = promise<'a>" - }, - { - "id": "Core.Promise.resolve", - "kind": "value", - "name": "resolve", - "docstrings": [ - "`resolve(value)` creates a resolved Promise with a given `value`.\nSee [`Promise.resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) on MDN.\n\n## Examples\n\n```rescript\nlet p = Promise.resolve(5) // promise\n```" - ], - "signature": "let resolve: 'a => t<'a>" - }, - { - "id": "Core.Promise.reject", - "kind": "value", - "name": "reject", - "docstrings": [ - "`reject(exn)` reject a Promise.\nSee [`Promise.reject`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) on MDN.\n\n## Examples\n\n```rescript\nexception TestError(string)\n\nlet p = Promise.reject(TestError(\"some rejected value\"))\n```" - ], - "signature": "let reject: exn => t<'a>" - }, - { - "id": "Core.Promise.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(callback)` creates a new Promise based on a `callback` that receives two\nuncurried functions `resolve` and `reject` for defining the Promise's result.\n\n## Examples\n\n```rescript\nopen Promise\n\nlet n = 4\nPromise.make((resolve, reject) => {\n if(n < 5) {\n resolve(. \"success\")\n }\n else {\n reject(. \"failed\")\n }\n})\n->then(str => {\n Console.log(str)->resolve\n})\n->catch(_ => {\n Console.log(\"Error occurred\")\n resolve()\n})\n->ignore\n```" - ], - "signature": "let make: (('a => unit, 'e => unit) => unit) => t<'a>" - }, - { - "id": "Core.Promise.promiseAndResolvers", - "kind": "type", - "name": "promiseAndResolvers", - "docstrings": [], - "signature": "type promiseAndResolvers<'a> = {\n promise: t<'a>,\n resolve: 'a => unit,\n reject: exn => unit,\n}" - }, - { - "id": "Core.Promise.withResolvers", - "kind": "value", - "name": "withResolvers", - "docstrings": [ - "`withResolvers()` returns a object containing a new promise with functions to resolve or reject it. See [`Promise.withResolvers`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers) on MDN.\n\n## Examples\n\n```rescript\nopen Promise\n\nlet {promise, resolve, _} = Promise.withResolvers()\n\nsetTimeout(() => {\n resolve(. \"success\")\n}, 1000)->ignore\n\npromise\n->thenResolve(str => {\n Console.log(str)\n})\n->ignore\n```" - ], - "signature": "let withResolvers: unit => promiseAndResolvers<'a>" - }, - { - "id": "Core.Promise.catch", - "kind": "value", - "name": "catch", - "docstrings": [ - "`catch(promise, errorCallback)` registers an exception handler in a promise chain.\nThe `errorCallback` receives an `exn` value that can later be refined into a JS\nerror or ReScript error. The `errorCallback` needs to return a promise with the\nsame type as the consumed promise. See [`Promise.catch`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch) on MDN.\n\n## Examples\n\n```rescript\nopen Promise\n\nexception SomeError(string)\n\nreject(SomeError(\"this is an error\"))\n->then(_ => {\n Ok(\"This result will never be returned\")->resolve\n})\n->catch(e => {\n let msg = switch(e) {\n | SomeError(msg) => \"ReScript error occurred: \" ++ msg\n | Exn.Error(obj) =>\n switch Exn.message(obj) {\n | Some(msg) => \"JS exception occurred: \" ++ msg\n | None => \"Some other JS value has been thrown\"\n }\n | _ => \"Unexpected error occurred\"\n }\n\n Error(msg)->resolve\n})\n->then(result => {\n switch result {\n | Ok(r) => Console.log2(\"Operation successful: \", r)\n | Error(msg) => Console.log2(\"Operation failed: \", msg)\n }->resolve\n})\n->ignore // Ignore needed for side-effects\n```\n\nIn case you want to return another promise in your `callback`, consider using\n`then` instead." - ], - "signature": "let catch: (t<'a>, exn => t<'a>) => t<'a>" - }, - { - "id": "Core.Promise.then", - "kind": "value", - "name": "then", - "docstrings": [ - "`then(promise, callback)` returns a new promise based on the result of `promise`'s \nvalue. The `callback` needs to explicitly return a new promise via `resolve`.\nIt is **not allowed** to resolve a nested promise (like `resolve(resolve(1))`).\nSee [`Promise.then`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) on MDN.\n## Examples\n\n```rescript\nopen Promise\nresolve(5)\n->then(num => {\n resolve(num + 5)\n})\n->then(num => {\n Console.log2(\"Your lucky number is: \", num)\n resolve()\n})\n->ignore\n```" - ], - "signature": "let then: (t<'a>, 'a => t<'b>) => t<'b>" - }, - { - "id": "Core.Promise.thenResolve", - "kind": "value", - "name": "thenResolve", - "docstrings": [ - "`thenResolve(promise, callback)` converts an encapsulated value of a promise\ninto another promise wrapped value. It is **not allowed** to return a promise\nwithin the provided callback (e.g. `thenResolve(value => resolve(value))`).\n\n## Examples\n\n```rescript\nopen Promise\nresolve(\"Anna\")\n->thenResolve(str => {\n \"Hello \" ++ str\n})\n->thenResolve(str => {\n Console.log(str)\n})\n->ignore // Ignore needed for side-effects\n```\n\nIn case you want to return another promise in your `callback`, consider using\n`then` instead." - ], - "signature": "let thenResolve: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Core.Promise.finally", - "kind": "value", - "name": "finally", - "docstrings": [ - "`finally(promise, callback)` is used to execute a function that is called no\nmatter if a promise was resolved or rejected. It will return the same `promise`\nit originally received. See [`Promise.finally`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally) on MDN.\n\n## Examples\n\n```rescript\nopen Promise\nexception SomeError(string)\nlet isDone = ref(false)\n\nresolve(5)\n->then(_ => {\n reject(SomeError(\"test\"))\n})\n->then(v => {\n Console.log2(\"final result\", v)\n resolve()\n})\n->catch(_ => {\n Console.log(\"Error handled\")\n resolve()\n})\n->finally(() => {\n Console.log(\"finally\")\n isDone := true\n})\n->then(() => {\n Console.log2(\"isDone:\", isDone.contents)\n resolve()\n})\n->ignore\n```" - ], - "signature": "let finally: (t<'a>, unit => unit) => t<'a>" - }, - { - "id": "Core.Promise.race", - "kind": "value", - "name": "race", - "docstrings": [ - "`race(arr)` runs all promises concurrently and returns promise settles with the eventual state of the first promise that settles. See [`Promise.race`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race) on MDN.\n\n## Examples\n\n```rescript\nopen Promise\nlet racer = (ms, name) => {\n Promise.make((resolve, _) => {\n setTimeout(() => {\n resolve(name)\n }, ms)->ignore\n })\n}\n\nlet promises = [racer(1000, \"Turtle\"), racer(500, \"Hare\"), racer(100, \"Eagle\")]\n\nrace(promises)->then(winner => {\n Console.log(\"The winner is \" ++ winner)\n resolve()\n})\n```" - ], - "signature": "let race: array> => t<'a>" - }, - { - "id": "Core.Promise.any", - "kind": "value", - "name": "any", - "docstrings": [ - "`any(arr)` runs all promises concurrently and returns promise fulfills when any of the input's promises fulfills, with this first fulfillment value. See [`Promise.any`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any) on MDN.\n\n## Examples\n\n```rescript\nopen Promise\nlet racer = (ms, name) => {\n Promise.make((resolve, _) => {\n setTimeout(() => {\n resolve(name)\n }, ms)->ignore\n })\n}\n\nlet promises = [racer(1000, \"Turtle\"), racer(500, \"Hare\"), racer(100, \"Eagle\")]\n\nany(promises)->then(winner => {\n Console.log(\"The winner is \" ++ winner)\n resolve()\n})\n```" - ], - "signature": "let any: array> => t<'a>" - }, - { - "id": "Core.Promise.all", - "kind": "value", - "name": "all", - "docstrings": [ - "`all(promises)` runs all promises concurrently and returns a promise fulfills when all of the input's promises fulfill, with an array of the fulfillment values. See [`Promise.all`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) on MDN.\n\n```rescript\nopen Promise\nlet promises = [resolve(1), resolve(2), resolve(3)]\n\nall(promises)\n->then((results) => {\n results->Array.forEach(num => {\n Console.log2(\"Number: \", num)\n })\n\n resolve()\n})\n->ignore\n```" - ], - "signature": "let all: array> => t>" - }, - { - "id": "Core.Promise.all2", - "kind": "value", - "name": "all2", - "docstrings": [ - "`all2((p1, p2))`. Like `all()`, but with a fixed size tuple of 2" - ], - "signature": "let all2: ((t<'a>, t<'b>)) => t<('a, 'b)>" - }, - { - "id": "Core.Promise.all3", - "kind": "value", - "name": "all3", - "docstrings": [ - "`all3((p1, p2, p3))`. Like `all()`, but with a fixed size tuple of 3" - ], - "signature": "let all3: ((t<'a>, t<'b>, t<'c>)) => t<('a, 'b, 'c)>" - }, - { - "id": "Core.Promise.all4", - "kind": "value", - "name": "all4", - "docstrings": [ - "`all4((p1, p2, p3, p4))`. Like `all()`, but with a fixed size tuple of 4" - ], - "signature": "let all4: ((t<'a>, t<'b>, t<'c>, t<'d>)) => t<('a, 'b, 'c, 'd)>" - }, - { - "id": "Core.Promise.all5", - "kind": "value", - "name": "all5", - "docstrings": [ - "`all5((p1, p2, p3, p4, p5))`. Like `all()`, but with a fixed size tuple of 5" - ], - "signature": "let all5: (\n (t<'a>, t<'b>, t<'c>, t<'d>, t<'e>),\n) => t<('a, 'b, 'c, 'd, 'e)>" - }, - { - "id": "Core.Promise.all6", - "kind": "value", - "name": "all6", - "docstrings": [ - "`all6((p1, p2, p4, p5, p6))`. Like `all()`, but with a fixed size tuple of 6\n\")" - ], - "signature": "let all6: (\n (t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>),\n) => t<('a, 'b, 'c, 'd, 'e, 'f)>" - }, - { - "id": "Core.Promise.settledResult", - "kind": "type", - "name": "settledResult", - "docstrings": [], - "signature": "type settledResult<'a> =\n | Fulfilled({value: 'a})\n | Rejected({reason: exn})" - }, - { - "id": "Core.Promise.allSettled", - "kind": "value", - "name": "allSettled", - "docstrings": [ - "`allSettled(promises)` runs all promises concurrently and returns promise fulfills when all of the input's promises settle with an array of objects that describe the outcome of each promise. See [`Promise.allSettled`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) on MDN.\n\n```rescript\nopen Promise\n\nexception TestError(string)\n\nlet promises = [resolve(1), resolve(2), reject(TestError(\"some rejected promise\"))]\n\nallSettled(promises)\n->then((results) => {\n results->Array.forEach((result) => {\n switch result {\n | Fulfilled({value: num}) => \n Console.log2(\"Number: \", num)\n | Rejected({reason}) =>\n Console.log(reason)\n }\n })\n\n resolve()\n})\n->ignore\n```" - ], - "signature": "let allSettled: array> => t>>" - }, - { - "id": "Core.Promise.allSettled2", - "kind": "value", - "name": "allSettled2", - "docstrings": [ - "`allSettled2((p1, p2))`. Like `allSettled()`, but with a fixed size tuple of 2" - ], - "signature": "let allSettled2: (\n (t<'a>, t<'b>),\n) => t<(settledResult<'a>, settledResult<'b>)>" - }, - { - "id": "Core.Promise.allSettled3", - "kind": "value", - "name": "allSettled3", - "docstrings": [ - "`allSettled3((p1, p2, p3))`. Like `allSettled()`, but with a fixed size tuple of 3" - ], - "signature": "let allSettled3: (\n (t<'a>, t<'b>, t<'c>),\n) => t<\n (settledResult<'a>, settledResult<'b>, settledResult<'c>),\n>" - }, - { - "id": "Core.Promise.allSettled4", - "kind": "value", - "name": "allSettled4", - "docstrings": [ - "`allSettled4((p1, p2, p3, p4))`. Like `allSettled()`, but with a fixed size tuple of 4" - ], - "signature": "let allSettled4: (\n (t<'a>, t<'b>, t<'c>, t<'d>),\n) => t<\n (\n settledResult<'a>,\n settledResult<'b>,\n settledResult<'c>,\n settledResult<'d>,\n ),\n>" - }, - { - "id": "Core.Promise.allSettled5", - "kind": "value", - "name": "allSettled5", - "docstrings": [ - "`allSettled5((p1, p2, p3, p4, p5))`. Like `allSettled()`, but with a fixed size tuple of 5" - ], - "signature": "let allSettled5: (\n (t<'a>, t<'b>, t<'c>, t<'d>, t<'e>),\n) => t<\n (\n settledResult<'a>,\n settledResult<'b>,\n settledResult<'c>,\n settledResult<'d>,\n settledResult<'e>,\n ),\n>" - }, - { - "id": "Core.Promise.allSettled6", - "kind": "value", - "name": "allSettled6", - "docstrings": [ - "`allSettled6((p1, p2, p4, p5, p6))`. Like `allSettled()`, but with a fixed size tuple of 6\n\")" - ], - "signature": "let allSettled6: (\n (t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>),\n) => t<\n (\n settledResult<'a>,\n settledResult<'b>,\n settledResult<'c>,\n settledResult<'d>,\n settledResult<'e>,\n settledResult<'f>,\n ),\n>" - }, - { - "id": "Core.Promise.done", - "kind": "value", - "name": "done", - "docstrings": [ - "`done(p)` is a safe way to ignore a promise. If a value is anything else than a\npromise, it will raise a type error." - ], - "signature": "let done: promise<'a> => unit" - } - ] - }, - "core/ordering": { - "id": "Core.Ordering", - "name": "Ordering", - "docstrings": [], - "items": [ - { - "id": "Core.Ordering.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = float" - }, - { - "id": "Core.Ordering.less", - "kind": "value", - "name": "less", - "docstrings": [], - "signature": "let less: float" - }, - { - "id": "Core.Ordering.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: float" - }, - { - "id": "Core.Ordering.greater", - "kind": "value", - "name": "greater", - "docstrings": [], - "signature": "let greater: float" - }, - { - "id": "Core.Ordering.isLess", - "kind": "value", - "name": "isLess", - "docstrings": [], - "signature": "let isLess: float => bool" - }, - { - "id": "Core.Ordering.isEqual", - "kind": "value", - "name": "isEqual", - "docstrings": [], - "signature": "let isEqual: float => bool" - }, - { - "id": "Core.Ordering.isGreater", - "kind": "value", - "name": "isGreater", - "docstrings": [], - "signature": "let isGreater: float => bool" - }, - { - "id": "Core.Ordering.invert", - "kind": "value", - "name": "invert", - "docstrings": [], - "signature": "let invert: float => float" - }, - { - "id": "Core.Ordering.fromInt", - "kind": "value", - "name": "fromInt", - "docstrings": [], - "signature": "let fromInt: int => float" - } - ] - }, - "core/object": { - "id": "Core.Object", - "name": "Object", - "docstrings": [], - "items": [ - { - "id": "Core.Object.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make` create a new object that inherits the properties and methods from the standard built-in Object, such as `toString`. See [Object on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n## Examples\n\n```rescript\nlet x = Object.make()\nx->Object.keysToArray->Array.length // 0\nx->Object.get(\"toString\")->Option.isSome // true\n```" - ], - "signature": "let make: unit => {..}" - }, - { - "id": "Core.Object.is", - "kind": "value", - "name": "is", - "docstrings": [ - "`is` determines if two objects are identical in all contexts. Objects, arrays, records, and other non-primitives are only identical if they reference the **exact** same object in memory. Primitives like ints, floats, and strings are identical if they have the same value. `+0` and `-0` are distinct. NaN is equal to itself. See [Object.is on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)\n\nIn most scenarios use `==` or `===` or the custom `equals` function (if provided) for the type.\n\n## Examples\n\n```rescript\nObject.is(25, 13) // false\nObject.is(\"abc\", \"abc\") // true\nObject.is(undefined, undefined) // true\nObject.is(undefined, null) // false\nObject.is(-0.0, 0.0) // false\nObject.is(list{1, 2}, list{1, 2}) // false\n\nObject.is([1, 2, 3], [1, 2, 3]) // false\n[1, 2, 3] == [1, 2, 3] // true\n[1, 2, 3] === [1, 2, 3] // false\n\nlet fruit = {\"name\": \"Apple\" }\nObject.is(fruit, fruit) // true\nObject.is(fruit, {\"name\": \"Apple\" }) // false\nfruit == {\"name\": \"Apple\" } // true\nfruit === {\"name\": \"Apple\" } // false\n```" - ], - "signature": "let is: ('a, 'a) => bool" - }, - { - "id": "Core.Object.create", - "kind": "value", - "name": "create", - "docstrings": [ - "`create` creates a new object, using an existing object as the prototype of the new object. See [Object.create on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)\n\n**Note:** ReScript provides [first-class support for immutable objects](https://rescript-lang.org/docs/manual/latest/object) and [records](https://rescript-lang.org/docs/manual/latest/record). This is often safer and more convenient than using `create` and other functions in this module.\n\n## Examples\n\n```rescript\nlet x = {\"fruit\": \"banana\"}\nlet y = Object.create(x)\ny->Object.get(\"fruit\") // Some(\"banana\")\n```" - ], - "signature": "let create: {..} => {..}" - }, - { - "id": "Core.Object.createWithProperties", - "kind": "value", - "name": "createWithProperties", - "docstrings": [], - "signature": "let createWithProperties: ({..}, {..}) => {..}" - }, - { - "id": "Core.Object.createWithNull", - "kind": "value", - "name": "createWithNull", - "docstrings": [], - "signature": "let createWithNull: unit => {..}" - }, - { - "id": "Core.Object.createWithNullAndProperties", - "kind": "value", - "name": "createWithNullAndProperties", - "docstrings": [], - "signature": "let createWithNullAndProperties: {..} => {..}" - }, - { - "id": "Core.Object.assign", - "kind": "value", - "name": "assign", - "docstrings": [ - "`assign(target, source)` copies enumerable own properties from the source to the target, overwriting properties with the same name. It returns the modified target object. A deep clone is not created; properties are copied by reference.\n\n**Warning:** ReScript provides compile-time support for type-safe access to JavaScript objects. This eliminates common errors such as accessing properties that do not exist, or using a property of type x as if it were a y. Using `assign` can bypass these safety checks and lead to run-time errors (if you are not careful). ReScript provides [first-class support for immutable objects](https://rescript-lang.org/docs/manual/latest/object) and [records](https://rescript-lang.org/docs/manual/latest/record). This is often safer and more convenient than using `assign` and other functions in this module.\n\nSee [Object.assign on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) or [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign).\n\n## Examples\n\n```rescript\nObject.assign({\"a\": 1}, {\"a\": 2}) // {\"a\": 2}\nObject.assign({\"a\": 1, \"b\": 2}, {\"a\": 0}) // {\"a\": 0, \"b\": 2}\nObject.assign({\"a\": 1}, {\"a\": null}) // {\"a\": null}\n```" - ], - "signature": "let assign: ({..}, {..}) => {..}" - }, - { - "id": "Core.Object.assignMany", - "kind": "value", - "name": "assignMany", - "docstrings": [ - "`assignMany(target, sources)` copies enumerable own properties from each source to the target, overwriting properties with the same name. Later sources' properties overwrite earlier ones. It returns the modified target object. A deep clone is not created; properties are copied by reference.\n\n**Note:** ReScript provides [first-class support for immutable objects](https://rescript-lang.org/docs/manual/latest/object), including spreading one object into another. This is often more convenient than using `assign` or `assignMany`. \n\nSee [Object.assign on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) or [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign)." - ], - "signature": "let assignMany: ({..}, array<{..}>) => {..}" - }, - { - "id": "Core.Object.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: ({..} as 'a) => 'a" - }, - { - "id": "Core.Object.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`get` gets the value of a property by name. Returns `None` if the property does not exist or has the value `undefined`. Otherwise returns `Some`, including if the value is `null`.\n\n## Examples\n\n```rescript\n{\"a\": 1}->Object.get(\"a\") // Some(1)\n{\"a\": 1}->Object.get(\"b\") // None\n{\"a\": undefined}->Object.get(\"a\") // None\n{\"a\": null}->Object.get(\"a\") // Some(null)\n{\"a\": 1}->Object.get(\"toString\")->Option.isSome // true\n```" - ], - "signature": "let get: ({..}, string) => option<'a>" - }, - { - "id": "Core.Object.getSymbol", - "kind": "value", - "name": "getSymbol", - "docstrings": [ - "`getSymbol` gets the value of a property by symbol. Returns `None` if the property does not exist or has the value `undefined`. Otherwise returns `Some`, including if the value is `null`.\n\n## Examples\n\n```rescript\nlet fruit = Symbol.make(\"fruit\")\nlet x = Object.make()\nx->Object.setSymbol(fruit, \"banana\")\nx->Object.getSymbol(fruit) // Some(\"banana\")\n```" - ], - "signature": "let getSymbol: ({..}, Core__Symbol.t) => option<'a>" - }, - { - "id": "Core.Object.getSymbolUnsafe", - "kind": "value", - "name": "getSymbolUnsafe", - "docstrings": [], - "signature": "let getSymbolUnsafe: ({..}, Core__Symbol.t) => 'a" - }, - { - "id": "Core.Object.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(name, value)` assigns a value to the named object property, overwriting the previous value if any. See [Working with Objects on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#objects_and_properties)\n\n## Examples\n\n```rescript\n{\"a\": 1}->Object.set(\"a\", 2) // {\"a\": 2}\n{\"a\": 1}->Object.set(\"a\", None) // {\"a\": None}\n{\"a\": 1}->Object.set(\"b\", 2) // {\"a\": 1, \"b\": 2}\n```" - ], - "signature": "let set: ({..}, string, 'a) => unit" - }, - { - "id": "Core.Object.setSymbol", - "kind": "value", - "name": "setSymbol", - "docstrings": [], - "signature": "let setSymbol: ({..}, Core__Symbol.t, 'a) => unit" - }, - { - "id": "Core.Object.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [ - "`keysToArray` returns an array of an object's own enumerable string-keyed property names. See [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.keys) \nor [Object.keys on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys).\n\n## Examples\n\n```rescript\n{\"a\": 1, \"b\": 2}->Object.keysToArray // [\"a\", \"b\"]\n{\"a\": None}->Object.keysToArray // [\"a\"]\nObject.make()->Object.keysToArray // []\n```" - ], - "signature": "let keysToArray: {..} => array" - }, - { - "id": "Core.Object.hasOwnProperty", - "kind": "value", - "name": "hasOwnProperty", - "docstrings": [ - "`hasOwnProperty` determines whether the object has the specified property as its **own** property, as opposed to inheriting it. See [hasOwnProperty on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)\n\n## Examples\n\n```rescript\nlet point = {\"x\": 1, \"y\": 2}\n{\"a\": 1}->Object.hasOwnProperty(\"a\") // true\n{\"a\": 1}->Object.hasOwnProperty(\"b\") // false\n{\"a\": 1}->Object.hasOwnProperty(\"toString\") // false\n```" - ], - "signature": "let hasOwnProperty: ({..}, string) => bool" - }, - { - "id": "Core.Object.seal", - "kind": "value", - "name": "seal", - "docstrings": [ - "`seal` seals an object. Sealing an object prevents extensions and makes existing properties non-configurable. A sealed object has a fixed set of properties. Unlike `freeze`, values of existing properties can still be changed as long as they are writable. \n\n**Note:** `seal` returns the same object that was passed in; it does not create a copy. Any attempt to delete or add properties to a sealed object will fail, either silently or by throwing an error. \n\nSee [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.seal) and [Object.seal on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)\n\n## Examples\n\n```rescript\nlet point = {\"x\": 1, \"y\": 2}\npoint->Object.set(\"x\", -7) // succeeds\npoint->Object.seal->ignore\npoint->Object.set(\"z\", 9) // fails\npoint->Object.set(\"x\", 13) // succeeds\n```" - ], - "signature": "let seal: ({..} as 'a) => 'a" - }, - { - "id": "Core.Object.preventExtensions", - "kind": "value", - "name": "preventExtensions", - "docstrings": [ - "`preventExtensions` prevents new properties from being added to the object. It modifies the object (rather than creating a copy) and returns it.\n\nSee [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.preventextensions) and [Object.preventExtensions on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)\n\n## Examples\n\n```rescript\nlet obj = {\"a\": 1}\nobj->Object.set(\"b\", 2) // succeeds\nobj->Object.preventExtensions->ignore\nobj->Object.set(\"c\", 3) // fails\n```" - ], - "signature": "let preventExtensions: ({..} as 'a) => 'a" - }, - { - "id": "Core.Object.freeze", - "kind": "value", - "name": "freeze", - "docstrings": [ - "`freeze` freezes an object. Freezing an object makes existing properties non-writable and prevents extensions. Once an object is frozen, new properties cannot be be added, existing properties cannot be removed, and their values cannot be changed.\n\n**Note:** `freeze` returns the same object that was passed in; it does not create a frozen copy. Any attempt to change a frozen object will fail, either silently or by throwing an exception.\n\nSee [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.isfrozen) and [Object.isFrozen on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen).\n\n## Examples\n\n ```rescript\nlet obj = {\"a\": 1}\nobj->Object.set(\"a\", 2) // succeeds\nobj->Object.freeze->ignore\nobj->Object.set(\"a\", 3) // fails\n```" - ], - "signature": "let freeze: ({..} as 'a) => 'a" - }, - { - "id": "Core.Object.isSealed", - "kind": "value", - "name": "isSealed", - "docstrings": [ - "`isSealed` determines if an object is sealed. A sealed object has a fixed set of properties.\n\nSee [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.issealed) and [Object.isSealed on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)\n\n## Examples\n\n```rescript\nlet point = {\"x\": 1, \"y\": 3}->Object.seal\nlet pointIsSealed = point->Object.isSealed // true\nlet fruit = {\"name\": \"Apple\" }\nlet fruitIsSealed = fruit->Object.isSealed // false\n ```" - ], - "signature": "let isSealed: 'a => bool" - }, - { - "id": "Core.Object.isFrozen", - "kind": "value", - "name": "isFrozen", - "docstrings": [ - "`isFrozen` determines if an object is frozen. An object is frozen if an only if it is not extensible, all its properties are non-configurable, and all its data properties are non-writable.\n\nSee [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.isfrozen) and [Object.isFrozen on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen).\n\n## Examples\n\n```rescript\nlet point = {\"x\": 1, \"y\": 3}->Object.freeze\nlet pointIsFrozen = point->Object.isFrozen // true\nlet fruit = {\"name\": \"Apple\" }\nlet fruitIsFrozen = fruit->Object.isFrozen // false\n ```" - ], - "signature": "let isFrozen: 'a => bool" - }, - { - "id": "Core.Object.isExtensible", - "kind": "value", - "name": "isExtensible", - "docstrings": [ - "`isExtensible` determines if an object is extensible (whether it can have new properties added to it).\n\nSee [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.isextensible) and [Object.isExtensible on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)\n\n## Examples\n\n```rescript\nlet obj = {\"a\": 1}\nobj->Object.isExtensible // true\nobj->Object.preventExtensions->ignore\nobj->Object.isExtensible // false\n```" - ], - "signature": "let isExtensible: 'a => bool" - } - ] - }, - "core/nullable": { - "id": "Core.Nullable", - "name": "Nullable", - "docstrings": [ - "Functions for handling nullable values.\n\nPrimarily useful when interoping with JavaScript when you don't know whether you'll get a value, `null` or `undefined`." - ], - "items": [ - { - "id": "Core.Nullable.t", - "kind": "type", - "name": "t", - "docstrings": [ - "Type representing a nullable value.\nA nullable value can be the value `'a`, `null` or `undefined`." - ], - "signature": "type t<'a> = Js.Nullable.t<'a> =\n | Value('a)\n | Null\n | Undefined" - }, - { - "id": "Core.Nullable.null", - "kind": "value", - "name": "null", - "docstrings": [ - "The value `null`.\n\nSee [`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/null) on MDN.\n\n## Examples\n```rescript\nConsole.log(Nullable.null) // Logs `null` to the console.\n```" - ], - "signature": "let null: t<'a>" - }, - { - "id": "Core.Nullable.undefined", - "kind": "value", - "name": "undefined", - "docstrings": [ - "The value `undefined`.\n\nSee [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/undefined) on MDN.\n\n## Examples\n```rescript\nConsole.log(undefined) // Logs `undefined` to the console.\n```" - ], - "signature": "let undefined: t<'a>" - }, - { - "id": "Core.Nullable.isNullable", - "kind": "value", - "name": "isNullable", - "docstrings": [ - "`isNullable(a)` returns `true` if `a` is null or undefined, `false` otherwise.\n\n## Examples\n\n```rescript\nlet myStr = \"Hello\"\nlet asNullable = myStr->Nullable.make\n\n// Can't do the below because we're now forced to check for nullability\n// myStr == asNullable\n\n// Check if asNullable is not null or undefined\nswitch asNullable->Nullable.isNullable {\n| true => assert(false)\n| false => assert(true)\n}\n```" - ], - "signature": "let isNullable: t<'a> => bool" - }, - { - "id": "Core.Nullable.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new nullable value from the provided value.\nThis means the compiler will enforce null checks for the new value.\n\n## Examples\n```rescript\nlet myStr = \"Hello\"\nlet asNullable = myStr->Nullable.make\n\n// Can't do the below because we're now forced to check for nullability\n// myStr == asNullable\n\n// Need to do this\nswitch asNullable->Nullable.toOption {\n| Some(value) if value == myStr => Console.log(\"Yay, values matched!\")\n| _ => Console.log(\"Values did not match.\")\n}\n```" - ], - "signature": "let make: 'a => t<'a>" - }, - { - "id": "Core.Nullable.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.Nullable.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (\n t<'a>,\n t<'b>,\n ('a, 'b) => Core__Ordering.t,\n) => Core__Ordering.t" - }, - { - "id": "Core.Nullable.toOption", - "kind": "value", - "name": "toOption", - "docstrings": [ - "Converts a nullable value into an option, so it can be pattern matched on.\nWill convert both `null` and `undefined` to `None`, and a present value to `Some(value)`.\n\n## Examples\n```rescript\nlet nullableString = Nullable.make(\"Hello\")\n\nswitch nullableString->Nullable.toOption {\n| Some(str) => Console.log2(\"Got string:\", str)\n| None => Console.log(\"Didn't have a value.\")\n}\n```" - ], - "signature": "let toOption: t<'a> => option<'a>" - }, - { - "id": "Core.Nullable.fromOption", - "kind": "value", - "name": "fromOption", - "docstrings": [ - "Turns an `option` into a `Nullable.t`.\n\n## Examples\n```rescript\nlet optString = Some(\"Hello\")\nlet asNullable = optString->Nullable.fromOption // Nullable.t\n```" - ], - "signature": "let fromOption: option<'a> => t<'a>" - }, - { - "id": "Core.Nullable.getOr", - "kind": "value", - "name": "getOr", - "docstrings": [ - "`getOr(value, default)` returns `value` if not `null` or `undefined`,\notherwise return `default`.\n\n## Examples\n\n```rescript\nNullable.getOr(Nullable.null, \"Banana\") // Banana\nNullable.getOr(Nullable.make(\"Apple\"), \"Banana\") // Apple\n\nlet greet = (firstName: option) =>\n \"Greetings \" ++ firstName->Option.getOr(\"Anonymous\")\n\nNullable.make(\"Jane\")->Nullable.toOption->greet // \"Greetings Jane\"\nNullable.null->Nullable.toOption->greet // \"Greetings Anonymous\"\n```" - ], - "signature": "let getOr: (t<'a>, 'a) => 'a" - }, - { - "id": "Core.Nullable.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'a>, 'a) => 'a", - "deprecated": "Use getOr instead" - }, - { - "id": "Core.Nullable.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "`getExn(value)` raises an exception if `null` or `undefined`, otherwise returns the value.\n\n```rescript\nNullable.getExn(Nullable.make(3)) // 3\nNullable.getExn(Nullable.null) /* Raises an Error */\n```\n\n## Exceptions\n\n- Raises `Invalid_argument` if `value` is `null` or `undefined`" - ], - "signature": "let getExn: t<'a> => 'a" - }, - { - "id": "Core.Nullable.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(value)` returns `value`.\n\n## Examples\n\n```rescript\nNullable.getUnsafe(Nullable.make(3)) == 3\nNullable.getUnsafe(Nullable.null) // Raises an error\n```\n\n## Important\n\n- This is an unsafe operation, it assumes `value` is not `null` or `undefined`." - ], - "signature": "let getUnsafe: t<'a> => 'a" - }, - { - "id": "Core.Nullable.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(value, f)` call `f` on `value`. if `value` is not `null` or `undefined`, \nthen if calls `f`, otherwise returns `unit`.\n\n## Examples\n\n```rescript\nNullable.forEach(Nullable.make(\"thing\"), x => Console.log(x)) // logs \"thing\"\nNullable.forEach(Nullable.null, x => Console.log(x)) // returns ()\nNullable.forEach(undefined, x => Console.log(x)) // returns ()\n```" - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Core.Nullable.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(value, f)` returns `f(value)` if `value` is not `null` or `undefined`,\notherwise returns `value` unchanged.\n\n## Examples\n\n```rescript\nNullable.map(Nullable.make(3), x => x * x) // Nullable.make(9)\nNullable.map(undefined, x => x * x) // undefined\n```" - ], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Core.Nullable.mapOr", - "kind": "value", - "name": "mapOr", - "docstrings": [ - "`mapOr(value, default, f)` returns `f(value)` if `value` is not `null`\nor `undefined`, otherwise returns `default`.\n\n## Examples\n\n```rescript\nlet someValue = Nullable.make(3)\nsomeValue->Nullable.mapOr(0, x => x + 5) // 8\n\nlet noneValue = Nullable.null\nnoneValue->Nullable.mapOr(0, x => x + 5) // 0\n```" - ], - "signature": "let mapOr: (t<'a>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Core.Nullable.mapWithDefault", - "kind": "value", - "name": "mapWithDefault", - "docstrings": [], - "signature": "let mapWithDefault: (t<'a>, 'b, 'a => 'b) => 'b", - "deprecated": "Use mapOr instead" - }, - { - "id": "Core.Nullable.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "`flatMap(value, f)` returns `f(value)` if `value` is not `null` or `undefined`,\notherwise returns `value` unchanged.\n\n## Examples\n\n```rescript\nlet addIfAboveOne = value =>\n if (value > 1) {\n Nullable.make(value + 1)\n } else {\n Nullable.null\n }\n\nNullable.flatMap(Nullable.make(2), addIfAboveOne) // Nullable.make(3)\nNullable.flatMap(Nullable.make(-4), addIfAboveOne) // undefined\nNullable.flatMap(Nullable.null, addIfAboveOne) // undefined\n```" - ], - "signature": "let flatMap: (t<'a>, 'a => t<'b>) => t<'b>" - } - ] - }, - "core/null": { - "id": "Core.Null", - "name": "Null", - "docstrings": [ - "Functions for handling values that could be `null`.\n\nIf you also need to cover `undefined`, check out `Nullable` instead." - ], - "items": [ - { - "id": "Core.Null.t", - "kind": "type", - "name": "t", - "docstrings": [ - "A type representing a value that can be either `'a` or `null`." - ], - "signature": "type t<'a> = Js.Null.t<'a> = Value('a) | Null" - }, - { - "id": "Core.Null.asNullable", - "kind": "value", - "name": "asNullable", - "docstrings": [ - "Converts a `Null.t` into a `Nullable.t`.\n\n## Examples\n```rescript\nlet nullValue = Null.make(\"Hello\")\nlet asNullable = nullValue->Null.asNullable // Nullable.t\n```" - ], - "signature": "let asNullable: t<'a> => Core__Nullable.t<'a>" - }, - { - "id": "Core.Null.null", - "kind": "value", - "name": "null", - "docstrings": [ - "The value `null`.\n\nSee [`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/null) on MDN.\n\n## Examples\n```rescript\nConsole.log(null) // Logs `null` to the console.\n```" - ], - "signature": "let null: t<'a>" - }, - { - "id": "Core.Null.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Creates a new `Null.t` from the provided value.\nThis means the compiler will enforce null checks for the new value.\n\n## Examples\n```rescript\nlet myStr = \"Hello\"\nlet asNullValue = myStr->Null.make // The compiler now thinks this can be `string` or `null`.\n```" - ], - "signature": "let make: 'a => t<'a>" - }, - { - "id": "Core.Null.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (t<'a>, t<'b>, ('a, 'b) => bool) => bool" - }, - { - "id": "Core.Null.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (\n t<'a>,\n t<'b>,\n ('a, 'b) => Core__Ordering.t,\n) => Core__Ordering.t" - }, - { - "id": "Core.Null.toOption", - "kind": "value", - "name": "toOption", - "docstrings": [ - "Converts a nullable value into an option, so it can be pattern matched on.\nWill convert `null` to `None`, and a present value to `Some(value)`.\n\n## Examples\n```rescript\nlet nullStr = Null.make(\"Hello\")\n\nswitch nullStr->Null.toOption {\n| Some(str) => Console.log2(\"Got string:\", str)\n| None => Console.log(\"Didn't have a value.\")\n}\n```" - ], - "signature": "let toOption: t<'a> => option<'a>" - }, - { - "id": "Core.Null.fromOption", - "kind": "value", - "name": "fromOption", - "docstrings": [ - "Turns an `option` into a `Null.t`. `None` will be converted to `null`.\n\n## Examples\n```rescript\nlet optString: option = None\nlet asNull = optString->Null.fromOption // Null.t\nConsole.log(asNull == Null.null) // Logs `true` to the console.\n```" - ], - "signature": "let fromOption: option<'a> => t<'a>" - }, - { - "id": "Core.Null.getOr", - "kind": "value", - "name": "getOr", - "docstrings": [ - "`getOr(value, default)` returns `value` if not `null`, otherwise return\n`default`.\n\n## Examples\n\n```rescript\nNull.getOr(Null.null, \"Banana\") // Banana\nNull.getOr(Null.make(\"Apple\"), \"Banana\") // Apple\n\nlet greet = (firstName: option) =>\n \"Greetings \" ++ firstName->Option.getOr(\"Anonymous\")\n\nNull.make(\"Jane\")->Null.toOption->greet // \"Greetings Jane\"\nNull.null->Null.toOption->greet // \"Greetings Anonymous\"\n```" - ], - "signature": "let getOr: (t<'a>, 'a) => 'a" - }, - { - "id": "Core.Null.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: (t<'a>, 'a) => 'a", - "deprecated": "Use getOr instead" - }, - { - "id": "Core.Null.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [ - "`getExn(value)` raises an exception if `null`, otherwise returns the value.\n\n```rescript\nNull.getExn(Null.make(3)) // 3\nNull.getExn(Null.null) /* Raises an Error */\n```\n\n## Exceptions\n\n- Raises `Invalid_argument` if `value` is `null`," - ], - "signature": "let getExn: t<'a> => 'a" - }, - { - "id": "Core.Null.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(value)` returns `value`.\n\n## Examples\n\n```rescript\nNull.getUnsafe(Null.make(3)) == 3\nNull.getUnsafe(Null.null) // Raises an error\n```\n\n## Important\n\n- This is an unsafe operation, it assumes `value` is not `null`." - ], - "signature": "let getUnsafe: t<'a> => 'a" - }, - { - "id": "Core.Null.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(value, f)` call `f` on `value`. if `value` is not `null`, then if calls\n`f`, otherwise returns `unit`.\n\n## Examples\n\n```rescript\nNull.forEach(Null.make(\"thing\"), x => Console.log(x)) // logs \"thing\"\nNull.forEach(Null.null, x => Console.log(x)) // logs nothing\n```" - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Core.Null.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(value, f)` returns `f(value)` if `value` is not `null`, otherwise returns\n`value` unchanged.\n\n## Examples\n\n```rescript\nNull.map(Null.make(3), x => x * x) // Null.make(9)\nNull.map(Null.null, x => x * x) // null\n```" - ], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Core.Null.mapOr", - "kind": "value", - "name": "mapOr", - "docstrings": [ - "`mapOr(value, default, f)` returns `f(value)` if `value` is not `null`,\notherwise returns `default`.\n\n## Examples\n\n```rescript\nlet someValue = Null.make(3)\nsomeValue->Null.mapOr(0, x => x + 5) // 8\n\nlet noneValue = Null.null\nnoneValue->Null.mapOr(0, x => x + 5) // 0\n```" - ], - "signature": "let mapOr: (t<'a>, 'b, 'a => 'b) => 'b" - }, - { - "id": "Core.Null.mapWithDefault", - "kind": "value", - "name": "mapWithDefault", - "docstrings": [], - "signature": "let mapWithDefault: (t<'a>, 'b, 'a => 'b) => 'b", - "deprecated": "Use mapOr instead" - }, - { - "id": "Core.Null.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "`flatMap(value, f)` returns `f(value)` if `value` is not `null`, otherwise\nreturns `value` unchanged.\n\n## Examples\n\n```rescript\nlet addIfAboveOne = value =>\n if (value > 1) {\n Null.make(value + 1)\n } else {\n Null.null\n }\n\nNull.flatMap(Null.make(2), addIfAboveOne) // Null.make(3)\nNull.flatMap(Null.make(-4), addIfAboveOne) // null\nNull.flatMap(Null.null, addIfAboveOne) // null\n```" - ], - "signature": "let flatMap: (t<'a>, 'a => t<'b>) => t<'b>" - } - ] - }, - "core/math": { - "id": "Core.Math", - "name": "Math", - "docstrings": [ - "Functions for interacting with JavaScript Math.\nSee: [`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math)." - ], - "items": [ - { - "id": "Core.Math.abs", - "kind": "value", - "name": "abs", - "docstrings": [ - "`abs(v)` returns absolute value of `v`.\nSee [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN.\n\n## Examples\n\n```rescript\nMath.abs(-2.0) // 2.0\nMath.abs(3.0) // 3.0\n```" - ], - "signature": "let abs: float => float" - }, - { - "id": "Core.Math.acos", - "kind": "value", - "name": "acos", - "docstrings": [ - "`acos(v)` returns arccosine (in radians) of argument `v`, returns `NaN` if the\nargument is outside the range [-1.0, 1.0].\nSee [`Math.acos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos) on MDN.\n\n## Examples\n\n```rescript\nMath.acos(-1.0) // 3.141592653589793\nMath.acos(-3.0)->Float.isNaN // true\n```" - ], - "signature": "let acos: float => float" - }, - { - "id": "Core.Math.acosh", - "kind": "value", - "name": "acosh", - "docstrings": [ - "`acosh(v)` returns the inverse hyperbolic arccosine (in radians) of argument `v`,\nreturns `NaN` if the argument is less than `1.0`.\nSee [`Math.acosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh) on MDN.\n\n## Examples\n\n```rescript\nMath.acosh(1.0) // 0.0\nMath.acosh(0.5)->Float.isNaN // true\n```" - ], - "signature": "let acosh: float => float" - }, - { - "id": "Core.Math.asin", - "kind": "value", - "name": "asin", - "docstrings": [ - "`asin(v)` returns the inverse sine (in radians) of argument `v`, returns `NaN`\nif the argument `v` is outside the range [-1.0, 1.0].\nSee [`Math.asin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin) on MDN.\n\n## Examples\n\n```rescript\nMath.asin(-1.0) // -1.5707963267948966\nMath.asin(-2.0)->Float.isNaN // true\n```" - ], - "signature": "let asin: float => float" - }, - { - "id": "Core.Math.asinh", - "kind": "value", - "name": "asinh", - "docstrings": [ - "`asinh(v)` returns the inverse hyperbolic sine of argument `v`.\nSee [`Math.asinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh) on MDN.\n\n## Examples\n\n```rescript\nMath.asinh(-1.0) // -0.881373587019543\nMath.asinh(-0.0) // -0.0\n```" - ], - "signature": "let asinh: float => float" - }, - { - "id": "Core.Math.atan", - "kind": "value", - "name": "atan", - "docstrings": [ - "`atan(v)` returns the inverse tangent (in radians) of argument `v`.\nSee [`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) on MDN.\n\n## Examples\n\n```rescript\nMath.atan(-0.0) // -0.0\nMath.atan(0.0) // 0.0\nMath.atan(1.0) // 0.7853981633974483\n```" - ], - "signature": "let atan: float => float" - }, - { - "id": "Core.Math.atanh", - "kind": "value", - "name": "atanh", - "docstrings": [ - "`atanh(v)` returns the invert hyperbolic tangent of argument `v`. Returns `NaN`\nif the argument `v` is is outside the range [-1.0, 1.0] and `Infinity` if `v`\nis `-1.0` or `1.0`.\nSee [`Math.atanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh) on MDN.\n\n## Examples\n\n```rescript\nMath.atanh(-2.0)->Float.isNaN // true\nMath.atanh(-1.0)->Float.isFinite // false\nMath.atanh(-0.0) // -0.0\nMath.atanh(0.0) // 0.0\nMath.atanh(0.5) // 0.5493061443340548\n```" - ], - "signature": "let atanh: float => float" - }, - { - "id": "Core.Math.atan2", - "kind": "value", - "name": "atan2", - "docstrings": [ - "`atan2(~y, ~x)` returns the angle (in radians) of the quotient `y /. x`. It is\nalso the angle between the *x*-axis and point (*x*, *y*).\nSee [`Math.atan2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2) on MDN.\n\n## Examples\n\n```rescript\nMath.atan2(~y=0.0, ~x=10.0) == 0.0\nMath.atan2(~x=5.0, ~y=5.0) == Math.Constants.pi /. 4.0\nMath.atan2(~x=90.0, ~y=15.0) // 1.4056476493802699\nMath.atan2(~x=15.0, ~y=90.0) // 0.16514867741462683\n```" - ], - "signature": "let atan2: (~y: float, ~x: float) => float" - }, - { - "id": "Core.Math.cbrt", - "kind": "value", - "name": "cbrt", - "docstrings": [ - "`cbrt(v)` returns the cube root of argument `v`.\nSee [`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) on MDN.\n\n## Examples\n\n```rescript\nMath.cbrt(-1.0) // -1.0\nMath.cbrt(-0.0) // -0.0\nMath.cbrt(0.0) // 0.0\n```" - ], - "signature": "let cbrt: float => float" - }, - { - "id": "Core.Math.ceil", - "kind": "value", - "name": "ceil", - "docstrings": [ - "`ceil(v)` returns the smallest integral value greater than or equal to the\nargument `v`. The result is a `float` and is not restricted to the `int` data\ntype range.\nSee [`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) on MDN.\n\n## Examples\n\n```rescript\nMath.ceil(3.1) == 4.0\nMath.ceil(3.0) == 3.0\nMath.ceil(-3.1) == -3.0\nMath.ceil(2_150_000_000.3) == 2_150_000_001.0\n```" - ], - "signature": "let ceil: float => float" - }, - { - "id": "Core.Math.cos", - "kind": "value", - "name": "cos", - "docstrings": [ - "`cos(v)` returns the cosine of argument `v`, which must be specified in radians.\nSee [`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) on MDN.\n\n## Examples\n\n```rescript\nMath.cos(-0.0) // 1.0\nMath.cos(0.0) // 1.0\nMath.cos(1.0) // 0.5403023058681398\n```" - ], - "signature": "let cos: float => float" - }, - { - "id": "Core.Math.cosh", - "kind": "value", - "name": "cosh", - "docstrings": [ - "`cosh(v)` returns the hyperbolic cosine of argument `v`, which must be specified\nin radians.\nSee [`Math.cosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh) on MDN.\n\n## Examples\n\n```rescript\nMath.cosh(-1.0) // 1.5430806348152437\nMath.cosh(-0.0) // 1.0\nMath.cosh(0.0) // 1.0\n```" - ], - "signature": "let cosh: float => float" - }, - { - "id": "Core.Math.exp", - "kind": "value", - "name": "exp", - "docstrings": [ - "`exp(v)` returns natural exponentional, returns *e* (the base of natural logarithms)\nto the power of the given argument `v`.\nSee [`Math.exp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp) on MDN.\n\n## Examples\n\n```rescript\nMath.exp(-1.0) // 0.36787944117144233\nMath.exp(0.0) // 1.0\n```" - ], - "signature": "let exp: float => float" - }, - { - "id": "Core.Math.expm1", - "kind": "value", - "name": "expm1", - "docstrings": [ - "`expm1(v)` returns *e* (the base of natural logarithms) to the power of the given\nargument `v` minus 1.\nSee [`Math.expm1`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1) on MDN.\n\n## Examples\n\n```rescript\nMath.expm1(-1.0) // -0.6321205588285577\nMath.expm1(-0.0) // -0\n```" - ], - "signature": "let expm1: float => float" - }, - { - "id": "Core.Math.floor", - "kind": "value", - "name": "floor", - "docstrings": [ - "`floor(v)` returns the largest integral value less than or equal to the argument\n`v`. The result is a `float` and is not restricted to the `int` data type range.\nSee [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) on MDN.\n\n## Examples\n\n```rescript\nMath.floor(-45.95) // -46.0\nMath.floor(-45.05) // -46.0\nMath.floor(-0.0) // -0.0\n```" - ], - "signature": "let floor: float => float" - }, - { - "id": "Core.Math.fround", - "kind": "value", - "name": "fround", - "docstrings": [ - "`fround(v)` returns the nearest single precision float.\nSee [`Math.fround`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround) on MDN.\n\n## Examples\n\n```rescript\nMath.fround(5.5) == 5.5\nMath.fround(5.05) == 5.050000190734863\n```" - ], - "signature": "let fround: float => float" - }, - { - "id": "Core.Math.hypot", - "kind": "value", - "name": "hypot", - "docstrings": [ - "`hypot(a, b)` returns the square root of the sum of squares of its two arguments\n(the Pythagorean formula).\nSee [`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot) on MDN.\n\n## Examples\n\n```rescript\nMath.hypot(3.0, 4.0) // 5.0\nMath.hypot(3.0, 5.0) // 5.8309518948453\n```" - ], - "signature": "let hypot: (float, float) => float" - }, - { - "id": "Core.Math.hypotMany", - "kind": "value", - "name": "hypotMany", - "docstrings": [ - "`hypotMany(arr)` returns the square root of the sum of squares of the numbers in\nthe array argument (generalized Pythagorean equation). Using an array allows you\nto have more than two items. If `arr` is an empty array then returns `0.0`.\nSee [`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot) on MDN.\n\n## Examples\n\n```rescript\nMath.hypotMany([3.0, 4.0, 5.0]) // 7.0710678118654755\nMath.hypotMany([]) // 0.0\n```" - ], - "signature": "let hypotMany: array => float" - }, - { - "id": "Core.Math.log", - "kind": "value", - "name": "log", - "docstrings": [ - "`log(v)` returns the natural logarithm of argument `v`, this is the number *x*\nsuch that `e^x` equals the argument. Returns `NaN` for negative arguments and\n`Infinity` for `0.0` or `-0.0`.\nSee [`Math.log`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log) on MDN.\n\n## Examples\n\n```rescript\nMath.log(-1.0)->Float.isNaN // true\nMath.log(-0.0)->Float.isFinite // false\nMath.log(0.0)->Float.isFinite // false\nMath.log(1.0) // 0\n```" - ], - "signature": "let log: float => float" - }, - { - "id": "Core.Math.log1p", - "kind": "value", - "name": "log1p", - "docstrings": [ - "`log1p(v)` returns the natural logarithm of one plus the argument `v`.\nReturns `NaN` for arguments less than `-1` and `Infinity` if `v` is `-1.0`.\nSee [`Math.log1p`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p) on MDN.\n\n## Examples\n\n```rescript\nMath.log1p(-2.0)->Float.isNaN // true\nMath.log1p(-1.0)->Float.isFinite // false\nMath.log1p(-0.0) // -0\n```" - ], - "signature": "let log1p: float => float" - }, - { - "id": "Core.Math.log10", - "kind": "value", - "name": "log10", - "docstrings": [ - "`log10(v)` returns the base 10 logarithm of argument `v`. Returns `NaN` for\nnegative `v`. If `v` is `-0.0` or `0.0` returns `Infinity`.\nSee [`Math.log10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10) on MDN.\n\n## Examples\n\n```rescript\nMath.log10(-2.0)->Float.isNaN // true\nMath.log10(-0.0)->Float.isFinite // false\nMath.log10(0.0)->Float.isFinite // false\nMath.log10(1.0) // 0\n```" - ], - "signature": "let log10: float => float" - }, - { - "id": "Core.Math.log2", - "kind": "value", - "name": "log2", - "docstrings": [ - "`log2(v)` returns the base 2 logarithm of argument `v`. Returns `NaN` for\nnegative `v` and `Infinity` if `v` is `-0.0` or `0.0`.\nSee [`Math.log2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2) on MDN.\n\n## Examples\n\n```rescript\nMath.log2(-2.0)->Float.isNaN // true\nMath.log2(-0.0)->Float.isFinite // false\nMath.log2(0.0)->Float.isFinite // false\nMath.log2(1.0) // 0.0\n```" - ], - "signature": "let log2: float => float" - }, - { - "id": "Core.Math.min", - "kind": "value", - "name": "min", - "docstrings": [ - "`min(a, b)` returns the minimum of its two float arguments.\nSee [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.\n\n## Examples\n\n```rescript\nMath.min(1.0, 2.0) // 1.0\nMath.min(-1.0, -2.0) // -2.0\n```" - ], - "signature": "let min: (float, float) => float" - }, - { - "id": "Core.Math.minMany", - "kind": "value", - "name": "minMany", - "docstrings": [ - "`minMany(arr)` returns the minimum of the float in the given array `arr`.\nReturns `Infinity` if `arr` is empty.\nSee [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.\n\n## Examples\n\n```rescript\nMath.minMany([1.0, 2.0]) // 1.0\nMath.minMany([-1.0, -2.0]) // -2.0\nMath.minMany([])->Float.isFinite // false\n```" - ], - "signature": "let minMany: array => float" - }, - { - "id": "Core.Math.max", - "kind": "value", - "name": "max", - "docstrings": [ - "`max(a, b)` returns the maximum of its two float arguments.\nSee [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.\n\n## Examples\n\n```rescript\nMath.max(1.0, 2.0) // 2.0\nMath.max(-1.0, -2.0) // -1.0\n```" - ], - "signature": "let max: (float, float) => float" - }, - { - "id": "Core.Math.maxMany", - "kind": "value", - "name": "maxMany", - "docstrings": [ - "`maxMany(arr)` returns the maximum of the float in the given array `arr`.\nReturns `Infinity` if `arr` is empty.\nSee [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.\n\n## Examples\n\n```rescript\nMath.maxMany([1.0, 2.0]) // 2.0\nMath.maxMany([-1.0, -2.0]) // -1.0\nMath.maxMany([])->Float.isFinite // false\n```" - ], - "signature": "let maxMany: array => float" - }, - { - "id": "Core.Math.pow", - "kind": "value", - "name": "pow", - "docstrings": [ - "`pow(a, ~exp)` raises the given base `a` to the given exponent `exp`.\nSee [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN.\n\n## Examples\n\n```rescript\nMath.pow(2.0, ~exp=4.0) // 16.0\nMath.pow(3.0, ~exp=4.0) // 81.0\n```" - ], - "signature": "let pow: (float, ~exp: float) => float" - }, - { - "id": "Core.Math.random", - "kind": "value", - "name": "random", - "docstrings": [ - "`random()` returns a random number in the half-closed interval [0,1].\nSee [`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) on MDN.\n\n## Examples\n\n```rescript\nMath.random()\n```" - ], - "signature": "let random: unit => float" - }, - { - "id": "Core.Math.round", - "kind": "value", - "name": "round", - "docstrings": [ - "`round(v)` returns then value of `v` rounded to nearest integral value\n(expressed as a float). If the fractional portion of the argument `v` is greater\nthan `0.5`, the argument `v` is rounded to the float with the next higher\nabsolute value.\nSee [`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round) on MDN.\n\n## Examples\n\n```rescript\nMath.round(-20.5) // -20.0\nMath.round(-0.1) // -0.0\nMath.round(0.0) // 0.0\nMath.round(-0.0) // -0.0\n```" - ], - "signature": "let round: float => float" - }, - { - "id": "Core.Math.sign", - "kind": "value", - "name": "sign", - "docstrings": [ - "`sign(v)` returns the sign of its foat argument: `-1` if negative, `0` if\nzero, `1` if positive.\nSee [`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) on MDN.\n\n## Examples\n\n```rescript\nMath.sign(3.0) // 1.0\nMath.sign(-3.0) // 1.0\nMath.sign(0.0) // 0.0\n```" - ], - "signature": "let sign: float => float" - }, - { - "id": "Core.Math.sin", - "kind": "value", - "name": "sin", - "docstrings": [ - "`sin(v)` returns the sine of argument `v`, which must be specified in radians.\nSee [`Math.sin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin) on MDN.\n\n## Examples\n\n```rescript\nMath.sin(-0.0) // -0.0\nMath.sin(0.0) // 0.0\nMath.sin(1.0) // 0.8414709848078965\n```" - ], - "signature": "let sin: float => float" - }, - { - "id": "Core.Math.sinh", - "kind": "value", - "name": "sinh", - "docstrings": [ - "`sinh(v)` returns then hyperbolic sine of argument `v`, which must be specified\nin radians.\nSee [`Math.sinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh) on MDN.\n\n## Examples\n\n```rescript\nMath.sinh(-0.0) // -0.0\nMath.sinh(0.0) // 0.0\nMath.sinh(1.0) // 1.1752011936438014\n```" - ], - "signature": "let sinh: float => float" - }, - { - "id": "Core.Math.sqrt", - "kind": "value", - "name": "sqrt", - "docstrings": [ - "`sqrt(v)` returns the square root of `v`. If `v` is negative returns `NaN`.\nSee [`Math.sqrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt) on MDN.\n\n## Examples\n\n```rescript\nMath.sqrt(-1.0)->Float.isNaN // true\nMath.sqrt(-0.0) // -0.0\nMath.sqrt(0.0) // 0.0\nMath.sqrt(1.0) // 1.0\nMath.sqrt(9.0) // 3.0\n```" - ], - "signature": "let sqrt: float => float" - }, - { - "id": "Core.Math.tan", - "kind": "value", - "name": "tan", - "docstrings": [ - "`tan(v)` returns the tangent of argument `v`, which must be specified in\nradians. Returns `NaN` if `v` is positive `Infinity` or negative `Infinity`.\nSee [`Math.tan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan) on MDN.\n\n## Examples\n\n```rescript\nMath.tan(-0.0) // -0.0\nMath.tan(0.0) // 0.0\nMath.tan(1.0) // 1.5574077246549023\n```" - ], - "signature": "let tan: float => float" - }, - { - "id": "Core.Math.tanh", - "kind": "value", - "name": "tanh", - "docstrings": [ - "`tanh(v)` returns the hyperbolic tangent of argument `v`, which must be\nspecified in radians.\nSee [`Math.tanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh) on MDN.\n\n## Examples\n\n```rescript\nMath.tanh(-0.0) // -0.0\nMath.tanh(0.0) // 0.0\nMath.tanh(1.0) // 0.7615941559557649\n```" - ], - "signature": "let tanh: float => float" - }, - { - "id": "Core.Math.trunc", - "kind": "value", - "name": "trunc", - "docstrings": [ - "`trunc(v)` truncates the argument `v`, i.e., removes fractional digits.\nSee [`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc) on MDN.\n\n## Examples\n\n```rescript\nMath.trunc(0.123) // 0.0\nMath.trunc(1.999) // 1.0\nMath.trunc(13.37) // 13.0\nMath.trunc(42.84) // 42.0\n```" - ], - "signature": "let trunc: float => float" - } - ] - }, - "core/bigint": { - "id": "Core.BigInt", - "name": "BigInt", - "docstrings": [], - "items": [ - { - "id": "Core.BigInt.asIntN", - "kind": "value", - "name": "asIntN", - "docstrings": [], - "signature": "let asIntN: (~width: int, bigint) => bigint" - }, - { - "id": "Core.BigInt.asUintN", - "kind": "value", - "name": "asUintN", - "docstrings": [], - "signature": "let asUintN: (~width: int, bigint) => bigint" - }, - { - "id": "Core.BigInt.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [], - "signature": "let fromString: string => bigint" - }, - { - "id": "Core.BigInt.fromStringExn", - "kind": "value", - "name": "fromStringExn", - "docstrings": [ - "Parses the given `string` into a `bigint` using JavaScript semantics. Return the\nnumber as a `bigint` if successfully parsed. Uncaught syntax exception otherwise.\n\n## Examples\n\n```rescript\n/* returns 123n */\nBigInt.fromStringExn(\"123\")\n\n/* returns 0n */\nBigInt.fromStringExn(\"\")\n\n/* returns 17n */\nBigInt.fromStringExn(\"0x11\")\n\n/* returns 3n */\nBigInt.fromStringExn(\"0b11\")\n\n/* returns 9n */\nBigInt.fromStringExn(\"0o11\")\n\n/* catch exception */\ntry {\n BigInt.fromStringExn(\"a\")\n} catch {\n| Exn.Error(_error) => 0n\n}\n```" - ], - "signature": "let fromStringExn: string => bigint" - }, - { - "id": "Core.BigInt.fromInt", - "kind": "value", - "name": "fromInt", - "docstrings": [], - "signature": "let fromInt: int => bigint" - }, - { - "id": "Core.BigInt.fromFloat", - "kind": "value", - "name": "fromFloat", - "docstrings": [], - "signature": "let fromFloat: float => bigint" - }, - { - "id": "Core.BigInt.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Formats a `bigint` as a string. Return a `string` representing the given value.\nSee [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"123\" */\nJs.BigInt.toString(123n)->Js.log\n```" - ], - "signature": "let toString: (bigint, ~radix: int=?) => string" - }, - { - "id": "Core.BigInt.toStringWithRadix", - "kind": "value", - "name": "toStringWithRadix", - "docstrings": [], - "signature": "let toStringWithRadix: (bigint, ~radix: int) => string", - "deprecated": "Use `toString` with `~radix` instead" - }, - { - "id": "Core.BigInt.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "Returns a string with a language-sensitive representation of this BigInt value.\n\n## Examples\n\n```rescript\n/* prints \"123\" */\nJs.BigInt.toString(123n)->Js.log\n```" - ], - "signature": "let toLocaleString: bigint => string" - }, - { - "id": "Core.BigInt.toFloat", - "kind": "value", - "name": "toFloat", - "docstrings": [], - "signature": "let toFloat: bigint => float" - }, - { - "id": "Core.BigInt.toInt", - "kind": "value", - "name": "toInt", - "docstrings": [], - "signature": "let toInt: bigint => int" - }, - { - "id": "Core.BigInt.+", - "kind": "value", - "name": "+", - "docstrings": [], - "signature": "let +: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.-", - "kind": "value", - "name": "-", - "docstrings": [], - "signature": "let -: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.*", - "kind": "value", - "name": "*", - "docstrings": [], - "signature": "let *: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt./", - "kind": "value", - "name": "/", - "docstrings": [], - "signature": "let /: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.~-", - "kind": "value", - "name": "~-", - "docstrings": [], - "signature": "let ~-: bigint => bigint" - }, - { - "id": "Core.BigInt.~+", - "kind": "value", - "name": "~+", - "docstrings": [], - "signature": "let ~+: bigint => bigint" - }, - { - "id": "Core.BigInt.**", - "kind": "value", - "name": "**", - "docstrings": [], - "signature": "let **: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.add", - "kind": "value", - "name": "add", - "docstrings": [], - "signature": "let add: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.sub", - "kind": "value", - "name": "sub", - "docstrings": [], - "signature": "let sub: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.mul", - "kind": "value", - "name": "mul", - "docstrings": [], - "signature": "let mul: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.div", - "kind": "value", - "name": "div", - "docstrings": [], - "signature": "let div: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.mod", - "kind": "value", - "name": "mod", - "docstrings": [], - "signature": "let mod: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.land", - "kind": "value", - "name": "land", - "docstrings": [], - "signature": "let land: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.lor", - "kind": "value", - "name": "lor", - "docstrings": [], - "signature": "let lor: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.lxor", - "kind": "value", - "name": "lxor", - "docstrings": [], - "signature": "let lxor: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.lsl", - "kind": "value", - "name": "lsl", - "docstrings": [], - "signature": "let lsl: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.asr", - "kind": "value", - "name": "asr", - "docstrings": [], - "signature": "let asr: (bigint, bigint) => bigint" - }, - { - "id": "Core.BigInt.lnot", - "kind": "value", - "name": "lnot", - "docstrings": [], - "signature": "let lnot: bigint => bigint" - } - ] - }, - "core/int": { - "id": "Core.Int", - "name": "Int", - "docstrings": [ - "Functions for interacting with JavaScript Number.\nSee: [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)." - ], - "items": [ - { - "id": "Core.Int.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (int, int) => bool" - }, - { - "id": "Core.Int.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (int, int) => Core__Ordering.t" - }, - { - "id": "Core.Int.toExponential", - "kind": "value", - "name": "toExponential", - "docstrings": [ - "`toExponential(n, ~digits=?)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\n\n## Examples\n\n```rescript\nInt.toExponential(1000) // \"1e+3\"\nInt.toExponential(-1000) // \"-1e+3\"\nInt.toExponential(77, ~digits=2) // \"7.70e+1\"\nInt.toExponential(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10." - ], - "signature": "let toExponential: (int, ~digits: int=?) => string" - }, - { - "id": "Core.Int.toExponentialWithPrecision", - "kind": "value", - "name": "toExponentialWithPrecision", - "docstrings": [ - "`toExponential(n, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\non MDN.\n\n## Examples\n\n```rescript\nInt.toExponentialWithPrecision(77, ~digits=2) // \"7.70e+1\"\nInt.toExponentialWithPrecision(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10." - ], - "signature": "let toExponentialWithPrecision: (int, ~digits: int) => string", - "deprecated": "Use `toExponential` instead" - }, - { - "id": "Core.Int.toFixed", - "kind": "value", - "name": "toFixed", - "docstrings": [ - "`toFixed(n, ~digits=?)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixed(123456) // \"123456.00\"\nInt.toFixed(10) // \"10.00\"\nInt.toFixed(300, ~digits=4) // \"300.0000\"\nInt.toFixed(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100." - ], - "signature": "let toFixed: (int, ~digits: int=?) => string" - }, - { - "id": "Core.Int.toFixedWithPrecision", - "kind": "value", - "name": "toFixedWithPrecision", - "docstrings": [ - "`toFixedWithPrecision(n, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixedWithPrecision(300, ~digits=4) // \"300.0000\"\nInt.toFixedWithPrecision(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100." - ], - "signature": "let toFixedWithPrecision: (int, ~digits: int) => string", - "deprecated": "Use `toFixed` instead" - }, - { - "id": "Core.Int.toPrecision", - "kind": "value", - "name": "toPrecision", - "docstrings": [ - "`toPrecision(n, ~digits=?)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecision(100) // \"100\"\nInt.toPrecision(1) // \"1\"\nInt.toPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\nImplementations are allowed to support larger and smaller values as well.\nECMA-262 only requires a precision of up to 21 significant digits." - ], - "signature": "let toPrecision: (int, ~digits: int=?) => string" - }, - { - "id": "Core.Int.toPrecisionWithPrecision", - "kind": "value", - "name": "toPrecisionWithPrecision", - "docstrings": [ - "`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecisionWithPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecisionWithPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\nImplementations are allowed to support larger and smaller values as well.\nECMA-262 only requires a precision of up to 21 significant digits." - ], - "signature": "let toPrecisionWithPrecision: (int, ~digits: int) => string", - "deprecated": "Use `toPrecision` instead" - }, - { - "id": "Core.Int.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "`toString(n, ~radix=?)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toString(1000) // \"1000\"\nInt.toString(-1000) // \"-1000\"\nInt.toString(6, ~radix=2) // \"110\"\nInt.toString(373592855, ~radix=16) // \"16449317\"\nInt.toString(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36." - ], - "signature": "let toString: (int, ~radix: int=?) => string" - }, - { - "id": "Core.Int.toStringWithRadix", - "kind": "value", - "name": "toStringWithRadix", - "docstrings": [ - "`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36." - ], - "signature": "let toStringWithRadix: (int, ~radix: int) => string", - "deprecated": "Use `toString` instead" - }, - { - "id": "Core.Int.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "`toLocaleString(n)` return a `string` with language-sensitive representing the\ngiven value. See [`Number.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString) on MDN.\n\n## Examples\n\n```rescript\n// If the application uses English as the default language\nInt.toLocaleString(1000) // \"1,000\"\n\n// If the application uses Portuguese Brazil as the default language\nInt.toLocaleString(1000) // \"1.000\"\n```" - ], - "signature": "let toLocaleString: int => string" - }, - { - "id": "Core.Int.toFloat", - "kind": "value", - "name": "toFloat", - "docstrings": [ - "`toFloat(n)` return a `float` representing the given value.\n\n## Examples\n\n```rescript\nInt.toFloat(100) == 100.0\nInt.toFloat(2) == 2.0\n```" - ], - "signature": "let toFloat: int => float" - }, - { - "id": "Core.Int.fromFloat", - "kind": "value", - "name": "fromFloat", - "docstrings": [ - "`fromFloat(n)` return an `int` representing the given value. The conversion is\ndone by truncating the decimal part.\n\n## Examples\n\n```rescript\nInt.fromFloat(2.0) == 2\nInt.fromFloat(1.999) == 1\nInt.fromFloat(1.5) == 1\nInt.fromFloat(0.9999) == 0\n```" - ], - "signature": "let fromFloat: float => int" - }, - { - "id": "Core.Int.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "`fromString(str, ~radix=?)` return an `option` representing the given value\n`str`. `~radix` specifies the radix base to use for the formatted number.\n\n## Examples\n\n```rescript\nInt.fromString(\"0\") == Some(0)\nInt.fromString(\"NaN\") == None\nInt.fromString(\"6\", ~radix=2) == None\n```" - ], - "signature": "let fromString: (string, ~radix: int=?) => option" - }, - { - "id": "Core.Int.mod", - "kind": "value", - "name": "mod", - "docstrings": [ - "`mod(n1, n2)` calculates the modulo (remainder after division) of two integers.\n\n## Examples\n\n```rescript\nInt.mod(7, 4) == 3\n```" - ], - "signature": "let mod: (int, int) => int" - }, - { - "id": "Core.Int.rangeOptions", - "kind": "type", - "name": "rangeOptions", - "docstrings": ["The options for `range`."], - "signature": "type rangeOptions = {step?: int, inclusive?: bool}" - }, - { - "id": "Core.Int.range", - "kind": "value", - "name": "range", - "docstrings": [ - "`range(start, end, ~options=?)` returns an int array of the sequence of integers in the\nrange `[start, end)`. That is, including `start` but excluding `end`.\n\nIf `step` is not set and `start < end`, the sequence will be increasing in steps of 1.\n\nIf `step` is not set and `start > end`, the sequence will be decreasing in steps of -1.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nraised as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.range(3, 6) == [3, 4, 5]\nInt.range(-3, -1) == [-3, -2]\nInt.range(3, 1) == [3, 2]\nInt.range(3, 7, ~options={step: 2}) == [3, 5]\nInt.range(3, 7, ~options={step: 2, inclusive: true}) == [3, 5, 7]\nInt.range(3, 6, ~options={step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`." - ], - "signature": "let range: (int, int, ~options: rangeOptions=?) => array" - }, - { - "id": "Core.Int.rangeWithOptions", - "kind": "value", - "name": "rangeWithOptions", - "docstrings": [ - "`rangeWithOptions(start, end, options)` is like `range`, but with `step` and\n`inclusive` options configurable.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nraised as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.rangeWithOptions(3, 7, {step: 2}) == [3, 5]\nInt.rangeWithOptions(3, 7, {step: 2, inclusive: true}) == [3, 5, 7]\nInt.rangeWithOptions(3, 6, {step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`." - ], - "signature": "let rangeWithOptions: (int, int, rangeOptions) => array", - "deprecated": "Use `range` instead" - }, - { - "id": "Core.Int.clamp", - "kind": "value", - "name": "clamp", - "docstrings": [ - "`clamp(~min=?, ~max=?, value)` returns `value`, optionally bounded by `min` and `max`.\n\nif `max` < `min` returns `min`.\n\n## Examples\n\n```rescript\nInt.clamp(42) == 42\nInt.clamp(42, ~min=50) == 50\nInt.clamp(42, ~max=40) == 40\nInt.clamp(42, ~min=50, ~max=40) == 50\n```" - ], - "signature": "let clamp: (~min: int=?, ~max: int=?, int) => int" - } - ] - }, - "core/float": { - "id": "Core.Float", - "name": "Float", - "docstrings": ["Functions for interacting with float."], - "items": [ - { - "id": "Core.Float.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (float, float) => bool" - }, - { - "id": "Core.Float.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (float, float) => Core__Ordering.t" - }, - { - "id": "Core.Float.isNaN", - "kind": "value", - "name": "isNaN", - "docstrings": [ - "`isNaN(v)` tests if the given `v` is `NaN`.\nSee [`NaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) on MDN.\n\n## Examples\n\n```rescript\nFloat.isNaN(3.0) // false\nFloat.isNaN(Float.Constants.nan) // true\n```" - ], - "signature": "let isNaN: float => bool" - }, - { - "id": "Core.Float.isFinite", - "kind": "value", - "name": "isFinite", - "docstrings": [ - "`isFinite(v)` tests if the given `v` is finite.\nSee [`isFinite`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite) on MDN.\n\n## Examples\n\n```rescript\nFloat.isFinite(1.0) // true\nFloat.isFinite(Float.Constants.nan) // false\nFloat.isFinite(Float.Constants.positiveInfinity) // false\n```" - ], - "signature": "let isFinite: float => bool" - }, - { - "id": "Core.Float.parseFloat", - "kind": "value", - "name": "parseFloat", - "docstrings": [ - "`parseFloat(v)` parse the given `v` and returns a float. Leading whitespace in\n`v` is ignored. Returns `NaN` if `v` can't be parsed. Use [`fromString`] to\nensure it returns a valid float and not `NaN`.\nSee [`parseFloat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat) on MDN.\n\n## Examples\n\n```rescript\nFloat.parseFloat(\"1.0\") // 1.0\nFloat.parseFloat(\" 3.14 \") // 3.14\nFloat.parseFloat(\"3.0\") // 3.0\nFloat.parseFloat(\"3.14some non-digit characters\") // 3.14\nFloat.parseFloat(\"error\")->Float.isNaN // true\n```" - ], - "signature": "let parseFloat: string => float" - }, - { - "id": "Core.Float.parseInt", - "kind": "value", - "name": "parseInt", - "docstrings": [ - "`parseInt(v, ~radix=?)` parse the given `v` and returns a float. Leading\nwhitespace in this argument `v`is ignored. `radix` specifies the radix base to\nuse for the formatted number. The value must be in the range [2, 36] (inclusive).\nReturns `NaN` if `v` can't be parsed and `radix` is smaller than 2 or bigger\nthan 36.\nSee [`parseInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt) on MDN.\n\n## Examples\n\n```rescript\nFloat.parseInt(\"1.0\") // 1.0\nFloat.parseInt(\" 3.14 \") // 3.0\nFloat.parseInt(3) // 3.0\nFloat.parseInt(\"3.14some non-digit characters\") // 3.0\nFloat.parseInt(\"error\")->Float.isNaN // true\nFloat.parseInt(\"10.0\", ~radix=2) // 2.0\nFloat.parseInt(\"15 * 3\", ~radix=10) // 15.0\nFloat.parseInt(\"12\", ~radix=13) // 15.0\nFloat.parseInt(\"17\", ~radix=40)->Float.isNaN // true\n```" - ], - "signature": "let parseInt: ('a, ~radix: int=?) => float" - }, - { - "id": "Core.Float.parseIntWithRadix", - "kind": "value", - "name": "parseIntWithRadix", - "docstrings": [ - "`parseIntWithRadix(v, ~radix)` parse the given `v` and returns a float. Leading\nwhitespace in this argument `v`is ignored. `radix` specifies the radix base to\nuse for the formatted number. The value must be in the range [2, 36] (inclusive).\nReturns `NaN` if `v` can't be parsed and `radix` is smaller than 2 or bigger\nthan 36.\nSee [`parseInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt) on MDN.\n\n## Examples\n\n```rescript\nFloat.parseIntWithRadix(\"10.0\", ~radix=2) // 2.0\nFloat.parseIntWithRadix(\"15 * 3\", ~radix=10) // 15.0\nFloat.parseIntWithRadix(\"12\", ~radix=13) // 15.0\nFloat.parseIntWithRadix(\"17\", ~radix=40)->Float.isNaN // true\n```" - ], - "signature": "let parseIntWithRadix: ('a, ~radix: int) => float", - "deprecated": "Use `parseInt` instead" - }, - { - "id": "Core.Float.toExponential", - "kind": "value", - "name": "toExponential", - "docstrings": [ - "`toExponential(v, ~digits=?)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point.\nSee [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN.\n\n## Examples\n\n```rescript\nFloat.toExponential(1000.0) // \"1e+3\"\nFloat.toExponential(-1000.0) // \"-1e+3\"\nFloat.toExponential(77.0, ~digits=2) // \"7.70e+1\"\nFloat.toExponential(5678.0, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10." - ], - "signature": "let toExponential: (float, ~digits: int=?) => string" - }, - { - "id": "Core.Float.toExponentialWithPrecision", - "kind": "value", - "name": "toExponentialWithPrecision", - "docstrings": [ - "`toExponential(v, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point.\nSee [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN.\n\n## Examples\n\n```rescript\nFloat.toExponentialWithPrecision(77.0, ~digits=2) // \"7.70e+1\"\nFloat.toExponentialWithPrecision(5678.0, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10." - ], - "signature": "let toExponentialWithPrecision: (float, ~digits: int) => string", - "deprecated": "Use `toExponential` instead" - }, - { - "id": "Core.Float.toFixed", - "kind": "value", - "name": "toFixed", - "docstrings": [ - "`toFixed(v, ~digits=?)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point.\nSee [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN.\n\n## Examples\n\n```rescript\nFloat.toFixed(123456.0) // \"123456.00\"\nFloat.toFixed(10.0) // \"10.00\"\nFloat.toFixed(300.0, ~digits=4) // \"300.0000\"\nFloat.toFixed(300.0, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100." - ], - "signature": "let toFixed: (float, ~digits: int=?) => string" - }, - { - "id": "Core.Float.toFixedWithPrecision", - "kind": "value", - "name": "toFixedWithPrecision", - "docstrings": [ - "`toFixedWithPrecision(v, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point.\nSee [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN.\n\n## Examples\n\n```rescript\nFloat.toFixedWithPrecision(300.0, ~digits=4) // \"300.0000\"\nFloat.toFixedWithPrecision(300.0, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100." - ], - "signature": "let toFixedWithPrecision: (float, ~digits: int) => string", - "deprecated": "Use `toFixed` instead" - }, - { - "id": "Core.Float.toPrecision", - "kind": "value", - "name": "toPrecision", - "docstrings": [ - "`toPrecision(v, ~digits=?)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits.\nSee [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nFloat.toPrecision(100.0) // \"100\"\nFloat.toPrecision(1.0) // \"1\"\nFloat.toPrecision(100.0, ~digits=2) // \"1.0e+2\"\nFloat.toPrecision(1.0, ~digits=1) // \"1\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\nImplementations are allowed to support larger and smaller values as well.\nECMA-262 only requires a precision of up to 21 significant digits." - ], - "signature": "let toPrecision: (float, ~digits: int=?) => string" - }, - { - "id": "Core.Float.toPrecisionWithPrecision", - "kind": "value", - "name": "toPrecisionWithPrecision", - "docstrings": [ - "`toPrecisionWithPrecision(v, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits.\nSee [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nFloat.toPrecisionWithPrecision(100.0, ~digits=2) // \"1.0e+2\"\nFloat.toPrecisionWithPrecision(1.0, ~digits=1) // \"1\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\nImplementations are allowed to support larger and smaller values as well.\nECMA-262 only requires a precision of up to 21 significant digits." - ], - "signature": "let toPrecisionWithPrecision: (float, ~digits: int) => string", - "deprecated": "Use `toPrecision` instead" - }, - { - "id": "Core.Float.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "`toString(v)` return a `string` representing the given value.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\nFloat.toString(1000.0) // \"1000\"\nFloat.toString(-1000.0) // \"-1000\"\n```" - ], - "signature": "let toString: (float, ~radix: int=?) => string" - }, - { - "id": "Core.Float.toStringWithRadix", - "kind": "value", - "name": "toStringWithRadix", - "docstrings": [ - "`toStringWithRadix(v, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\nFloat.toStringWithRadix(6.0, ~radix=2) // \"110\"\nFloat.toStringWithRadix(3735928559.0, ~radix=16) // \"deadbeef\"\nFloat.toStringWithRadix(123456.0, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36." - ], - "signature": "let toStringWithRadix: (float, ~radix: int) => string", - "deprecated": "Use `toString` with `~radix` instead" - }, - { - "id": "Core.Float.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "`toLocaleString(v)` return a `string` with language-sensitive representing the\ngiven value.\nSee [`Number.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString) on MDN.\n\n## Examples\n\n```rescript\n// If the application uses English as the default language\nFloat.toLocaleString(1000.0) // \"1,000\"\n\n// If the application uses Portuguese Brazil as the default language\nFloat.toLocaleString(1000.0) // \"1.000\"\n```" - ], - "signature": "let toLocaleString: float => string" - }, - { - "id": "Core.Float.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "`fromString(str)` return an `option` representing the given value `str`.\n\n## Examples\n\n```rescript\nFloat.fromString(\"0\") == Some(0.0)\nFloat.fromString(\"NaN\") == None\nFloat.fromString(\"6\") == Some(6.0)\n```" - ], - "signature": "let fromString: string => option" - }, - { - "id": "Core.Float.toInt", - "kind": "value", - "name": "toInt", - "docstrings": [ - "`toInt(v)` returns an int to given float `v`.\n\n## Examples\n\n```rescript\nFloat.toInt(2.0) == 2\nFloat.toInt(1.0) == 1\nFloat.toInt(1.1) == 1\nFloat.toInt(1.6) == 1\n```" - ], - "signature": "let toInt: float => int" - }, - { - "id": "Core.Float.fromInt", - "kind": "value", - "name": "fromInt", - "docstrings": [ - "`fromInt(v)` returns a float to given int `v`.\n\n## Examples\n\n```rescript\nFloat.fromInt(2) == 2.0\nFloat.fromInt(1) == 1.0\n```" - ], - "signature": "let fromInt: int => float" - }, - { - "id": "Core.Float.mod", - "kind": "value", - "name": "mod", - "docstrings": [ - "`mod(n1, n2)` calculates the modulo (remainder after division) of two floats.\n\n## Examples\n\n```rescript\nFloat.mod(7.0, 4.0) == 3.0\n```" - ], - "signature": "let mod: (float, float) => float" - }, - { - "id": "Core.Float.clamp", - "kind": "value", - "name": "clamp", - "docstrings": [ - "`clamp(~min=?, ~max=?, value)` returns `value`, optionally bounded by `min` and `max`.\n\nif `max` < `min` returns `min`.\n\n## Examples\n\n```rescript\nFloat.clamp(4.2) == 4.2\nFloat.clamp(4.2, ~min=4.3) == 4.3\nFloat.clamp(4.2, ~max=4.1) == 4.1\nFloat.clamp(4.2, ~min=4.3, ~max=4.1) == 4.3\n```" - ], - "signature": "let clamp: (~min: float=?, ~max: float=?, float) => float" - } - ] - }, - "core/error": { - "id": "Core.Error", - "name": "Error", - "docstrings": [ - "Functions for working with JavaScript exceptions.\n\nSee [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) on MDN." - ], - "items": [ - { - "id": "Core.Error.t", - "kind": "type", - "name": "t", - "docstrings": ["Represents a JavaScript exception."], - "signature": "type t = Js.Exn.t" - }, - { - "id": "Core.Error.fromException", - "kind": "value", - "name": "fromException", - "docstrings": [], - "signature": "let fromException: exn => option" - }, - { - "id": "Core.Error.toException", - "kind": "value", - "name": "toException", - "docstrings": [ - "Turns an `Error.t` into an `exn`.\n\n## Examples\n```rescript\nlet error = Error.make(\"Something went wrong.\")\n\nlet asExn = error->Error.toException // `asExn` is now type `exn`\n```" - ], - "signature": "let toException: t => exn" - }, - { - "id": "Core.Error.stack", - "kind": "value", - "name": "stack", - "docstrings": [ - "`stack(error)` retrieves the `stack` property of the error, if it exists. The stack is a list of what functions were called, and what files they are defined in, prior to the error happening.\n\nSee [`Error.prototype.stack`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack) on MDN.\n\n## Example\n```rescript\nlet error = Error.make(\"error\")\nConsole.log(error->Error.stack) // Logs `stack` if it exists on `someError`\n```" - ], - "signature": "let stack: t => option" - }, - { - "id": "Core.Error.message", - "kind": "value", - "name": "message", - "docstrings": [ - "`message(error)` retrieves the `message` property of the error, if it exists.\n\nSee [`Error.prototype.message`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message) on MDN.\n\n## Example\n```rescript\nlet error = Error.SyntaxError.make(\"Some message here\")\nConsole.log(error->Error.message) // Logs \"Some message here\" to the console\n```" - ], - "signature": "let message: t => option" - }, - { - "id": "Core.Error.name", - "kind": "value", - "name": "name", - "docstrings": [ - "`name(error)` retrieves the `name` property of the error, if it exists.\n\nSee [`Error.prototype.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name) on MDN.\n\n## Example\n```rescript\nlet error = Error.SyntaxError.make(\"Some message here\")\nConsole.log(error->Error.name) // Logs \"SyntaxError\" to the console\n```" - ], - "signature": "let name: t => option" - }, - { - "id": "Core.Error.fileName", - "kind": "value", - "name": "fileName", - "docstrings": [ - "`fileName(error)` retrieves the `fileName` property of the error, if it exists.\n\nSee [`Error.prototype.fileName`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName) on MDN." - ], - "signature": "let fileName: t => option" - }, - { - "id": "Core.Error.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(message)` creates a new error, setting its `message` to the provided value.\n\nSee [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error) on MDN.\n\n## Example\n```rescript\nlet error = Error.make(\"Some message here\")\nConsole.log(error->Error.message) // Logs \"Some message here\" to the console\nConsole.log(error->Error.name) // Logs \"Error\" to the console, because this is a regular error\n```" - ], - "signature": "let make: string => t" - }, - { - "id": "Core.Error.raise", - "kind": "value", - "name": "raise", - "docstrings": [ - "Raises (throws in JavaScript language) the provided `Error.t`, which will stop execution.\n\n## Examples\n```rescript\nlet error = Error.make(\"Everything is upside down.\")\n\nif 5 > 10 {\n error->Error.raise\n} else {\n Console.log(\"Phew, sanity still rules.\")\n}\n```" - ], - "signature": "let raise: t => 'a" - }, - { - "id": "Core.Error.panic", - "kind": "value", - "name": "panic", - "docstrings": [ - "Raises a panic exception with the given message.\n\nA panic exception is a native JavaScript exception that is not intended to be caught and\nhandled. Compared to a ReScript exception this will give a better stack trace and\ndebugging experience.\n\n## Examples\n```rescript\nError.panic(\"Uh oh. This was unexpected!\")\n```" - ], - "signature": "let panic: string => 'a" - } - ] - }, - "core/dict": { - "id": "Core.Dict", - "name": "Dict", - "docstrings": [ - "A mutable dictionary with string keys.\n\nCompiles to a regular JavaScript object." - ], - "items": [ - { - "id": "Core.Dict.t", - "kind": "type", - "name": "t", - "docstrings": ["Type representing a dictionary of value `'a`."], - "signature": "type t<'a> = Js.Dict.t<'a>" - }, - { - "id": "Core.Dict.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(dict, key)` Returns the `value` at the provided `key`.\n\nThis is _unsafe_, meaning it will return `undefined` value if `key` does not exist in `dict`.\n\nUse `Dict.getUnsafe` only when you are sure the key exists (i.e. when iterating `Dict.keys` result).\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([(\"key1\", \"value1\"), (\"key2\", \"value2\")])\nlet value = dict->Dict.getUnsafe(\"key1\")\nConsole.log(value) // value1\n```" - ], - "signature": "let getUnsafe: (t<'a>, string) => 'a" - }, - { - "id": "Core.Dict.get", - "kind": "value", - "name": "get", - "docstrings": [ - "Returns the value at the provided key, if it exists. Returns an option.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([(\"someKey\", \"someValue\")])\n\nswitch dict->Dict.get(\"someKey\") {\n| None => Console.log(\"Nope, didn't have the key.\")\n| Some(value) => Console.log(value)\n}\n```" - ], - "signature": "let get: (t<'a>, string) => option<'a>" - }, - { - "id": "Core.Dict.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(dictionary, key, value)` sets the value at the provided key to the provided value.\n\n## Examples\n```rescript\nlet dict = Dict.make()\n\ndict->Dict.set(\"someKey\", \"someValue\")\n```" - ], - "signature": "let set: (t<'a>, string, 'a) => unit" - }, - { - "id": "Core.Dict.delete", - "kind": "value", - "name": "delete", - "docstrings": [ - "`delete(dictionary, key)` deletes the value at `key`, if it exists.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([(\"someKey\", \"someValue\")])\n\ndict->Dict.delete(\"someKey\")\n```" - ], - "signature": "let delete: (t<'a>, string) => unit" - }, - { - "id": "Core.Dict.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make()` creates a new, empty dictionary.\n\n## Examples\n```rescript\nlet dict1: Dict.t = Dict.make() // You can annotate the type of the values of your dict yourself if you want\n\nlet dict2 = Dict.make() // Or you can let ReScript infer it via usage.\ndict2->Dict.set(\"someKey\", 12)\n```" - ], - "signature": "let make: unit => t<'a>" - }, - { - "id": "Core.Dict.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "`fromArray(entries)` creates a new dictionary from the provided array of key/value pairs.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([(\"key1\", \"value1\"), (\"key2\", \"value2\")])\n```" - ], - "signature": "let fromArray: array<(string, 'a)> => t<'a>" - }, - { - "id": "Core.Dict.fromIterator", - "kind": "value", - "name": "fromIterator", - "docstrings": [ - "`fromIterator(entries)` creates a new dictionary from the provided iterator of key/value pairs.\n\n## Examples\n```rescript\n// Pretend we have an iterator of the correct shape\n@val external someIterator: Iterator.t<(string, int)> = \"someIterator\"\n\nlet dict = Dict.fromIterator(someIterator) // Dict.t\n```" - ], - "signature": "let fromIterator: Core__Iterator.t<(string, 'a)> => t<'a>" - }, - { - "id": "Core.Dict.toArray", - "kind": "value", - "name": "toArray", - "docstrings": [ - "`toArray(dictionary)` returns an array of all the key/value pairs of the dictionary.\n\n## Examples\n```rescript\nlet dict = Dict.make()\ndict->Dict.set(\"someKey\", 1)\ndict->Dict.set(\"someKey2\", 2)\nlet asArray = dict->Dict.toArray\nConsole.log(asArray) // Logs `[[\"someKey\", 1], [\"someKey2\", 2]]` to the console\n```" - ], - "signature": "let toArray: t<'a> => array<(string, 'a)>" - }, - { - "id": "Core.Dict.keysToArray", - "kind": "value", - "name": "keysToArray", - "docstrings": [ - "`keysToArray(dictionary)` returns an array of all the keys of the dictionary.\n\n## Examples\n```rescript\nlet dict = Dict.make()\ndict->Dict.set(\"someKey\", 1)\ndict->Dict.set(\"someKey2\", 2)\nlet keys = dict->Dict.keysToArray\nConsole.log(keys) // Logs `[\"someKey\", \"someKey2\"]` to the console\n```" - ], - "signature": "let keysToArray: t<'a> => array" - }, - { - "id": "Core.Dict.valuesToArray", - "kind": "value", - "name": "valuesToArray", - "docstrings": [ - "`valuesToArray(dictionary)` returns an array of all the values of the dictionary.\n\n## Examples\n```rescript\nlet dict = Dict.make()\ndict->Dict.set(\"someKey\", 1)\ndict->Dict.set(\"someKey2\", 2)\nlet values = dict->Dict.valuesToArray\nConsole.log(values) // Logs `[1, 2]` to the console\n```" - ], - "signature": "let valuesToArray: t<'a> => array<'a>" - }, - { - "id": "Core.Dict.assign", - "kind": "value", - "name": "assign", - "docstrings": [ - "`assign(dictionary1, dictionary2)` [shallowly](https://developer.mozilla.org/en-US/docs/Glossary/Shallow_copy) merges dictionary2 into dictionary1, and returns dictionary1.\n\nBeware this will *mutate* dictionary1. If you're looking for a way to copy a dictionary, check out `Dict.copy`.\n\n## Examples\n```rescript\nlet dict1 = Dict.make()\ndict1->Dict.set(\"firstKey\", 1)\nConsole.log(dict1->Dict.keysToArray) // Logs `[\"firstKey\"]`\n\nlet dict2 = Dict.make()\ndict2->Dict.set(\"someKey\", 2)\ndict2->Dict.set(\"someKey2\", 3)\n\nlet dict1 = dict1->Dict.assign(dict2)\n\nConsole.log(dict1->Dict.keysToArray) // Logs `[\"firstKey\", \"someKey\", \"someKey2\"]`\n\n```" - ], - "signature": "let assign: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Core.Dict.copy", - "kind": "value", - "name": "copy", - "docstrings": [ - "`copy(dictionary)` [shallowly copies](https://developer.mozilla.org/en-US/docs/Glossary/Shallow_copy) the provided dictionary to a new dictionary.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([(\"key1\", \"value1\"), (\"key2\", \"value2\")])\nlet dict2 = dict->Dict.copy\n\n// Both log `[\"key1\", \"key2\"]` here.\nConsole.log2(dict->Dict.keysToArray, dict2->Dict.keysToArray)\n```" - ], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Core.Dict.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(dictionary, f)` iterates through all values of the dict.\n\n> Please note that this is *without the keys*, just the values. If you need the key as well, use `Dict.forEachWithKey`.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([(\"key1\", \"value1\"), (\"key2\", \"value2\")])\n\ndict->Dict.forEach(value => {\n Console.log(value)\n})\n```" - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Core.Dict.forEachWithKey", - "kind": "value", - "name": "forEachWithKey", - "docstrings": [ - "`forEachWithKey(dictionary, f)` iterates through all values of the dict, including the key for each value.\n\n## Examples\n```rescript\nlet dict = Dict.fromArray([(\"key1\", \"value1\"), (\"key2\", \"value2\")])\n\ndict->Dict.forEachWithKey((value, key) => {\n Console.log2(value, key)\n})\n```" - ], - "signature": "let forEachWithKey: (t<'a>, ('a, string) => unit) => unit" - }, - { - "id": "Core.Dict.mapValues", - "kind": "value", - "name": "mapValues", - "docstrings": [ - "`mapValues(dictionary, f)` returns a new dictionary with the same keys, and `f` applied to each value in the original dictionary.\n\n## Examples\n\n```rescript\nlet dict = Dict.fromArray([(\"key1\", 1), (\"key2\", 2)])\n\ndict->Dict.mapValues(v => v + 10)->Dict.toArray // [(\"key1\", 11), (\"key2\", 12)]\ndict->Dict.mapValues(v => Int.toString(v))->Dict.toArray // [(\"key1\", \"1\"), (\"key2\", \"2\")]\n```" - ], - "signature": "let mapValues: (t<'a>, 'a => 'b) => t<'b>" - } - ] - }, - "core/date": { - "id": "Core.Date", - "name": "Date", - "docstrings": ["Functions for interacting with JavaScript Dates."], - "items": [ - { - "id": "Core.Date.t", - "kind": "type", - "name": "t", - "docstrings": ["A type representing a JavaScript date."], - "signature": "type t = Js.Date.t" - }, - { - "id": "Core.Date.msSinceEpoch", - "kind": "type", - "name": "msSinceEpoch", - "docstrings": [ - "Time, in milliseconds, since / until the UNIX epoch (January 1, 1970 00:00:00 UTC).\nPositive numbers represent dates after, negative numbers dates before epoch." - ], - "signature": "type msSinceEpoch = float" - }, - { - "id": "Core.Date.localeOptions", - "kind": "type", - "name": "localeOptions", - "docstrings": [ - "A type representing date time format options.\n\nNote: There are some properties missing:\n- fractionalSecondDigits\n- dayPeriod\n- calendar\n- numberingSystem\n- localeMatcher\n- timeZone\n- hour12\n- hourCycle\n- formatMatcher\n\nSee full spec at https://tc39.es/ecma402/#datetimeformat-objects" - ], - "signature": "type localeOptions = {\n dateStyle?: [#full | #long | #medium | #short],\n timeStyle?: [#full | #long | #medium | #short],\n weekday?: [#long | #narrow | #short],\n era?: [#long | #narrow | #short],\n year?: [#\"2-digit\" | #numeric],\n month?: [\n | #\"2-digit\"\n | #long\n | #narrow\n | #numeric\n | #short\n ],\n day?: [#\"2-digit\" | #numeric],\n hour?: [#\"2-digit\" | #numeric],\n minute?: [#\"2-digit\" | #numeric],\n second?: [#\"2-digit\" | #numeric],\n timeZoneName?: [#long | #short],\n}" - }, - { - "id": "Core.Date.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make()`\n\nCreates a date object with the current date time as value.\n\n## Examples\n```rescript\nDate.make()\n```" - ], - "signature": "let make: unit => t" - }, - { - "id": "Core.Date.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "`fromString(dateTimeString)`\n\nCreates a date object from given date time string.\nThe string has to be in the ISO 8601 format YYYY-MM-DDTHH:mm:ss.sssZ (https://tc39.es/ecma262/#sec-date-time-string-format).\n\nInvalid date time strings will create invalid dates.\nYou can use the result like any valid date, but many functions like `toString` will return \"Invalid Date\" or functions like `Date.getTime` will return NaN.\n\n## Examples\n```rescript\nDate.fromString(\"2023\") // 2023-01-01T00:00:00.000Z\n\nDate.fromString(\"2023-02-20\") // 2023-02-20T00:00:00.000Z\n\nDate.fromString(\"2023-02-20T16:40:00.00Z\") // 2023-02-20T16:40:00.000Z\n\nDate.fromString(\"\") // Invalid Date\n\nDate.fromString(\"\")->Date.getTime // NaN\n```" - ], - "signature": "let fromString: string => t" - }, - { - "id": "Core.Date.fromTime", - "kind": "value", - "name": "fromTime", - "docstrings": [ - "`fromTime(msSinceEpoch)`\n\nCreates a date object from the given time in milliseconds since / until UNIX epoch (January 1, 1970 00:00:00 UTC).\nPositive numbers create dates after epoch, negative numbers create dates before epoch.\n\n## Examples\n```rescript\nDate.fromTime(0.0)\n// 1970-01-01T00:00:00.000Z\n\nDate.fromTime(-86_400_000.0)\n// 1969-12-31T00:00:00.000Z\n\nDate.fromTime(86_400_000.0)\n// 1970-01-02T00:00:00.000Z\n```" - ], - "signature": "let fromTime: msSinceEpoch => t" - }, - { - "id": "Core.Date.makeWithYM", - "kind": "value", - "name": "makeWithYM", - "docstrings": [ - "Creates a date object with the given year and month.\nBe aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\nMonths are 0-indexed (0 = January, 11 = December).\nValues, which are out of range, will be carried over to the next bigger unit (s. example).\n\n## Examples\n```rescript\nDate.makeWithYM(~year=2023, ~month=0)\n// 2023-01-01T00:00:00.000Z\n\nDate.makeWithYM(~year=2023, ~month=11)\n// 2023-12-01T00:00:00.000Z\n\nDate.makeWithYM(~year=2023, ~month=12)\n// 2024-01-01T00:00:00.000Z\n\nDate.makeWithYM(~year=2023, ~month=-1)\n// 2022-12-01T00:00:00.000Z\n\n// Note: The output depends on your local time zone.\n// In nodejs you can change it by using the TZ env (`export TZ='Europe/London' && node index.bs.js`)\n\n```" - ], - "signature": "let makeWithYM: (~year: int, ~month: int) => t" - }, - { - "id": "Core.Date.makeWithYMD", - "kind": "value", - "name": "makeWithYMD", - "docstrings": [ - "Creates a date object with the given year, month and date (day of month).\nBe aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\nMonths are 0-indexed (0 = January, 11 = December).\nValues, which are out of range, will be carried over to the next bigger unit (s. example).\n\n## Examples\n```rescript\nDate.makeWithYMD(~year=2023, ~month=1, ~date=20)\n// 2023-02-20T00:00:00.000Z\n\nDate.makeWithYMD(~year=2023, ~month=1, ~date=-1)\n// 2022-11-29T00:00:00.000Z\n\nDate.makeWithYMD(~year=2023, ~month=1, ~date=29)\n// 2023-03-01T00:00:00.000Z\n```" - ], - "signature": "let makeWithYMD: (~year: int, ~month: int, ~date: int) => t" - }, - { - "id": "Core.Date.makeWithYMDH", - "kind": "value", - "name": "makeWithYMDH", - "docstrings": [ - "Creates a date object with the given year, month, date (day of month) and hours.\nBe aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\nMonths are 0-indexed (0 = January, 11 = December).\nValues, which are out of range, will be carried over to the next bigger unit (s. example).\n\n## Examples\n```rescript\nDate.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=16)\n// 2023-02-20T16:00:00.000Z\n\nDate.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=24)\n// 2023-02-21T00:00:00.000Z\n\nDate.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=-1)\n// 2023-02-19T23:00:00.000Z\n\n// Note: The output depends on your local time zone.\n// In nodejs you can change it by using the TZ env (`export TZ='Europe/London' && node index.bs.js`)\n\n```" - ], - "signature": "let makeWithYMDH: (~year: int, ~month: int, ~date: int, ~hours: int) => t" - }, - { - "id": "Core.Date.makeWithYMDHM", - "kind": "value", - "name": "makeWithYMDHM", - "docstrings": [ - "Creates a date object with the given year, month, date (day of month), hours and minutes.\nBe aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\nMonths are 0-indexed (0 = January, 11 = December).\nValues, which are out of range, will be carried over to the next bigger unit (s. example).\n\n## Examples\n```rescript\nDate.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40)\n// 2023-02-20T16:40:00.000Z\n\nDate.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=60)\n// 2023-02-20T17:00:00.000Z\n\nDate.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=-1)\n// 2023-02-20T15:59:00.000Z\n\n// Note: The output depends on your local time zone.\n// In nodejs you can change it by using the TZ env (`export TZ='Europe/London' && node index.bs.js`)\n\n```" - ], - "signature": "let makeWithYMDHM: (\n ~year: int,\n ~month: int,\n ~date: int,\n ~hours: int,\n ~minutes: int,\n) => t" - }, - { - "id": "Core.Date.makeWithYMDHMS", - "kind": "value", - "name": "makeWithYMDHMS", - "docstrings": [ - "Creates a date object with the given year, month, date (day of month), hours, minutes and seconds.\nBe aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\nMonths are 0-indexed (0 = January, 11 = December).\nValues, which are out of range, will be carried over to the next bigger unit (s. example).\n\n## Examples\n```rescript\nDate.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0)\n// 2023-02-20T16:40:00.000Z\n\nDate.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=60)\n// 2023-02-20T16:41:00.000Z\n\nDate.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=-1)\n// 2023-02-20T16:39:59.000Z\n\n// Note: The output depends on your local time zone.\n// In nodejs you can change it by using the TZ env (`export TZ='Europe/London' && node index.bs.js`)\n\n```" - ], - "signature": "let makeWithYMDHMS: (\n ~year: int,\n ~month: int,\n ~date: int,\n ~hours: int,\n ~minutes: int,\n ~seconds: int,\n) => t" - }, - { - "id": "Core.Date.makeWithYMDHMSM", - "kind": "value", - "name": "makeWithYMDHMSM", - "docstrings": [ - "Creates a date object with the given year, month, date (day of month), hours, minutes, seconds and milliseconds.\nBe aware of using a value for year < 100, because it behaves inconsistent (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years).\nMonths are 0-indexed (0 = January, 11 = December).\nValues, which are out of range, will be carried over to the next bigger unit (s. example).\n\n## Examples\n```rescript\nDate.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=0)\n// 2023-02-20T16:40:00.000Z\n\nDate.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=1000)\n// 2023-02-20T16:40:01.000Z\n\nDate.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=-1)\n// 2023-02-20T16:39:59.999Z\n\n// Note: The output depends on your local time zone.\n// In nodejs you can change it by using the TZ env (`export TZ='Europe/London' && node index.bs.js`)\n\n```" - ], - "signature": "let makeWithYMDHMSM: (\n ~year: int,\n ~month: int,\n ~date: int,\n ~hours: int,\n ~minutes: int,\n ~seconds: int,\n ~milliseconds: int,\n) => t" - }, - { - "id": "Core.Date.now", - "kind": "value", - "name": "now", - "docstrings": [ - "`now()`\n\nReturns the time, in milliseconds, between UNIX epoch (January 1, 1970 00:00:00 UTC) and the current date time." - ], - "signature": "let now: unit => msSinceEpoch" - }, - { - "id": "Core.Date.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (t, t) => bool" - }, - { - "id": "Core.Date.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (t, t) => Core__Ordering.t" - }, - { - "id": "Core.Date.getTime", - "kind": "value", - "name": "getTime", - "docstrings": [ - "`getTime(date)`\n\nReturns the time, in milliseconds, between UNIX epoch (January 1, 1970 00:00:00 UTC) and the current date time.\nInvalid dates will return NaN.\nDates before epoch will return negative numbers.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20\")->Date.getTime\n// 1676851200000\n```" - ], - "signature": "let getTime: t => msSinceEpoch" - }, - { - "id": "Core.Date.getTimezoneOffset", - "kind": "value", - "name": "getTimezoneOffset", - "docstrings": [ - "`getTimezoneOffset(date)`\n\nReturns the time in minutes between the UTC time and the locale time.\nThe timezone of the given date doesn't matter.\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01\")->Date.getTimezoneOffset\n// -60 with local time zone = Europe/Berlin\n\nDate.fromString(\"2023-06-01\")->Date.getTimezoneOffset\n// -120 with local time zone = Europe/Berlin\n```" - ], - "signature": "let getTimezoneOffset: t => int" - }, - { - "id": "Core.Date.getFullYear", - "kind": "value", - "name": "getFullYear", - "docstrings": [ - "`getFullYear(date)`\n\nReturns the year of a given date (according to local time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20\")->Date.getFullYear\n// 2023\n```" - ], - "signature": "let getFullYear: t => int" - }, - { - "id": "Core.Date.getMonth", - "kind": "value", - "name": "getMonth", - "docstrings": [ - "`getMonth(date)`\n\nReturns the month (0-indexed) of a given date (according to local time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01\")->Date.getMonth\n// 0\n```" - ], - "signature": "let getMonth: t => int" - }, - { - "id": "Core.Date.getDate", - "kind": "value", - "name": "getDate", - "docstrings": [ - "`getDate(date)`\n\nReturns the date (day of month) of a given date (according to local time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.getDate\n// 20\n```" - ], - "signature": "let getDate: t => int" - }, - { - "id": "Core.Date.getHours", - "kind": "value", - "name": "getHours", - "docstrings": [ - "`getHours(date)`\n\nReturns the hours of a given date (according to local time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.getHours\n// 16\n```" - ], - "signature": "let getHours: t => int" - }, - { - "id": "Core.Date.getMinutes", - "kind": "value", - "name": "getMinutes", - "docstrings": [ - "`getMinutes(date)`\n\nReturns the minutes of a given date (according to local time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.getMinutes\n// 40\n```" - ], - "signature": "let getMinutes: t => int" - }, - { - "id": "Core.Date.getSeconds", - "kind": "value", - "name": "getSeconds", - "docstrings": [ - "`getSeconds(date)`\n\nReturns the seconds of a given date (according to local time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.getSeconds\n// 0\n```" - ], - "signature": "let getSeconds: t => int" - }, - { - "id": "Core.Date.getMilliseconds", - "kind": "value", - "name": "getMilliseconds", - "docstrings": [ - "`getMilliseconds(date)`\n\nReturns the milliseconds of a given date (according to local time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.getMilliseconds\n// 0\n```" - ], - "signature": "let getMilliseconds: t => int" - }, - { - "id": "Core.Date.getDay", - "kind": "value", - "name": "getDay", - "docstrings": [ - "`getDay(date)`\n\nReturns the day of week of a given date (according to local time).\n0 = Sunday, 1 = Monday, ... 6 = Saturday\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.getDay\n// 1\n```" - ], - "signature": "let getDay: t => int" - }, - { - "id": "Core.Date.setFullYear", - "kind": "value", - "name": "setFullYear", - "docstrings": [ - "`setFullYear(date, year)`\n\nSets the year of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setFullYear(2024)\n```" - ], - "signature": "let setFullYear: (t, int) => unit" - }, - { - "id": "Core.Date.setFullYearM", - "kind": "value", - "name": "setFullYearM", - "docstrings": [ - "`setFullYearM(date, ~year, ~month)`\n\nSets the year and month of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setFullYearM(~year=2024, ~month=0)\n```" - ], - "signature": "let setFullYearM: (t, ~year: int, ~month: int) => unit" - }, - { - "id": "Core.Date.setFullYearMD", - "kind": "value", - "name": "setFullYearMD", - "docstrings": [ - "`setFullYearMD(date, ~year, ~month, ~date)`\n\nSets the year, month and date (day of month) of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setFullYearMD(~year=2024, ~month=0, ~date=1)\n```" - ], - "signature": "let setFullYearMD: (t, ~year: int, ~month: int, ~date: int) => unit" - }, - { - "id": "Core.Date.setMonth", - "kind": "value", - "name": "setMonth", - "docstrings": [ - "`setMonth(date, month)`\n\nSets the month of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setMonth(0)\n```" - ], - "signature": "let setMonth: (t, int) => unit" - }, - { - "id": "Core.Date.setDate", - "kind": "value", - "name": "setDate", - "docstrings": [ - "`setDate(date, day)`\n\nSets the date (day of month) of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setDate(1)\n```" - ], - "signature": "let setDate: (t, int) => unit" - }, - { - "id": "Core.Date.setHours", - "kind": "value", - "name": "setHours", - "docstrings": [ - "`setHours(date, hours)`\n\nSets the hours of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setHours(0)\n```" - ], - "signature": "let setHours: (t, int) => unit" - }, - { - "id": "Core.Date.setHoursM", - "kind": "value", - "name": "setHoursM", - "docstrings": [ - "`setHoursM(date, ~hours, ~minutes)`\n\nSets the hours and minutes of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setHoursM(~hours=0, ~minutes=0)\n```" - ], - "signature": "let setHoursM: (t, ~hours: int, ~minutes: int) => unit" - }, - { - "id": "Core.Date.setHoursMS", - "kind": "value", - "name": "setHoursMS", - "docstrings": [ - "`setHoursMS(date, ~hours, ~minutes, ~seconds)`\n\nSets the hours, minutes and seconds of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setHoursMS(~hours=0, ~minutes=0, ~seconds=0)\n```" - ], - "signature": "let setHoursMS: (t, ~hours: int, ~minutes: int, ~seconds: int) => unit" - }, - { - "id": "Core.Date.setHoursMSMs", - "kind": "value", - "name": "setHoursMSMs", - "docstrings": [ - "`setHoursMSMs(date, ~hours, ~minutes, ~seconds, ~milliseconds)`\n\nSets the hours, minutes, seconds and milliseconds of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setHoursMSMs(~hours=0, ~minutes=0, ~seconds=0, ~milliseconds=0)\n```" - ], - "signature": "let setHoursMSMs: (\n t,\n ~hours: int,\n ~minutes: int,\n ~seconds: int,\n ~milliseconds: int,\n) => unit" - }, - { - "id": "Core.Date.setMinutes", - "kind": "value", - "name": "setMinutes", - "docstrings": [ - "`setMinutes(date, minutes)`\n\nSets the minutes of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setMinutes(0)\n```" - ], - "signature": "let setMinutes: (t, int) => unit" - }, - { - "id": "Core.Date.setMinutesS", - "kind": "value", - "name": "setMinutesS", - "docstrings": [ - "`setMinutesS(date, ~minutes, ~seconds)`\n\nSets the minutes and seconds of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setMinutesS(~minutes=0, ~seconds=0)\n```" - ], - "signature": "let setMinutesS: (t, ~minutes: int, ~seconds: int) => unit" - }, - { - "id": "Core.Date.setMinutesSMs", - "kind": "value", - "name": "setMinutesSMs", - "docstrings": [ - "`setMinutesSMs(date, ~minutes, ~seconds, ~milliseconds)`\n\nSets the minutes, seconds and milliseconds of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setMinutesSMs(~minutes=0, ~seconds=0, ~milliseconds=0)\n```" - ], - "signature": "let setMinutesSMs: (\n t,\n ~minutes: int,\n ~seconds: int,\n ~milliseconds: int,\n) => unit" - }, - { - "id": "Core.Date.setSeconds", - "kind": "value", - "name": "setSeconds", - "docstrings": [ - "`setSeconds(date, seconds)`\n\nSets the seconds of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setSeconds(0)\n```" - ], - "signature": "let setSeconds: (t, int) => unit" - }, - { - "id": "Core.Date.setSecondsMs", - "kind": "value", - "name": "setSecondsMs", - "docstrings": [ - "`setSecondsMs(date, ~seconds, ~milliseconds)`\n\nSets the seconds and milliseconds of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setSecondsMs(~seconds=0, ~milliseconds=0)\n```" - ], - "signature": "let setSecondsMs: (t, ~seconds: int, ~milliseconds: int) => unit" - }, - { - "id": "Core.Date.setMilliseconds", - "kind": "value", - "name": "setMilliseconds", - "docstrings": [ - "`setMilliseconds(date, milliseconds)`\n\nSets the milliseconds of a date (according to local time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setMilliseconds(0)\n```" - ], - "signature": "let setMilliseconds: (t, int) => unit" - }, - { - "id": "Core.Date.getUTCFullYear", - "kind": "value", - "name": "getUTCFullYear", - "docstrings": [ - "`getUTCFullYear(date)`\n\nReturns the year of a given date (according to UTC time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCFullYear // 2022\n```" - ], - "signature": "let getUTCFullYear: t => int" - }, - { - "id": "Core.Date.getUTCMonth", - "kind": "value", - "name": "getUTCMonth", - "docstrings": [ - "`getUTCMonth(date)`\n\nReturns the month of a given date (according to UTC time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCMonth // 11\n```" - ], - "signature": "let getUTCMonth: t => int" - }, - { - "id": "Core.Date.getUTCDate", - "kind": "value", - "name": "getUTCDate", - "docstrings": [ - "`getUTCDate(date)`\n\nReturns the date (day of month) of a given date (according to UTC time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCDate // 31\n```" - ], - "signature": "let getUTCDate: t => int" - }, - { - "id": "Core.Date.getUTCHours", - "kind": "value", - "name": "getUTCHours", - "docstrings": [ - "`getUTCHours(date)`\n\nReturns the hours of a given date (according to UTC time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCHours // 23\n```" - ], - "signature": "let getUTCHours: t => int" - }, - { - "id": "Core.Date.getUTCMinutes", - "kind": "value", - "name": "getUTCMinutes", - "docstrings": [ - "`getUTCMinutes(date)`\n\nReturns the minutes of a given date (according to UTC time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCMinutes // 0\n```" - ], - "signature": "let getUTCMinutes: t => int" - }, - { - "id": "Core.Date.getUTCSeconds", - "kind": "value", - "name": "getUTCSeconds", - "docstrings": [ - "`getUTCSeconds(date)`\n\nReturns the seconds of a given date (according to UTC time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCSeconds // 0\n```" - ], - "signature": "let getUTCSeconds: t => int" - }, - { - "id": "Core.Date.getUTCMilliseconds", - "kind": "value", - "name": "getUTCMilliseconds", - "docstrings": [ - "`getUTCMilliseconds(date)`\n\nReturns the milliseconds of a given date (according to UTC time).\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCMilliseconds // 0\n```" - ], - "signature": "let getUTCMilliseconds: t => int" - }, - { - "id": "Core.Date.getUTCDay", - "kind": "value", - "name": "getUTCDay", - "docstrings": [ - "`getUTCDay(date)`\n\nReturns the day (day of week) of a given date (according to UTC time).\n0 = Sunday, 1 = Monday, ... 6 = Saturday\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.getUTCDay // 6\n```" - ], - "signature": "let getUTCDay: t => int" - }, - { - "id": "Core.Date.setUTCFullYear", - "kind": "value", - "name": "setUTCFullYear", - "docstrings": [ - "`setUTCFullYear(date, year)`\n\nSets the year of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCFullYear(2024)\n```" - ], - "signature": "let setUTCFullYear: (t, int) => unit" - }, - { - "id": "Core.Date.setUTCFullYearM", - "kind": "value", - "name": "setUTCFullYearM", - "docstrings": [ - "`setUTCFullYearM(date, ~year, ~month)`\n\nSets the year and month of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCFullYearM(~year=2024, ~month=0)\n```" - ], - "signature": "let setUTCFullYearM: (t, ~year: int, ~month: int) => unit" - }, - { - "id": "Core.Date.setUTCFullYearMD", - "kind": "value", - "name": "setUTCFullYearMD", - "docstrings": [ - "`setUTCFullYearMD(date, ~year, ~month, ~date)`\n\nSets the year, month and date (day of month) of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCFullYearMD(~year=2024, ~month=0, ~date=1)\n```" - ], - "signature": "let setUTCFullYearMD: (t, ~year: int, ~month: int, ~date: int) => unit" - }, - { - "id": "Core.Date.setUTCMonth", - "kind": "value", - "name": "setUTCMonth", - "docstrings": [ - "`setUTCMonth(date, month)`\n\nSets the month of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCMonth(0)\n```" - ], - "signature": "let setUTCMonth: (t, int) => unit" - }, - { - "id": "Core.Date.setUTCDate", - "kind": "value", - "name": "setUTCDate", - "docstrings": [ - "`setDate(date, day)`\n\nSets the date (day of month) of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCDate(1)\n```" - ], - "signature": "let setUTCDate: (t, int) => unit" - }, - { - "id": "Core.Date.setUTCHours", - "kind": "value", - "name": "setUTCHours", - "docstrings": [ - "`setUTCHours(date, hours)`\n\nSets the hours of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCHours(0)\n```" - ], - "signature": "let setUTCHours: (t, int) => unit" - }, - { - "id": "Core.Date.setUTCHoursM", - "kind": "value", - "name": "setUTCHoursM", - "docstrings": [ - "`setHoursM(date, ~hours, ~minutes)`\n\nSets the hours and minutes of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCHoursM(~hours=0, ~minutes=0)\n```" - ], - "signature": "let setUTCHoursM: (t, ~hours: int, ~minutes: int) => unit" - }, - { - "id": "Core.Date.setUTCHoursMS", - "kind": "value", - "name": "setUTCHoursMS", - "docstrings": [ - "`setUTCHoursMS(date, ~hours, ~minutes, ~seconds)`\n\nSets the hours, minutes and seconds of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCHoursMS(~hours=0, ~minutes=0, ~seconds=0)\n```" - ], - "signature": "let setUTCHoursMS: (t, ~hours: int, ~minutes: int, ~seconds: int) => unit" - }, - { - "id": "Core.Date.setUTCHoursMSMs", - "kind": "value", - "name": "setUTCHoursMSMs", - "docstrings": [ - "`setUTCHoursMSMs(date, ~hours, ~minutes, ~seconds, ~milliseconds)`\n\nSets the hours, minutes, seconds and milliseconds of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCHoursMSMs(~hours=0, ~minutes=0, ~seconds=0, ~milliseconds=0)\n```" - ], - "signature": "let setUTCHoursMSMs: (\n t,\n ~hours: int,\n ~minutes: int,\n ~seconds: int,\n ~milliseconds: int,\n) => unit" - }, - { - "id": "Core.Date.setUTCMinutes", - "kind": "value", - "name": "setUTCMinutes", - "docstrings": [ - "`setUTCMinutes(date, minutes)`\n\nSets the minutes of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCMinutes(0)\n```" - ], - "signature": "let setUTCMinutes: (t, int) => unit" - }, - { - "id": "Core.Date.setUTCMinutesS", - "kind": "value", - "name": "setUTCMinutesS", - "docstrings": [ - "`setUTCMinutesS(date, ~minutes, ~seconds)`\n\nSets the minutes and seconds of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCMinutesS(~minutes=0, ~seconds=0)\n```" - ], - "signature": "let setUTCMinutesS: (t, ~minutes: int, ~seconds: int) => unit" - }, - { - "id": "Core.Date.setUTCMinutesSMs", - "kind": "value", - "name": "setUTCMinutesSMs", - "docstrings": [ - "`setUTCMinutesSMs(date, ~minutes, ~seconds, ~milliseconds)`\n\nSets the minutes, seconds and milliseconds of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCMinutesSMs(~minutes=0, ~seconds=0, ~milliseconds=0)\n```" - ], - "signature": "let setUTCMinutesSMs: (\n t,\n ~minutes: int,\n ~seconds: int,\n ~milliseconds: int,\n) => unit" - }, - { - "id": "Core.Date.setUTCSeconds", - "kind": "value", - "name": "setUTCSeconds", - "docstrings": [ - "`setUTCSeconds(date, seconds)`\n\nSets the seconds of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCSeconds(0)\n```" - ], - "signature": "let setUTCSeconds: (t, int) => unit" - }, - { - "id": "Core.Date.setUTCSecondsMs", - "kind": "value", - "name": "setUTCSecondsMs", - "docstrings": [ - "`setUTCSecondsMs(date, ~seconds, ~milliseconds)`\n\nSets the seconds and milliseconds of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCSecondsMs(~seconds=0, ~milliseconds=0)\n```" - ], - "signature": "let setUTCSecondsMs: (t, ~seconds: int, ~milliseconds: int) => unit" - }, - { - "id": "Core.Date.setUTCMilliseconds", - "kind": "value", - "name": "setUTCMilliseconds", - "docstrings": [ - "`setUTCMilliseconds(date, milliseconds)`\n\nSets the milliseconds of a date (according to UTC time).\nBeware this will *mutate* the date.\n\n## Examples\n```rescript\nDate.fromString(\"2023-02-20T16:40:00.00\")->Date.setUTCMilliseconds(0)\n```" - ], - "signature": "let setUTCMilliseconds: (t, int) => unit" - }, - { - "id": "Core.Date.toDateString", - "kind": "value", - "name": "toDateString", - "docstrings": [ - "`toDateString(date)`\n\nConverts a JavaScript date to a standard date string. The date will be mapped to the current time zone.\nIf you want to convert it to a localized string, use `Date.toLocaleDateString` instead.\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.toDateString->Console.log\n// Sun Jan 01 2023\n\nDate.fromString(\"2023-01-01T00:00:00.00+08:00\")->Date.toDateString->Console.log\n// Sat Dec 31 2022\n```" - ], - "signature": "let toDateString: t => string" - }, - { - "id": "Core.Date.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "`toString(date)`\n\nConverts a JavaScript date to a standard date time string. The date will be mapped to the current time zone.\nIf you want to convert it to a localized string, use `Date.toLocaleString` instead.\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.toString->Console.log\n// Sun Jan 01 2023 00:00:00 GMT+0100 (Central European Standard Time)\n\nDate.fromString(\"2023-06-01T00:00:00.00+01:00\")->Date.toString->Console.log\n// Thu Jun 01 2023 01:00:00 GMT+0200 (Central European Summer Time)\n```" - ], - "signature": "let toString: t => string" - }, - { - "id": "Core.Date.toTimeString", - "kind": "value", - "name": "toTimeString", - "docstrings": [ - "`toTimeString(date)`\n\nConverts a JavaScript date to a standard time string. The date will be mapped to the current time zone.\nIf you want to convert it to a localized string, use `Date.toLocaleStimeString` instead.\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+01:00\")->Date.toTimeString->Console.log\n// 00:00:00 GMT+0100 (Central European Standard Time)\n\nDate.fromString(\"2023-01-01T00:00:00.00+08:00\")->Date.toTimeString->Console.log\n// 17:00:00 GMT+0100 (Central European Standard Time)\n```" - ], - "signature": "let toTimeString: t => string" - }, - { - "id": "Core.Date.toLocaleDateString", - "kind": "value", - "name": "toLocaleDateString", - "docstrings": [ - "`toLocaleDateString(date)`\n\nConverts a JavaScript date to a localized date string. It will use the current locale.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleDateString->Console.log\n// 2/19/2023\n```" - ], - "signature": "let toLocaleDateString: t => string" - }, - { - "id": "Core.Date.toLocaleDateStringWithLocale", - "kind": "value", - "name": "toLocaleDateStringWithLocale", - "docstrings": [ - "`toLocaleDateStringWithLocale(date, locale)`\n\nConverts a JavaScript date to a localized date string. It will use the specified locale.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleDateStringWithLocale(\"en-US\")->Console.log\n// 2/19/2023\n```" - ], - "signature": "let toLocaleDateStringWithLocale: (t, string) => string" - }, - { - "id": "Core.Date.toLocaleDateStringWithLocaleAndOptions", - "kind": "value", - "name": "toLocaleDateStringWithLocaleAndOptions", - "docstrings": [ - "`toLocaleDateStringWithLocaleAndOptions(date, locale, options)`\n\nConverts a JavaScript date to a localized date string. It will use the specified locale and formatting options.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleDateStringWithLocaleAndOptions(\"en-US\", { dateStyle: #long })->Console.log\n// February 19, 2023\n\nDate.make()->Date.toLocaleDateStringWithLocaleAndOptions(\"de\", { hour: #\"2-digit\", minute: #\"2-digit\" })->Console.log\n// 19.2.2023, 15:40\n\nDate.make()->Date.toLocaleDateStringWithLocaleAndOptions(\"de\", { year: #numeric })->Console.log\n// 2023\n```" - ], - "signature": "let toLocaleDateStringWithLocaleAndOptions: (t, string, localeOptions) => string" - }, - { - "id": "Core.Date.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "`toLocaleString(date)`\n\nConverts a JavaScript date to a localized date-time string. It will use the current locale.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleString->Console.log\n// 2/19/2023, 3:40:00 PM\n```" - ], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Core.Date.toLocaleStringWithLocale", - "kind": "value", - "name": "toLocaleStringWithLocale", - "docstrings": [ - "`toLocaleStringWithLocale(date, locale)`\n\nConverts a JavaScript date to a localized date-time string. It will use the specified locale.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleStringWithLocale(\"en-US\")->Console.log\n// 2/19/2023, 3:40:00 PM\n```" - ], - "signature": "let toLocaleStringWithLocale: (t, string) => string" - }, - { - "id": "Core.Date.toLocaleStringWithLocaleAndOptions", - "kind": "value", - "name": "toLocaleStringWithLocaleAndOptions", - "docstrings": [ - "`toLocaleStringWithLocaleAndOptions(date, locale, options)`\n\nConverts a JavaScript date to a localized date-time string. It will use the specified locale and formatting options.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleStringWithLocaleAndOptions(\"en\", { dateStyle: #short, timeStyle: #short })->Console.log\n// 2/19/23, 3:40 PM\n\nDate.make()->Date.toLocaleStringWithLocaleAndOptions(\"en\", { era: #long, year: #numeric, month: #\"2-digit\", day: #\"2-digit\", hour: #numeric, timeZoneName: #short })->Console.log\n// 02/19/2023 Anno Domini, 3 PM GMT+1\n```" - ], - "signature": "let toLocaleStringWithLocaleAndOptions: (t, string, localeOptions) => string" - }, - { - "id": "Core.Date.toLocaleTimeString", - "kind": "value", - "name": "toLocaleTimeString", - "docstrings": [ - "`toLocaleTimeString(date)`\n\nConverts a JavaScript date to a localized time string. It will use the current locale.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleTimeString->Console.log\n// 3:40:00 PM\n```" - ], - "signature": "let toLocaleTimeString: t => string" - }, - { - "id": "Core.Date.toLocaleTimeStringWithLocale", - "kind": "value", - "name": "toLocaleTimeStringWithLocale", - "docstrings": [ - "`toLocaleTimeStringWithLocale(date, locale)`\n\nConverts a JavaScript date to a localized time string. It will use the specified locale.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleTimeStringWithLocale(\"en-US\")->Console.log\n// 3:40:00 PM\n```" - ], - "signature": "let toLocaleTimeStringWithLocale: (t, string) => string" - }, - { - "id": "Core.Date.toLocaleTimeStringWithLocaleAndOptions", - "kind": "value", - "name": "toLocaleTimeStringWithLocaleAndOptions", - "docstrings": [ - "`toLocaleTimeStringWithLocaleAndOptions(date, locale, options)`\n\nConverts a JavaScript date to a localized time string. It will use the specified locale and formatting options.\n\n## Examples\n```rescript\nDate.make()->Date.toLocaleTimeStringWithLocaleAndOptions(\"en-US\", { timeStyle: #long })->Console.log\n// 3:40:00 PM GMT+1\n\nDate.make()->Date.toLocaleTimeStringWithLocaleAndOptions(\"de\", { hour: #\"2-digit\", minute: #\"2-digit\" })->Console.log\n// 15:40\n```" - ], - "signature": "let toLocaleTimeStringWithLocaleAndOptions: (t, string, localeOptions) => string" - }, - { - "id": "Core.Date.toISOString", - "kind": "value", - "name": "toISOString", - "docstrings": [ - "`toISOString(date)`\n\nConverts a JavaScript date to a ISO 8601 string (YYYY-MM-DDTHH:mm:ss.sssZ). The date will be mapped to the UTC time.\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+00:00\")->Date.toISOString->Console.log\n// 2023-01-01T00:00:00.000Z\n\nDate.fromString(\"2023-01-01T00:00:00.00+08:00\")->Date.toISOString->Console.log\n// 2022-12-31T16:00:00.000Z\n```" - ], - "signature": "let toISOString: t => string" - }, - { - "id": "Core.Date.toUTCString", - "kind": "value", - "name": "toUTCString", - "docstrings": [ - "`toUTCString(date)`\n\nConverts a JavaScript date to date time string. The date will be mapped to the UTC time.\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+00:00\")->Date.toUTCString->Console.log\n// Sun, 01 Jan 2023 00:00:00 GMT\n\nDate.fromString(\"2023-01-01T00:00:00.00+08:00\")->Date.toUTCString->Console.log\n// Sat, 31 Dec 2022 16:00:00 GMT\n```" - ], - "signature": "let toUTCString: t => string" - }, - { - "id": "Core.Date.toJSON", - "kind": "value", - "name": "toJSON", - "docstrings": [ - "`toJSON(date)`\n\nConverts a JavaScript date to a string.\nIf the date is valid, the function will return the same result as `Date.toISOString`.\nInvalid dates will return `None`.\n\n## Examples\n```rescript\nDate.fromString(\"2023-01-01T00:00:00.00+00:00\")->Date.toJSON\n// Some(\"2023-01-01T00:00:00.000Z\")\n\nDate.fromString(\"\")->Date.toJSON\n// None\n```" - ], - "signature": "let toJSON: t => option" - } - ] - }, - "core/dataview": { - "id": "Core.DataView", - "name": "DataView", - "docstrings": [], - "items": [ - { - "id": "Core.DataView.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Core.DataView.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [], - "signature": "let fromBuffer: Core__ArrayBuffer.t => t" - }, - { - "id": "Core.DataView.fromBufferToEnd", - "kind": "value", - "name": "fromBufferToEnd", - "docstrings": [], - "signature": "let fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t" - }, - { - "id": "Core.DataView.fromBufferWithRange", - "kind": "value", - "name": "fromBufferWithRange", - "docstrings": [], - "signature": "let fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t" - }, - { - "id": "Core.DataView.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => Core__ArrayBuffer.t" - }, - { - "id": "Core.DataView.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Core.DataView.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Core.DataView.getInt8", - "kind": "value", - "name": "getInt8", - "docstrings": [], - "signature": "let getInt8: t => int" - }, - { - "id": "Core.DataView.getUint8", - "kind": "value", - "name": "getUint8", - "docstrings": [], - "signature": "let getUint8: t => int" - }, - { - "id": "Core.DataView.getInt16", - "kind": "value", - "name": "getInt16", - "docstrings": [], - "signature": "let getInt16: t => int" - }, - { - "id": "Core.DataView.getUint16", - "kind": "value", - "name": "getUint16", - "docstrings": [], - "signature": "let getUint16: t => int" - }, - { - "id": "Core.DataView.getInt32", - "kind": "value", - "name": "getInt32", - "docstrings": [], - "signature": "let getInt32: t => int" - }, - { - "id": "Core.DataView.getUint32", - "kind": "value", - "name": "getUint32", - "docstrings": [], - "signature": "let getUint32: t => int" - }, - { - "id": "Core.DataView.getFloat32", - "kind": "value", - "name": "getFloat32", - "docstrings": [], - "signature": "let getFloat32: t => float" - }, - { - "id": "Core.DataView.getFloat64", - "kind": "value", - "name": "getFloat64", - "docstrings": [], - "signature": "let getFloat64: t => float" - }, - { - "id": "Core.DataView.getBigInt64", - "kind": "value", - "name": "getBigInt64", - "docstrings": [], - "signature": "let getBigInt64: t => bigint" - }, - { - "id": "Core.DataView.getBigUint64", - "kind": "value", - "name": "getBigUint64", - "docstrings": [], - "signature": "let getBigUint64: t => bigint" - }, - { - "id": "Core.DataView.setInt8", - "kind": "value", - "name": "setInt8", - "docstrings": [], - "signature": "let setInt8: (t, int) => unit" - }, - { - "id": "Core.DataView.setUint8", - "kind": "value", - "name": "setUint8", - "docstrings": [], - "signature": "let setUint8: (t, int) => unit" - }, - { - "id": "Core.DataView.setInt16", - "kind": "value", - "name": "setInt16", - "docstrings": [], - "signature": "let setInt16: (t, int) => unit" - }, - { - "id": "Core.DataView.setUint16", - "kind": "value", - "name": "setUint16", - "docstrings": [], - "signature": "let setUint16: (t, int) => unit" - }, - { - "id": "Core.DataView.setInt32", - "kind": "value", - "name": "setInt32", - "docstrings": [], - "signature": "let setInt32: (t, int) => unit" - }, - { - "id": "Core.DataView.setUint32", - "kind": "value", - "name": "setUint32", - "docstrings": [], - "signature": "let setUint32: (t, int) => unit" - }, - { - "id": "Core.DataView.setFloat32", - "kind": "value", - "name": "setFloat32", - "docstrings": [], - "signature": "let setFloat32: (t, float) => unit" - }, - { - "id": "Core.DataView.setFloat64", - "kind": "value", - "name": "setFloat64", - "docstrings": [], - "signature": "let setFloat64: (t, float) => unit" - }, - { - "id": "Core.DataView.setBigInt64", - "kind": "value", - "name": "setBigInt64", - "docstrings": [], - "signature": "let setBigInt64: (t, bigint) => unit" - }, - { - "id": "Core.DataView.setBigUint64", - "kind": "value", - "name": "setBigUint64", - "docstrings": [], - "signature": "let setBigUint64: (t, bigint) => unit" - } - ] - }, - "core/console": { - "id": "Core.Console", - "name": "Console", - "docstrings": [ - "Functions for interacting with JavaScript console.\n\nSee: [`console`](https://developer.mozilla.org/en-US/docs/Web/API/Console)." - ], - "items": [ - { - "id": "Core.Console.assert_", - "kind": "value", - "name": "assert_", - "docstrings": [ - "`assert_(assertion, value)` print a message to console if `assertion` evaluates `false`. Does nothing if it's `true`.\n\nSee [`console.assert`](https://developer.mozilla.org/en-US/docs/Web/API/console/assert)\non MDN.\n\n## Examples\n\n```rescript\nConsole.assert_(false, \"Hello World!\")\nConsole.assert_(42 == 42, \"The answer\")\n```" - ], - "signature": "let assert_: (bool, 'a) => unit" - }, - { - "id": "Core.Console.assert2", - "kind": "value", - "name": "assert2", - "docstrings": [ - "`assert2(v1, v2)`. Like `assert_`, but with two arguments.\n\n## Examples\n\n```rescript\nConsole.assert2(false, \"Hello\", \"World\")\nConsole.assert2(42 == 42, [1, 2, 3], '4')\n```" - ], - "signature": "let assert2: (bool, 'a, 'b) => unit" - }, - { - "id": "Core.Console.assert3", - "kind": "value", - "name": "assert3", - "docstrings": [ - "`assert3(v1, v2, v3)`. Like `assert_`, but with three arguments.\n\n## Examples\n\n```rescript\nConsole.assert3(false, \"Hello\", \"World\", \"ReScript\")\nConsole.assert3(42 == 42, \"One\", 2, #3)\n```" - ], - "signature": "let assert3: (bool, 'a, 'b, 'c) => unit" - }, - { - "id": "Core.Console.assert4", - "kind": "value", - "name": "assert4", - "docstrings": [ - "`assert4(v1, v2, v3, v4)`. Like `assert_`, but with four arguments.\n\n## Examples\n\n```rescript\nlet value = 42\nConsole.assert4(false, \"Hello\", \"World\", \"ReScript\", \"!!!\")\nConsole.assert4(value == 42, [1, 2], (3, 4), [#5, #6], #\"polyvar\")\n```" - ], - "signature": "let assert4: (bool, 'a, 'b, 'c, 'd) => unit" - }, - { - "id": "Core.Console.assert5", - "kind": "value", - "name": "assert5", - "docstrings": [ - "`assert5(v1, v2, v3, v4, v5)`. Like `assert_`, but with five arguments.\n\n## Examples\n\n```rescript\nlet value = 42\nConsole.assert5(false, \"Hello\", \"World\", \"JS\", '!', '!')\nConsole.assert5(value == 42, [1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"})\n```" - ], - "signature": "let assert5: (bool, 'a, 'b, 'c, 'd, 'e) => unit" - }, - { - "id": "Core.Console.assert6", - "kind": "value", - "name": "assert6", - "docstrings": [ - "`assert6(v1, v2)`. Like `assert_`, but with six arguments.\n\n## Examples\n\n```rescript\nlet value = 42\nConsole.assert6(false, \"Hello\", \"World\", \"JS\", '!', '!', '?')\nConsole.assert6(value == 42, [1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"}, 42)\n```" - ], - "signature": "let assert6: (bool, 'a, 'b, 'c, 'd, 'e, 'f) => unit" - }, - { - "id": "Core.Console.assertMany", - "kind": "value", - "name": "assertMany", - "docstrings": [ - "`assertMany(assertion, arr)`. Like `assert_`, but variadic.\n\n## Examples\n\n```rescript\nlet value = 42\nConsole.assertMany(false, [\"Hello\", \"World\"])\nConsole.assertMany(value == 42, [1, 2, 3])\n```" - ], - "signature": "let assertMany: (bool, array<'a>) => unit" - }, - { - "id": "Core.Console.clear", - "kind": "value", - "name": "clear", - "docstrings": [ - "`clear()` clears the console, if allowed.\n\nSee [`console.clear`](https://developer.mozilla.org/en-US/docs/Web/API/console/clear)\non MDN.\n\n## Examples\n\n```rescript\nConsole.clear()\n```" - ], - "signature": "let clear: unit => unit" - }, - { - "id": "Core.Console.count", - "kind": "value", - "name": "count", - "docstrings": [ - "`count(label)` prints to the console the number of times it's been called with the given label.\n\nSee [`console.count`](https://developer.mozilla.org/en-US/docs/Web/API/console/count)\non MDN.\n\n## Examples\n\n```rescript\nConsole.count(\"rescript\")\n```" - ], - "signature": "let count: string => unit" - }, - { - "id": "Core.Console.countReset", - "kind": "value", - "name": "countReset", - "docstrings": [ - "`countReset(label)` resets the count for the given label to 0.\n\nSee [`console.countReset`](https://developer.mozilla.org/en-US/docs/Web/API/console/countReset)\non MDN.\n\n## Examples\n\n```rescript\nConsole.countReset(\"rescript\")\n```" - ], - "signature": "let countReset: string => unit" - }, - { - "id": "Core.Console.debug", - "kind": "value", - "name": "debug", - "docstrings": [ - "`debug(value)` print a debug message to console.\n\nSee [`console.debug`](https://developer.mozilla.org/en-US/docs/Web/API/console/debug)\non MDN.\n\n## Examples\n\n```rescript\nConsole.debug(\"Hello\")\nlet obj = {\"name\": \"ReScript\", \"version\": 10}\nConsole.debug(obj)\n```" - ], - "signature": "let debug: 'a => unit" - }, - { - "id": "Core.Console.debug2", - "kind": "value", - "name": "debug2", - "docstrings": [ - "`debug2(v1, v2)`. Like `debug`, but with two arguments.\n\n## Examples\n\n```rescript\nConsole.debug2(\"Hello\", \"World\")\nConsole.debug2([1, 2, 3], '4')\n```" - ], - "signature": "let debug2: ('a, 'b) => unit" - }, - { - "id": "Core.Console.debug3", - "kind": "value", - "name": "debug3", - "docstrings": [ - "`debug3(v1, v2, v3)`. Like `debug`, but with three arguments.\n\n## Examples\n\n```rescript\nConsole.debug3(\"Hello\", \"World\", \"ReScript\")\nConsole.debug3(\"One\", 2, #3)\n```" - ], - "signature": "let debug3: ('a, 'b, 'c) => unit" - }, - { - "id": "Core.Console.debug4", - "kind": "value", - "name": "debug4", - "docstrings": [ - "`debug4(v1, v2, v3, v4)`. Like `debug`, but with four arguments.\n\n## Examples\n\n```rescript\nConsole.debug4(\"Hello\", \"World\", \"ReScript\", \"!!!\")\nConsole.debug4([1, 2], (3, 4), [#5, #6], #\"polyvar\")\n```" - ], - "signature": "let debug4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Core.Console.debug5", - "kind": "value", - "name": "debug5", - "docstrings": [ - "`debug5(v1, v2, v3, v4, v5)`. Like `debug`, but with five arguments.\n\n## Examples\n\n```rescript\nConsole.debug5(\"Hello\", \"World\", \"JS\", '!', '!')\nConsole.debug5([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"})\n```" - ], - "signature": "let debug5: ('a, 'b, 'c, 'd, 'e) => unit" - }, - { - "id": "Core.Console.debug6", - "kind": "value", - "name": "debug6", - "docstrings": [ - "`debug6(v1, v2, v3, v4, v5, v6)`. Like `debug`, but with six arguments.\n\n## Examples\n\n```rescript\nConsole.debug6(\"Hello\", \"World\", \"JS\", '!', '!', '?')\nConsole.debug6([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"}, 42)\n```" - ], - "signature": "let debug6: ('a, 'b, 'c, 'd, 'e, 'f) => unit" - }, - { - "id": "Core.Console.debugMany", - "kind": "value", - "name": "debugMany", - "docstrings": [ - "`debugMany(arr)`. Like `debug`, but variadic.\n\n## Examples\n\n```rescript\nConsole.debugMany([\"Hello\", \"World\"])\nConsole.debugMany([1, 2, 3])\n```" - ], - "signature": "let debugMany: array<'a> => unit" - }, - { - "id": "Core.Console.dir", - "kind": "value", - "name": "dir", - "docstrings": [ - "`dir(object)` displays an interactive view of the object in the console.\n\nSee [`console.dir`](https://developer.mozilla.org/en-US/docs/Web/API/console/dir)\non MDN.\n\n## Examples\n\n```rescript\nConsole.dir({\"language\": \"rescript\", \"version\": \"10.1.2\"})\n```" - ], - "signature": "let dir: 'a => unit" - }, - { - "id": "Core.Console.dirxml", - "kind": "value", - "name": "dirxml", - "docstrings": [ - "`dirxml(object)` displays an interactive tree view of an XML/HTML element in the console.\n\nSee [`console.dirxml`](https://developer.mozilla.org/en-US/docs/Web/API/console/dirxml)\non MDN." - ], - "signature": "let dirxml: 'a => unit" - }, - { - "id": "Core.Console.error", - "kind": "value", - "name": "error", - "docstrings": [ - "`error(value)` prints an error message to console.\n\nSee [`console.error`](https://developer.mozilla.org/en-US/docs/Web/API/console/error)\non MDN.\n\n## Examples\n\n```rescript\nConsole.error(\"error message\")\nConsole.error((\"error\", \"invalid value\"))\n```" - ], - "signature": "let error: 'a => unit" - }, - { - "id": "Core.Console.error2", - "kind": "value", - "name": "error2", - "docstrings": [ - "`error(v1, v2)`. Like `error`, but two arguments.\n\n## Examples\n\n```rescript\nConsole.error2(\"Error\", \"here\")\nConsole.error2((\"log\", \"error\"), \"message\")\n```" - ], - "signature": "let error2: ('a, 'b) => unit" - }, - { - "id": "Core.Console.error3", - "kind": "value", - "name": "error3", - "docstrings": [ - "`error3(v1, v2, v3)`. Like `error`, but three arguments.\n\n## Examples\n\n```rescript\nConsole.error3(\"Hello\", \"World\", \"!!!\")\nConsole.error3(#first, #second, #third)\n```" - ], - "signature": "let error3: ('a, 'b, 'c) => unit" - }, - { - "id": "Core.Console.error4", - "kind": "value", - "name": "error4", - "docstrings": [ - "`error4(v1, v2, v3, v4)`. Like `error`, but with four arguments.\n\n## Examples\n\n```rescript\nConsole.error4(\"Hello\", \"World\", \"ReScript\", '!')\nConsole.error4(#first, #second, #third, (\"fourth\"))\n```" - ], - "signature": "let error4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Core.Console.error5", - "kind": "value", - "name": "error5", - "docstrings": [ - "`error5(v1, v2, v3, v4, v5)`. Like `error`, but with five arguments.\n\n## Examples\n\n```rescript\nConsole.error5('e', 'r', 'r', 'o', 'r')\nConsole.error5(1, #second, #third, (\"fourth\"), 'c')\n```" - ], - "signature": "let error5: ('a, 'b, 'c, 'd, 'e) => unit" - }, - { - "id": "Core.Console.error6", - "kind": "value", - "name": "error6", - "docstrings": [ - "`error6(v1, v2, v3, v4, v5, v6)`. Like `error`, but with six arguments.\n\n## Examples\n\n```rescript\nConsole.error6(\"Hello\", \"World\", \"from\", \"JS\", \"!!!\", '!')\nConsole.error6([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"}, 42)\n```" - ], - "signature": "let error6: ('a, 'b, 'c, 'd, 'e, 'f) => unit" - }, - { - "id": "Core.Console.group", - "kind": "value", - "name": "group", - "docstrings": [ - "`group(label)` creates a new \"group\" level with the given label.\n\nSee [`console.group`](https://developer.mozilla.org/en-US/docs/Web/API/console/group)\non MDN.\n\n## Example\n\n```rescript\nConsole.group(\"first group\")\nConsole.group(\"second group\")\nConsole.log(\"a message on the second level\")\nConsole.groupEnd()\nConsole.log(\"a message message on the first level\")\nConsole.groupEnd()\n```" - ], - "signature": "let group: string => unit" - }, - { - "id": "Core.Console.groupCollapsed", - "kind": "value", - "name": "groupCollapsed", - "docstrings": [ - "`groupCollapsed(label)`. Like `group` but collapses the group initially.\n\nSee [`console.groupCollapsed`](https://developer.mozilla.org/en-US/docs/Web/API/console/groupCollapsed)\non MDN." - ], - "signature": "let groupCollapsed: string => unit" - }, - { - "id": "Core.Console.groupEnd", - "kind": "value", - "name": "groupEnd", - "docstrings": [ - "`groupEnd()` ends the current group.\n\nSee [`console.groupEnd`](https://developer.mozilla.org/en-US/docs/Web/API/console/groupEnd)\non MDN." - ], - "signature": "let groupEnd: unit => unit" - }, - { - "id": "Core.Console.errorMany", - "kind": "value", - "name": "errorMany", - "docstrings": [ - "`errorMany(arr)`. Like `error`, but variadic.\n\n## Examples\n\n```rescript\nConsole.errorMany([\"Hello\", \"World\"])\nConsole.errorMany([1, 2, 3])\n```" - ], - "signature": "let errorMany: array<'a> => unit" - }, - { - "id": "Core.Console.info", - "kind": "value", - "name": "info", - "docstrings": [ - "`info(value)` print an informational message to console.\n\nSee [`console.info`](https://developer.mozilla.org/en-US/docs/Web/API/console/info)\non MDN.\n\n## Examples\n\n```rescript\nConsole.info(\"Information\")\nConsole.info((\"Hello\", \"JS\"))\n```" - ], - "signature": "let info: 'a => unit" - }, - { - "id": "Core.Console.info2", - "kind": "value", - "name": "info2", - "docstrings": [ - "`info2(v1, v2)`. Like `info`, but with two arguments.\n\n## Examples\n\n```rescript\nConsole.info2(\"Info\", \"failed to download\")\nConsole.info2(#info, {\"name\": \"ReScript\"})\n```" - ], - "signature": "let info2: ('a, 'b) => unit" - }, - { - "id": "Core.Console.info3", - "kind": "value", - "name": "info3", - "docstrings": [ - "`info3(v1, v2, v3)`. Like `info`, but with three arguments.\n\n## Examples\n\n```rescript\nConsole.info3(\"Hello\", \"World\", \"ReScript\")\nConsole.info3([1, 2, 3], #4, #5)\n```" - ], - "signature": "let info3: ('a, 'b, 'c) => unit" - }, - { - "id": "Core.Console.info4", - "kind": "value", - "name": "info4", - "docstrings": [ - "`info4(v1, v2, v3, v4)`. Like `info`, but with four arguments.\n\n## Examples\n\n```rescript\nConsole.info4(\"Hello\", \"World\", \"ReScript\", '!')\nConsole.info4([1, 2, 3], #4, #5, #lastinfo)\n```" - ], - "signature": "let info4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Core.Console.info5", - "kind": "value", - "name": "info5", - "docstrings": [ - "`info5(v1, v2, v3, v4, v5)`. Like `info`, but with five arguments.\n\n## Examples\n\n```rescript\nConsole.info5(\"Hello\", \"World\", \"from\", \"JS\", \"!!!\")\nConsole.info5([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"})\n```" - ], - "signature": "let info5: ('a, 'b, 'c, 'd, 'e) => unit" - }, - { - "id": "Core.Console.info6", - "kind": "value", - "name": "info6", - "docstrings": [ - "`info6(v1, v2, v3, v4, v5, v6)`. Like `info`, but with six arguments.\n\n## Examples\n\n```rescript\nConsole.info6(\"Hello\", \"World\", \"from\", \"JS\", \"!!!\", '!')\nConsole.info6([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"}, 42)\n```" - ], - "signature": "let info6: ('a, 'b, 'c, 'd, 'e, 'f) => unit" - }, - { - "id": "Core.Console.infoMany", - "kind": "value", - "name": "infoMany", - "docstrings": [ - "`infoMany(arr)`. Like `info`, but variadic.\n\n## Examples\n\n```rescript\nConsole.infoMany([\"Hello\", \"World\"])\nConsole.infoMany([1, 2, 3])\n```" - ], - "signature": "let infoMany: array<'a> => unit" - }, - { - "id": "Core.Console.log", - "kind": "value", - "name": "log", - "docstrings": [ - "`log(value)` print a message to console.\n\nSee [`console.log`](https://developer.mozilla.org/en-US/docs/Web/API/console/log)\non MDN.\n\n## Examples\n\n```rescript\nConsole.log(\"Hello\")\nlet obj = {\"name\": \"ReScript\", \"version\": 10}\nConsole.log(obj)\n```" - ], - "signature": "let log: 'a => unit" - }, - { - "id": "Core.Console.log2", - "kind": "value", - "name": "log2", - "docstrings": [ - "`log2(v1, v2)`. Like `log`, but with two arguments.\n\n## Examples\n\n```rescript\nConsole.log2(\"Hello\", \"World\")\nConsole.log2([1, 2, 3], '4')\n```" - ], - "signature": "let log2: ('a, 'b) => unit" - }, - { - "id": "Core.Console.log3", - "kind": "value", - "name": "log3", - "docstrings": [ - "`log3(v1, v2, v3)`. Like `log`, but with three arguments.\n\n## Examples\n\n```rescript\nConsole.log3(\"Hello\", \"World\", \"ReScript\")\nConsole.log3(\"One\", 2, #3)\n```" - ], - "signature": "let log3: ('a, 'b, 'c) => unit" - }, - { - "id": "Core.Console.log4", - "kind": "value", - "name": "log4", - "docstrings": [ - "`log4(v1, v2, v3, v4)`. Like `log`, but with four arguments.\n\n## Examples\n\n```rescript\nConsole.log4(\"Hello\", \"World\", \"ReScript\", \"!!!\")\nConsole.log4([1, 2], (3, 4), [#5, #6], #\"polyvar\")\n```" - ], - "signature": "let log4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Core.Console.log5", - "kind": "value", - "name": "log5", - "docstrings": [ - "`log5(v1, v2, v3, v4, v5)`. Like `log`, but with five arguments.\n\n## Examples\n\n```rescript\nConsole.log5(\"Hello\", \"World\", \"JS\", '!', '!')\nConsole.log5([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"})\n```" - ], - "signature": "let log5: ('a, 'b, 'c, 'd, 'e) => unit" - }, - { - "id": "Core.Console.log6", - "kind": "value", - "name": "log6", - "docstrings": [ - "`log6(v1, v2, v3, v4, v5, v6)`. Like `log`, but with six arguments.\n\n## Examples\n\n```rescript\nConsole.log6(\"Hello\", \"World\", \"JS\", '!', '!', '?')\nConsole.log6([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"}, 42)\n```" - ], - "signature": "let log6: ('a, 'b, 'c, 'd, 'e, 'f) => unit" - }, - { - "id": "Core.Console.logMany", - "kind": "value", - "name": "logMany", - "docstrings": [ - "`logMany(arr)`. Like `log`, but variadic.\n\n## Examples\n\n```rescript\nConsole.logMany([\"Hello\", \"World\"])\nConsole.logMany([1, 2, 3])\n```" - ], - "signature": "let logMany: array<'a> => unit" - }, - { - "id": "Core.Console.table", - "kind": "value", - "name": "table", - "docstrings": [ - "`table(object)` displays an tabular view of the object in the console.\n\nSee [`console.table`](https://developer.mozilla.org/en-US/docs/Web/API/console/table)\non MDN.\n\n## Examples\n\n```rescript\nConsole.table({\"language\": \"rescript\", \"version\": \"10.1.2\"})\n```" - ], - "signature": "let table: 'a => unit" - }, - { - "id": "Core.Console.time", - "kind": "value", - "name": "time", - "docstrings": [ - "`time(label)` creates a timer to measure how long an operation takes. `label`\nmust be a unique name. Call `console.timeEnd` with the same `label` to print\noutput time.\n\nSee [`console.time`](https://developer.mozilla.org/en-US/docs/Web/API/console/time)\non MDN.\n\n## Examples\n\n```rescript\nConsole.time(\"for_time\")\nfor x in 3 downto 1 {\n Console.log(x)\n Console.timeLog(\"for_time\")\n}\nConsole.timeEnd(\"for_time\")\n```" - ], - "signature": "let time: string => unit" - }, - { - "id": "Core.Console.timeEnd", - "kind": "value", - "name": "timeEnd", - "docstrings": [ - "`timeEnd(label)` stops a timer created by `time`.\n\nSee [`console.timeEnd`](https://developer.mozilla.org/en-US/docs/Web/API/console/timeEnd)\non MDN.\n\n## Examples\n\n```rescript\nConsole.time(\"for_time\")\nfor x in 3 downto 1 {\n Console.log(x)\n Console.timeLog(\"for_time\")\n}\nConsole.timeEnd(\"for_time\")\n```" - ], - "signature": "let timeEnd: string => unit" - }, - { - "id": "Core.Console.timeLog", - "kind": "value", - "name": "timeLog", - "docstrings": [ - "`timeLog(label)` prints the current elapsed time of the given timer to the console.\n\nSee [`console.timeLog`](https://developer.mozilla.org/en-US/docs/Web/API/console/timeLog)\non MDN.\n\n## Examples\n\n```rescript\nConsole.time(\"for_time\")\nfor x in 3 downto 1 {\n Console.log(x)\n Console.timeLog(\"for_time\")\n}\nConsole.timeEnd(\"for_time\")\n```" - ], - "signature": "let timeLog: string => unit" - }, - { - "id": "Core.Console.trace", - "kind": "value", - "name": "trace", - "docstrings": [ - "`trace()` print a stack trace to console.\n\nSee [`console.trace`](https://developer.mozilla.org/en-US/docs/Web/API/console/trace)\non MDN.\n\n## Examples\n\n```rescript\nlet main = () => {\n Console.trace()\n}\nmain()\n// In the console, the following trace will be displayed:\n// main\n// \n```" - ], - "signature": "let trace: unit => unit" - }, - { - "id": "Core.Console.warn", - "kind": "value", - "name": "warn", - "docstrings": [ - "`warn(value)` print a warning message to console.\n\nSee [`console.warn`](https://developer.mozilla.org/en-US/docs/Web/API/console/warn)\non MDN.\n\n## Examples\n\n```rescript\nConsole.warn(\"Warning\")\nConsole.warn((\"Warning\", \"invalid number\"))\n```" - ], - "signature": "let warn: 'a => unit" - }, - { - "id": "Core.Console.warn2", - "kind": "value", - "name": "warn2", - "docstrings": [ - "`warn2(v1, v2)`. Like `warn`, but two arguments.\n\n## Examples\n\n```rescript\nConsole.warn2(\"Hello\", \"World\")\nConsole.warn2([1, 2, 3], 4)\n```" - ], - "signature": "let warn2: ('a, 'b) => unit" - }, - { - "id": "Core.Console.warn3", - "kind": "value", - "name": "warn3", - "docstrings": [ - "`warn3(v1, v2, v3)`. Like `warn`, but three arguments.\n\n## Examples\n\n```rescript\nConsole.warn3(\"Hello\", \"World\", \"ReScript\")\nConsole.warn3([1, 2, 3], #4, #5)\n```" - ], - "signature": "let warn3: ('a, 'b, 'c) => unit" - }, - { - "id": "Core.Console.warn4", - "kind": "value", - "name": "warn4", - "docstrings": [ - "`warn4(v1, v2, v3, v4)`. Like `warn`, but with four arguments.\n\n## Examples\n\n```rescript\nConsole.warn4(\"Hello\", \"World\", \"ReScript\", \"!!!\")\nConsole.warn4(#first, #second, #third, (\"fourth\"))\n```" - ], - "signature": "let warn4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Core.Console.warn5", - "kind": "value", - "name": "warn5", - "docstrings": [ - "`warn5(v1, v2, v3, v4, v5)`. Like `warn`, but with five arguments.\n\n## Examples\n\n```rescript\nConsole.warn5(\"Hello\", \"World\", \"from\", \"JS\", \"!!!\")\nConsole.warn5([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"})\n```" - ], - "signature": "let warn5: ('a, 'b, 'c, 'd, 'e) => unit" - }, - { - "id": "Core.Console.warn6", - "kind": "value", - "name": "warn6", - "docstrings": [ - "`warn6(v1, v2, v3, v4, v5, v6)`. Like `warn`, but with six arguments.\n\n## Examples\n\n```rescript\nConsole.warn6(\"Hello\", \"World\", \"from\", \"JS\", \"!!!\", '!')\nConsole.warn6([1, 2], (3, 4), [#5, #6], #\"polyvar\", {\"name\": \"ReScript\"}, 42)\n```" - ], - "signature": "let warn6: ('a, 'b, 'c, 'd, 'e, 'f) => unit" - }, - { - "id": "Core.Console.warnMany", - "kind": "value", - "name": "warnMany", - "docstrings": [ - "`warnMany(arr)`. Like `warn`, but variadic.\n\n## Examples\n\n```rescript\nConsole.warnMany([\"Hello\", \"World\"])\nConsole.warnMany([1, 2, 3])\n```" - ], - "signature": "let warnMany: array<'a> => unit" - } - ] - }, - "core/array": { - "id": "Core.Array", - "name": "Array", - "docstrings": [], - "items": [ - { - "id": "Core.Array.fromIterator", - "kind": "value", - "name": "fromIterator", - "docstrings": [ - "`fromIterator(iterator)`\n\n Creates an array from the provided `iterator`\n\n ```res example\n let map = Map.fromArray([(\"foo\", 1), (\"bar\", 2)])\n\n Array.fromIterator(map->Map.values) // [1, 2]\n ```" - ], - "signature": "let fromIterator: Core__Iterator.t<'a> => array<'a>" - }, - { - "id": "Core.Array.fromArrayLike", - "kind": "value", - "name": "fromArrayLike", - "docstrings": [], - "signature": "let fromArrayLike: Js.Array2.array_like<'a> => array<'a>" - }, - { - "id": "Core.Array.fromArrayLikeWithMap", - "kind": "value", - "name": "fromArrayLikeWithMap", - "docstrings": [], - "signature": "let fromArrayLikeWithMap: (Js.Array2.array_like<'a>, 'a => 'b) => array<'b>" - }, - { - "id": "Core.Array.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(~length, init)`\n\n Creates an array of length `length` initialized with the value of `init`.\n\n ```res example\n Array.make(~length=3, #apple) == [#apple, #apple, #apple]\n ```" - ], - "signature": "let make: (~length: int, 'a) => array<'a>" - }, - { - "id": "Core.Array.fromInitializer", - "kind": "value", - "name": "fromInitializer", - "docstrings": [ - "`fromInitializer(~length, f)`\n\n Creates an array of length `length` initialized with the value returned from `f ` for each index.\n\n ```res example\n Array.fromInitializer(~length=3, i => i + 3) == [3, 4, 5]\n ```" - ], - "signature": "let fromInitializer: (~length: int, int => 'a) => array<'a>" - }, - { - "id": "Core.Array.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (array<'a>, array<'a>, ('a, 'a) => bool) => bool" - }, - { - "id": "Core.Array.compare", - "kind": "value", - "name": "compare", - "docstrings": [], - "signature": "let compare: (\n array<'a>,\n array<'a>,\n ('a, 'a) => Core__Ordering.t,\n) => Core__Ordering.t" - }, - { - "id": "Core.Array.isArray", - "kind": "value", - "name": "isArray", - "docstrings": [], - "signature": "let isArray: 'a => bool" - }, - { - "id": "Core.Array.length", - "kind": "value", - "name": "length", - "docstrings": [ - "`length(array)` returns the length of (i.e. number of items in) the array.\n\nSee [`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\n\nConsole.log(someArray->Array.length) // 2\n```" - ], - "signature": "let length: array<'a> => int" - }, - { - "id": "Core.Array.copyAllWithin", - "kind": "value", - "name": "copyAllWithin", - "docstrings": [], - "signature": "let copyAllWithin: (array<'a>, ~target: int) => array<'a>" - }, - { - "id": "Core.Array.copyWithinToEnd", - "kind": "value", - "name": "copyWithinToEnd", - "docstrings": [], - "signature": "let copyWithinToEnd: (array<'a>, ~target: int, ~start: int) => array<'a>" - }, - { - "id": "Core.Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (\n array<'a>,\n ~target: int,\n ~start: int,\n ~end: int,\n) => array<'a>" - }, - { - "id": "Core.Array.fillAll", - "kind": "value", - "name": "fillAll", - "docstrings": [ - "`fillAll(array, value)` fills the entire `array` with `value`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillAll(9)\n\nConsole.log(myArray) // [9, 9, 9, 9]\n```" - ], - "signature": "let fillAll: (array<'a>, 'a) => unit" - }, - { - "id": "Core.Array.fillToEnd", - "kind": "value", - "name": "fillToEnd", - "docstrings": [ - "`fillToEnd(array, value, ~start)` fills `array` with `value` from the `start` index.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillToEnd(9, ~start=1)\n\nConsole.log(myArray) // [1, 9, 9, 9]\n```" - ], - "signature": "let fillToEnd: (array<'a>, 'a, ~start: int) => unit" - }, - { - "id": "Core.Array.fill", - "kind": "value", - "name": "fill", - "docstrings": [ - "`fill(array, value, ~start, ~end)` fills `array` with `value` from `start` to `end`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fill(9, ~start=1, ~end=2)\n\nConsole.log(myArray) // [1, 9, 9, 4]\n```" - ], - "signature": "let fill: (array<'a>, 'a, ~start: int, ~end: int) => unit" - }, - { - "id": "Core.Array.pop", - "kind": "value", - "name": "pop", - "docstrings": [ - "`pop(array)` removes the last item from `array` and returns it.\n\nBeware this will *mutate* the array.\n\nSee [`Array.pop`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nlet lastItem = someArray->Array.pop // \"hello\"\n\nConsole.log(someArray) // [\"hi\"]. Notice last item is gone.\n```" - ], - "signature": "let pop: array<'a> => option<'a>" - }, - { - "id": "Core.Array.push", - "kind": "value", - "name": "push", - "docstrings": [ - "`push(array, item)` appends `item` to the end of `array`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nsomeArray->Array.push(\"yay\")\n\nConsole.log(someArray) // [\"hi\", \"hello\", \"yay\"]\n```" - ], - "signature": "let push: (array<'a>, 'a) => unit" - }, - { - "id": "Core.Array.pushMany", - "kind": "value", - "name": "pushMany", - "docstrings": [ - "`pushMany(array, itemsArray)` appends many new items to the end of the array.\n\nBeware this will *mutate* the array.\n\nSee [`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nsomeArray->Array.pushMany([\"yay\", \"wehoo\"])\n\nConsole.log(someArray) // [\"hi\", \"hello\", \"yay\", \"wehoo\"]\n```" - ], - "signature": "let pushMany: (array<'a>, array<'a>) => unit" - }, - { - "id": "Core.Array.reverse", - "kind": "value", - "name": "reverse", - "docstrings": [ - "`reverse(array)` reverses the order of the items in `array`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.reverse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nsomeArray->Array.reverse\n\nConsole.log(someArray) // [\"hello\", \"h1\"]\n```" - ], - "signature": "let reverse: array<'a> => unit" - }, - { - "id": "Core.Array.shift", - "kind": "value", - "name": "shift", - "docstrings": [ - "`shift(array)` removes the first item in the array, and returns it.\n\nBeware this will *mutate* the array.\n\nSee [`Array.shift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nlet lastItem = someArray->Array.shift // \"hi\"\n\nConsole.log(someArray) // [\"hello\"]. Notice first item is gone.\n```" - ], - "signature": "let shift: array<'a> => option<'a>" - }, - { - "id": "Core.Array.toSorted", - "kind": "value", - "name": "toSorted", - "docstrings": [ - "`toSorted(array, comparator)` returns a new, sorted array from `array`, using the `comparator` function.\n\nSee [`Array.toSorted`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted) on MDN.\n\n## Examples\n```rescript\nlet someArray = [3, 2, 1]\nlet sorted = someArray->Array.toSorted(Int.compare)\n\nConsole.log(sorted) // [1, 2, 3]\nConsole.log(someArray) // [3, 2, 1]. Original unchanged\n```" - ], - "signature": "let toSorted: (array<'a>, ('a, 'a) => Core__Ordering.t) => array<'a>" - }, - { - "id": "Core.Array.sort", - "kind": "value", - "name": "sort", - "docstrings": [ - "`sort(array, comparator)` sorts `array` in-place using the `comparator` function.\n\nBeware this will *mutate* the array.\n\nSee [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) on MDN.\n\n## Examples\n```rescript\nlet someArray = [3, 2, 1]\nsomeArray->Array.sort((a, b) => float(a - b))\n\nConsole.log(someArray) // [1, 2, 3]\n```" - ], - "signature": "let sort: (array<'a>, ('a, 'a) => Core__Ordering.t) => unit" - }, - { - "id": "Core.Array.splice", - "kind": "value", - "name": "splice", - "docstrings": [], - "signature": "let splice: (\n array<'a>,\n ~start: int,\n ~remove: int,\n ~insert: array<'a>,\n) => unit" - }, - { - "id": "Core.Array.toSpliced", - "kind": "value", - "name": "toSpliced", - "docstrings": [], - "signature": "let toSpliced: (\n array<'a>,\n ~start: int,\n ~remove: int,\n ~insert: array<'a>,\n) => array<'a>" - }, - { - "id": "Core.Array.with", - "kind": "value", - "name": "with", - "docstrings": [], - "signature": "let with: (array<'a>, int, 'a) => array<'a>" - }, - { - "id": "Core.Array.unshift", - "kind": "value", - "name": "unshift", - "docstrings": [ - "`unshift(array, item)` inserts a new item at the start of the array.\n\nBeware this will *mutate* the array.\n\nSee [`Array.unshift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nsomeArray->Array.unshift(\"yay\")\n\nConsole.log(someArray) // [\"yay\", \"hi\", \"hello\"]\n```" - ], - "signature": "let unshift: (array<'a>, 'a) => unit" - }, - { - "id": "Core.Array.unshiftMany", - "kind": "value", - "name": "unshiftMany", - "docstrings": [ - "`unshiftMany(array, itemsArray)` inserts many new items to the start of the array.\n\nBeware this will *mutate* the array.\n\nSee [`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nsomeArray->Array.unshiftMany([\"yay\", \"wehoo\"])\n\nConsole.log(someArray) // [\"yay\", \"wehoo\", \"hi\", \"hello\"]\n```" - ], - "signature": "let unshiftMany: (array<'a>, array<'a>) => unit" - }, - { - "id": "Core.Array.concat", - "kind": "value", - "name": "concat", - "docstrings": [ - "`concat(array1, array2)` concatenates the two arrays, creating a new array.\n\nSee [`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) on MDN.\n\n## Examples\n```rescript\nlet array1 = [\"hi\", \"hello\"]\nlet array2 = [\"yay\", \"wehoo\"]\n\nlet someArray = array1->Array.concat(array2)\n\nConsole.log(someArray) // [\"hi\", \"hello\", \"yay\", \"wehoo\"]\n```" - ], - "signature": "let concat: (array<'a>, array<'a>) => array<'a>" - }, - { - "id": "Core.Array.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [ - "`concatMany(array1, arrays)` concatenates array1 with several other arrays, creating a new array.\n\nSee [`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) on MDN.\n\n## Examples\n```rescript\nlet array1 = [\"hi\", \"hello\"]\nlet array2 = [\"yay\"]\nlet array3 = [\"wehoo\"]\n\nlet someArray = array1->Array.concatMany([array2, array3])\n\nConsole.log(someArray) // [\"hi\", \"hello\", \"yay\", \"wehoo\"]\n```" - ], - "signature": "let concatMany: (array<'a>, array>) => array<'a>" - }, - { - "id": "Core.Array.flat", - "kind": "value", - "name": "flat", - "docstrings": [ - "`flat(arrays)` concatenates an array of arrays into a single array.\n\nSee [`Array.flat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) on MDN.\n\n## Examples\n```rescript\nConsole.log([[1], [2], [3, 4]]->Array.flat) // [1, 2, 3, 4]\n```" - ], - "signature": "let flat: array> => array<'a>" - }, - { - "id": "Core.Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [ - "`includes(array, item)` checks whether `array` includes `item`, by doing a [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality).\n\nSee [`Array.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) on MDN.\n\n## Examples\n```rescript\nConsole.log([1, 2]->Array.includes(1)) // true\nConsole.log([1, 2]->Array.includes(3)) // false\nConsole.log([{\"language\": \"ReScript\"}]->Array.includes({\"language\": \"ReScript\"})) // false, because of strict equality\n```" - ], - "signature": "let includes: (array<'a>, 'a) => bool" - }, - { - "id": "Core.Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [ - "`indexOf(array, item)` returns the index of the provided `item` in `array`. Uses [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) when comparing items.\n\nReturns `-1` if the item doesn not exist. Check out `Array.indexOfOpt` for a version that returns `None` instead of `-1` if the item does not exist.\n\nSee [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) on MDN.\n\n## Examples\n```rescript\nConsole.log([1, 2]->Array.indexOf(2)) // 1\nConsole.log([1, 2]->Array.indexOf(3)) // -1\nConsole.log([{\"language\": \"ReScript\"}]->Array.indexOf({\"language\": \"ReScript\"})) // -1, because of strict equality\n```" - ], - "signature": "let indexOf: (array<'a>, 'a) => int" - }, - { - "id": "Core.Array.indexOfOpt", - "kind": "value", - "name": "indexOfOpt", - "docstrings": [ - "`indexOfOpt(array, item)` returns an option of the index of the provided `item` in `array`. Uses [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) when comparing items.\n\nSee [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) on MDN.\n\n## Examples\n```rescript\nConsole.log([1, 2]->Array.indexOfOpt(2)) // Some(1)\nConsole.log([1, 2]->Array.indexOfOpt(3)) // None\nConsole.log([{\"language\": \"ReScript\"}]->Array.indexOfOpt({\"language\": \"ReScript\"})) // None, because of strict equality\n```" - ], - "signature": "let indexOfOpt: (array<'a>, 'a) => option" - }, - { - "id": "Core.Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (array<'a>, 'a, int) => int" - }, - { - "id": "Core.Array.join", - "kind": "value", - "name": "join", - "docstrings": [ - "`join(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Array items must be strings, to join number or other arrays, use `joinUnsafe`. Under the hood this will run JavaScript's `toString` on all the array items.\n\nSee [Array.join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)\n\n## Examples\n```rescript\nlet array = [\"One\", \"Two\", \"Three\"]\n\nConsole.log(array->Array.join(\" -- \")) // One -- Two -- Three\n```" - ], - "signature": "let join: (array, string) => string" - }, - { - "id": "Core.Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [ - "`joinWith(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Array items must be strings, to join number or other arrays, use `joinWithUnsafe`. Under the hood this will run JavaScript's `toString` on all the array items.\n\n## Examples\n```rescript\nlet array = [\"One\", \"Two\", \"Three\"]\n\nConsole.log(array->Array.joinWith(\" -- \")) // One -- Two -- Three\n```" - ], - "signature": "let joinWith: (array, string) => string", - "deprecated": "Use `join` instead" - }, - { - "id": "Core.Array.joinUnsafe", - "kind": "value", - "name": "joinUnsafe", - "docstrings": [ - "`joinUnsafe(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Under the hood this will run JavaScript's `toString` on all the array items.\n\nSee [Array.join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)\n\n## Examples\n```rescript\nlet array = [1, 2, 3]\n\nConsole.log(array->Array.joinUnsafe(\" -- \")) // 1 -- 2 -- 3\n```" - ], - "signature": "let joinUnsafe: (array<'a>, string) => string" - }, - { - "id": "Core.Array.joinWithUnsafe", - "kind": "value", - "name": "joinWithUnsafe", - "docstrings": [ - "`joinWithUnsafe(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Under the hood this will run JavaScript's `toString` on all the array items.\n\n## Examples\n```rescript\nlet array = [1, 2, 3]\n\nConsole.log(array->Array.joinWithUnsafe(\" -- \")) // 1 -- 2 -- 3\n```" - ], - "signature": "let joinWithUnsafe: (array<'a>, string) => string", - "deprecated": "Use `joinUnsafe` instead" - }, - { - "id": "Core.Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (array<'a>, 'a) => int" - }, - { - "id": "Core.Array.lastIndexOfOpt", - "kind": "value", - "name": "lastIndexOfOpt", - "docstrings": [], - "signature": "let lastIndexOfOpt: (array<'a>, 'a) => option" - }, - { - "id": "Core.Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (array<'a>, 'a, int) => int" - }, - { - "id": "Core.Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [ - "`slice(array, ~start, ~end)` creates a new array of items copied from `array` from `start` until (but not including) `end`.\n\nSee [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN.\n\n## Examples\n```rescript\nlet myArray = [1, 2, 3, 4]\n\nConsole.log(myArray->Array.slice(~start=1, ~end=3)) // [2, 3]\n```" - ], - "signature": "let slice: (array<'a>, ~start: int, ~end: int) => array<'a>" - }, - { - "id": "Core.Array.sliceToEnd", - "kind": "value", - "name": "sliceToEnd", - "docstrings": [ - "`sliceToEnd(array, start)` creates a new array from `array`, with all items from `array` starting from `start`.\n\nSee [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN.\n\n## Examples\n```rescript\nlet myArray = [1, 2, 3, 4]\n\nConsole.log(myArray->Array.sliceToEnd(~start=1)) // [2, 3, 4]\n```" - ], - "signature": "let sliceToEnd: (array<'a>, ~start: int) => array<'a>" - }, - { - "id": "Core.Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [ - "`copy(array)` makes a copy of the array with the items in it, but does not make copies of the items themselves.\n\n## Examples\n```rescript\nlet myArray = [1, 2, 3]\nlet copyOfMyArray = myArray->Array.copy\n\nConsole.log(copyOfMyArray) // [1, 2, 3]\nConsole.log(myArray === copyOfMyArray) // false\n```" - ], - "signature": "let copy: array<'a> => array<'a>" - }, - { - "id": "Core.Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "`toString(array)` stringifies `array` by running `toString` on all of the array elements and joining them with \",\".\n\nSee [`Array.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString) on MDN.\n\n## Examples\n```rescript\nlet array = [1, 2, 3, 4]\n\nConsole.log(array->Array.toString) // \"1,2,3,4\"\n```" - ], - "signature": "let toString: array<'a> => string" - }, - { - "id": "Core.Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: array<'a> => string" - }, - { - "id": "Core.Array.every", - "kind": "value", - "name": "every", - "docstrings": [ - "`every(array, predicate)` returns true if `predicate` returns true for all items in `array`.\n\nSee [`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) on MDN.\n\n## Examples\n```rescript\nlet array = [1, 2, 3, 4]\n\nConsole.log(array->Array.every(num => num <= 4)) // true\nConsole.log(array->Array.every(num => num === 1)) // false\n```" - ], - "signature": "let every: (array<'a>, 'a => bool) => bool" - }, - { - "id": "Core.Array.everyWithIndex", - "kind": "value", - "name": "everyWithIndex", - "docstrings": [ - "`everyWithIndex(array, checker)` returns true if all items in `array` returns true when running the provided `checker` function.\n\nSee [`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) on MDN.\n\n## Examples\n```rescript\nlet array = [1, 2, 3, 4]\n\nConsole.log(array->Array.everyWithIndex((num, index) => index < 2 && num <= 2)) // true\nConsole.log(array->Array.everyWithIndex((num, index) => index < 2 && num >= 2)) // false\n```" - ], - "signature": "let everyWithIndex: (array<'a>, ('a, int) => bool) => bool" - }, - { - "id": "Core.Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [ - "`filter(array, checker)` returns a new array containing all elements from `array` for which the provided `checker` function returns true.\n\nSee [`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) on MDN.\n\n## Examples\n```rescript\nlet array = [1, 2, 3, 4]\n\nConsole.log(array->Array.filter(num => num > 2)) // [3, 4]\n```" - ], - "signature": "let filter: (array<'a>, 'a => bool) => array<'a>" - }, - { - "id": "Core.Array.filterWithIndex", - "kind": "value", - "name": "filterWithIndex", - "docstrings": [ - "`filterWithIndex(array, checker)` returns a new array containing all elements from `array` for which the provided `checker` function returns true.\n\nSee [`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) on MDN.\n\n## Examples\n```rescript\nlet array = [1, 2, 3, 4]\n\nConsole.log(array->Array.filterWithIndex((num, index) => index === 0 || num === 2)) // [1, 2]\n```" - ], - "signature": "let filterWithIndex: (array<'a>, ('a, int) => bool) => array<'a>" - }, - { - "id": "Core.Array.find", - "kind": "value", - "name": "find", - "docstrings": [ - "`find(array, checker)` returns the first element of `array` where the provided `checker` function returns true.\n\nSee [`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) on MDN.\n\n## Examples\n```rescript\ntype languages = ReScript | TypeScript | JavaScript\n\nlet array = [ReScript, TypeScript, JavaScript]\n\nswitch array->Array.find(item => item == ReScript) {\n| None => Console.log(\"No item...\")\n| Some(_) => Console.log(\"Yay, ReScript!\")\n}\n```" - ], - "signature": "let find: (array<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Core.Array.findWithIndex", - "kind": "value", - "name": "findWithIndex", - "docstrings": [ - "`findWithIndex(array, checker)` returns the first element of `array` where the provided `checker` function returns true.\n\nSee [`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) on MDN.\n\n## Examples\n```rescript\ntype languages = ReScript | TypeScript | JavaScript\n\nlet array = [TypeScript, JavaScript, ReScript]\n\nswitch array->Array.findWithIndex((item, index) => index > 1 && item == ReScript) {\n| None => Console.log(\"No item...\")\n| Some(_) => Console.log(\"Yay, ReScript exists in a later position!\")\n}\n```" - ], - "signature": "let findWithIndex: (array<'a>, ('a, int) => bool) => option<'a>" - }, - { - "id": "Core.Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [ - "`findIndex(array, checker)` returns the index of the first element of `array` where the provided `checker` function returns true.\n\nReturns `-1` if the item does not exist. Consider using `Array.findIndexOpt` if you want an option instead (where `-1` would be `None`).\n\nSee [`Array.findIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) on MDN.\n\n## Examples\n```rescript\ntype languages = ReScript | TypeScript | JavaScript\n\nlet array = [ReScript, JavaScript]\n\nConsole.log(array->Array.findIndex(item => item == ReScript)) // 0\nConsole.log(array->Array.findIndex(item => item == TypeScript)) // -1\n```" - ], - "signature": "let findIndex: (array<'a>, 'a => bool) => int" - }, - { - "id": "Core.Array.findIndexWithIndex", - "kind": "value", - "name": "findIndexWithIndex", - "docstrings": [ - "`findIndexWithIndex(array, checker)` returns the index of the first element of `array` where the provided `checker` function returns true.\n\nReturns `-1` if the item does not exist. Consider using `Array.findIndexOpt` if you want an option instead (where `-1` would be `None`).\n\nSee [`Array.findIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) on MDN.\n\n## Examples\n```rescript\ntype languages = ReScript | TypeScript | JavaScript\n\nlet array = [ReScript, JavaScript]\n\nlet isReScriptFirst = array->Array.findIndexWithIndex((item, index) => index === 0 && item == ReScript)\nlet isTypeScriptFirst = array->Array.findIndexWithIndex((item, index) => index === 0 && item == TypeScript)\n\nConsole.log(isReScriptFirst) // 0\nConsole.log(isTypeScriptFirst) // -1\n```" - ], - "signature": "let findIndexWithIndex: (array<'a>, ('a, int) => bool) => int" - }, - { - "id": "Core.Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "`forEach(array, fn)` runs the provided `fn` on every element of `array`.\n\nSee [`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) on MDN.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\n\narray->Array.forEach(item => {\n Console.log(item)\n})\n```" - ], - "signature": "let forEach: (array<'a>, 'a => unit) => unit" - }, - { - "id": "Core.Array.forEachWithIndex", - "kind": "value", - "name": "forEachWithIndex", - "docstrings": [ - "`forEachWithIndex(array, fn)` runs the provided `fn` on every element of `array`.\n\nSee [`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) on MDN.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\n\narray->Array.forEachWithIndex((item, index) => {\n Console.log(\"At item \" ++ Int.toString(index) ++ \": \" ++ item)\n})\n```" - ], - "signature": "let forEachWithIndex: (array<'a>, ('a, int) => unit) => unit" - }, - { - "id": "Core.Array.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(array, fn)` returns a new array with all elements from `array`, each element transformed using the provided `fn`.\n\nSee [`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) on MDN.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\nlet mappedArray = array->Array.map(greeting => greeting ++ \" to you\")\n\nConsole.log(mappedArray) // [\"Hello to you\", \"Hi to you\", \"Good bye to you\"]\n```" - ], - "signature": "let map: (array<'a>, 'a => 'b) => array<'b>" - }, - { - "id": "Core.Array.mapWithIndex", - "kind": "value", - "name": "mapWithIndex", - "docstrings": [ - "`mapWithIndex(array, fn)` returns a new array with all elements from `array`, each element transformed using the provided `fn`.\n\nSee [`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) on MDN.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\nlet mappedArray =\n array->Array.mapWithIndex((greeting, index) =>\n greeting ++ \" at position \" ++ Int.toString(index)\n )\n\nConsole.log(mappedArray) // [\"Hello at position 0\", \"Hi at position 1\", \"Good bye at position 2\"]\n```" - ], - "signature": "let mapWithIndex: (array<'a>, ('a, int) => 'b) => array<'b>" - }, - { - "id": "Core.Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "`reduce(xs, init, fn)`\n\n Applies `fn` to each element of `xs` from beginning to end. Function `fn` has two parameters: the item from the list and an “accumulator”; which starts with a value of `init`. `reduce` returns the final value of the accumulator.\n\n ```res example\n Array.reduce([2, 3, 4], 1, (a, b) => a + b) == 10\n\n Array.reduce([\"a\", \"b\", \"c\", \"d\"], \"\", (a, b) => a ++ b) == \"abcd\"\n ```" - ], - "signature": "let reduce: (array<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Core.Array.reduceWithIndex", - "kind": "value", - "name": "reduceWithIndex", - "docstrings": [ - "`reduceWithIndex(x, init, fn)`\n\n Applies `fn` to each element of `xs` from beginning to end. Function `fn` has three parameters: the item from the array and an “accumulator”, which starts with a value of `init` and the index of each element. `reduceWithIndex` returns the final value of the accumulator.\n\n ```res example\n Array.reduceWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i) == 16\n ```" - ], - "signature": "let reduceWithIndex: (array<'a>, 'b, ('b, 'a, int) => 'b) => 'b" - }, - { - "id": "Core.Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [ - "`reduceRight(xs, init, fn)`\n\n Works like `Array.reduce`; except that function `fn` is applied to each item of `xs` from the last back to the first.\n\n ```res example\n Array.reduceRight([\"a\", \"b\", \"c\", \"d\"], \"\", (a, b) => a ++ b) == \"dcba\"\n ```" - ], - "signature": "let reduceRight: (array<'a>, 'b, ('b, 'a) => 'b) => 'b" - }, - { - "id": "Core.Array.reduceRightWithIndex", - "kind": "value", - "name": "reduceRightWithIndex", - "docstrings": [ - "`reduceRightWithIndex(xs, init, fn)`\n\n Like `reduceRight`, but with an additional index argument on the callback function.\n\n ```res example\n Array.reduceRightWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i) == 16\n ```" - ], - "signature": "let reduceRightWithIndex: (array<'a>, 'b, ('b, 'a, int) => 'b) => 'b" - }, - { - "id": "Core.Array.some", - "kind": "value", - "name": "some", - "docstrings": [ - "`some(array, predicate)` returns true if `predicate` returns true for any element in `array`.\n\nSee [`Array.some`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) on MDN.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\n\nConsole.log(array->Array.some(greeting => greeting === \"Hello\")) // true\n```" - ], - "signature": "let some: (array<'a>, 'a => bool) => bool" - }, - { - "id": "Core.Array.someWithIndex", - "kind": "value", - "name": "someWithIndex", - "docstrings": [ - "`someWithIndex(array, checker)` returns true if running the provided `checker` function on any element in `array` returns true.\n\nSee [`Array.some`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) on MDN.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\n\nConsole.log(array->Array.someWithIndex((greeting, index) => greeting === \"Hello\" && index === 0)) // true\n```" - ], - "signature": "let someWithIndex: (array<'a>, ('a, int) => bool) => bool" - }, - { - "id": "Core.Array.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`get(array, index)` returns the element at `index` of `array`.\n\nReturns `None` if the index does not exist in the array. Equivalent to doing `array[index]` in JavaScript.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\n\narray->Array.get(0) == Some(\"Hello\") // true\narray->Array.get(3) == None // true\n```" - ], - "signature": "let get: (array<'a>, int) => option<'a>" - }, - { - "id": "Core.Array.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`set(array, index, item)` sets the provided `item` at `index` of `array`.\n\nBeware this will *mutate* the array.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\narray->Array.set(1, \"Hello\")\n\nConsole.log(array[1]) // \"Hello\"\n```" - ], - "signature": "let set: (array<'a>, int, 'a) => unit" - }, - { - "id": "Core.Array.getSymbol", - "kind": "value", - "name": "getSymbol", - "docstrings": [], - "signature": "let getSymbol: (array<'a>, Core__Symbol.t) => option<'b>" - }, - { - "id": "Core.Array.getSymbolUnsafe", - "kind": "value", - "name": "getSymbolUnsafe", - "docstrings": [], - "signature": "let getSymbolUnsafe: (array<'a>, Core__Symbol.t) => 'b" - }, - { - "id": "Core.Array.setSymbol", - "kind": "value", - "name": "setSymbol", - "docstrings": [], - "signature": "let setSymbol: (array<'a>, Core__Symbol.t, 'b) => unit" - }, - { - "id": "Core.Array.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [ - "`getUnsafe(array, index)` returns the element at `index` of `array`.\n\nThis is _unsafe_, meaning it will return `undefined` value if `index` does not exist in `array`.\n\nUse `Array.getUnsafe` only when you are sure the `index` exists (i.e. when using for-loop).\n\n## Examples\n```rescript\nlet array = [1, 2, 3]\nfor index in 0 to array->Array.length - 1 {\n let value = array->Array.getUnsafe(index)\n Console.log(value)\n}\n```" - ], - "signature": "let getUnsafe: (array<'a>, int) => 'a" - }, - { - "id": "Core.Array.setUnsafe", - "kind": "value", - "name": "setUnsafe", - "docstrings": [ - "`setUnsafe(array, index, item)` sets the provided `item` at `index` of `array`.\n\nBeware this will *mutate* the array, and is *unsafe*.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\narray->Array.setUnsafe(1, \"Hello\")\n\nConsole.log(array[1]) // \"Hello\"\n```" - ], - "signature": "let setUnsafe: (array<'a>, int, 'a) => unit" - }, - { - "id": "Core.Array.findIndexOpt", - "kind": "value", - "name": "findIndexOpt", - "docstrings": [ - "`findIndexOpt(array, checker)` returns the index of the first element of `array` where the provided `checker` function returns true.\n\nReturns `None` if no item matches.\n\nSee [`Array.findIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) on MDN.\n\n## Examples\n```rescript\ntype languages = ReScript | TypeScript | JavaScript\n\nlet array = [ReScript, TypeScript, JavaScript]\n\nswitch array->Array.findIndexOpt(item => item == ReScript) {\n| None => Console.log(\"Ahh, no ReScript...\")\n| Some(index) => Console.log(\"Yay, ReScript at index \" ++ Int.toString(index))\n}\n```" - ], - "signature": "let findIndexOpt: (array<'a>, 'a => bool) => option" - }, - { - "id": "Core.Array.toReversed", - "kind": "value", - "name": "toReversed", - "docstrings": [ - "`toReversed(array)` creates a new array with all items from `array` in reversed order.\n\nSee [`Array.toReversed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed) on MDN.\n\n## Examples\n```rescript\nlet someArray = [\"hi\", \"hello\"]\nlet reversed = someArray->Array.toReversed\n\nConsole.log(reversed) // [\"hello\", \"h1\"]\nConsole.log(someArray) // [\"h1\", \"hello\"]. Original unchanged\n```" - ], - "signature": "let toReversed: array<'a> => array<'a>" - }, - { - "id": "Core.Array.filterMap", - "kind": "value", - "name": "filterMap", - "docstrings": [ - "`filterMap(array, fn)`\n\nCalls `fn` for each element and returns a new array containing results of the `fn` calls which are not `None`.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\n\nConsole.log(\n array->Array.filterMap(item =>\n switch item {\n | \"Hello\" => Some(item->String.length)\n | _ => None\n }\n ),\n) // [5]\n```" - ], - "signature": "let filterMap: (array<'a>, 'a => option<'b>) => array<'b>" - }, - { - "id": "Core.Array.keepSome", - "kind": "value", - "name": "keepSome", - "docstrings": [ - "`keepSome(arr)`\n\n Returns a new array containing `value` for all elements that are `Some(value)`\n and ignoring every value that is `None`\n\n ```res example\n Array.keepSome([Some(1), None, Some(3)]) == [1, 3]\n ```" - ], - "signature": "let keepSome: array> => array<'a>" - }, - { - "id": "Core.Array.toShuffled", - "kind": "value", - "name": "toShuffled", - "docstrings": [ - "`toShuffled(array)` returns a new array with all items in `array` in a random order.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\nlet shuffledArray = array->Array.toShuffled\n\nConsole.log(shuffledArray)\n```" - ], - "signature": "let toShuffled: array<'a> => array<'a>" - }, - { - "id": "Core.Array.shuffle", - "kind": "value", - "name": "shuffle", - "docstrings": [ - "`shuffle(array)` randomizes the position of all items in `array`.\n\nBeware this will *mutate* the array.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\narray->Array.shuffle\n\nConsole.log(array)\n```" - ], - "signature": "let shuffle: array<'a> => unit" - }, - { - "id": "Core.Array.flatMap", - "kind": "value", - "name": "flatMap", - "docstrings": [ - "`flatMap(array, mapper)` returns a new array concatenating the arrays returned from running `mapper` on all items in `array`.\n\n## Examples\n```rescript\ntype language = ReScript | TypeScript | JavaScript\n\nlet array = [ReScript, TypeScript, JavaScript]\n\nConsole.log(\n array->Array.flatMap(item =>\n switch item {\n | ReScript => [1, 2, 3]\n | TypeScript => [4, 5, 6]\n | JavaScript => [7, 8, 9]\n }\n ),\n)\n// [1, 2, 3, 4, 5, 6, 7, 8, 9]\n```" - ], - "signature": "let flatMap: (array<'a>, 'a => array<'b>) => array<'b>" - }, - { - "id": "Core.Array.flatMapWithIndex", - "kind": "value", - "name": "flatMapWithIndex", - "docstrings": [ - "`flatMapWithIndex(array, mapper)` returns a new array concatenating the arrays returned from running `mapper` on all items in `array`.\n\n## Examples\n```rescript\ntype language = ReScript | TypeScript | JavaScript\n\nlet array = [ReScript, TypeScript, JavaScript]\n\nConsole.log(\n array->Array.flatMapWithIndex((item, index) =>\n switch item {\n | ReScript => [index]\n | TypeScript => [index, index + 1]\n | JavaScript => [index, index + 1, index + 2]\n }\n ),\n)\n// [0, 1, 2, 2, 3, 4]\n```" - ], - "signature": "let flatMapWithIndex: (array<'a>, ('a, int) => array<'b>) => array<'b>" - }, - { - "id": "Core.Array.findMap", - "kind": "value", - "name": "findMap", - "docstrings": [ - "`findMap(arr, fn)`\n\n Calls `fn` for each element and returns the first value from `fn` that is `Some(_)`.\n Otherwise returns `None`\n\n ```res example\n Array.findMap([1, 2, 3], n => mod(n, 2) == 0 ? Some(n - 2) : None) == Some(0) // true\n ```" - ], - "signature": "let findMap: (array<'a>, 'a => option<'b>) => option<'b>" - }, - { - "id": "Core.Array.at", - "kind": "value", - "name": "at", - "docstrings": [ - "`at(array, index)`\n\n Get an element by its index. Negative indices count backwards from the last item.\n\n ## Examples\n ```rescript\n [\"a\", \"b\", \"c\"]->Array.at(0) // Some(\"a\")\n [\"a\", \"b\", \"c\"]->Array.at(2) // Some(\"c\")\n [\"a\", \"b\", \"c\"]->Array.at(3) // None\n [\"a\", \"b\", \"c\"]->Array.at(-1) // Some(\"c\")\n [\"a\", \"b\", \"c\"]->Array.at(-3) // Some(\"a\")\n [\"a\", \"b\", \"c\"]->Array.at(-4) // None\n ```" - ], - "signature": "let at: (array<'a>, int) => option<'a>" - }, - { - "id": "Core.Array.last", - "kind": "value", - "name": "last", - "docstrings": [ - "`last(array)` returns the last element of `array`.\n\nReturns `None` if the array is empty.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\n\narray->Array.last == Some(\"Good bye\") // true\n[]->Array.last == None // true\n```" - ], - "signature": "let last: array<'a> => option<'a>" - } - ] - } -} diff --git a/data/api/v11.0.0/dom.json b/data/api/v11.0.0/dom.json deleted file mode 100644 index d8f78bf1e..000000000 --- a/data/api/v11.0.0/dom.json +++ /dev/null @@ -1,1990 +0,0 @@ -{ - "dom": { - "id": "Dom", - "name": "Dom", - "docstrings": [], - "items": [ - { - "id": "Dom._baseClass", - "kind": "type", - "name": "_baseClass", - "docstrings": [], - "signature": "type _baseClass" - }, - { - "id": "Dom.animation", - "kind": "type", - "name": "animation", - "docstrings": [], - "signature": "type animation" - }, - { - "id": "Dom.cssStyleDeclaration", - "kind": "type", - "name": "cssStyleDeclaration", - "docstrings": [], - "signature": "type cssStyleDeclaration" - }, - { - "id": "Dom.cssStyleSheet", - "kind": "type", - "name": "cssStyleSheet", - "docstrings": [], - "signature": "type cssStyleSheet" - }, - { - "id": "Dom.eventTarget_like", - "kind": "type", - "name": "eventTarget_like", - "docstrings": [], - "signature": "type eventTarget_like<'a>" - }, - { - "id": "Dom.eventTarget", - "kind": "type", - "name": "eventTarget", - "docstrings": [], - "signature": "type eventTarget = eventTarget_like<_baseClass>" - }, - { - "id": "Dom._node", - "kind": "type", - "name": "_node", - "docstrings": [], - "signature": "type _node<'a>" - }, - { - "id": "Dom.node_like", - "kind": "type", - "name": "node_like", - "docstrings": [], - "signature": "type node_like<'a> = eventTarget_like<_node<'a>>" - }, - { - "id": "Dom.node", - "kind": "type", - "name": "node", - "docstrings": [], - "signature": "type node = node_like<_baseClass>" - }, - { - "id": "Dom._attr", - "kind": "type", - "name": "_attr", - "docstrings": [], - "signature": "type _attr" - }, - { - "id": "Dom.attr", - "kind": "type", - "name": "attr", - "docstrings": [], - "signature": "type attr = node_like<_attr>" - }, - { - "id": "Dom._characterData", - "kind": "type", - "name": "_characterData", - "docstrings": [], - "signature": "type _characterData<'a>" - }, - { - "id": "Dom.characterData_like", - "kind": "type", - "name": "characterData_like", - "docstrings": [], - "signature": "type characterData_like<'a> = node_like<_characterData<'a>>" - }, - { - "id": "Dom.characterData", - "kind": "type", - "name": "characterData", - "docstrings": [], - "signature": "type characterData = characterData_like<_baseClass>" - }, - { - "id": "Dom._cdataSection", - "kind": "type", - "name": "_cdataSection", - "docstrings": [], - "signature": "type _cdataSection" - }, - { - "id": "Dom.cdataSection", - "kind": "type", - "name": "cdataSection", - "docstrings": [], - "signature": "type cdataSection = characterData_like<_cdataSection>" - }, - { - "id": "Dom._comment", - "kind": "type", - "name": "_comment", - "docstrings": [], - "signature": "type _comment" - }, - { - "id": "Dom.comment", - "kind": "type", - "name": "comment", - "docstrings": [], - "signature": "type comment = characterData_like<_comment>" - }, - { - "id": "Dom._document", - "kind": "type", - "name": "_document", - "docstrings": [], - "signature": "type _document<'a>" - }, - { - "id": "Dom.document_like", - "kind": "type", - "name": "document_like", - "docstrings": [], - "signature": "type document_like<'a> = node_like<_document<'a>>" - }, - { - "id": "Dom.document", - "kind": "type", - "name": "document", - "docstrings": [], - "signature": "type document = document_like<_baseClass>" - }, - { - "id": "Dom._documentFragment", - "kind": "type", - "name": "_documentFragment", - "docstrings": [], - "signature": "type _documentFragment" - }, - { - "id": "Dom.documentFragment", - "kind": "type", - "name": "documentFragment", - "docstrings": [], - "signature": "type documentFragment = node_like<_documentFragment>" - }, - { - "id": "Dom._documentType", - "kind": "type", - "name": "_documentType", - "docstrings": [], - "signature": "type _documentType" - }, - { - "id": "Dom.documentType", - "kind": "type", - "name": "documentType", - "docstrings": [], - "signature": "type documentType = node_like<_documentType>" - }, - { - "id": "Dom.domImplementation", - "kind": "type", - "name": "domImplementation", - "docstrings": [], - "signature": "type domImplementation" - }, - { - "id": "Dom._element", - "kind": "type", - "name": "_element", - "docstrings": [], - "signature": "type _element<'a>" - }, - { - "id": "Dom.element_like", - "kind": "type", - "name": "element_like", - "docstrings": [], - "signature": "type element_like<'a> = node_like<_element<'a>>" - }, - { - "id": "Dom.element", - "kind": "type", - "name": "element", - "docstrings": [], - "signature": "type element = element_like<_baseClass>" - }, - { - "id": "Dom.htmlCollection", - "kind": "type", - "name": "htmlCollection", - "docstrings": [], - "signature": "type htmlCollection" - }, - { - "id": "Dom.htmlFormControlsCollection", - "kind": "type", - "name": "htmlFormControlsCollection", - "docstrings": [], - "signature": "type htmlFormControlsCollection" - }, - { - "id": "Dom.htmlOptionsCollection", - "kind": "type", - "name": "htmlOptionsCollection", - "docstrings": [], - "signature": "type htmlOptionsCollection" - }, - { - "id": "Dom.intersectionObserver", - "kind": "type", - "name": "intersectionObserver", - "docstrings": [], - "signature": "type intersectionObserver" - }, - { - "id": "Dom.intersectionObserverEntry", - "kind": "type", - "name": "intersectionObserverEntry", - "docstrings": [], - "signature": "type intersectionObserverEntry" - }, - { - "id": "Dom.mutationObserver", - "kind": "type", - "name": "mutationObserver", - "docstrings": [], - "signature": "type mutationObserver" - }, - { - "id": "Dom.mutationRecord", - "kind": "type", - "name": "mutationRecord", - "docstrings": [], - "signature": "type mutationRecord" - }, - { - "id": "Dom.performanceObserver", - "kind": "type", - "name": "performanceObserver", - "docstrings": [], - "signature": "type performanceObserver" - }, - { - "id": "Dom.performanceObserverEntryList", - "kind": "type", - "name": "performanceObserverEntryList", - "docstrings": [], - "signature": "type performanceObserverEntryList" - }, - { - "id": "Dom.reportingObserver", - "kind": "type", - "name": "reportingObserver", - "docstrings": [], - "signature": "type reportingObserver" - }, - { - "id": "Dom.reportingObserverOptions", - "kind": "type", - "name": "reportingObserverOptions", - "docstrings": [], - "signature": "type reportingObserverOptions" - }, - { - "id": "Dom.resizeObserver", - "kind": "type", - "name": "resizeObserver", - "docstrings": [], - "signature": "type resizeObserver" - }, - { - "id": "Dom.resizeObserverEntry", - "kind": "type", - "name": "resizeObserverEntry", - "docstrings": [], - "signature": "type resizeObserverEntry" - }, - { - "id": "Dom.namedNodeMap", - "kind": "type", - "name": "namedNodeMap", - "docstrings": [], - "signature": "type namedNodeMap" - }, - { - "id": "Dom.nodeList", - "kind": "type", - "name": "nodeList", - "docstrings": [], - "signature": "type nodeList" - }, - { - "id": "Dom.radioNodeList", - "kind": "type", - "name": "radioNodeList", - "docstrings": [], - "signature": "type radioNodeList" - }, - { - "id": "Dom.processingInstruction", - "kind": "type", - "name": "processingInstruction", - "docstrings": [], - "signature": "type processingInstruction" - }, - { - "id": "Dom._shadowRoot", - "kind": "type", - "name": "_shadowRoot", - "docstrings": [], - "signature": "type _shadowRoot" - }, - { - "id": "Dom.shadowRoot", - "kind": "type", - "name": "shadowRoot", - "docstrings": [], - "signature": "type shadowRoot = node_like<_shadowRoot>" - }, - { - "id": "Dom._text", - "kind": "type", - "name": "_text", - "docstrings": [], - "signature": "type _text" - }, - { - "id": "Dom.text", - "kind": "type", - "name": "text", - "docstrings": [], - "signature": "type text = characterData_like<_text>" - }, - { - "id": "Dom.domRect", - "kind": "type", - "name": "domRect", - "docstrings": [], - "signature": "type domRect" - }, - { - "id": "Dom.dataTransfer", - "kind": "type", - "name": "dataTransfer", - "docstrings": [], - "signature": "type dataTransfer" - }, - { - "id": "Dom.domStringMap", - "kind": "type", - "name": "domStringMap", - "docstrings": [], - "signature": "type domStringMap" - }, - { - "id": "Dom.history", - "kind": "type", - "name": "history", - "docstrings": [], - "signature": "type history" - }, - { - "id": "Dom._htmlDocument", - "kind": "type", - "name": "_htmlDocument", - "docstrings": [], - "signature": "type _htmlDocument" - }, - { - "id": "Dom.htmlDocument", - "kind": "type", - "name": "htmlDocument", - "docstrings": [], - "signature": "type htmlDocument = document_like<_htmlDocument>" - }, - { - "id": "Dom._htmlElement", - "kind": "type", - "name": "_htmlElement", - "docstrings": [], - "signature": "type _htmlElement<'a>" - }, - { - "id": "Dom.htmlElement_like", - "kind": "type", - "name": "htmlElement_like", - "docstrings": [], - "signature": "type htmlElement_like<'a> = element_like<_htmlElement<'a>>" - }, - { - "id": "Dom.htmlElement", - "kind": "type", - "name": "htmlElement", - "docstrings": [], - "signature": "type htmlElement = htmlElement_like<_baseClass>" - }, - { - "id": "Dom._htmlAnchorElement", - "kind": "type", - "name": "_htmlAnchorElement", - "docstrings": [], - "signature": "type _htmlAnchorElement" - }, - { - "id": "Dom.htmlAnchorElement", - "kind": "type", - "name": "htmlAnchorElement", - "docstrings": [], - "signature": "type htmlAnchorElement = htmlElement_like<\n _htmlAnchorElement,\n>" - }, - { - "id": "Dom._htmlAreaElement", - "kind": "type", - "name": "_htmlAreaElement", - "docstrings": [], - "signature": "type _htmlAreaElement" - }, - { - "id": "Dom.htmlAreaElement", - "kind": "type", - "name": "htmlAreaElement", - "docstrings": [], - "signature": "type htmlAreaElement = htmlElement_like<_htmlAreaElement>" - }, - { - "id": "Dom._htmlAudioElement", - "kind": "type", - "name": "_htmlAudioElement", - "docstrings": [], - "signature": "type _htmlAudioElement" - }, - { - "id": "Dom.htmlAudioElement", - "kind": "type", - "name": "htmlAudioElement", - "docstrings": [], - "signature": "type htmlAudioElement = htmlElement_like<_htmlAudioElement>" - }, - { - "id": "Dom._htmlBaseElement", - "kind": "type", - "name": "_htmlBaseElement", - "docstrings": [], - "signature": "type _htmlBaseElement" - }, - { - "id": "Dom.htmlBaseElement", - "kind": "type", - "name": "htmlBaseElement", - "docstrings": [], - "signature": "type htmlBaseElement = htmlElement_like<_htmlBaseElement>" - }, - { - "id": "Dom._htmlBodyElement", - "kind": "type", - "name": "_htmlBodyElement", - "docstrings": [], - "signature": "type _htmlBodyElement" - }, - { - "id": "Dom.htmlBodyElement", - "kind": "type", - "name": "htmlBodyElement", - "docstrings": [], - "signature": "type htmlBodyElement = htmlElement_like<_htmlBodyElement>" - }, - { - "id": "Dom._htmlBrElement", - "kind": "type", - "name": "_htmlBrElement", - "docstrings": [], - "signature": "type _htmlBrElement" - }, - { - "id": "Dom.htmlBrElement", - "kind": "type", - "name": "htmlBrElement", - "docstrings": [], - "signature": "type htmlBrElement = htmlElement_like<_htmlBrElement>" - }, - { - "id": "Dom._htmlButtonElement", - "kind": "type", - "name": "_htmlButtonElement", - "docstrings": [], - "signature": "type _htmlButtonElement" - }, - { - "id": "Dom.htmlButtonElement", - "kind": "type", - "name": "htmlButtonElement", - "docstrings": [], - "signature": "type htmlButtonElement = htmlElement_like<\n _htmlButtonElement,\n>" - }, - { - "id": "Dom._htmlCanvasElement", - "kind": "type", - "name": "_htmlCanvasElement", - "docstrings": [], - "signature": "type _htmlCanvasElement" - }, - { - "id": "Dom.htmlCanvasElement", - "kind": "type", - "name": "htmlCanvasElement", - "docstrings": [], - "signature": "type htmlCanvasElement = htmlElement_like<\n _htmlCanvasElement,\n>" - }, - { - "id": "Dom._htmlDataElement", - "kind": "type", - "name": "_htmlDataElement", - "docstrings": [], - "signature": "type _htmlDataElement" - }, - { - "id": "Dom.htmlDataElement", - "kind": "type", - "name": "htmlDataElement", - "docstrings": [], - "signature": "type htmlDataElement = htmlElement_like<_htmlDataElement>" - }, - { - "id": "Dom._htmlDataListElement", - "kind": "type", - "name": "_htmlDataListElement", - "docstrings": [], - "signature": "type _htmlDataListElement" - }, - { - "id": "Dom.htmlDataListElement", - "kind": "type", - "name": "htmlDataListElement", - "docstrings": [], - "signature": "type htmlDataListElement = htmlElement_like<\n _htmlDataListElement,\n>" - }, - { - "id": "Dom._htmlDialogElement", - "kind": "type", - "name": "_htmlDialogElement", - "docstrings": [], - "signature": "type _htmlDialogElement" - }, - { - "id": "Dom.htmlDialogElement", - "kind": "type", - "name": "htmlDialogElement", - "docstrings": [], - "signature": "type htmlDialogElement = htmlElement_like<\n _htmlDialogElement,\n>" - }, - { - "id": "Dom._htmlDivElement", - "kind": "type", - "name": "_htmlDivElement", - "docstrings": [], - "signature": "type _htmlDivElement" - }, - { - "id": "Dom.htmlDivElement", - "kind": "type", - "name": "htmlDivElement", - "docstrings": [], - "signature": "type htmlDivElement = htmlElement_like<_htmlDivElement>" - }, - { - "id": "Dom._htmlDlistElement", - "kind": "type", - "name": "_htmlDlistElement", - "docstrings": [], - "signature": "type _htmlDlistElement" - }, - { - "id": "Dom.htmlDlistElement", - "kind": "type", - "name": "htmlDlistElement", - "docstrings": [], - "signature": "type htmlDlistElement = htmlElement_like<_htmlDlistElement>" - }, - { - "id": "Dom._htmlEmbedElement", - "kind": "type", - "name": "_htmlEmbedElement", - "docstrings": [], - "signature": "type _htmlEmbedElement" - }, - { - "id": "Dom.htmlEmbedElement", - "kind": "type", - "name": "htmlEmbedElement", - "docstrings": [], - "signature": "type htmlEmbedElement = htmlElement_like<_htmlEmbedElement>" - }, - { - "id": "Dom._htmlFieldSetElement", - "kind": "type", - "name": "_htmlFieldSetElement", - "docstrings": [], - "signature": "type _htmlFieldSetElement" - }, - { - "id": "Dom.htmlFieldSetElement", - "kind": "type", - "name": "htmlFieldSetElement", - "docstrings": [], - "signature": "type htmlFieldSetElement = htmlElement_like<\n _htmlFieldSetElement,\n>" - }, - { - "id": "Dom._htmlFormElement", - "kind": "type", - "name": "_htmlFormElement", - "docstrings": [], - "signature": "type _htmlFormElement" - }, - { - "id": "Dom.htmlFormElement", - "kind": "type", - "name": "htmlFormElement", - "docstrings": [], - "signature": "type htmlFormElement = htmlElement_like<_htmlFormElement>" - }, - { - "id": "Dom._htmlHeadElement", - "kind": "type", - "name": "_htmlHeadElement", - "docstrings": [], - "signature": "type _htmlHeadElement" - }, - { - "id": "Dom.htmlHeadElement", - "kind": "type", - "name": "htmlHeadElement", - "docstrings": [], - "signature": "type htmlHeadElement = htmlElement_like<_htmlHeadElement>" - }, - { - "id": "Dom._htmlHeadingElement", - "kind": "type", - "name": "_htmlHeadingElement", - "docstrings": [], - "signature": "type _htmlHeadingElement" - }, - { - "id": "Dom.htmlHeadingElement", - "kind": "type", - "name": "htmlHeadingElement", - "docstrings": [], - "signature": "type htmlHeadingElement = htmlElement_like<\n _htmlHeadingElement,\n>" - }, - { - "id": "Dom._htmlHrElement", - "kind": "type", - "name": "_htmlHrElement", - "docstrings": [], - "signature": "type _htmlHrElement" - }, - { - "id": "Dom.htmlHrElement", - "kind": "type", - "name": "htmlHrElement", - "docstrings": [], - "signature": "type htmlHrElement = htmlElement_like<_htmlHrElement>" - }, - { - "id": "Dom._htmlHtmlElement", - "kind": "type", - "name": "_htmlHtmlElement", - "docstrings": [], - "signature": "type _htmlHtmlElement" - }, - { - "id": "Dom.htmlHtmlElement", - "kind": "type", - "name": "htmlHtmlElement", - "docstrings": [], - "signature": "type htmlHtmlElement = htmlElement_like<_htmlHtmlElement>" - }, - { - "id": "Dom._htmlIframeElement", - "kind": "type", - "name": "_htmlIframeElement", - "docstrings": [], - "signature": "type _htmlIframeElement" - }, - { - "id": "Dom.htmlIframeElement", - "kind": "type", - "name": "htmlIframeElement", - "docstrings": [], - "signature": "type htmlIframeElement = htmlElement_like<\n _htmlIframeElement,\n>" - }, - { - "id": "Dom._htmlImageElement", - "kind": "type", - "name": "_htmlImageElement", - "docstrings": [], - "signature": "type _htmlImageElement" - }, - { - "id": "Dom.htmlImageElement", - "kind": "type", - "name": "htmlImageElement", - "docstrings": [], - "signature": "type htmlImageElement = htmlElement_like<_htmlImageElement>" - }, - { - "id": "Dom._htmlInputElement", - "kind": "type", - "name": "_htmlInputElement", - "docstrings": [], - "signature": "type _htmlInputElement" - }, - { - "id": "Dom.htmlInputElement", - "kind": "type", - "name": "htmlInputElement", - "docstrings": [], - "signature": "type htmlInputElement = htmlElement_like<_htmlInputElement>" - }, - { - "id": "Dom._htmlLabelElement", - "kind": "type", - "name": "_htmlLabelElement", - "docstrings": [], - "signature": "type _htmlLabelElement" - }, - { - "id": "Dom.htmlLabelElement", - "kind": "type", - "name": "htmlLabelElement", - "docstrings": [], - "signature": "type htmlLabelElement = htmlElement_like<_htmlLabelElement>" - }, - { - "id": "Dom._htmlLegendElement", - "kind": "type", - "name": "_htmlLegendElement", - "docstrings": [], - "signature": "type _htmlLegendElement" - }, - { - "id": "Dom.htmlLegendElement", - "kind": "type", - "name": "htmlLegendElement", - "docstrings": [], - "signature": "type htmlLegendElement = htmlElement_like<\n _htmlLegendElement,\n>" - }, - { - "id": "Dom._htmlLiElement", - "kind": "type", - "name": "_htmlLiElement", - "docstrings": [], - "signature": "type _htmlLiElement" - }, - { - "id": "Dom.htmlLiElement", - "kind": "type", - "name": "htmlLiElement", - "docstrings": [], - "signature": "type htmlLiElement = htmlElement_like<_htmlLiElement>" - }, - { - "id": "Dom._htmlLinkElement", - "kind": "type", - "name": "_htmlLinkElement", - "docstrings": [], - "signature": "type _htmlLinkElement" - }, - { - "id": "Dom.htmlLinkElement", - "kind": "type", - "name": "htmlLinkElement", - "docstrings": [], - "signature": "type htmlLinkElement = htmlElement_like<_htmlLinkElement>" - }, - { - "id": "Dom._htmlMapElement", - "kind": "type", - "name": "_htmlMapElement", - "docstrings": [], - "signature": "type _htmlMapElement" - }, - { - "id": "Dom.htmlMapElement", - "kind": "type", - "name": "htmlMapElement", - "docstrings": [], - "signature": "type htmlMapElement = htmlElement_like<_htmlMapElement>" - }, - { - "id": "Dom._htmlMediaElement", - "kind": "type", - "name": "_htmlMediaElement", - "docstrings": [], - "signature": "type _htmlMediaElement" - }, - { - "id": "Dom.htmlMediaElement", - "kind": "type", - "name": "htmlMediaElement", - "docstrings": [], - "signature": "type htmlMediaElement = htmlElement_like<_htmlMediaElement>" - }, - { - "id": "Dom._htmlMenuElement", - "kind": "type", - "name": "_htmlMenuElement", - "docstrings": [], - "signature": "type _htmlMenuElement" - }, - { - "id": "Dom.htmlMenuElement", - "kind": "type", - "name": "htmlMenuElement", - "docstrings": [], - "signature": "type htmlMenuElement = htmlElement_like<_htmlMenuElement>" - }, - { - "id": "Dom._htmlMetaElement", - "kind": "type", - "name": "_htmlMetaElement", - "docstrings": [], - "signature": "type _htmlMetaElement" - }, - { - "id": "Dom.htmlMetaElement", - "kind": "type", - "name": "htmlMetaElement", - "docstrings": [], - "signature": "type htmlMetaElement = htmlElement_like<_htmlMetaElement>" - }, - { - "id": "Dom._htmlMeterElement", - "kind": "type", - "name": "_htmlMeterElement", - "docstrings": [], - "signature": "type _htmlMeterElement" - }, - { - "id": "Dom.htmlMeterElement", - "kind": "type", - "name": "htmlMeterElement", - "docstrings": [], - "signature": "type htmlMeterElement = htmlElement_like<_htmlMeterElement>" - }, - { - "id": "Dom._htmlModElement", - "kind": "type", - "name": "_htmlModElement", - "docstrings": [], - "signature": "type _htmlModElement" - }, - { - "id": "Dom.htmlModElement", - "kind": "type", - "name": "htmlModElement", - "docstrings": [], - "signature": "type htmlModElement = htmlElement_like<_htmlModElement>" - }, - { - "id": "Dom._htmlOListElement", - "kind": "type", - "name": "_htmlOListElement", - "docstrings": [], - "signature": "type _htmlOListElement" - }, - { - "id": "Dom.htmlOListElement", - "kind": "type", - "name": "htmlOListElement", - "docstrings": [], - "signature": "type htmlOListElement = htmlElement_like<_htmlOListElement>" - }, - { - "id": "Dom._htmlObjectElement", - "kind": "type", - "name": "_htmlObjectElement", - "docstrings": [], - "signature": "type _htmlObjectElement" - }, - { - "id": "Dom.htmlObjectElement", - "kind": "type", - "name": "htmlObjectElement", - "docstrings": [], - "signature": "type htmlObjectElement = htmlElement_like<\n _htmlObjectElement,\n>" - }, - { - "id": "Dom._htmlOptGroupElement", - "kind": "type", - "name": "_htmlOptGroupElement", - "docstrings": [], - "signature": "type _htmlOptGroupElement" - }, - { - "id": "Dom.htmlOptGroupElement", - "kind": "type", - "name": "htmlOptGroupElement", - "docstrings": [], - "signature": "type htmlOptGroupElement = htmlElement_like<\n _htmlOptGroupElement,\n>" - }, - { - "id": "Dom._htmlOptionElement", - "kind": "type", - "name": "_htmlOptionElement", - "docstrings": [], - "signature": "type _htmlOptionElement" - }, - { - "id": "Dom.htmlOptionElement", - "kind": "type", - "name": "htmlOptionElement", - "docstrings": [], - "signature": "type htmlOptionElement = htmlElement_like<\n _htmlOptionElement,\n>" - }, - { - "id": "Dom._htmlOutputElement", - "kind": "type", - "name": "_htmlOutputElement", - "docstrings": [], - "signature": "type _htmlOutputElement" - }, - { - "id": "Dom.htmlOutputElement", - "kind": "type", - "name": "htmlOutputElement", - "docstrings": [], - "signature": "type htmlOutputElement = htmlElement_like<\n _htmlOutputElement,\n>" - }, - { - "id": "Dom._htmlParagraphElement", - "kind": "type", - "name": "_htmlParagraphElement", - "docstrings": [], - "signature": "type _htmlParagraphElement" - }, - { - "id": "Dom.htmlParagraphElement", - "kind": "type", - "name": "htmlParagraphElement", - "docstrings": [], - "signature": "type htmlParagraphElement = htmlElement_like<\n _htmlParagraphElement,\n>" - }, - { - "id": "Dom._htmlParamElement", - "kind": "type", - "name": "_htmlParamElement", - "docstrings": [], - "signature": "type _htmlParamElement" - }, - { - "id": "Dom.htmlParamElement", - "kind": "type", - "name": "htmlParamElement", - "docstrings": [], - "signature": "type htmlParamElement = htmlElement_like<_htmlParamElement>" - }, - { - "id": "Dom._htmlPreElement", - "kind": "type", - "name": "_htmlPreElement", - "docstrings": [], - "signature": "type _htmlPreElement" - }, - { - "id": "Dom.htmlPreElement", - "kind": "type", - "name": "htmlPreElement", - "docstrings": [], - "signature": "type htmlPreElement = htmlElement_like<_htmlPreElement>" - }, - { - "id": "Dom._htmlProgressElement", - "kind": "type", - "name": "_htmlProgressElement", - "docstrings": [], - "signature": "type _htmlProgressElement" - }, - { - "id": "Dom.htmlProgressElement", - "kind": "type", - "name": "htmlProgressElement", - "docstrings": [], - "signature": "type htmlProgressElement = htmlElement_like<\n _htmlProgressElement,\n>" - }, - { - "id": "Dom._htmlQuoteElement", - "kind": "type", - "name": "_htmlQuoteElement", - "docstrings": [], - "signature": "type _htmlQuoteElement" - }, - { - "id": "Dom.htmlQuoteElement", - "kind": "type", - "name": "htmlQuoteElement", - "docstrings": [], - "signature": "type htmlQuoteElement = htmlElement_like<_htmlQuoteElement>" - }, - { - "id": "Dom._htmlScriptElement", - "kind": "type", - "name": "_htmlScriptElement", - "docstrings": [], - "signature": "type _htmlScriptElement" - }, - { - "id": "Dom.htmlScriptElement", - "kind": "type", - "name": "htmlScriptElement", - "docstrings": [], - "signature": "type htmlScriptElement = htmlElement_like<\n _htmlScriptElement,\n>" - }, - { - "id": "Dom._htmlSelectElement", - "kind": "type", - "name": "_htmlSelectElement", - "docstrings": [], - "signature": "type _htmlSelectElement" - }, - { - "id": "Dom.htmlSelectElement", - "kind": "type", - "name": "htmlSelectElement", - "docstrings": [], - "signature": "type htmlSelectElement = htmlElement_like<\n _htmlSelectElement,\n>" - }, - { - "id": "Dom._htmlSlotElement", - "kind": "type", - "name": "_htmlSlotElement", - "docstrings": [], - "signature": "type _htmlSlotElement" - }, - { - "id": "Dom.htmlSlotElement", - "kind": "type", - "name": "htmlSlotElement", - "docstrings": [], - "signature": "type htmlSlotElement = htmlElement_like<_htmlSlotElement>" - }, - { - "id": "Dom._htmlSourceElement", - "kind": "type", - "name": "_htmlSourceElement", - "docstrings": [], - "signature": "type _htmlSourceElement" - }, - { - "id": "Dom.htmlSourceElement", - "kind": "type", - "name": "htmlSourceElement", - "docstrings": [], - "signature": "type htmlSourceElement = htmlElement_like<\n _htmlSourceElement,\n>" - }, - { - "id": "Dom._htmlSpanElement", - "kind": "type", - "name": "_htmlSpanElement", - "docstrings": [], - "signature": "type _htmlSpanElement" - }, - { - "id": "Dom.htmlSpanElement", - "kind": "type", - "name": "htmlSpanElement", - "docstrings": [], - "signature": "type htmlSpanElement = htmlElement_like<_htmlSpanElement>" - }, - { - "id": "Dom._htmlStyleElement", - "kind": "type", - "name": "_htmlStyleElement", - "docstrings": [], - "signature": "type _htmlStyleElement" - }, - { - "id": "Dom.htmlStyleElement", - "kind": "type", - "name": "htmlStyleElement", - "docstrings": [], - "signature": "type htmlStyleElement = htmlElement_like<_htmlStyleElement>" - }, - { - "id": "Dom._htmlTableCaptionElement", - "kind": "type", - "name": "_htmlTableCaptionElement", - "docstrings": [], - "signature": "type _htmlTableCaptionElement" - }, - { - "id": "Dom.htmlTableCaptionElement", - "kind": "type", - "name": "htmlTableCaptionElement", - "docstrings": [], - "signature": "type htmlTableCaptionElement = htmlElement_like<\n _htmlTableCaptionElement,\n>" - }, - { - "id": "Dom._htmlTableCellElement", - "kind": "type", - "name": "_htmlTableCellElement", - "docstrings": [], - "signature": "type _htmlTableCellElement" - }, - { - "id": "Dom.htmlTableCellElement", - "kind": "type", - "name": "htmlTableCellElement", - "docstrings": [], - "signature": "type htmlTableCellElement = htmlElement_like<\n _htmlTableCellElement,\n>" - }, - { - "id": "Dom._htmlTableColElement", - "kind": "type", - "name": "_htmlTableColElement", - "docstrings": [], - "signature": "type _htmlTableColElement" - }, - { - "id": "Dom.htmlTableColElement", - "kind": "type", - "name": "htmlTableColElement", - "docstrings": [], - "signature": "type htmlTableColElement = htmlElement_like<\n _htmlTableColElement,\n>" - }, - { - "id": "Dom._htmlTableDataCellElement", - "kind": "type", - "name": "_htmlTableDataCellElement", - "docstrings": [], - "signature": "type _htmlTableDataCellElement" - }, - { - "id": "Dom.htmlTableDataCellElement", - "kind": "type", - "name": "htmlTableDataCellElement", - "docstrings": [], - "signature": "type htmlTableDataCellElement = htmlElement_like<\n _htmlTableDataCellElement,\n>" - }, - { - "id": "Dom._htmlTableElement", - "kind": "type", - "name": "_htmlTableElement", - "docstrings": [], - "signature": "type _htmlTableElement" - }, - { - "id": "Dom.htmlTableElement", - "kind": "type", - "name": "htmlTableElement", - "docstrings": [], - "signature": "type htmlTableElement = htmlElement_like<_htmlTableElement>" - }, - { - "id": "Dom._htmlTableHeaderCellElement", - "kind": "type", - "name": "_htmlTableHeaderCellElement", - "docstrings": [], - "signature": "type _htmlTableHeaderCellElement" - }, - { - "id": "Dom.htmlTableHeaderCellElement", - "kind": "type", - "name": "htmlTableHeaderCellElement", - "docstrings": [], - "signature": "type htmlTableHeaderCellElement = htmlElement_like<\n _htmlTableHeaderCellElement,\n>" - }, - { - "id": "Dom._htmlTableRowElement", - "kind": "type", - "name": "_htmlTableRowElement", - "docstrings": [], - "signature": "type _htmlTableRowElement" - }, - { - "id": "Dom.htmlTableRowElement", - "kind": "type", - "name": "htmlTableRowElement", - "docstrings": [], - "signature": "type htmlTableRowElement = htmlElement_like<\n _htmlTableRowElement,\n>" - }, - { - "id": "Dom._htmlTableSectionElement", - "kind": "type", - "name": "_htmlTableSectionElement", - "docstrings": [], - "signature": "type _htmlTableSectionElement" - }, - { - "id": "Dom.htmlTableSectionElement", - "kind": "type", - "name": "htmlTableSectionElement", - "docstrings": [], - "signature": "type htmlTableSectionElement = htmlElement_like<\n _htmlTableSectionElement,\n>" - }, - { - "id": "Dom._htmlTextAreaElement", - "kind": "type", - "name": "_htmlTextAreaElement", - "docstrings": [], - "signature": "type _htmlTextAreaElement" - }, - { - "id": "Dom.htmlTextAreaElement", - "kind": "type", - "name": "htmlTextAreaElement", - "docstrings": [], - "signature": "type htmlTextAreaElement = htmlElement_like<\n _htmlTextAreaElement,\n>" - }, - { - "id": "Dom._htmlTimeElement", - "kind": "type", - "name": "_htmlTimeElement", - "docstrings": [], - "signature": "type _htmlTimeElement" - }, - { - "id": "Dom.htmlTimeElement", - "kind": "type", - "name": "htmlTimeElement", - "docstrings": [], - "signature": "type htmlTimeElement = htmlElement_like<_htmlTimeElement>" - }, - { - "id": "Dom._htmlTitleElement", - "kind": "type", - "name": "_htmlTitleElement", - "docstrings": [], - "signature": "type _htmlTitleElement" - }, - { - "id": "Dom.htmlTitleElement", - "kind": "type", - "name": "htmlTitleElement", - "docstrings": [], - "signature": "type htmlTitleElement = htmlElement_like<_htmlTitleElement>" - }, - { - "id": "Dom._htmlTrackElement", - "kind": "type", - "name": "_htmlTrackElement", - "docstrings": [], - "signature": "type _htmlTrackElement" - }, - { - "id": "Dom.htmlTrackElement", - "kind": "type", - "name": "htmlTrackElement", - "docstrings": [], - "signature": "type htmlTrackElement = htmlElement_like<_htmlTrackElement>" - }, - { - "id": "Dom._htmlUlistElement", - "kind": "type", - "name": "_htmlUlistElement", - "docstrings": [], - "signature": "type _htmlUlistElement" - }, - { - "id": "Dom.htmlUlistElement", - "kind": "type", - "name": "htmlUlistElement", - "docstrings": [], - "signature": "type htmlUlistElement = htmlElement_like<_htmlUlistElement>" - }, - { - "id": "Dom._htmlUnknownElement", - "kind": "type", - "name": "_htmlUnknownElement", - "docstrings": [], - "signature": "type _htmlUnknownElement" - }, - { - "id": "Dom.htmlUnknownElement", - "kind": "type", - "name": "htmlUnknownElement", - "docstrings": [], - "signature": "type htmlUnknownElement = htmlElement_like<\n _htmlUnknownElement,\n>" - }, - { - "id": "Dom._htmlVideoElement", - "kind": "type", - "name": "_htmlVideoElement", - "docstrings": [], - "signature": "type _htmlVideoElement" - }, - { - "id": "Dom.htmlVideoElement", - "kind": "type", - "name": "htmlVideoElement", - "docstrings": [], - "signature": "type htmlVideoElement = htmlElement_like<_htmlVideoElement>" - }, - { - "id": "Dom.location", - "kind": "type", - "name": "location", - "docstrings": [], - "signature": "type location" - }, - { - "id": "Dom.window", - "kind": "type", - "name": "window", - "docstrings": [], - "signature": "type window" - }, - { - "id": "Dom._xmlDocument", - "kind": "type", - "name": "_xmlDocument", - "docstrings": [], - "signature": "type _xmlDocument" - }, - { - "id": "Dom.xmlDocument", - "kind": "type", - "name": "xmlDocument", - "docstrings": [], - "signature": "type xmlDocument = document_like<_xmlDocument>" - }, - { - "id": "Dom.event_like", - "kind": "type", - "name": "event_like", - "docstrings": [], - "signature": "type event_like<'a>" - }, - { - "id": "Dom.event", - "kind": "type", - "name": "event", - "docstrings": [], - "signature": "type event = event_like<_baseClass>" - }, - { - "id": "Dom._uiEvent", - "kind": "type", - "name": "_uiEvent", - "docstrings": [], - "signature": "type _uiEvent<'a>" - }, - { - "id": "Dom.uiEvent_like", - "kind": "type", - "name": "uiEvent_like", - "docstrings": [], - "signature": "type uiEvent_like<'a> = event_like<_uiEvent<'a>>" - }, - { - "id": "Dom.uiEvent", - "kind": "type", - "name": "uiEvent", - "docstrings": [], - "signature": "type uiEvent = uiEvent_like<_baseClass>" - }, - { - "id": "Dom._animationEvent", - "kind": "type", - "name": "_animationEvent", - "docstrings": [], - "signature": "type _animationEvent" - }, - { - "id": "Dom.animationEvent", - "kind": "type", - "name": "animationEvent", - "docstrings": [], - "signature": "type animationEvent = event_like<_animationEvent>" - }, - { - "id": "Dom._beforeUnloadEvent", - "kind": "type", - "name": "_beforeUnloadEvent", - "docstrings": [], - "signature": "type _beforeUnloadEvent" - }, - { - "id": "Dom.beforeUnloadEvent", - "kind": "type", - "name": "beforeUnloadEvent", - "docstrings": [], - "signature": "type beforeUnloadEvent = event_like<_beforeUnloadEvent>" - }, - { - "id": "Dom._clipboardEvent", - "kind": "type", - "name": "_clipboardEvent", - "docstrings": [], - "signature": "type _clipboardEvent" - }, - { - "id": "Dom.clipboardEvent", - "kind": "type", - "name": "clipboardEvent", - "docstrings": [], - "signature": "type clipboardEvent = event_like<_clipboardEvent>" - }, - { - "id": "Dom._closeEvent", - "kind": "type", - "name": "_closeEvent", - "docstrings": [], - "signature": "type _closeEvent" - }, - { - "id": "Dom.closeEvent", - "kind": "type", - "name": "closeEvent", - "docstrings": [], - "signature": "type closeEvent = event_like<_closeEvent>" - }, - { - "id": "Dom._compositionEvent", - "kind": "type", - "name": "_compositionEvent", - "docstrings": [], - "signature": "type _compositionEvent" - }, - { - "id": "Dom.compositionEvent", - "kind": "type", - "name": "compositionEvent", - "docstrings": [], - "signature": "type compositionEvent = uiEvent_like<_compositionEvent>" - }, - { - "id": "Dom._customEvent", - "kind": "type", - "name": "_customEvent", - "docstrings": [], - "signature": "type _customEvent" - }, - { - "id": "Dom.customEvent", - "kind": "type", - "name": "customEvent", - "docstrings": [], - "signature": "type customEvent = event_like<_customEvent>" - }, - { - "id": "Dom._dragEvent", - "kind": "type", - "name": "_dragEvent", - "docstrings": [], - "signature": "type _dragEvent" - }, - { - "id": "Dom.dragEvent", - "kind": "type", - "name": "dragEvent", - "docstrings": [], - "signature": "type dragEvent = event_like<_dragEvent>" - }, - { - "id": "Dom._errorEvent", - "kind": "type", - "name": "_errorEvent", - "docstrings": [], - "signature": "type _errorEvent" - }, - { - "id": "Dom.errorEvent", - "kind": "type", - "name": "errorEvent", - "docstrings": [], - "signature": "type errorEvent = event_like<_errorEvent>" - }, - { - "id": "Dom._focusEvent", - "kind": "type", - "name": "_focusEvent", - "docstrings": [], - "signature": "type _focusEvent" - }, - { - "id": "Dom.focusEvent", - "kind": "type", - "name": "focusEvent", - "docstrings": [], - "signature": "type focusEvent = uiEvent_like<_focusEvent>" - }, - { - "id": "Dom._idbVersionChangeEvent", - "kind": "type", - "name": "_idbVersionChangeEvent", - "docstrings": [], - "signature": "type _idbVersionChangeEvent" - }, - { - "id": "Dom.idbVersionChangeEvent", - "kind": "type", - "name": "idbVersionChangeEvent", - "docstrings": [], - "signature": "type idbVersionChangeEvent = event_like<\n _idbVersionChangeEvent,\n>" - }, - { - "id": "Dom._inputEvent", - "kind": "type", - "name": "_inputEvent", - "docstrings": [], - "signature": "type _inputEvent" - }, - { - "id": "Dom.inputEvent", - "kind": "type", - "name": "inputEvent", - "docstrings": [], - "signature": "type inputEvent = uiEvent_like<_inputEvent>" - }, - { - "id": "Dom._keyboardEvent", - "kind": "type", - "name": "_keyboardEvent", - "docstrings": [], - "signature": "type _keyboardEvent" - }, - { - "id": "Dom.keyboardEvent", - "kind": "type", - "name": "keyboardEvent", - "docstrings": [], - "signature": "type keyboardEvent = uiEvent_like<_keyboardEvent>" - }, - { - "id": "Dom._mouseEvent", - "kind": "type", - "name": "_mouseEvent", - "docstrings": [], - "signature": "type _mouseEvent<'a>" - }, - { - "id": "Dom.mouseEvent_like", - "kind": "type", - "name": "mouseEvent_like", - "docstrings": [], - "signature": "type mouseEvent_like<'a> = uiEvent_like<_mouseEvent<'a>>" - }, - { - "id": "Dom.mouseEvent", - "kind": "type", - "name": "mouseEvent", - "docstrings": [], - "signature": "type mouseEvent = mouseEvent_like<_baseClass>" - }, - { - "id": "Dom._pageTransitionEvent", - "kind": "type", - "name": "_pageTransitionEvent", - "docstrings": [], - "signature": "type _pageTransitionEvent" - }, - { - "id": "Dom.pageTransitionEvent", - "kind": "type", - "name": "pageTransitionEvent", - "docstrings": [], - "signature": "type pageTransitionEvent = event_like<_pageTransitionEvent>" - }, - { - "id": "Dom._pointerEvent", - "kind": "type", - "name": "_pointerEvent", - "docstrings": [], - "signature": "type _pointerEvent" - }, - { - "id": "Dom.pointerEvent", - "kind": "type", - "name": "pointerEvent", - "docstrings": [], - "signature": "type pointerEvent = mouseEvent_like<_pointerEvent>" - }, - { - "id": "Dom._popStateEvent", - "kind": "type", - "name": "_popStateEvent", - "docstrings": [], - "signature": "type _popStateEvent" - }, - { - "id": "Dom.popStateEvent", - "kind": "type", - "name": "popStateEvent", - "docstrings": [], - "signature": "type popStateEvent = event_like<_popStateEvent>" - }, - { - "id": "Dom._progressEvent", - "kind": "type", - "name": "_progressEvent", - "docstrings": [], - "signature": "type _progressEvent" - }, - { - "id": "Dom.progressEvent", - "kind": "type", - "name": "progressEvent", - "docstrings": [], - "signature": "type progressEvent = event_like<_progressEvent>" - }, - { - "id": "Dom._relatedEvent", - "kind": "type", - "name": "_relatedEvent", - "docstrings": [], - "signature": "type _relatedEvent" - }, - { - "id": "Dom.relatedEvent", - "kind": "type", - "name": "relatedEvent", - "docstrings": [], - "signature": "type relatedEvent = event_like<_relatedEvent>" - }, - { - "id": "Dom._storageEvent", - "kind": "type", - "name": "_storageEvent", - "docstrings": [], - "signature": "type _storageEvent" - }, - { - "id": "Dom.storageEvent", - "kind": "type", - "name": "storageEvent", - "docstrings": [], - "signature": "type storageEvent = event_like<_storageEvent>" - }, - { - "id": "Dom._svgZoomEvent", - "kind": "type", - "name": "_svgZoomEvent", - "docstrings": [], - "signature": "type _svgZoomEvent" - }, - { - "id": "Dom.svgZoomEvent", - "kind": "type", - "name": "svgZoomEvent", - "docstrings": [], - "signature": "type svgZoomEvent = event_like<_svgZoomEvent>" - }, - { - "id": "Dom._timeEvent", - "kind": "type", - "name": "_timeEvent", - "docstrings": [], - "signature": "type _timeEvent" - }, - { - "id": "Dom.timeEvent", - "kind": "type", - "name": "timeEvent", - "docstrings": [], - "signature": "type timeEvent = event_like<_timeEvent>" - }, - { - "id": "Dom._touchEvent", - "kind": "type", - "name": "_touchEvent", - "docstrings": [], - "signature": "type _touchEvent" - }, - { - "id": "Dom.touchEvent", - "kind": "type", - "name": "touchEvent", - "docstrings": [], - "signature": "type touchEvent = uiEvent_like<_touchEvent>" - }, - { - "id": "Dom._trackEvent", - "kind": "type", - "name": "_trackEvent", - "docstrings": [], - "signature": "type _trackEvent" - }, - { - "id": "Dom.trackEvent", - "kind": "type", - "name": "trackEvent", - "docstrings": [], - "signature": "type trackEvent = event_like<_trackEvent>" - }, - { - "id": "Dom._transitionEvent", - "kind": "type", - "name": "_transitionEvent", - "docstrings": [], - "signature": "type _transitionEvent" - }, - { - "id": "Dom.transitionEvent", - "kind": "type", - "name": "transitionEvent", - "docstrings": [], - "signature": "type transitionEvent = event_like<_transitionEvent>" - }, - { - "id": "Dom._webGlContextEvent", - "kind": "type", - "name": "_webGlContextEvent", - "docstrings": [], - "signature": "type _webGlContextEvent" - }, - { - "id": "Dom.webGlContextEvent", - "kind": "type", - "name": "webGlContextEvent", - "docstrings": [], - "signature": "type webGlContextEvent = event_like<_webGlContextEvent>" - }, - { - "id": "Dom._wheelEvent", - "kind": "type", - "name": "_wheelEvent", - "docstrings": [], - "signature": "type _wheelEvent" - }, - { - "id": "Dom.wheelEvent", - "kind": "type", - "name": "wheelEvent", - "docstrings": [], - "signature": "type wheelEvent = uiEvent_like<_wheelEvent>" - }, - { - "id": "Dom.range", - "kind": "type", - "name": "range", - "docstrings": [], - "signature": "type range" - }, - { - "id": "Dom.selection", - "kind": "type", - "name": "selection", - "docstrings": [], - "signature": "type selection" - }, - { - "id": "Dom.domTokenList", - "kind": "type", - "name": "domTokenList", - "docstrings": [], - "signature": "type domTokenList" - }, - { - "id": "Dom.domSettableTokenList", - "kind": "type", - "name": "domSettableTokenList", - "docstrings": [], - "signature": "type domSettableTokenList" - }, - { - "id": "Dom.nodeFilter", - "kind": "type", - "name": "nodeFilter", - "docstrings": [], - "signature": "type nodeFilter = {acceptNode: element => int}" - }, - { - "id": "Dom.nodeIterator", - "kind": "type", - "name": "nodeIterator", - "docstrings": [], - "signature": "type nodeIterator" - }, - { - "id": "Dom.treeWalker", - "kind": "type", - "name": "treeWalker", - "docstrings": [], - "signature": "type treeWalker" - }, - { - "id": "Dom.svgRect", - "kind": "type", - "name": "svgRect", - "docstrings": [], - "signature": "type svgRect" - }, - { - "id": "Dom.svgPoint", - "kind": "type", - "name": "svgPoint", - "docstrings": [], - "signature": "type svgPoint" - }, - { - "id": "Dom.eventPointerId", - "kind": "type", - "name": "eventPointerId", - "docstrings": [], - "signature": "type eventPointerId" - } - ] - }, - "dom/storage2": { - "id": "Dom.Storage2", - "name": "Storage2", - "docstrings": [], - "items": [ - { - "id": "Dom.Storage2.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Dom.Storage2.getItem", - "kind": "value", - "name": "getItem", - "docstrings": [], - "signature": "let getItem: (t, string) => option" - }, - { - "id": "Dom.Storage2.setItem", - "kind": "value", - "name": "setItem", - "docstrings": [], - "signature": "let setItem: (t, string, string) => unit" - }, - { - "id": "Dom.Storage2.removeItem", - "kind": "value", - "name": "removeItem", - "docstrings": [], - "signature": "let removeItem: (t, string) => unit" - }, - { - "id": "Dom.Storage2.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t => unit" - }, - { - "id": "Dom.Storage2.key", - "kind": "value", - "name": "key", - "docstrings": [], - "signature": "let key: (t, int) => option" - }, - { - "id": "Dom.Storage2.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Dom.Storage2.localStorage", - "kind": "value", - "name": "localStorage", - "docstrings": [], - "signature": "let localStorage: t" - }, - { - "id": "Dom.Storage2.sessionStorage", - "kind": "value", - "name": "sessionStorage", - "docstrings": [], - "signature": "let sessionStorage: t" - } - ] - }, - "dom/storage": { - "id": "Dom.Storage", - "name": "Storage", - "docstrings": [], - "items": [ - { - "id": "Dom.Storage.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = Dom_storage2.t" - }, - { - "id": "Dom.Storage.getItem", - "kind": "value", - "name": "getItem", - "docstrings": [], - "signature": "let getItem: (t, string) => option" - }, - { - "id": "Dom.Storage.getItem", - "kind": "value", - "name": "getItem", - "docstrings": [], - "signature": "let getItem: (string, t) => option" - }, - { - "id": "Dom.Storage.setItem", - "kind": "value", - "name": "setItem", - "docstrings": [], - "signature": "let setItem: (t, string, string) => unit" - }, - { - "id": "Dom.Storage.setItem", - "kind": "value", - "name": "setItem", - "docstrings": [], - "signature": "let setItem: (string, string, t) => unit" - }, - { - "id": "Dom.Storage.removeItem", - "kind": "value", - "name": "removeItem", - "docstrings": [], - "signature": "let removeItem: (t, string) => unit" - }, - { - "id": "Dom.Storage.removeItem", - "kind": "value", - "name": "removeItem", - "docstrings": [], - "signature": "let removeItem: (string, t) => unit" - }, - { - "id": "Dom.Storage.clear", - "kind": "value", - "name": "clear", - "docstrings": [], - "signature": "let clear: t => unit" - }, - { - "id": "Dom.Storage.key", - "kind": "value", - "name": "key", - "docstrings": [], - "signature": "let key: (t, int) => option" - }, - { - "id": "Dom.Storage.key", - "kind": "value", - "name": "key", - "docstrings": [], - "signature": "let key: (int, t) => option" - }, - { - "id": "Dom.Storage.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Dom.Storage.localStorage", - "kind": "value", - "name": "localStorage", - "docstrings": [], - "signature": "let localStorage: t" - }, - { - "id": "Dom.Storage.sessionStorage", - "kind": "value", - "name": "sessionStorage", - "docstrings": [], - "signature": "let sessionStorage: t" - } - ] - } -} diff --git a/data/api/v11.0.0/js.json b/data/api/v11.0.0/js.json deleted file mode 100644 index 7a4edda29..000000000 --- a/data/api/v11.0.0/js.json +++ /dev/null @@ -1,14747 +0,0 @@ -{ - "js": { - "id": "Js", - "name": "Js", - "docstrings": [ - "The Js module mostly contains ReScript bindings to _standard JavaScript APIs_\nlike [console.log](https://developer.mozilla.org/en-US/docs/Web/API/Console/log),\nor the JavaScript\n[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String),\n[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date), and\n[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\nclasses.\n\nIt 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)\n\n## Argument Order\n\nFor historical reasons, some APIs in the Js namespace (e.g. [Js.String](js/string)) are\nusing the data-last argument order whereas others (e.g. [Js.Date](js/date)) are using data-first.\n\nFor more information about these argument orders and the trade-offs between them, see\n[this blog post](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/).\n\n_Eventually, all modules in the Js namespace are going to be migrated to data-first though._\n\nIn the meantime, there are several options for dealing with the data-last APIs:\n\n## Examples\n\n```rescript\n/* Js.String (data-last API used with pipe last operator) */\nJs.log(\"2019-11-10\" |> Js.String.split(\"-\"))\nJs.log(\"ReScript\" |> Js.String.startsWith(\"Re\"))\n\n/* Js.String (data-last API used with pipe first operator) */\nJs.log(\"2019-11-10\"->Js.String.split(\"-\", _))\nJs.log(\"ReScript\"->Js.String.startsWith(\"Re\", _))\n\n/* Js.String (data-last API used without any piping) */\nJs.log(Js.String.split(\"-\", \"2019-11-10\"))\nJs.log(Js.String.startsWith(\"Re\", \"ReScript\"))\n```\n## Js.Xxx2 Modules\n\nPrefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latters are old modules." - ], - "items": [ - { - "id": "Js.t", - "kind": "type", - "name": "t", - "docstrings": ["JS object type"], - "signature": "type t<'a> = 'a\n constraint 'a = {..}" - }, - { - "id": "Js.null", - "kind": "type", - "name": "null", - "docstrings": [ - "Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t." - ], - "signature": "type null<'a> = Value('a) | Null" - }, - { - "id": "Js.undefined", - "kind": "type", - "name": "undefined", - "docstrings": [ - "A value of this type can be either undefined or 'a. This type is equivalent to Js.Undefined.t." - ], - "signature": "type undefined<+'a>" - }, - { - "id": "Js.nullable", - "kind": "type", - "name": "nullable", - "docstrings": [], - "signature": "type nullable<'a> = Value('a) | Null | Undefined" - }, - { - "id": "Js.null_undefined", - "kind": "type", - "name": "null_undefined", - "docstrings": [], - "signature": "type null_undefined<'a> = nullable<'a>" - }, - { - "id": "Js.toOption", - "kind": "value", - "name": "toOption", - "docstrings": [], - "signature": "let toOption: nullable<'a> => option<'a>" - }, - { - "id": "Js.undefinedToOption", - "kind": "value", - "name": "undefinedToOption", - "docstrings": [], - "signature": "let undefinedToOption: undefined<'a> => option<'a>" - }, - { - "id": "Js.nullToOption", - "kind": "value", - "name": "nullToOption", - "docstrings": [], - "signature": "let nullToOption: null<'a> => option<'a>" - }, - { - "id": "Js.isNullable", - "kind": "value", - "name": "isNullable", - "docstrings": [], - "signature": "let isNullable: nullable<'a> => bool" - }, - { - "id": "Js.import", - "kind": "value", - "name": "import", - "docstrings": [], - "signature": "let import: 'a => promise<'a>" - }, - { - "id": "Js.testAny", - "kind": "value", - "name": "testAny", - "docstrings": [ - "The same as {!test} except that it is more permissive on the types of input" - ], - "signature": "let testAny: 'a => bool" - }, - { - "id": "Js.promise", - "kind": "type", - "name": "promise", - "docstrings": [ - "The promise type, defined here for interoperation across packages." - ], - "signature": "type promise<+'a, +'e>" - }, - { - "id": "Js.null", - "kind": "value", - "name": "null", - "docstrings": ["The same as empty in `Js.Null`. Compiles to `null`."], - "signature": "let null: null<'a>" - }, - { - "id": "Js.undefined", - "kind": "value", - "name": "undefined", - "docstrings": [ - "The same as empty `Js.Undefined`. Compiles to `undefined`." - ], - "signature": "let undefined: undefined<'a>" - }, - { - "id": "Js.typeof", - "kind": "value", - "name": "typeof", - "docstrings": [ - "`typeof x` will be compiled as `typeof x` in JS. Please consider functions in\n`Js.Types` for a type safe way of reflection." - ], - "signature": "let typeof: 'a => string" - }, - { - "id": "Js.log", - "kind": "value", - "name": "log", - "docstrings": ["Equivalent to console.log any value."], - "signature": "let log: 'a => unit" - }, - { - "id": "Js.log2", - "kind": "value", - "name": "log2", - "docstrings": [], - "signature": "let log2: ('a, 'b) => unit" - }, - { - "id": "Js.log3", - "kind": "value", - "name": "log3", - "docstrings": [], - "signature": "let log3: ('a, 'b, 'c) => unit" - }, - { - "id": "Js.log4", - "kind": "value", - "name": "log4", - "docstrings": [], - "signature": "let log4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Js.logMany", - "kind": "value", - "name": "logMany", - "docstrings": [ - "A convenience function to console.log more than 4 arguments" - ], - "signature": "let logMany: array<'a> => unit" - }, - { - "id": "Js.eqNull", - "kind": "value", - "name": "eqNull", - "docstrings": [], - "signature": "let eqNull: ('a, null<'a>) => bool" - }, - { - "id": "Js.eqUndefined", - "kind": "value", - "name": "eqUndefined", - "docstrings": [], - "signature": "let eqUndefined: ('a, undefined<'a>) => bool" - }, - { - "id": "Js.eqNullable", - "kind": "value", - "name": "eqNullable", - "docstrings": [], - "signature": "let eqNullable: ('a, nullable<'a>) => bool" - }, - { - "id": "Js.unsafe_lt", - "kind": "value", - "name": "unsafe_lt", - "docstrings": [ - "`unsafe_lt(a, b)` will be compiled as `a < b`.\n It is marked as unsafe, since it is impossible\n to give a proper semantics for comparision which applies to any type" - ], - "signature": "let unsafe_lt: ('a, 'a) => bool" - }, - { - "id": "Js.unsafe_le", - "kind": "value", - "name": "unsafe_le", - "docstrings": [ - "`unsafe_le(a, b)` will be compiled as `a <= b`.\n See also `Js.unsafe_lt`." - ], - "signature": "let unsafe_le: ('a, 'a) => bool" - }, - { - "id": "Js.unsafe_gt", - "kind": "value", - "name": "unsafe_gt", - "docstrings": [ - "`unsafe_gt(a, b)` will be compiled as `a > b`.\n See also `Js.unsafe_lt`." - ], - "signature": "let unsafe_gt: ('a, 'a) => bool" - }, - { - "id": "Js.unsafe_ge", - "kind": "value", - "name": "unsafe_ge", - "docstrings": [ - "`unsafe_ge(a, b)` will be compiled as `a >= b`.\n See also `Js.unsafe_lt`." - ], - "signature": "let unsafe_ge: ('a, 'a) => bool" - } - ] - }, - "js/typedarray2/dataview": { - "id": "Js.TypedArray2.DataView", - "name": "DataView", - "docstrings": [ - "The DataView view provides a low-level interface for reading and writing\nmultiple number types in an ArrayBuffer irrespective of the platform's endianness.\n\n**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)" - ], - "items": [ - { - "id": "Js.TypedArray2.DataView.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Js.TypedArray2.DataView.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array_buffer => t" - }, - { - "id": "Js.TypedArray2.DataView.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.DataView.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.DataView.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.DataView.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.DataView.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.DataView.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.DataView.getInt8", - "kind": "value", - "name": "getInt8", - "docstrings": [], - "signature": "let getInt8: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getUint8", - "kind": "value", - "name": "getUint8", - "docstrings": [], - "signature": "let getUint8: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getInt16", - "kind": "value", - "name": "getInt16", - "docstrings": [], - "signature": "let getInt16: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getInt16LittleEndian", - "kind": "value", - "name": "getInt16LittleEndian", - "docstrings": [], - "signature": "let getInt16LittleEndian: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getUint16", - "kind": "value", - "name": "getUint16", - "docstrings": [], - "signature": "let getUint16: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getUint16LittleEndian", - "kind": "value", - "name": "getUint16LittleEndian", - "docstrings": [], - "signature": "let getUint16LittleEndian: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getInt32", - "kind": "value", - "name": "getInt32", - "docstrings": [], - "signature": "let getInt32: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getInt32LittleEndian", - "kind": "value", - "name": "getInt32LittleEndian", - "docstrings": [], - "signature": "let getInt32LittleEndian: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getUint32", - "kind": "value", - "name": "getUint32", - "docstrings": [], - "signature": "let getUint32: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getUint32LittleEndian", - "kind": "value", - "name": "getUint32LittleEndian", - "docstrings": [], - "signature": "let getUint32LittleEndian: (t, int) => int" - }, - { - "id": "Js.TypedArray2.DataView.getFloat32", - "kind": "value", - "name": "getFloat32", - "docstrings": [], - "signature": "let getFloat32: (t, int) => float" - }, - { - "id": "Js.TypedArray2.DataView.getFloat32LittleEndian", - "kind": "value", - "name": "getFloat32LittleEndian", - "docstrings": [], - "signature": "let getFloat32LittleEndian: (t, int) => float" - }, - { - "id": "Js.TypedArray2.DataView.getFloat64", - "kind": "value", - "name": "getFloat64", - "docstrings": [], - "signature": "let getFloat64: (t, int) => float" - }, - { - "id": "Js.TypedArray2.DataView.getFloat64LittleEndian", - "kind": "value", - "name": "getFloat64LittleEndian", - "docstrings": [], - "signature": "let getFloat64LittleEndian: (t, int) => float" - }, - { - "id": "Js.TypedArray2.DataView.setInt8", - "kind": "value", - "name": "setInt8", - "docstrings": [], - "signature": "let setInt8: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setUint8", - "kind": "value", - "name": "setUint8", - "docstrings": [], - "signature": "let setUint8: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setInt16", - "kind": "value", - "name": "setInt16", - "docstrings": [], - "signature": "let setInt16: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setInt16LittleEndian", - "kind": "value", - "name": "setInt16LittleEndian", - "docstrings": [], - "signature": "let setInt16LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setUint16", - "kind": "value", - "name": "setUint16", - "docstrings": [], - "signature": "let setUint16: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setUint16LittleEndian", - "kind": "value", - "name": "setUint16LittleEndian", - "docstrings": [], - "signature": "let setUint16LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setInt32", - "kind": "value", - "name": "setInt32", - "docstrings": [], - "signature": "let setInt32: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setInt32LittleEndian", - "kind": "value", - "name": "setInt32LittleEndian", - "docstrings": [], - "signature": "let setInt32LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setUint32", - "kind": "value", - "name": "setUint32", - "docstrings": [], - "signature": "let setUint32: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setUint32LittleEndian", - "kind": "value", - "name": "setUint32LittleEndian", - "docstrings": [], - "signature": "let setUint32LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setFloat32", - "kind": "value", - "name": "setFloat32", - "docstrings": [], - "signature": "let setFloat32: (t, int, float) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setFloat32LittleEndian", - "kind": "value", - "name": "setFloat32LittleEndian", - "docstrings": [], - "signature": "let setFloat32LittleEndian: (t, int, float) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setFloat64", - "kind": "value", - "name": "setFloat64", - "docstrings": [], - "signature": "let setFloat64: (t, int, float) => unit" - }, - { - "id": "Js.TypedArray2.DataView.setFloat64LittleEndian", - "kind": "value", - "name": "setFloat64LittleEndian", - "docstrings": [], - "signature": "let setFloat64LittleEndian: (t, int, float) => unit" - } - ] - }, - "js/typedarray2/float64array": { - "id": "Js.TypedArray2.Float64Array", - "name": "Float64Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Float64Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = float" - }, - { - "id": "Js.TypedArray2.Float64Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Float64Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Float64Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Float64Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Float64Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Float64Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Float64Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Float64Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Float64Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Float64Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Float64Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Float64Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Float64Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Float64Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Float64Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Float64Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Float64Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Float64Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Float64Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Float64Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Float64Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Float64Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Float64Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float64Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float64Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Float64Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Float64Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Float64Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Float64Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Float64Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Float64Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Float64Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Float64Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float64Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float64Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float64Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float64Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float64Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float64Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Float64Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Float64Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Float64Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Float64Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Float64Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/float32array": { - "id": "Js.TypedArray2.Float32Array", - "name": "Float32Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Float32Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = float" - }, - { - "id": "Js.TypedArray2.Float32Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Float32Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Float32Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Float32Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Float32Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Float32Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Float32Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Float32Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Float32Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Float32Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Float32Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Float32Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Float32Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Float32Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Float32Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Float32Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Float32Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Float32Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Float32Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Float32Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Float32Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Float32Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Float32Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float32Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float32Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Float32Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Float32Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Float32Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Float32Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Float32Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Float32Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Float32Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Float32Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float32Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float32Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float32Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Float32Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float32Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Float32Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Float32Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Float32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Float32Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Float32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Float32Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/uint32array": { - "id": "Js.TypedArray2.Uint32Array", - "name": "Uint32Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Uint32Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.TypedArray2.Uint32Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Uint32Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Uint32Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Uint32Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Uint32Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Uint32Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Uint32Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Uint32Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Uint32Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Uint32Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Uint32Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Uint32Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Uint32Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint32Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint32Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint32Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint32Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint32Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint32Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint32Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint32Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint32Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint32Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint32Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint32Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint32Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint32Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint32Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Uint32Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Uint32Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/int32array": { - "id": "Js.TypedArray2.Int32Array", - "name": "Int32Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Int32Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.TypedArray2.Int32Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Int32Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Int32Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Int32Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Int32Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Int32Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Int32Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Int32Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Int32Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Int32Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Int32Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Int32Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Int32Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Int32Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Int32Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Int32Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Int32Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Int32Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Int32Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Int32Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Int32Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Int32Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Int32Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int32Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int32Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Int32Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Int32Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Int32Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Int32Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Int32Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Int32Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Int32Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Int32Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int32Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int32Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int32Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int32Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int32Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int32Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Int32Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Int32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Int32Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Int32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Int32Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/uint16array": { - "id": "Js.TypedArray2.Uint16Array", - "name": "Uint16Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Uint16Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.TypedArray2.Uint16Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Uint16Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Uint16Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Uint16Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Uint16Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Uint16Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Uint16Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Uint16Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Uint16Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Uint16Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Uint16Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Uint16Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Uint16Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint16Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint16Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint16Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint16Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint16Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint16Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint16Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint16Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint16Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint16Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint16Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint16Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint16Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint16Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint16Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Uint16Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Uint16Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/int16array": { - "id": "Js.TypedArray2.Int16Array", - "name": "Int16Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Int16Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.TypedArray2.Int16Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Int16Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Int16Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Int16Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Int16Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Int16Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Int16Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Int16Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Int16Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Int16Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Int16Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Int16Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Int16Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Int16Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Int16Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Int16Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Int16Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Int16Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Int16Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Int16Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Int16Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Int16Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Int16Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int16Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int16Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Int16Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Int16Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Int16Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Int16Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Int16Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Int16Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Int16Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Int16Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int16Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int16Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int16Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int16Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int16Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int16Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Int16Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Int16Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Int16Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Int16Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Int16Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/uint8clampedarray": { - "id": "Js.TypedArray2.Uint8ClampedArray", - "name": "Uint8ClampedArray", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Uint8ClampedArray.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Uint8ClampedArray.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/uint8array": { - "id": "Js.TypedArray2.Uint8Array", - "name": "Uint8Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Uint8Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.TypedArray2.Uint8Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Uint8Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Uint8Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Uint8Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Uint8Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Uint8Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Uint8Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Uint8Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Uint8Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Uint8Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Uint8Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Uint8Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Uint8Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint8Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Uint8Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Uint8Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint8Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Uint8Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint8Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Uint8Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Uint8Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Uint8Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Uint8Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Uint8Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/int8array": { - "id": "Js.TypedArray2.Int8Array", - "name": "Int8Array", - "docstrings": [], - "items": [ - { - "id": "Js.TypedArray2.Int8Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.TypedArray2.Int8Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.TypedArray2.Int8Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.TypedArray2.Int8Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.TypedArray2.Int8Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.TypedArray2.Int8Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.TypedArray2.Int8Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.Int8Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.TypedArray2.Int8Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (t, array) => unit" - }, - { - "id": "Js.TypedArray2.Int8Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (t, array, int) => unit" - }, - { - "id": "Js.TypedArray2.Int8Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.TypedArray2.Int8Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (t, ~to_: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (t, ~to_: int, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (t, elt) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (t, elt, ~from: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Int8Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.TypedArray2.Int8Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (t, (elt, elt) => int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, elt) => bool" - }, - { - "id": "Js.TypedArray2.Int8Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Int8Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Int8Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.TypedArray2.Int8Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (t, string) => string" - }, - { - "id": "Js.TypedArray2.Int8Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, elt) => int" - }, - { - "id": "Js.TypedArray2.Int8Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, elt, ~from: int) => int" - }, - { - "id": "Js.TypedArray2.Int8Array.slice", - "kind": "value", - "name": "slice", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let slice: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.TypedArray2.Int8Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": ["`start` is inclusive, `end_` exclusive"], - "signature": "let subarray: (t, ~start: int, ~end_: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (t, int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.TypedArray2.Int8Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.TypedArray2.Int8Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int8Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int8Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (t, elt => bool) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (t, (elt, int) => bool) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (t, elt => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Int8Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (t, (elt, int) => bool) => Js.undefined" - }, - { - "id": "Js.TypedArray2.Int8Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (t, elt => bool) => int" - }, - { - "id": "Js.TypedArray2.Int8Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (t, (elt, int) => bool) => int" - }, - { - "id": "Js.TypedArray2.Int8Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (t, elt => unit) => unit" - }, - { - "id": "Js.TypedArray2.Int8Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (t, (elt, int) => unit) => unit" - }, - { - "id": "Js.TypedArray2.Int8Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (t, elt => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Int8Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (t, (elt, int) => 'b) => typed_array<'b>" - }, - { - "id": "Js.TypedArray2.Int8Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int8Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int8Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (t, ('b, elt) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int8Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.TypedArray2.Int8Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (t, elt => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int8Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (t, (elt, int) => bool) => bool" - }, - { - "id": "Js.TypedArray2.Int8Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.TypedArray2.Int8Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.TypedArray2.Int8Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.TypedArray2.Int8Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.TypedArray2.Int8Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.TypedArray2.Int8Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typedarray2/arraybuffer": { - "id": "Js.TypedArray2.ArrayBuffer", - "name": "ArrayBuffer", - "docstrings": [ - "The underlying buffer that the typed arrays provide views of\n\n **see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)" - ], - "items": [ - { - "id": "Js.TypedArray2.ArrayBuffer.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = array_buffer" - }, - { - "id": "Js.TypedArray2.ArrayBuffer.make", - "kind": "value", - "name": "make", - "docstrings": ["takes length. initializes elements to 0"], - "signature": "let make: int => t" - }, - { - "id": "Js.TypedArray2.ArrayBuffer.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.TypedArray2.ArrayBuffer.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (t, ~start: int, ~end_: int) => array_buffer" - }, - { - "id": "Js.TypedArray2.ArrayBuffer.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (t, int) => array_buffer" - } - ] - }, - "js/typed_array/dataview": { - "id": "Js.Typed_array.DataView", - "name": "DataView", - "docstrings": [ - "The DataView view provides a low-level interface for reading and writing\nmultiple number types in an ArrayBuffer irrespective of the platform's endianness.\n\n**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)" - ], - "items": [ - { - "id": "Js.Typed_array.DataView.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = Js_typed_array2.DataView.t" - }, - { - "id": "Js.Typed_array.DataView.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array_buffer => t" - }, - { - "id": "Js.Typed_array.DataView.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": [], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.DataView.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.DataView.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.DataView.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.DataView.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.DataView.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.DataView.getInt8", - "kind": "value", - "name": "getInt8", - "docstrings": [], - "signature": "let getInt8: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getUint8", - "kind": "value", - "name": "getUint8", - "docstrings": [], - "signature": "let getUint8: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getInt16", - "kind": "value", - "name": "getInt16", - "docstrings": [], - "signature": "let getInt16: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getInt16LittleEndian", - "kind": "value", - "name": "getInt16LittleEndian", - "docstrings": [], - "signature": "let getInt16LittleEndian: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getUint16", - "kind": "value", - "name": "getUint16", - "docstrings": [], - "signature": "let getUint16: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getUint16LittleEndian", - "kind": "value", - "name": "getUint16LittleEndian", - "docstrings": [], - "signature": "let getUint16LittleEndian: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getInt32", - "kind": "value", - "name": "getInt32", - "docstrings": [], - "signature": "let getInt32: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getInt32LittleEndian", - "kind": "value", - "name": "getInt32LittleEndian", - "docstrings": [], - "signature": "let getInt32LittleEndian: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getUint32", - "kind": "value", - "name": "getUint32", - "docstrings": [], - "signature": "let getUint32: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getUint32LittleEndian", - "kind": "value", - "name": "getUint32LittleEndian", - "docstrings": [], - "signature": "let getUint32LittleEndian: (t, int) => int" - }, - { - "id": "Js.Typed_array.DataView.getFloat32", - "kind": "value", - "name": "getFloat32", - "docstrings": [], - "signature": "let getFloat32: (t, int) => float" - }, - { - "id": "Js.Typed_array.DataView.getFloat32LittleEndian", - "kind": "value", - "name": "getFloat32LittleEndian", - "docstrings": [], - "signature": "let getFloat32LittleEndian: (t, int) => float" - }, - { - "id": "Js.Typed_array.DataView.getFloat64", - "kind": "value", - "name": "getFloat64", - "docstrings": [], - "signature": "let getFloat64: (t, int) => float" - }, - { - "id": "Js.Typed_array.DataView.getFloat64LittleEndian", - "kind": "value", - "name": "getFloat64LittleEndian", - "docstrings": [], - "signature": "let getFloat64LittleEndian: (t, int) => float" - }, - { - "id": "Js.Typed_array.DataView.setInt8", - "kind": "value", - "name": "setInt8", - "docstrings": [], - "signature": "let setInt8: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setUint8", - "kind": "value", - "name": "setUint8", - "docstrings": [], - "signature": "let setUint8: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setInt16", - "kind": "value", - "name": "setInt16", - "docstrings": [], - "signature": "let setInt16: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setInt16LittleEndian", - "kind": "value", - "name": "setInt16LittleEndian", - "docstrings": [], - "signature": "let setInt16LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setUint16", - "kind": "value", - "name": "setUint16", - "docstrings": [], - "signature": "let setUint16: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setUint16LittleEndian", - "kind": "value", - "name": "setUint16LittleEndian", - "docstrings": [], - "signature": "let setUint16LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setInt32", - "kind": "value", - "name": "setInt32", - "docstrings": [], - "signature": "let setInt32: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setInt32LittleEndian", - "kind": "value", - "name": "setInt32LittleEndian", - "docstrings": [], - "signature": "let setInt32LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setUint32", - "kind": "value", - "name": "setUint32", - "docstrings": [], - "signature": "let setUint32: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setUint32LittleEndian", - "kind": "value", - "name": "setUint32LittleEndian", - "docstrings": [], - "signature": "let setUint32LittleEndian: (t, int, int) => unit" - }, - { - "id": "Js.Typed_array.DataView.setFloat32", - "kind": "value", - "name": "setFloat32", - "docstrings": [], - "signature": "let setFloat32: (t, int, float) => unit" - }, - { - "id": "Js.Typed_array.DataView.setFloat32LittleEndian", - "kind": "value", - "name": "setFloat32LittleEndian", - "docstrings": [], - "signature": "let setFloat32LittleEndian: (t, int, float) => unit" - }, - { - "id": "Js.Typed_array.DataView.setFloat64", - "kind": "value", - "name": "setFloat64", - "docstrings": [], - "signature": "let setFloat64: (t, int, float) => unit" - }, - { - "id": "Js.Typed_array.DataView.setFloat64LittleEndian", - "kind": "value", - "name": "setFloat64LittleEndian", - "docstrings": [], - "signature": "let setFloat64LittleEndian: (t, int, float) => unit" - } - ] - }, - "js/typed_array/float64_array": { - "id": "Js.Typed_array.Float64_array", - "name": "Float64_array", - "docstrings": [], - "items": [] - }, - "js/typed_array/float64array": { - "id": "Js.Typed_array.Float64Array", - "name": "Float64Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Float64Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = float" - }, - { - "id": "Js.Typed_array.Float64Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Float64Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Float64Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Float64Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Float64Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Float64Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Float64Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Float64Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Float64Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Float64Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Float64Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Float64Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Float64Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Float64Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Float64Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Float64Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Float64Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Float64Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Float64Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Float64Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Float64Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Float64Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Float64Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Float64Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float64Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float64Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Float64Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Float64Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Float64Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Float64Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Float64Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Float64Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Float64Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Float64Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Float64Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float64Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float64Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float64Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float64Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float64Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float64Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Float64Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Float64Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Float64Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Float64Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Float64Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Float64Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - }, - { - "id": "Js.Typed_array.Float64Array.create", - "kind": "value", - "name": "create", - "docstrings": [], - "signature": "let create: array => t", - "deprecated": "use `make` instead" - }, - { - "id": "Js.Typed_array.Float64Array.of_buffer", - "kind": "value", - "name": "of_buffer", - "docstrings": [], - "signature": "let of_buffer: array_buffer => t", - "deprecated": "use `fromBuffer` instead" - } - ] - }, - "js/typed_array/float32_array": { - "id": "Js.Typed_array.Float32_array", - "name": "Float32_array", - "docstrings": [], - "items": [] - }, - "js/typed_array/float32array": { - "id": "Js.Typed_array.Float32Array", - "name": "Float32Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Float32Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = float" - }, - { - "id": "Js.Typed_array.Float32Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Float32Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Float32Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Float32Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Float32Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Float32Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Float32Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Float32Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Float32Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Float32Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Float32Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Float32Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Float32Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Float32Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Float32Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Float32Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Float32Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Float32Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Float32Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Float32Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Float32Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Float32Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Float32Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Float32Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float32Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float32Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Float32Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Float32Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Float32Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Float32Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Float32Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Float32Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Float32Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Float32Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Float32Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float32Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float32Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float32Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Float32Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float32Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Float32Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Float32Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Float32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Float32Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Float32Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Float32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Float32Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - }, - { - "id": "Js.Typed_array.Float32Array.create", - "kind": "value", - "name": "create", - "docstrings": [], - "signature": "let create: array => t", - "deprecated": "use `make` instead" - }, - { - "id": "Js.Typed_array.Float32Array.of_buffer", - "kind": "value", - "name": "of_buffer", - "docstrings": [], - "signature": "let of_buffer: array_buffer => t", - "deprecated": "use `fromBuffer` instead" - } - ] - }, - "js/typed_array/uint32array": { - "id": "Js.Typed_array.Uint32Array", - "name": "Uint32Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Uint32Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.Typed_array.Uint32Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Uint32Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint32Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Uint32Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Uint32Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Uint32Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Uint32Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Uint32Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Uint32Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Uint32Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Uint32Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Uint32Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint32Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint32Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Uint32Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint32Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint32Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Uint32Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Uint32Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint32Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint32Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Uint32Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Uint32Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Uint32Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint32Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint32Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint32Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint32Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint32Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint32Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint32Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint32Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint32Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint32Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint32Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint32Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint32Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint32Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint32Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint32Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Uint32Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Uint32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Uint32Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Uint32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Uint32Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typed_array/int32_array": { - "id": "Js.Typed_array.Int32_array", - "name": "Int32_array", - "docstrings": [], - "items": [] - }, - "js/typed_array/int32array": { - "id": "Js.Typed_array.Int32Array", - "name": "Int32Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Int32Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.Typed_array.Int32Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Int32Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int32Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Int32Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Int32Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Int32Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Int32Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Int32Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Int32Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Int32Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Int32Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Int32Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Int32Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Int32Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Int32Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Int32Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Int32Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Int32Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Int32Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Int32Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Int32Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Int32Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Int32Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Int32Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int32Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int32Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Int32Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Int32Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Int32Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Int32Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Int32Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Int32Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Int32Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int32Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int32Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int32Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int32Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int32Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int32Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int32Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int32Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Int32Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Int32Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Int32Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Int32Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Int32Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Int32Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - }, - { - "id": "Js.Typed_array.Int32Array.create", - "kind": "value", - "name": "create", - "docstrings": [], - "signature": "let create: array => t", - "deprecated": "use `make` instead" - }, - { - "id": "Js.Typed_array.Int32Array.of_buffer", - "kind": "value", - "name": "of_buffer", - "docstrings": [], - "signature": "let of_buffer: array_buffer => t", - "deprecated": "use `fromBuffer` instead" - } - ] - }, - "js/typed_array/uint16array": { - "id": "Js.Typed_array.Uint16Array", - "name": "Uint16Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Uint16Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.Typed_array.Uint16Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Uint16Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint16Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Uint16Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Uint16Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Uint16Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Uint16Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Uint16Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Uint16Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Uint16Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Uint16Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Uint16Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint16Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint16Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Uint16Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint16Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint16Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Uint16Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Uint16Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint16Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint16Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Uint16Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Uint16Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Uint16Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint16Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint16Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint16Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint16Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint16Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint16Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint16Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint16Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint16Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint16Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint16Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint16Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint16Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint16Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint16Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint16Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Uint16Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Uint16Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Uint16Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Uint16Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Uint16Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typed_array/int16array": { - "id": "Js.Typed_array.Int16Array", - "name": "Int16Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Int16Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.Typed_array.Int16Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Int16Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int16Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Int16Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Int16Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Int16Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Int16Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Int16Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Int16Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Int16Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Int16Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Int16Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Int16Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Int16Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Int16Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Int16Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Int16Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Int16Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Int16Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Int16Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Int16Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Int16Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Int16Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Int16Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int16Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int16Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Int16Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Int16Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Int16Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Int16Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Int16Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Int16Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Int16Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int16Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int16Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int16Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int16Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int16Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int16Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int16Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int16Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Int16Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Int16Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Int16Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Int16Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Int16Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Int16Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typed_array/uint8clampedarray": { - "id": "Js.Typed_array.Uint8ClampedArray", - "name": "Uint8ClampedArray", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Uint8ClampedArray.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Uint8ClampedArray.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Uint8ClampedArray.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typed_array/uint8array": { - "id": "Js.Typed_array.Uint8Array", - "name": "Uint8Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Uint8Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.Typed_array.Uint8Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Uint8Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint8Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Uint8Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Uint8Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Uint8Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Uint8Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Uint8Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Uint8Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Uint8Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint8Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Uint8Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint8Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint8Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Uint8Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Uint8Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Uint8Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Uint8Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Uint8Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Uint8Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Uint8Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint8Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Uint8Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint8Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Uint8Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Uint8Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint8Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Uint8Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Uint8Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Uint8Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Uint8Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Uint8Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Uint8Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "**raise** Js.Exn.Error raise Js exception\n\n **param** offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "**raise** Js.Exn.Error raises Js exception\n\n **param** offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Uint8Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Uint8Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typed_array/int8array": { - "id": "Js.Typed_array.Int8Array", - "name": "Int8Array", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Int8Array.elt", - "kind": "type", - "name": "elt", - "docstrings": [""], - "signature": "type elt = int" - }, - { - "id": "Js.Typed_array.Int8Array.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<\n 'a,\n> = Js_typed_array2.Int8Array.typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int8Array.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.Int8Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.Int8Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.Int8Array.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.Int8Array.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.Int8Array.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.Int8Array.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.Int8Array.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.Int8Array.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.Int8Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.Int8Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.Int8Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.Int8Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Int8Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Int8Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.Int8Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.Int8Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.Int8Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.Int8Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.Int8Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.Int8Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.Int8Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int8Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int8Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.Int8Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Int8Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.Int8Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.Int8Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.Int8Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Int8Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.Int8Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int8Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'a, t) => typed_array<'a>" - }, - { - "id": "Js.Typed_array.Int8Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int8Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int8Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, elt) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int8Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, elt, int) => 'a, 'a, t) => 'a" - }, - { - "id": "Js.Typed_array.Int8Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int8Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.Int8Array._BYTES_PER_ELEMENT", - "kind": "value", - "name": "_BYTES_PER_ELEMENT", - "docstrings": [], - "signature": "let _BYTES_PER_ELEMENT: int" - }, - { - "id": "Js.Typed_array.Int8Array.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: array => t" - }, - { - "id": "Js.Typed_array.Int8Array.fromBuffer", - "kind": "value", - "name": "fromBuffer", - "docstrings": ["can throw"], - "signature": "let fromBuffer: array_buffer => t" - }, - { - "id": "Js.Typed_array.Int8Array.fromBufferOffset", - "kind": "value", - "name": "fromBufferOffset", - "docstrings": [ - "raise Js.Exn.Error raise Js exception\n\n param offset is in bytes" - ], - "signature": "let fromBufferOffset: (array_buffer, int) => t" - }, - { - "id": "Js.Typed_array.Int8Array.fromBufferRange", - "kind": "value", - "name": "fromBufferRange", - "docstrings": [ - "raise Js.Exn.Error raises Js exception\n\n param offset is in bytes, length in elements" - ], - "signature": "let fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t" - }, - { - "id": "Js.Typed_array.Int8Array.fromLength", - "kind": "value", - "name": "fromLength", - "docstrings": [], - "signature": "let fromLength: int => t" - }, - { - "id": "Js.Typed_array.Int8Array.from", - "kind": "value", - "name": "from", - "docstrings": [], - "signature": "let from: array_like => t" - } - ] - }, - "js/typed_array/s": { - "id": "Js.Typed_array.S", - "name": "S", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.S.elt", - "kind": "type", - "name": "elt", - "docstrings": [], - "signature": "type elt" - }, - { - "id": "Js.Typed_array.S.typed_array", - "kind": "type", - "name": "typed_array", - "docstrings": [], - "signature": "type typed_array<'a>" - }, - { - "id": "Js.Typed_array.S.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = typed_array" - }, - { - "id": "Js.Typed_array.S.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t, int) => elt" - }, - { - "id": "Js.Typed_array.S.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t, int, elt) => unit" - }, - { - "id": "Js.Typed_array.S.buffer", - "kind": "value", - "name": "buffer", - "docstrings": [], - "signature": "let buffer: t => array_buffer" - }, - { - "id": "Js.Typed_array.S.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.S.byteOffset", - "kind": "value", - "name": "byteOffset", - "docstrings": [], - "signature": "let byteOffset: t => int" - }, - { - "id": "Js.Typed_array.S.setArray", - "kind": "value", - "name": "setArray", - "docstrings": [], - "signature": "let setArray: (array, t) => unit" - }, - { - "id": "Js.Typed_array.S.setArrayOffset", - "kind": "value", - "name": "setArrayOffset", - "docstrings": [], - "signature": "let setArrayOffset: (array, int, t) => unit" - }, - { - "id": "Js.Typed_array.S.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t => int" - }, - { - "id": "Js.Typed_array.S.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t) => t" - }, - { - "id": "Js.Typed_array.S.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.S.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.S.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: (elt, t) => t" - }, - { - "id": "Js.Typed_array.S.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: (elt, ~from: int, t) => t" - }, - { - "id": "Js.Typed_array.S.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.S.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [], - "signature": "let reverseInPlace: t => t" - }, - { - "id": "Js.Typed_array.S.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [], - "signature": "let sortInPlace: t => t" - }, - { - "id": "Js.Typed_array.S.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: ((elt, elt) => int, t) => t" - }, - { - "id": "Js.Typed_array.S.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (elt, t) => bool" - }, - { - "id": "Js.Typed_array.S.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.S.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.S.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t => string" - }, - { - "id": "Js.Typed_array.S.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t) => string" - }, - { - "id": "Js.Typed_array.S.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (elt, t) => int" - }, - { - "id": "Js.Typed_array.S.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (elt, ~from: int, t) => int" - }, - { - "id": "Js.Typed_array.S.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.S.copy", - "kind": "value", - "name": "copy", - "docstrings": [], - "signature": "let copy: t => t" - }, - { - "id": "Js.Typed_array.S.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.S.subarray", - "kind": "value", - "name": "subarray", - "docstrings": [], - "signature": "let subarray: (~start: int, ~end_: int, t) => t" - }, - { - "id": "Js.Typed_array.S.subarrayFrom", - "kind": "value", - "name": "subarrayFrom", - "docstrings": [], - "signature": "let subarrayFrom: (int, t) => t" - }, - { - "id": "Js.Typed_array.S.toString", - "kind": "value", - "name": "toString", - "docstrings": [], - "signature": "let toString: t => string" - }, - { - "id": "Js.Typed_array.S.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Typed_array.S.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.S.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: ((elt, int) => bool, t) => bool" - }, - { - "id": "Js.Typed_array.S.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: (elt => bool, t) => t" - }, - { - "id": "Js.Typed_array.S.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: ((elt, int) => bool, t) => t" - }, - { - "id": "Js.Typed_array.S.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: (elt => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.S.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: ((elt, int) => bool, t) => Js.undefined" - }, - { - "id": "Js.Typed_array.S.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: (elt => bool, t) => int" - }, - { - "id": "Js.Typed_array.S.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: ((elt, int) => bool, t) => int" - }, - { - "id": "Js.Typed_array.S.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: (elt => unit, t) => unit" - }, - { - "id": "Js.Typed_array.S.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: ((elt, int) => unit, t) => unit" - }, - { - "id": "Js.Typed_array.S.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: (elt => 'b, t) => typed_array<'b>" - }, - { - "id": "Js.Typed_array.S.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((elt, int) => 'b, t) => typed_array<'b>" - }, - { - "id": "Js.Typed_array.S.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('b, elt) => 'b, 'b, t) => 'b" - }, - { - "id": "Js.Typed_array.S.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('b, elt, int) => 'b, 'b, t) => 'b" - }, - { - "id": "Js.Typed_array.S.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('b, elt) => 'b, 'b, t) => 'b" - }, - { - "id": "Js.Typed_array.S.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('b, elt, int) => 'b, 'b, t) => 'b" - }, - { - "id": "Js.Typed_array.S.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: (elt => bool, t) => bool" - }, - { - "id": "Js.Typed_array.S.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: ((elt, int) => bool, t) => bool" - } - ] - }, - "js/typed_array/arraybuffer": { - "id": "Js.Typed_array.ArrayBuffer", - "name": "ArrayBuffer", - "docstrings": [ - "The underlying buffer that the typed arrays provide views of\n\n **see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)" - ], - "items": [ - { - "id": "Js.Typed_array.ArrayBuffer.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = array_buffer" - }, - { - "id": "Js.Typed_array.ArrayBuffer.make", - "kind": "value", - "name": "make", - "docstrings": ["takes length. initializes elements to 0"], - "signature": "let make: int => t" - }, - { - "id": "Js.Typed_array.ArrayBuffer.byteLength", - "kind": "value", - "name": "byteLength", - "docstrings": [], - "signature": "let byteLength: t => int" - }, - { - "id": "Js.Typed_array.ArrayBuffer.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t) => array_buffer" - }, - { - "id": "Js.Typed_array.ArrayBuffer.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t) => array_buffer" - } - ] - }, - "js/typed_array/type": { - "id": "Js.Typed_array.Type", - "name": "Type", - "docstrings": [], - "items": [ - { - "id": "Js.Typed_array.Type.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - } - ] - }, - "js/json/kind": { - "id": "Js.Json.Kind", - "name": "Kind", - "docstrings": [], - "items": [ - { - "id": "Js.Json.Kind.json", - "kind": "type", - "name": "json", - "docstrings": [], - "signature": "type json = t" - }, - { - "id": "Js.Json.Kind.t", - "kind": "type", - "name": "t", - "docstrings": ["Underlying type of a JSON value"], - "signature": "type t<_> =\n | String: t\n | Number: t\n | Object: t>\n | Array: t>\n | Boolean: t\n | Null: t" - } - ] - }, - "js/weakmap": { - "id": "Js.WeakMap", - "name": "WeakMap", - "docstrings": ["Provides bindings for ES6 WeakMap", "ES6 WeakMap API"], - "items": [ - { - "id": "Js.WeakMap.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'k, 'v>" - } - ] - }, - "js/map": { - "id": "Js.Map", - "name": "Map", - "docstrings": ["Provides bindings for ES6 Map", "ES6 Map API"], - "items": [ - { - "id": "Js.Map.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'k, 'v>" - } - ] - }, - "js/weakset": { - "id": "Js.WeakSet", - "name": "WeakSet", - "docstrings": ["Provides bindings for ES6 WeakSet", "ES6 WeakSet API"], - "items": [ - { - "id": "Js.WeakSet.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a>" - } - ] - }, - "js/set": { - "id": "Js.Set", - "name": "Set", - "docstrings": ["Provides bindings for ES6 Set", "ES6 Set API"], - "items": [ - { - "id": "Js.Set.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a>" - } - ] - }, - "js/console": { - "id": "Js.Console", - "name": "Console", - "docstrings": ["Provides bindings for console"], - "items": [ - { - "id": "Js.Console.log", - "kind": "value", - "name": "log", - "docstrings": [], - "signature": "let log: 'a => unit" - }, - { - "id": "Js.Console.log2", - "kind": "value", - "name": "log2", - "docstrings": [], - "signature": "let log2: ('a, 'b) => unit" - }, - { - "id": "Js.Console.log3", - "kind": "value", - "name": "log3", - "docstrings": [], - "signature": "let log3: ('a, 'b, 'c) => unit" - }, - { - "id": "Js.Console.log4", - "kind": "value", - "name": "log4", - "docstrings": [], - "signature": "let log4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Js.Console.logMany", - "kind": "value", - "name": "logMany", - "docstrings": [], - "signature": "let logMany: array<'a> => unit" - }, - { - "id": "Js.Console.info", - "kind": "value", - "name": "info", - "docstrings": [], - "signature": "let info: 'a => unit" - }, - { - "id": "Js.Console.info2", - "kind": "value", - "name": "info2", - "docstrings": [], - "signature": "let info2: ('a, 'b) => unit" - }, - { - "id": "Js.Console.info3", - "kind": "value", - "name": "info3", - "docstrings": [], - "signature": "let info3: ('a, 'b, 'c) => unit" - }, - { - "id": "Js.Console.info4", - "kind": "value", - "name": "info4", - "docstrings": [], - "signature": "let info4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Js.Console.infoMany", - "kind": "value", - "name": "infoMany", - "docstrings": [], - "signature": "let infoMany: array<'a> => unit" - }, - { - "id": "Js.Console.warn", - "kind": "value", - "name": "warn", - "docstrings": [], - "signature": "let warn: 'a => unit" - }, - { - "id": "Js.Console.warn2", - "kind": "value", - "name": "warn2", - "docstrings": [], - "signature": "let warn2: ('a, 'b) => unit" - }, - { - "id": "Js.Console.warn3", - "kind": "value", - "name": "warn3", - "docstrings": [], - "signature": "let warn3: ('a, 'b, 'c) => unit" - }, - { - "id": "Js.Console.warn4", - "kind": "value", - "name": "warn4", - "docstrings": [], - "signature": "let warn4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Js.Console.warnMany", - "kind": "value", - "name": "warnMany", - "docstrings": [], - "signature": "let warnMany: array<'a> => unit" - }, - { - "id": "Js.Console.error", - "kind": "value", - "name": "error", - "docstrings": [], - "signature": "let error: 'a => unit" - }, - { - "id": "Js.Console.error2", - "kind": "value", - "name": "error2", - "docstrings": [], - "signature": "let error2: ('a, 'b) => unit" - }, - { - "id": "Js.Console.error3", - "kind": "value", - "name": "error3", - "docstrings": [], - "signature": "let error3: ('a, 'b, 'c) => unit" - }, - { - "id": "Js.Console.error4", - "kind": "value", - "name": "error4", - "docstrings": [], - "signature": "let error4: ('a, 'b, 'c, 'd) => unit" - }, - { - "id": "Js.Console.errorMany", - "kind": "value", - "name": "errorMany", - "docstrings": [], - "signature": "let errorMany: array<'a> => unit" - }, - { - "id": "Js.Console.trace", - "kind": "value", - "name": "trace", - "docstrings": [], - "signature": "let trace: unit => unit" - }, - { - "id": "Js.Console.timeStart", - "kind": "value", - "name": "timeStart", - "docstrings": [], - "signature": "let timeStart: string => unit" - }, - { - "id": "Js.Console.timeEnd", - "kind": "value", - "name": "timeEnd", - "docstrings": [], - "signature": "let timeEnd: string => unit" - } - ] - }, - "js/vector": { - "id": "Js.Vector", - "name": "Vector", - "docstrings": ["Provides bindings for JS Vector"], - "items": [ - { - "id": "Js.Vector.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = array<'a>" - }, - { - "id": "Js.Vector.filterInPlace", - "kind": "value", - "name": "filterInPlace", - "docstrings": [], - "signature": "let filterInPlace: ('a => bool, t<'a>) => unit" - }, - { - "id": "Js.Vector.empty", - "kind": "value", - "name": "empty", - "docstrings": [], - "signature": "let empty: t<'a> => unit" - }, - { - "id": "Js.Vector.pushBack", - "kind": "value", - "name": "pushBack", - "docstrings": [], - "signature": "let pushBack: ('a, t<'a>) => unit" - }, - { - "id": "Js.Vector.copy", - "kind": "value", - "name": "copy", - "docstrings": ["shallow copy"], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Js.Vector.memByRef", - "kind": "value", - "name": "memByRef", - "docstrings": [], - "signature": "let memByRef: ('a, t<'a>) => bool" - }, - { - "id": "Js.Vector.iter", - "kind": "value", - "name": "iter", - "docstrings": [], - "signature": "let iter: ('a => unit, t<'a>) => unit" - }, - { - "id": "Js.Vector.iteri", - "kind": "value", - "name": "iteri", - "docstrings": [], - "signature": "let iteri: ((int, 'a) => unit, t<'a>) => unit" - }, - { - "id": "Js.Vector.toList", - "kind": "value", - "name": "toList", - "docstrings": [], - "signature": "let toList: t<'a> => list<'a>" - }, - { - "id": "Js.Vector.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: ('a => 'b, t<'a>) => t<'b>" - }, - { - "id": "Js.Vector.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: ((int, 'a) => 'b, t<'a>) => t<'b>" - }, - { - "id": "Js.Vector.foldLeft", - "kind": "value", - "name": "foldLeft", - "docstrings": [], - "signature": "let foldLeft: (('a, 'b) => 'a, 'a, t<'b>) => 'a" - }, - { - "id": "Js.Vector.foldRight", - "kind": "value", - "name": "foldRight", - "docstrings": [], - "signature": "let foldRight: (('b, 'a) => 'a, t<'b>, 'a) => 'a" - }, - { - "id": "Js.Vector.length", - "kind": "value", - "name": "length", - "docstrings": [ - "Return the length (number of elements) of the given array." - ], - "signature": "let length: t<'a> => int" - }, - { - "id": "Js.Vector.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`Vector.get(a, n)` returns the element number `n` of vector `a`. The first\nelement has number 0. The last element has number `Vector.length(a) - 1`. You\ncan also write `a[n]` instead of `Vector.get(a, n)`. Raise `Invalid_argument\n\"index out of bounds\"` if `n` is outside the range 0 to (`Array.length(a) -\n1`)." - ], - "signature": "let get: (t<'a>, int) => 'a" - }, - { - "id": "Js.Vector.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`Vector.set(a, n, x)` modifies vector `a` in place, replacing element number\n`n` with `x`. Raise `Invalid_argument \"index out of bounds\"` if `n` is outside\nthe range 0 to `Array.length(a) - 1`." - ], - "signature": "let set: (t<'a>, int, 'a) => unit" - }, - { - "id": "Js.Vector.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`Vector.make(n, x)` returns a fresh vector of length `n`, initialized with `x`.\nAll the elements of this new vector are initially physically equal to `x` (in\nthe sense of the `==` predicate). Consequently, if `x` is mutable, it is shared\namong all elements of the array, and modifying `x` through one of the array\nentries will modify all other entries at the same time. Raise\n`Invalid_argument` if `n < 0` or `n > Sys.max_array_length`. If the value of\n`x` is a floating-point number, then the maximum size is only\n`Sys.max_array_length / 2`." - ], - "signature": "let make: (int, 'a) => t<'a>" - }, - { - "id": "Js.Vector.init", - "kind": "value", - "name": "init", - "docstrings": ["Raises `RangeError` when n is negative.\nn : size"], - "signature": "let init: (int, int => 'a) => t<'a>" - }, - { - "id": "Js.Vector.append", - "kind": "value", - "name": "append", - "docstrings": [ - "`append(x, a)` returns a fresh vector with `x` appended to `a`." - ], - "signature": "let append: ('a, t<'a>) => t<'a>" - }, - { - "id": "Js.Vector.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [], - "signature": "let unsafe_get: (t<'a>, int) => 'a" - }, - { - "id": "Js.Vector.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [], - "signature": "let unsafe_set: (t<'a>, int, 'a) => unit" - } - ] - }, - "js/list": { - "id": "Js.List", - "name": "List", - "docstrings": ["Provide utilities for list"], - "items": [ - { - "id": "Js.List.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = list<'a>" - }, - { - "id": "Js.List.length", - "kind": "value", - "name": "length", - "docstrings": [], - "signature": "let length: t<'a> => int" - }, - { - "id": "Js.List.cons", - "kind": "value", - "name": "cons", - "docstrings": [], - "signature": "let cons: ('a, t<'a>) => t<'a>" - }, - { - "id": "Js.List.isEmpty", - "kind": "value", - "name": "isEmpty", - "docstrings": [], - "signature": "let isEmpty: t<'a> => bool" - }, - { - "id": "Js.List.hd", - "kind": "value", - "name": "hd", - "docstrings": [], - "signature": "let hd: t<'a> => option<'a>" - }, - { - "id": "Js.List.tl", - "kind": "value", - "name": "tl", - "docstrings": [], - "signature": "let tl: t<'a> => option>" - }, - { - "id": "Js.List.nth", - "kind": "value", - "name": "nth", - "docstrings": [], - "signature": "let nth: (t<'a>, int) => option<'a>" - }, - { - "id": "Js.List.revAppend", - "kind": "value", - "name": "revAppend", - "docstrings": [], - "signature": "let revAppend: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Js.List.rev", - "kind": "value", - "name": "rev", - "docstrings": [], - "signature": "let rev: t<'a> => t<'a>" - }, - { - "id": "Js.List.mapRev", - "kind": "value", - "name": "mapRev", - "docstrings": [], - "signature": "let mapRev: ('a => 'b, t<'a>) => t<'b>" - }, - { - "id": "Js.List.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: ('a => 'b, t<'a>) => t<'b>" - }, - { - "id": "Js.List.iter", - "kind": "value", - "name": "iter", - "docstrings": [], - "signature": "let iter: ('a => unit, t<'a>) => unit" - }, - { - "id": "Js.List.iteri", - "kind": "value", - "name": "iteri", - "docstrings": [], - "signature": "let iteri: ((int, 'a) => unit, t<'a>) => unit" - }, - { - "id": "Js.List.foldLeft", - "kind": "value", - "name": "foldLeft", - "docstrings": ["Application order is left to right, tail recurisve"], - "signature": "let foldLeft: (('a, 'b) => 'a, 'a, list<'b>) => 'a" - }, - { - "id": "Js.List.foldRight", - "kind": "value", - "name": "foldRight", - "docstrings": ["Application order is right to left tail-recursive."], - "signature": "let foldRight: (('a, 'b) => 'b, list<'a>, 'b) => 'b" - }, - { - "id": "Js.List.flatten", - "kind": "value", - "name": "flatten", - "docstrings": [], - "signature": "let flatten: t> => t<'a>" - }, - { - "id": "Js.List.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: ('a => bool, t<'a>) => t<'a>" - }, - { - "id": "Js.List.filterMap", - "kind": "value", - "name": "filterMap", - "docstrings": [], - "signature": "let filterMap: ('a => option<'b>, t<'a>) => t<'b>" - }, - { - "id": "Js.List.countBy", - "kind": "value", - "name": "countBy", - "docstrings": [], - "signature": "let countBy: ('a => bool, list<'a>) => int" - }, - { - "id": "Js.List.init", - "kind": "value", - "name": "init", - "docstrings": [], - "signature": "let init: (int, int => 'a) => t<'a>" - }, - { - "id": "Js.List.toVector", - "kind": "value", - "name": "toVector", - "docstrings": [], - "signature": "let toVector: t<'a> => array<'a>" - }, - { - "id": "Js.List.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (('a, 'a) => bool, list<'a>, list<'a>) => bool" - } - ] - }, - "js/result": { - "id": "Js.Result", - "name": "Result", - "docstrings": ["Define the interface for result"], - "items": [ - { - "id": "Js.Result.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'good, 'bad> = Ok('good) | Error('bad)", - "deprecated": "Please use `Belt.Result.t` instead" - } - ] - }, - "js/option": { - "id": "Js.Option", - "name": "Option", - "docstrings": ["Provide utilities for option"], - "items": [ - { - "id": "Js.Option.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = option<'a>" - }, - { - "id": "Js.Option.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: 'a => option<'a>" - }, - { - "id": "Js.Option.isSome", - "kind": "value", - "name": "isSome", - "docstrings": [], - "signature": "let isSome: option<'a> => bool" - }, - { - "id": "Js.Option.isSomeValue", - "kind": "value", - "name": "isSomeValue", - "docstrings": [], - "signature": "let isSomeValue: (('a, 'a) => bool, 'a, option<'a>) => bool" - }, - { - "id": "Js.Option.isNone", - "kind": "value", - "name": "isNone", - "docstrings": [], - "signature": "let isNone: option<'a> => bool" - }, - { - "id": "Js.Option.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: option<'a> => 'a" - }, - { - "id": "Js.Option.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (('a, 'b) => bool, option<'a>, option<'b>) => bool" - }, - { - "id": "Js.Option.andThen", - "kind": "value", - "name": "andThen", - "docstrings": [], - "signature": "let andThen: ('a => option<'b>, option<'a>) => option<'b>" - }, - { - "id": "Js.Option.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: ('a => 'b, option<'a>) => option<'b>" - }, - { - "id": "Js.Option.getWithDefault", - "kind": "value", - "name": "getWithDefault", - "docstrings": [], - "signature": "let getWithDefault: ('a, option<'a>) => 'a" - }, - { - "id": "Js.Option.default", - "kind": "value", - "name": "default", - "docstrings": [], - "signature": "let default: ('a, option<'a>) => 'a", - "deprecated": "Use `getWithDefault` instead since default has special meaning in ES module" - }, - { - "id": "Js.Option.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: ('a => bool, option<'a>) => option<'a>" - }, - { - "id": "Js.Option.firstSome", - "kind": "value", - "name": "firstSome", - "docstrings": [], - "signature": "let firstSome: (option<'a>, option<'a>) => option<'a>" - } - ] - }, - "js/blob": { - "id": "Js.Blob", - "name": "Blob", - "docstrings": ["Provide utilities for Blob", "JavaScript Blob API"], - "items": [ - { - "id": "Js.Blob.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - } - ] - }, - "js/file": { - "id": "Js.File", - "name": "File", - "docstrings": ["Provide utilities for File", "JavaScript File API"], - "items": [ - { - "id": "Js.File.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - } - ] - }, - "js/bigint": { - "id": "Js.BigInt", - "name": "BigInt", - "docstrings": ["Provide utilities for bigint", "JavaScript BigInt API"], - "items": [ - { - "id": "Js.BigInt.fromStringExn", - "kind": "value", - "name": "fromStringExn", - "docstrings": [ - "Parses the given `string` into a `bigint` using JavaScript semantics. Return the\nnumber as a `bigint` if successfully parsed. Uncaught syntax exception otherwise.\n\n## Examples\n\n```rescript\n/* returns 123n */\nJs.BigInt.fromStringExn(\"123\")\n\n/* returns 0n */\nJs.BigInt.fromStringExn(\"\")\n\n/* returns 17n */\nJs.BigInt.fromStringExn(\"0x11\")\n\n/* returns 3n */\nJs.BigInt.fromStringExn(\"0b11\")\n\n/* returns 9n */\nJs.BigInt.fromStringExn(\"0o11\")\n\n/* catch exception */\ntry {\n Js.BigInt.fromStringExn(\"a\")\n} catch {\n| _ => ...\n}\n```" - ], - "signature": "let fromStringExn: string => bigint" - }, - { - "id": "Js.BigInt.~-", - "kind": "value", - "name": "~-", - "docstrings": [], - "signature": "let ~-: bigint => bigint" - }, - { - "id": "Js.BigInt.~+", - "kind": "value", - "name": "~+", - "docstrings": [], - "signature": "let ~+: bigint => bigint" - }, - { - "id": "Js.BigInt.+", - "kind": "value", - "name": "+", - "docstrings": [], - "signature": "let +: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.-", - "kind": "value", - "name": "-", - "docstrings": [], - "signature": "let -: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.*", - "kind": "value", - "name": "*", - "docstrings": [], - "signature": "let *: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt./", - "kind": "value", - "name": "/", - "docstrings": [], - "signature": "let /: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.mod", - "kind": "value", - "name": "mod", - "docstrings": [], - "signature": "let mod: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.**", - "kind": "value", - "name": "**", - "docstrings": [], - "signature": "let **: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.land", - "kind": "value", - "name": "land", - "docstrings": [], - "signature": "let land: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.lor", - "kind": "value", - "name": "lor", - "docstrings": [], - "signature": "let lor: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.lxor", - "kind": "value", - "name": "lxor", - "docstrings": [], - "signature": "let lxor: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.lnot", - "kind": "value", - "name": "lnot", - "docstrings": [], - "signature": "let lnot: bigint => bigint" - }, - { - "id": "Js.BigInt.lsl", - "kind": "value", - "name": "lsl", - "docstrings": [], - "signature": "let lsl: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.asr", - "kind": "value", - "name": "asr", - "docstrings": [], - "signature": "let asr: (bigint, bigint) => bigint" - }, - { - "id": "Js.BigInt.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Formats a `bigint` as a string. Return a `string` representing the given value.\nSee [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"123\" */\nJs.BigInt.toString(123n)->Js.log\n```" - ], - "signature": "let toString: bigint => string" - }, - { - "id": "Js.BigInt.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "Returns a string with a language-sensitive representation of this BigInt value.\n\n## Examples\n\n```rescript\n/* prints \"123\" */\nJs.BigInt.toString(123n)->Js.log\n```" - ], - "signature": "let toLocaleString: bigint => string" - } - ] - }, - "js/int": { - "id": "Js.Int", - "name": "Int", - "docstrings": [ - "Provide utilities for int", - "Provide utilities for handling `int`." - ], - "items": [ - { - "id": "Js.Int.toExponential", - "kind": "value", - "name": "toExponential", - "docstrings": [ - "Formats an `int` using exponential (scientific) notation.\nReturns a `string` representing the given value in exponential notation.\nRaises `RangeError` if digits is not in the range \\[0, 20\\] (inclusive).\n\nSee [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"7.7e+1\" */\nJs.log(Js.Int.toExponential(77))\n```" - ], - "signature": "let toExponential: int => string" - }, - { - "id": "Js.Int.toExponentialWithPrecision", - "kind": "value", - "name": "toExponentialWithPrecision", - "docstrings": [ - "Formats an `int` using exponential (scientific) notation.\n`digits` specifies how many digits should appear after the decimal point. The value must be in the range \\[0, 20\\] (inclusive).\n\nReturns a `string` representing the given value in exponential notation.\n\nThe output will be rounded or padded with zeroes if necessary.\nRaises `RangeError` if `digits` is not in the range \\[0, 20\\] (inclusive).\n\nSee [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"7.70e+1\" */\nJs.log(Js.Int.toExponentialWithPrecision(77, ~digits=2))\n\n/* prints \"5.68e+3\" */\nJs.log(Js.Int.toExponentialWithPrecision(5678, ~digits=2))\n```" - ], - "signature": "let toExponentialWithPrecision: (int, ~digits: int) => string" - }, - { - "id": "Js.Int.toPrecision", - "kind": "value", - "name": "toPrecision", - "docstrings": [ - "Formats an `int` using some fairly arbitrary rules.\nReturns a `string` representing the given value in fixed-point (usually).\n\n`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.\nRaises `RangeError` if `digits` is not in the range accepted by this function.\n\nSee [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"123456789\" */\nJs.log(Js.Int.toPrecision(123456789))\n```" - ], - "signature": "let toPrecision: int => string" - }, - { - "id": "Js.Int.toPrecisionWithPrecision", - "kind": "value", - "name": "toPrecisionWithPrecision", - "docstrings": [ - "Formats an `int` using some fairly arbitrary rules.\n`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).\n\nReturns a `string` representing the given value in fixed-point or scientific notation.\n\nThe output will be rounded or padded with zeroes if necessary.\n\n`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.\n`toPrecisionWithPrecision` will also use scientific notation if the specified precision is less than the number of digits before the decimal point.\nRaises `RangeError` if `digits` is not in the range accepted by this function.\n\n\nSee [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"1.2e+8\" */\nJs.log(Js.Int.toPrecisionWithPrecision(123456789, ~digits=2))\n\n/* prints \"0.0\" */\nJs.log(Js.Int.toPrecisionWithPrecision(0, ~digits=2))\n```" - ], - "signature": "let toPrecisionWithPrecision: (int, ~digits: int) => string" - }, - { - "id": "Js.Int.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Formats an `int` as a `string`. Returns a `string` representing the given value\nin fixed-point (usually).\n\nSee [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"123456789\" */\nJs.log(Js.Int.toString(123456789))\n```" - ], - "signature": "let toString: int => string" - }, - { - "id": "Js.Int.toStringWithRadix", - "kind": "value", - "name": "toStringWithRadix", - "docstrings": [ - "Formats an `int` as a `string`. `radix` specifies the radix base to use for the\nformatted number. The value must be in the range \\[2, 36\\] (inclusive). Returns\na `string` representing the given value in fixed-point (usually). Raises\n`RangeError` if `radix` is not in the range \\[2, 36\\] (inclusive).\n\n\nSee [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"110\" */\nJs.log(Js.Int.toStringWithRadix(6, ~radix=2))\n\n/* prints \"deadbeef\" */\nJs.log(Js.Int.toStringWithRadix(3735928559, ~radix=16))\n\n/* prints \"2n9c\" */\nJs.log(Js.Int.toStringWithRadix(123456, ~radix=36))\n```" - ], - "signature": "let toStringWithRadix: (int, ~radix: int) => string" - }, - { - "id": "Js.Int.toFloat", - "kind": "value", - "name": "toFloat", - "docstrings": [], - "signature": "let toFloat: int => float" - }, - { - "id": "Js.Int.equal", - "kind": "value", - "name": "equal", - "docstrings": [], - "signature": "let equal: (int, int) => bool" - }, - { - "id": "Js.Int.max", - "kind": "value", - "name": "max", - "docstrings": [], - "signature": "let max: int" - }, - { - "id": "Js.Int.min", - "kind": "value", - "name": "min", - "docstrings": [], - "signature": "let min: int" - } - ] - }, - "js/float": { - "id": "Js.Float", - "name": "Float", - "docstrings": [ - "Provide utilities for JS float", - "Provide utilities for JS float." - ], - "items": [ - { - "id": "Js.Float._NaN", - "kind": "value", - "name": "_NaN", - "docstrings": [ - "The special value \"Not a Number\". See [`NaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) on MDN." - ], - "signature": "let _NaN: float" - }, - { - "id": "Js.Float.isNaN", - "kind": "value", - "name": "isNaN", - "docstrings": [ - "Tests if the given value is `_NaN`\n\nNote that both `_NaN = _NaN` and `_NaN == _NaN` will return `false`. `isNaN` is\ntherefore necessary to test for `_NaN`. Return `true` if the given value is\n`_NaN`, `false` otherwise. See [`isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) on MDN." - ], - "signature": "let isNaN: float => bool" - }, - { - "id": "Js.Float.isFinite", - "kind": "value", - "name": "isFinite", - "docstrings": [ - "Tests if the given value is finite. Return `true` if the given value is a finite\nnumber, `false` otherwise. See [`isFinite`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite) on MDN.\n\n## Examples\n\n```rescript\n/* returns [false] */\nJs.Float.isFinite(infinity)\n\n/* returns [false] */\nJs.Float.isFinite(neg_infinity)\n\n/* returns [false] */\nJs.Float.isFinite(Js.Float._NaN)\n\n/* returns [true] */\nJs.Float.isFinite(1234.)\n```" - ], - "signature": "let isFinite: float => bool" - }, - { - "id": "Js.Float.toExponential", - "kind": "value", - "name": "toExponential", - "docstrings": [ - "Formats a `float` using exponential (scientific) notation. Return a\n`string` representing the given value in exponential notation. Raise\nRangeError 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.\n\n## Examples\n\n```rescript\n/* prints \"7.71234e+1\" */\nJs.Float.toExponential(77.1234)->Js.log\n\n/* prints \"7.7e+1\" */\nJs.Float.toExponential(77.)->Js.log\n```" - ], - "signature": "let toExponential: float => string" - }, - { - "id": "Js.Float.toExponentialWithPrecision", - "kind": "value", - "name": "toExponentialWithPrecision", - "docstrings": [ - "Formats a `float` using exponential (scientific) notation. `digits` specifies\nhow many digits should appear after the decimal point. The value must be in\nthe range [0, 20] (inclusive). Return a `string` representing the given value\nin exponential notation. The output will be rounded or padded with zeroes if\nnecessary. Raise RangeError if `digits` is not in the range [0, 20] (inclusive).\nSee [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"7.71e+1\" */\nJs.Float.toExponentialWithPrecision(77.1234, ~digits=2)->Js.log\n```" - ], - "signature": "let toExponentialWithPrecision: (float, ~digits: int) => string" - }, - { - "id": "Js.Float.toFixed", - "kind": "value", - "name": "toFixed", - "docstrings": [ - "Formats a `float` using fixed point notation. Return a `string` representing the\ngiven value in fixed-point notation (usually). Raise RangeError if digits is not\nin the range [0, 20] (inclusive). See [`toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"12346\" (note the rounding) */\nJs.Float.toFixed(12345.6789)->Js.log\n\n/* print \"1.2e+21\" */\nJs.Float.toFixed(1.2e21)->Js.log\n```" - ], - "signature": "let toFixed: float => string" - }, - { - "id": "Js.Float.toFixedWithPrecision", - "kind": "value", - "name": "toFixedWithPrecision", - "docstrings": [ - "Formats a `float` using fixed point notation. `digits` specifies how many digits\nshould appear after the decimal point. The value must be in the range [0, 20]\n(inclusive). Defaults to `0`. Return a `string` representing the given value in\nfixed-point notation (usually). See [`toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN.\n\nThe output will be rounded or padded with zeroes if necessary.\n\nRaise RangeError if digits is not in the range [0, 20] (inclusive)\n\n## Examples\n\n```rescript\n/* prints \"12345.7\" (note the rounding) */\nJs.Float.toFixedWithPrecision(12345.6789, ~digits=1)->Js.log\n\n/* prints \"0.00\" (note the added zeroes) */\nJs.Float.toFixedWithPrecision(0., ~digits=2)->Js.log\n```" - ], - "signature": "let toFixedWithPrecision: (float, ~digits: int) => string" - }, - { - "id": "Js.Float.toPrecision", - "kind": "value", - "name": "toPrecision", - "docstrings": [ - "Formats a `float` using some fairly arbitrary rules. Return a `string`\nrepresenting the given value in fixed-point (usually). `toPrecision` differs\nfrom `Js.Float.toFixed` in that the former will format the number with full\nprecision, while the latter will not output any digits after the decimal point.\nSee [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\nRaise RangeError if digits is not in the range accepted by this function (what do you mean \"vague\"?)\n\n## Examples\n\n```rescript\n/* prints \"12345.6789\" */\nJs.Float.toPrecision(12345.6789)->Js.log\n\n/* print \"1.2e+21\" */\nJs.Float.toPrecision(1.2e21)->Js.log\n```" - ], - "signature": "let toPrecision: float => string" - }, - { - "id": "Js.Float.toPrecisionWithPrecision", - "kind": "value", - "name": "toPrecisionWithPrecision", - "docstrings": [ - "Formats a `float` using some fairly arbitrary rules. `digits` specifies how many\ndigits should appear in total. The value must between 0 and some arbitrary number\nthat's hopefully at least larger than 20 (for Node it's 21. Why? Who knows).\nSee [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\nReturn a `string` representing the given value in fixed-point or scientific\nnotation. The output will be rounded or padded with zeroes if necessary.\n\n`toPrecisionWithPrecision` differs from `toFixedWithPrecision` in that the former\nwill count all digits against the precision, while the latter will count only\nthe digits after the decimal point. `toPrecisionWithPrecision` will also use\nscientific notation if the specified precision is less than the number for digits\nbefore the decimal point.\n\nRaise RangeError if digits is not in the range accepted by this function (what do you mean \"vague\"?)\n\n## Examples\n\n```rescript\n/* prints \"1e+4\" */\nJs.Float.toPrecisionWithPrecision(12345.6789, ~digits=1)->Js.log\n\n/* prints \"0.0\" */\nJs.Float.toPrecisionWithPrecision(0., ~digits=2)->Js.log\n```" - ], - "signature": "let toPrecisionWithPrecision: (float, ~digits: int) => string" - }, - { - "id": "Js.Float.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Formats a `float` as a string. Return a `string` representing the given value in\nfixed-point (usually). See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\n/* prints \"12345.6789\" */\nJs.Float.toString(12345.6789)->Js.log\n```" - ], - "signature": "let toString: float => string" - }, - { - "id": "Js.Float.toStringWithRadix", - "kind": "value", - "name": "toStringWithRadix", - "docstrings": [ - "Formats a `float` as a string. `radix` specifies the radix base to use for the\nformatted number. The value must be in the range [2, 36] (inclusive). Return a\n`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.\n\nRaise RangeError if radix is not in the range [2, 36] (inclusive)\n\n## Examples\n\n```rescript\n/* prints \"110\" */\nJs.Float.toStringWithRadix(6., ~radix=2)->Js.log\n\n/* prints \"11.001000111101011100001010001111010111000010100011111\" */\nJs.Float.toStringWithRadix(3.14, ~radix=2)->Js.log\n\n/* prints \"deadbeef\" */\nJs.Float.toStringWithRadix(3735928559., ~radix=16)->Js.log\n\n/* prints \"3f.gez4w97ry0a18ymf6qadcxr\" */\nJs.Float.toStringWithRadix(123.456, ~radix=36)->Js.log\n```" - ], - "signature": "let toStringWithRadix: (float, ~radix: int) => string" - }, - { - "id": "Js.Float.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "Parses the given `string` into a `float` using JavaScript semantics. Return the\nnumber as a `float` if successfully parsed, `_NaN` otherwise.\n\n## Examples\n\n```rescript\n/* returns 123 */\nJs.Float.fromString(\"123\")\n\n/* returns 12.3 */\nJs.Float.fromString(\"12.3\")\n\n/* returns 0 */\nJs.Float.fromString(\"\")\n\n/* returns 17 */\nJs.Float.fromString(\"0x11\")\n\n/* returns 3 */\nJs.Float.fromString(\"0b11\")\n\n/* returns 9 */\nJs.Float.fromString(\"0o11\")\n\n/* returns [_NaN] */\nJs.Float.fromString(\"hello\")\n\n/* returns [_NaN] */\nJs.Float.fromString(\"100a\")\n```" - ], - "signature": "let fromString: string => float" - } - ] - }, - "js/types": { - "id": "Js.Types", - "name": "Types", - "docstrings": [ - "Provide utilities for manipulating JS types", - "Provide utilities for manipulating JS types." - ], - "items": [ - { - "id": "Js.Types.symbol", - "kind": "type", - "name": "symbol", - "docstrings": ["Js symbol type (only available in ES6)"], - "signature": "type symbol" - }, - { - "id": "Js.Types.bigint_val", - "kind": "type", - "name": "bigint_val", - "docstrings": ["Js bigint type only available in ES2020"], - "signature": "type bigint_val" - }, - { - "id": "Js.Types.obj_val", - "kind": "type", - "name": "obj_val", - "docstrings": [], - "signature": "type obj_val" - }, - { - "id": "Js.Types.undefined_val", - "kind": "type", - "name": "undefined_val", - "docstrings": ["This type has only one value `undefined`"], - "signature": "type undefined_val" - }, - { - "id": "Js.Types.null_val", - "kind": "type", - "name": "null_val", - "docstrings": ["This type has only one value `null`"], - "signature": "type null_val" - }, - { - "id": "Js.Types.function_val", - "kind": "type", - "name": "function_val", - "docstrings": [], - "signature": "type function_val" - }, - { - "id": "Js.Types.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<_> =\n | Undefined: t\n | Null: t\n | Boolean: t\n | Number: t\n | String: t\n | Function: t\n | Object: t\n | Symbol: t\n | BigInt: t" - }, - { - "id": "Js.Types.test", - "kind": "value", - "name": "test", - "docstrings": [ - "`test(value, t)` returns `true` if `value` is `typeof t`, otherwise `false`.\nThis is useful for doing runtime reflection on any given value.\n\n## Examples\n\n```rescript\ntest(\"test\", String) == true\ntest(() => true, Function) == true\ntest(\"test\", Boolean) == false\n```" - ], - "signature": "let test: ('a, t<'b>) => bool" - }, - { - "id": "Js.Types.tagged_t", - "kind": "type", - "name": "tagged_t", - "docstrings": [], - "signature": "type tagged_t =\n | JSFalse\n | JSTrue\n | JSNull\n | JSUndefined\n | JSNumber(float)\n | JSString(string)\n | JSFunction(function_val)\n | JSObject(obj_val)\n | JSSymbol(symbol)\n | JSBigInt(bigint_val)" - }, - { - "id": "Js.Types.classify", - "kind": "value", - "name": "classify", - "docstrings": [], - "signature": "let classify: 'a => tagged_t" - } - ] - }, - "js/typedarray2": { - "id": "Js.TypedArray2", - "name": "TypedArray2", - "docstrings": [ - "Provide bindings for JS typed array", - "JavaScript Typed Array API\n\n**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)" - ], - "items": [ - { - "id": "Js.TypedArray2.array_buffer", - "kind": "type", - "name": "array_buffer", - "docstrings": [], - "signature": "type array_buffer" - }, - { - "id": "Js.TypedArray2.array_like", - "kind": "type", - "name": "array_like", - "docstrings": [], - "signature": "type array_like<'a>" - } - ] - }, - "js/typed_array": { - "id": "Js.Typed_array", - "name": "Typed_array", - "docstrings": [ - "Provide bindings for JS typed array", - "JavaScript Typed Array API\n\n**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)" - ], - "items": [ - { - "id": "Js.Typed_array.array_buffer", - "kind": "type", - "name": "array_buffer", - "docstrings": [], - "signature": "type array_buffer = Js_typed_array2.array_buffer" - }, - { - "id": "Js.Typed_array.array_like", - "kind": "type", - "name": "array_like", - "docstrings": [], - "signature": "type array_like<'a> = Js_typed_array2.array_like<'a>" - } - ] - }, - "js/obj": { - "id": "Js.Obj", - "name": "Obj", - "docstrings": [ - "Provide utilities for `Js.t`", - "Provides functions for inspecting and manipulating native JavaScript objects" - ], - "items": [ - { - "id": "Js.Obj.empty", - "kind": "value", - "name": "empty", - "docstrings": ["`empty()` returns the empty object `{}`"], - "signature": "let empty: unit => {..}" - }, - { - "id": "Js.Obj.assign", - "kind": "value", - "name": "assign", - "docstrings": [ - "`assign(target, source)` copies properties from source to target.\nProperties in `target` will be overwritten by properties in `source` if they have the same key.\nReturns `target`.\n\n**See** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)\n\n## Examples\n\n```rescript\n/* Copy an object */\n\nlet obj = {\"a\": 1}\n\nlet copy = Js.Obj.assign(Js.Obj.empty(), obj)\n\n/* prints \"{ a: 1 }\" */\nJs.log(copy)\n\n/* Merge objects with same properties */\n\nlet target = {\"a\": 1, \"b\": 1}\nlet source = {\"b\": 2}\n\nlet obj = Js.Obj.assign(target, source)\n\n/* prints \"{ a: 1, b: 2 }\" */\nJs.log(obj)\n\n/* prints \"{ a: 1, b: 2 }\", target is modified */\nJs.log(target)\n```" - ], - "signature": "let assign: ({..}, {..}) => {..}" - }, - { - "id": "Js.Obj.keys", - "kind": "value", - "name": "keys", - "docstrings": [ - "`keys(obj)` returns an `array` of the keys of `obj`'s own enumerable properties." - ], - "signature": "let keys: {..} => array" - } - ] - }, - "js/math": { - "id": "Js.Math", - "name": "Math", - "docstrings": [ - "Provide bindings for JS `Math` object", - "Provide utilities for JS Math. Note: The constants `_E`, `_LN10`, `_LN2`,\n`_LOG10E`, `_LOG2E`, `_PI`, `_SQRT1_2`, and `_SQRT2` begin with an underscore\nbecause ReScript variable names cannot begin with a capital letter. (Module\nnames begin with upper case.)" - ], - "items": [ - { - "id": "Js.Math._E", - "kind": "value", - "name": "_E", - "docstrings": [ - "Euler's number; ≈ 2.718281828459045. See\n[`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E)\non MDN." - ], - "signature": "let _E: float" - }, - { - "id": "Js.Math._LN2", - "kind": "value", - "name": "_LN2", - "docstrings": [ - "Natural logarithm of 2; ≈ 0.6931471805599453. See\n[`Math.LN2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2)\non MDN." - ], - "signature": "let _LN2: float" - }, - { - "id": "Js.Math._LN10", - "kind": "value", - "name": "_LN10", - "docstrings": [ - "Natural logarithm of 10; ≈ 2.302585092994046. See\n[`Math.LN10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10)\non MDN." - ], - "signature": "let _LN10: float" - }, - { - "id": "Js.Math._LOG2E", - "kind": "value", - "name": "_LOG2E", - "docstrings": [ - "Base 2 logarithm of E; ≈ 1.4426950408889634. See\n[`Math.LOG2E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E)\non MDN." - ], - "signature": "let _LOG2E: float" - }, - { - "id": "Js.Math._LOG10E", - "kind": "value", - "name": "_LOG10E", - "docstrings": [ - "Base 10 logarithm of E; ≈ 0.4342944819032518. See\n[`Math.LOG10E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E)\non MDN." - ], - "signature": "let _LOG10E: float" - }, - { - "id": "Js.Math._PI", - "kind": "value", - "name": "_PI", - "docstrings": [ - "Pi - ratio of the circumference to the diameter of a circle; ≈ 3.141592653589793. See\n[`Math.PI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI)\non MDN." - ], - "signature": "let _PI: float" - }, - { - "id": "Js.Math._SQRT1_2", - "kind": "value", - "name": "_SQRT1_2", - "docstrings": [ - "Square root of 1/2; ≈ 0.7071067811865476. See\n[`Math.SQRT1_2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2)\non MDN." - ], - "signature": "let _SQRT1_2: float" - }, - { - "id": "Js.Math._SQRT2", - "kind": "value", - "name": "_SQRT2", - "docstrings": [ - "Square root of 2; ≈ 1.4142135623730951. See\n[`Math.SQRT2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2)\non MDN." - ], - "signature": "let _SQRT2: float" - }, - { - "id": "Js.Math.abs_int", - "kind": "value", - "name": "abs_int", - "docstrings": [ - "Absolute value for integer argument. See\n[`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)\non MDN." - ], - "signature": "let abs_int: int => int" - }, - { - "id": "Js.Math.abs_float", - "kind": "value", - "name": "abs_float", - "docstrings": [ - "Absolute value for float argument. See\n[`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)\non MDN." - ], - "signature": "let abs_float: float => float" - }, - { - "id": "Js.Math.acos", - "kind": "value", - "name": "acos", - "docstrings": [ - "Arccosine (in radians) of argument; returns `NaN` if the argument is outside\nthe range [-1.0, 1.0]. See\n[`Math.acos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)\non MDN." - ], - "signature": "let acos: float => float" - }, - { - "id": "Js.Math.acosh", - "kind": "value", - "name": "acosh", - "docstrings": [ - "Hyperbolic arccosine (in radians) of argument; returns `NaN` if the argument\nis less than 1.0. See\n[`Math.acosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)\non MDN." - ], - "signature": "let acosh: float => float" - }, - { - "id": "Js.Math.asin", - "kind": "value", - "name": "asin", - "docstrings": [ - "Arcsine (in radians) of argument; returns `NaN` if the argument is outside\nthe range [-1.0, 1.0]. See\n[`Math.asin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)\non MDN." - ], - "signature": "let asin: float => float" - }, - { - "id": "Js.Math.asinh", - "kind": "value", - "name": "asinh", - "docstrings": [ - "Hyperbolic arcsine (in radians) of argument. See\n[`Math.asinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)\non MDN." - ], - "signature": "let asinh: float => float" - }, - { - "id": "Js.Math.atan", - "kind": "value", - "name": "atan", - "docstrings": [ - "Arctangent (in radians) of argument. See\n[`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan)\non MDN." - ], - "signature": "let atan: float => float" - }, - { - "id": "Js.Math.atanh", - "kind": "value", - "name": "atanh", - "docstrings": [ - "Hyperbolic arctangent (in radians) of argument; returns `NaN` if the argument\nis is outside the range [-1.0, 1.0]. Returns `-Infinity` and `Infinity` for\narguments -1.0 and 1.0. See\n[`Math.atanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)\non MDN." - ], - "signature": "let atanh: float => float" - }, - { - "id": "Js.Math.atan2", - "kind": "value", - "name": "atan2", - "docstrings": [ - "Returns the angle (in radians) of the quotient `y /. x`. It is also the angle\nbetween the *x*-axis and point (*x*, *y*). See\n[`Math.atan2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.atan2(~y=0.0, ~x=10.0, ()) == 0.0\nJs.Math.atan2(~x=5.0, ~y=5.0, ()) == Js.Math._PI /. 4.0\nJs.Math.atan2(~x=-5.0, ~y=5.0, ())\nJs.Math.atan2(~x=-5.0, ~y=5.0, ()) == 3.0 *. Js.Math._PI /. 4.0\nJs.Math.atan2(~x=-0.0, ~y=-5.0, ()) == -.Js.Math._PI /. 2.0\n```" - ], - "signature": "let atan2: (~y: float, ~x: float, unit) => float" - }, - { - "id": "Js.Math.cbrt", - "kind": "value", - "name": "cbrt", - "docstrings": [ - "Cube root. See\n[`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)\non MDN" - ], - "signature": "let cbrt: float => float" - }, - { - "id": "Js.Math.unsafe_ceil_int", - "kind": "value", - "name": "unsafe_ceil_int", - "docstrings": [ - "Returns the smallest integer greater than or equal to the argument. This\nfunction may return values not representable by `int`, whose range is\n-2147483648 to 2147483647. This is because, in JavaScript, there are only\n64-bit floating point numbers, which can represent integers in the range\n±(253-1) exactly. See\n[`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.unsafe_ceil_int(3.1) == 4\nJs.Math.unsafe_ceil_int(3.0) == 3\nJs.Math.unsafe_ceil_int(-3.1) == -3\nJs.Math.unsafe_ceil_int(1.0e15) // result is outside range of int datatype\n```" - ], - "signature": "let unsafe_ceil_int: float => int" - }, - { - "id": "Js.Math.unsafe_ceil", - "kind": "value", - "name": "unsafe_ceil", - "docstrings": [], - "signature": "let unsafe_ceil: float => int", - "deprecated": "Please use `unsafe_ceil_int` instead" - }, - { - "id": "Js.Math.ceil_int", - "kind": "value", - "name": "ceil_int", - "docstrings": [ - "Returns the smallest `int` greater than or equal to the argument; the result\nis pinned to the range of the `int` data type: -2147483648 to 2147483647. See\n[`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.ceil_int(3.1) == 4\nJs.Math.ceil_int(3.0) == 3\nJs.Math.ceil_int(-3.1) == -3\nJs.Math.ceil_int(-1.0e15) == -2147483648\nJs.Math.ceil_int(1.0e15) == 2147483647\n```" - ], - "signature": "let ceil_int: float => int" - }, - { - "id": "Js.Math.ceil", - "kind": "value", - "name": "ceil", - "docstrings": [], - "signature": "let ceil: float => int", - "deprecated": "Please use `ceil_int` instead" - }, - { - "id": "Js.Math.ceil_float", - "kind": "value", - "name": "ceil_float", - "docstrings": [ - "Returns the smallest integral value greater than or equal to the argument.\nThe result is a `float` and is not restricted to the `int` data type range.\nSee\n[`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.ceil_float(3.1) == 4.0\nJs.Math.ceil_float(3.0) == 3.0\nJs.Math.ceil_float(-3.1) == -3.0\nJs.Math.ceil_float(2_150_000_000.3) == 2_150_000_001.0\n```" - ], - "signature": "let ceil_float: float => float" - }, - { - "id": "Js.Math.clz32", - "kind": "value", - "name": "clz32", - "docstrings": [ - "Number of leading zero bits of the argument's 32 bit int representation. See\n[`Math.clz32`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.clz32(0) == 32\nJs.Math.clz32(-1) == 0\nJs.Math.clz32(255) == 24\n```" - ], - "signature": "let clz32: int => int" - }, - { - "id": "Js.Math.cos", - "kind": "value", - "name": "cos", - "docstrings": [ - "Cosine of argument, which must be specified in radians. See\n[`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)\non MDN." - ], - "signature": "let cos: float => float" - }, - { - "id": "Js.Math.cosh", - "kind": "value", - "name": "cosh", - "docstrings": [ - "Hyperbolic cosine of argument, which must be specified in radians. See\n[`Math.cosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)\non MDN." - ], - "signature": "let cosh: float => float" - }, - { - "id": "Js.Math.exp", - "kind": "value", - "name": "exp", - "docstrings": [ - "Natural exponentional; returns *e* (the base of natural logarithms) to the\npower of the given argument. See\n[`Math.exp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)\non MDN." - ], - "signature": "let exp: float => float" - }, - { - "id": "Js.Math.expm1", - "kind": "value", - "name": "expm1", - "docstrings": [ - "Returns *e* (the base of natural logarithms) to the power of the given\nargument minus 1. See\n[`Math.expm1`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)\non MDN." - ], - "signature": "let expm1: float => float" - }, - { - "id": "Js.Math.unsafe_floor_int", - "kind": "value", - "name": "unsafe_floor_int", - "docstrings": [ - "Returns the largest integer less than or equal to the argument. This function\nmay return values not representable by `int`, whose range is -2147483648 to\n2147483647. This is because, in JavaScript, there are only 64-bit floating\npoint numbers, which can represent integers in the range\n±(253-1) exactly. See\n[`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.unsafe_floor_int(3.7) == 3\nJs.Math.unsafe_floor_int(3.0) == 3\nJs.Math.unsafe_floor_int(-3.7) == -4\nJs.Math.unsafe_floor_int(1.0e15) // result is outside range of int datatype\n```" - ], - "signature": "let unsafe_floor_int: float => int" - }, - { - "id": "Js.Math.unsafe_floor", - "kind": "value", - "name": "unsafe_floor", - "docstrings": [], - "signature": "let unsafe_floor: float => int", - "deprecated": "Please use `unsafe_floor_int` instead" - }, - { - "id": "Js.Math.floor_int", - "kind": "value", - "name": "floor_int", - "docstrings": [ - "Returns the largest `int` less than or equal to the argument; the result is\npinned to the range of the `int` data type: -2147483648 to 2147483647. See\n[`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.floor_int(3.7) == 3\nJs.Math.floor_int(3.0) == 3\nJs.Math.floor_int(-3.1) == -4\nJs.Math.floor_int(-1.0e15) == -2147483648\nJs.Math.floor_int(1.0e15) == 2147483647\n```" - ], - "signature": "let floor_int: float => int" - }, - { - "id": "Js.Math.floor", - "kind": "value", - "name": "floor", - "docstrings": [], - "signature": "let floor: float => int", - "deprecated": "Please use `floor_int` instead" - }, - { - "id": "Js.Math.floor_float", - "kind": "value", - "name": "floor_float", - "docstrings": [ - "Returns the largest integral value less than or equal to the argument. The\nresult is a `float` and is not restricted to the `int` data type range. See\n[`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.floor_float(3.7) == 3.0\nJs.Math.floor_float(3.0) == 3.0\nJs.Math.floor_float(-3.1) == -4.0\nJs.Math.floor_float(2_150_000_000.3) == 2_150_000_000.0\n```" - ], - "signature": "let floor_float: float => float" - }, - { - "id": "Js.Math.fround", - "kind": "value", - "name": "fround", - "docstrings": [ - "Round to nearest single precision float. See\n[`Math.fround`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.fround(5.5) == 5.5\nJs.Math.fround(5.05) == 5.050000190734863\n```" - ], - "signature": "let fround: float => float" - }, - { - "id": "Js.Math.hypot", - "kind": "value", - "name": "hypot", - "docstrings": [ - "Returns the square root of the sum of squares of its two arguments (the\nPythagorean formula). See\n[`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)\non MDN." - ], - "signature": "let hypot: (float, float) => float" - }, - { - "id": "Js.Math.hypotMany", - "kind": "value", - "name": "hypotMany", - "docstrings": [ - "Returns the square root of the sum of squares of the numbers in the array\nargument (generalized Pythagorean equation). Using an array allows you to\nhave more than two items. See\n[`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.hypotMany([3.0, 4.0, 12.0]) == 13.0\n```" - ], - "signature": "let hypotMany: array => float" - }, - { - "id": "Js.Math.imul", - "kind": "value", - "name": "imul", - "docstrings": [ - "32-bit integer multiplication. Use this only when you need to optimize\nperformance of multiplication of numbers stored as 32-bit integers. See\n[`Math.imul`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)\non MDN." - ], - "signature": "let imul: (int, int) => int" - }, - { - "id": "Js.Math.log", - "kind": "value", - "name": "log", - "docstrings": [ - "Returns the natural logarithm of its argument; this is the number *x* such\nthat *e**x* equals the argument. Returns `NaN` for negative\narguments. See\n[`Math.log`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.log(Js.Math._E) == 1.0\nJs.Math.log(100.0) == 4.605170185988092\n```" - ], - "signature": "let log: float => float" - }, - { - "id": "Js.Math.log1p", - "kind": "value", - "name": "log1p", - "docstrings": [ - "Returns the natural logarithm of one plus the argument. Returns `NaN` for\narguments less than -1. See\n[`Math.log1p`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.log1p(Js.Math._E -. 1.0) == 1.0\nJs.Math.log1p(99.0) == 4.605170185988092\n```" - ], - "signature": "let log1p: float => float" - }, - { - "id": "Js.Math.log10", - "kind": "value", - "name": "log10", - "docstrings": [ - "Returns the base 10 logarithm of its argument. Returns `NaN` for negative\narguments. See\n[`Math.log10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.log10(1000.0) == 3.0\nJs.Math.log10(0.01) == -2.0\nJs.Math.log10(Js.Math.sqrt(10.0)) == 0.5\n```" - ], - "signature": "let log10: float => float" - }, - { - "id": "Js.Math.log2", - "kind": "value", - "name": "log2", - "docstrings": [ - "Returns the base 2 logarithm of its argument. Returns `NaN` for negative\narguments. See\n[`Math.log2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.log2(512.0) == 9.0\nJs.Math.log2(0.125) == -3.0\nJs.Math.log2(Js.Math._SQRT2) == 0.5000000000000001 // due to precision\n```" - ], - "signature": "let log2: float => float" - }, - { - "id": "Js.Math.max_int", - "kind": "value", - "name": "max_int", - "docstrings": [ - "Returns the maximum of its two integer arguments. See\n[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)\non MDN." - ], - "signature": "let max_int: (int, int) => int" - }, - { - "id": "Js.Math.maxMany_int", - "kind": "value", - "name": "maxMany_int", - "docstrings": [ - "Returns the maximum of the integers in the given array. See\n[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)\non MDN." - ], - "signature": "let maxMany_int: array => int" - }, - { - "id": "Js.Math.max_float", - "kind": "value", - "name": "max_float", - "docstrings": [ - "Returns the maximum of its two floating point arguments. See\n[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)\non MDN." - ], - "signature": "let max_float: (float, float) => float" - }, - { - "id": "Js.Math.maxMany_float", - "kind": "value", - "name": "maxMany_float", - "docstrings": [ - "Returns the maximum of the floating point values in the given array. See\n[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)\non MDN." - ], - "signature": "let maxMany_float: array => float" - }, - { - "id": "Js.Math.min_int", - "kind": "value", - "name": "min_int", - "docstrings": [ - "Returns the minimum of its two integer arguments. See\n[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)\non MDN." - ], - "signature": "let min_int: (int, int) => int" - }, - { - "id": "Js.Math.minMany_int", - "kind": "value", - "name": "minMany_int", - "docstrings": [ - "Returns the minimum of the integers in the given array. See\n[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)\non MDN." - ], - "signature": "let minMany_int: array => int" - }, - { - "id": "Js.Math.min_float", - "kind": "value", - "name": "min_float", - "docstrings": [ - "Returns the minimum of its two floating point arguments. See\n[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)\non MDN." - ], - "signature": "let min_float: (float, float) => float" - }, - { - "id": "Js.Math.minMany_float", - "kind": "value", - "name": "minMany_float", - "docstrings": [ - "Returns the minimum of the floating point values in the given array. See\n[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)\non MDN." - ], - "signature": "let minMany_float: array => float" - }, - { - "id": "Js.Math.pow_int", - "kind": "value", - "name": "pow_int", - "docstrings": [ - "Raises the given base to the given exponent. (Arguments and result are\nintegers.) See\n[`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.pow_int(~base=3, ~exp=4) == 81\n```" - ], - "signature": "let pow_int: (~base: int, ~exp: int) => int", - "deprecated": "use `pow_float` instead, the return type may be not int" - }, - { - "id": "Js.Math.pow_float", - "kind": "value", - "name": "pow_float", - "docstrings": [ - "Raises the given base to the given exponent. (Arguments and result are\nfloats.) Returns `NaN` if the result would be imaginary. See\n[`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.pow_float(~base=3.0, ~exp=4.0) == 81.0\nJs.Math.pow_float(~base=4.0, ~exp=-2.0) == 0.0625\nJs.Math.pow_float(~base=625.0, ~exp=0.5) == 25.0\nJs.Math.pow_float(~base=625.0, ~exp=-0.5) == 0.04\nJs.Float.isNaN(Js.Math.pow_float(~base=-2.0, ~exp=0.5)) == true\n```" - ], - "signature": "let pow_float: (~base: float, ~exp: float) => float" - }, - { - "id": "Js.Math.random", - "kind": "value", - "name": "random", - "docstrings": [ - "Returns a random number in the half-closed interval [0,1). See\n[`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)\non MDN." - ], - "signature": "let random: unit => float" - }, - { - "id": "Js.Math.random_int", - "kind": "value", - "name": "random_int", - "docstrings": [ - "A call to `random_int(minVal, maxVal)` returns a random number in the\nhalf-closed interval [minVal, maxVal). See\n[`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)\non MDN." - ], - "signature": "let random_int: (int, int) => int" - }, - { - "id": "Js.Math.unsafe_round", - "kind": "value", - "name": "unsafe_round", - "docstrings": [ - "Rounds its argument to nearest integer. For numbers with a fractional portion\nof exactly 0.5, the argument is rounded to the next integer in the direction\nof positive infinity. This function may return values not representable by\n`int`, whose range is -2147483648 to 2147483647. This is because, in\nJavaScript, there are only 64-bit floating point numbers, which can represent\nintegers in the range ±(253-1) exactly. See\n[`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)\non MDN.\n\n## Examples\n\n```rescript\nJs.Math.unsafe_round(3.7) == 4\nJs.Math.unsafe_round(-3.5) == -3\nJs.Math.unsafe_round(2_150_000_000_000.3) // out of range for int\n```" - ], - "signature": "let unsafe_round: float => int" - }, - { - "id": "Js.Math.round", - "kind": "value", - "name": "round", - "docstrings": [ - "Rounds to nearest integral value (expressed as a float). See\n[`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)\non MDN." - ], - "signature": "let round: float => float" - }, - { - "id": "Js.Math.sign_int", - "kind": "value", - "name": "sign_int", - "docstrings": [ - "Returns the sign of its integer argument: -1 if negative, 0 if zero, 1 if\npositive. See\n[`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)\non MDN." - ], - "signature": "let sign_int: int => int" - }, - { - "id": "Js.Math.sign_float", - "kind": "value", - "name": "sign_float", - "docstrings": [ - "Returns the sign of its float argument: -1.0 if negative, 0.0 if zero, 1.0 if\npositive. See\n[`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)\non MDN." - ], - "signature": "let sign_float: float => float" - }, - { - "id": "Js.Math.sin", - "kind": "value", - "name": "sin", - "docstrings": [ - "Sine of argument, which must be specified in radians. See\n[`Math.sin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)\non MDN." - ], - "signature": "let sin: float => float" - }, - { - "id": "Js.Math.sinh", - "kind": "value", - "name": "sinh", - "docstrings": [ - "Hyperbolic sine of argument, which must be specified in radians. See\n[`Math.sinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)\non MDN." - ], - "signature": "let sinh: float => float" - }, - { - "id": "Js.Math.sqrt", - "kind": "value", - "name": "sqrt", - "docstrings": [ - "Square root. If the argument is negative, this function returns `NaN`. See\n[`Math.sqrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)\non MDN." - ], - "signature": "let sqrt: float => float" - }, - { - "id": "Js.Math.tan", - "kind": "value", - "name": "tan", - "docstrings": [ - "Tangent of argument, which must be specified in radians. Returns `NaN` if the\nargument is positive infinity or negative infinity. See\n[`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)\non MDN." - ], - "signature": "let tan: float => float" - }, - { - "id": "Js.Math.tanh", - "kind": "value", - "name": "tanh", - "docstrings": [ - "Hyperbolic tangent of argument, which must be specified in radians. See\n[`Math.tanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)\non MDN." - ], - "signature": "let tanh: float => float" - }, - { - "id": "Js.Math.unsafe_trunc", - "kind": "value", - "name": "unsafe_trunc", - "docstrings": [ - "Truncates its argument; i.e., removes fractional digits. This function may\nreturn values not representable by `int`, whose range is -2147483648 to\n2147483647. This is because, in JavaScript, there are only 64-bit floating\npoint numbers, which can represent integers in the range ±(253-1)\nexactly. See\n[`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)\non MDN." - ], - "signature": "let unsafe_trunc: float => int" - }, - { - "id": "Js.Math.trunc", - "kind": "value", - "name": "trunc", - "docstrings": [ - "Truncates its argument; i.e., removes fractional digits. See\n[`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)\non MDN." - ], - "signature": "let trunc: float => float" - } - ] - }, - "js/json": { - "id": "Js.Json", - "name": "Json", - "docstrings": [ - "Provide utilities for json", - "Efficient JSON encoding using JavaScript API\n\n**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON)" - ], - "items": [ - { - "id": "Js.Json.t", - "kind": "type", - "name": "t", - "docstrings": ["The JSON data structure"], - "signature": "type t =\n | Boolean(bool)\n | Null\n | String(string)\n | Number(float)\n | Object(Js.Dict.t)\n | Array(array)" - }, - { - "id": "Js.Json.tagged_t", - "kind": "type", - "name": "tagged_t", - "docstrings": [], - "signature": "type tagged_t =\n | JSONFalse\n | JSONTrue\n | JSONNull\n | JSONString(string)\n | JSONNumber(float)\n | JSONObject(Js_dict.t)\n | JSONArray(array)" - }, - { - "id": "Js.Json.classify", - "kind": "value", - "name": "classify", - "docstrings": [], - "signature": "let classify: t => tagged_t" - }, - { - "id": "Js.Json.test", - "kind": "value", - "name": "test", - "docstrings": ["`test(v, kind)` returns `true` if `v` is of `kind`."], - "signature": "let test: ('a, Kind.t<'b>) => bool" - }, - { - "id": "Js.Json.decodeString", - "kind": "value", - "name": "decodeString", - "docstrings": [ - "`decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise." - ], - "signature": "let decodeString: t => option" - }, - { - "id": "Js.Json.decodeNumber", - "kind": "value", - "name": "decodeNumber", - "docstrings": [ - "`decodeNumber(json)` returns `Some(n)` if `json` is a `number`, `None` otherwise." - ], - "signature": "let decodeNumber: t => option" - }, - { - "id": "Js.Json.decodeObject", - "kind": "value", - "name": "decodeObject", - "docstrings": [ - "`decodeObject(json)` returns `Some(o)` if `json` is an `object`, `None` otherwise." - ], - "signature": "let decodeObject: t => option>" - }, - { - "id": "Js.Json.decodeArray", - "kind": "value", - "name": "decodeArray", - "docstrings": [ - "`decodeArray(json)` returns `Some(a)` if `json` is an `array`, `None` otherwise." - ], - "signature": "let decodeArray: t => option>" - }, - { - "id": "Js.Json.decodeBoolean", - "kind": "value", - "name": "decodeBoolean", - "docstrings": [ - "`decodeBoolean(json)` returns `Some(b)` if `json` is a `boolean`, `None` otherwise." - ], - "signature": "let decodeBoolean: t => option" - }, - { - "id": "Js.Json.decodeNull", - "kind": "value", - "name": "decodeNull", - "docstrings": [ - "`decodeNull(json)` returns `Some(null)` if `json` is a `null`, `None` otherwise." - ], - "signature": "let decodeNull: t => option>" - }, - { - "id": "Js.Json.null", - "kind": "value", - "name": "null", - "docstrings": ["`null` is the singleton null JSON value."], - "signature": "let null: t" - }, - { - "id": "Js.Json.string", - "kind": "value", - "name": "string", - "docstrings": ["`string(s)` makes a JSON string of the `string` `s`."], - "signature": "let string: string => t" - }, - { - "id": "Js.Json.number", - "kind": "value", - "name": "number", - "docstrings": ["`number(n)` makes a JSON number of the `float` `n`."], - "signature": "let number: float => t" - }, - { - "id": "Js.Json.boolean", - "kind": "value", - "name": "boolean", - "docstrings": ["`boolean(b)` makes a JSON boolean of the `bool` `b`."], - "signature": "let boolean: bool => t" - }, - { - "id": "Js.Json.object_", - "kind": "value", - "name": "object_", - "docstrings": [ - "`object_(dict)` makes a JSON object of the `Js.Dict.t` `dict`." - ], - "signature": "let object_: Js_dict.t => t" - }, - { - "id": "Js.Json.array", - "kind": "value", - "name": "array", - "docstrings": [ - "`array_(a)` makes a JSON array of the `Js.Json.t` array `a`." - ], - "signature": "let array: array => t" - }, - { - "id": "Js.Json.stringArray", - "kind": "value", - "name": "stringArray", - "docstrings": [ - "`stringArray(a)` makes a JSON array of the `string` array `a`." - ], - "signature": "let stringArray: array => t" - }, - { - "id": "Js.Json.numberArray", - "kind": "value", - "name": "numberArray", - "docstrings": [ - "`numberArray(a)` makes a JSON array of the `float` array `a`." - ], - "signature": "let numberArray: array => t" - }, - { - "id": "Js.Json.booleanArray", - "kind": "value", - "name": "booleanArray", - "docstrings": [ - "`booleanArray(a)` makes a JSON array of the `bool` array `a`." - ], - "signature": "let booleanArray: array => t" - }, - { - "id": "Js.Json.objectArray", - "kind": "value", - "name": "objectArray", - "docstrings": [ - "`objectArray(a) makes a JSON array of the `JsDict.t` array `a`." - ], - "signature": "let objectArray: array> => t" - }, - { - "id": "Js.Json.parseExn", - "kind": "value", - "name": "parseExn", - "docstrings": [ - "`parseExn(s)` parses the `string` `s` into a JSON data structure.\nReturns a JSON data structure.\nRaises `SyntaxError` if the given string is not a valid JSON. Note: `SyntaxError` is a JavaScript exception.\n\nSee [`parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) on MDN.\n\n## Examples\n\n```rescript\n/* parse a simple JSON string */\n\nlet json = try Js.Json.parseExn(` \"hello\" `) catch {\n| _ => failwith(\"Error parsing JSON string\")\n}\n\nswitch Js.Json.classify(json) {\n| Js.Json.JSONString(value) => Js.log(value)\n| _ => failwith(\"Expected a string\")\n}\n```\n\n```rescript\n/* parse a complex JSON string */\n\nlet getIds = s => {\n let json = try Js.Json.parseExn(s) catch {\n | _ => failwith(\"Error parsing JSON string\")\n }\n\n switch Js.Json.classify(json) {\n | Js.Json.JSONObject(value) =>\n /* In this branch, compiler infer value : Js.Json.t Js.Dict.t */\n switch Js.Dict.get(value, \"ids\") {\n | Some(ids) =>\n switch Js.Json.classify(ids) {\n | Js.Json.JSONArray(ids) => /* In this branch compiler infer ids : Js.Json.t array */\n ids\n | _ => failwith(\"Expected an array\")\n }\n | None => failwith(\"Expected an `ids` property\")\n }\n | _ => failwith(\"Expected an object\")\n }\n}\n\n/* prints `1, 2, 3` */\nJs.log(getIds(` { \"ids\" : [1, 2, 3 ] } `))\n```" - ], - "signature": "let parseExn: string => t" - }, - { - "id": "Js.Json.stringify", - "kind": "value", - "name": "stringify", - "docstrings": [ - "`stringify(json)` formats the JSON data structure as a `string`.\nReturns the string representation of a given JSON data structure.\n\nSee [`stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) on MDN.\n\n## Examples\n\n```rescript\n/* Creates and stringifies a simple JS object */\n\nlet dict = Js.Dict.empty()\nJs.Dict.set(dict, \"name\", Js.Json.string(\"John Doe\"))\nJs.Dict.set(dict, \"age\", Js.Json.number(30.0))\nJs.Dict.set(dict, \"likes\", Js.Json.stringArray([\"ReScript\", \"ocaml\", \"js\"]))\n\nJs.log(Js.Json.stringify(Js.Json.object_(dict)))\n```" - ], - "signature": "let stringify: t => string" - }, - { - "id": "Js.Json.stringifyWithSpace", - "kind": "value", - "name": "stringifyWithSpace", - "docstrings": [ - "`stringifyWithSpace(json)` formats the JSON data structure as a `string`.\nReturns the string representation of a given JSON data structure with spacing.\n\nSee [`stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) on MDN.\n\n## Examples\n\n```rescript\n/* Creates and stringifies a simple JS object with spacing */\n\nlet dict = Js.Dict.empty()\nJs.Dict.set(dict, \"name\", Js.Json.string(\"John Doe\"))\nJs.Dict.set(dict, \"age\", Js.Json.number(30.0))\nJs.Dict.set(dict, \"likes\", Js.Json.stringArray([\"ReScript\", \"ocaml\", \"js\"]))\n\nJs.log(Js.Json.stringifyWithSpace(Js.Json.object_(dict), 2))\n```" - ], - "signature": "let stringifyWithSpace: (t, int) => string" - }, - { - "id": "Js.Json.stringifyAny", - "kind": "value", - "name": "stringifyAny", - "docstrings": [ - "`stringifyAny(value)` formats any value into a JSON string.\n\n## Examples\n\n```rescript\n/* prints `[\"hello\", \"world\"]` */\nJs.log(Js.Json.stringifyAny([\"hello\", \"world\"]))\n```" - ], - "signature": "let stringifyAny: 'a => option" - }, - { - "id": "Js.Json.deserializeUnsafe", - "kind": "value", - "name": "deserializeUnsafe", - "docstrings": [ - "Best-effort serialization, it tries to seralize as\nmany objects as possible and deserialize it back\n\nIt is unsafe in two aspects\n- It may throw during parsing\n- when you cast it to a specific type, it may have a type mismatch" - ], - "signature": "let deserializeUnsafe: string => 'a" - }, - { - "id": "Js.Json.serializeExn", - "kind": "value", - "name": "serializeExn", - "docstrings": [ - "It will raise in such situations:\n- The object can not be serlialized to a JSON\n- There are cycles\n- Some JS engines can not stringify deeply nested json objects" - ], - "signature": "let serializeExn: 'a => string" - } - ] - }, - "js/global": { - "id": "Js.Global", - "name": "Global", - "docstrings": [ - "Provide bindings to JS global functions in global namespace", - "Contains functions available in the global scope (`window` in a browser context)" - ], - "items": [ - { - "id": "Js.Global.intervalId", - "kind": "type", - "name": "intervalId", - "docstrings": [ - "Identify an interval started by `Js.Global.setInterval`." - ], - "signature": "type intervalId" - }, - { - "id": "Js.Global.timeoutId", - "kind": "type", - "name": "timeoutId", - "docstrings": ["Identify timeout started by `Js.Global.setTimeout`."], - "signature": "type timeoutId" - }, - { - "id": "Js.Global.clearInterval", - "kind": "value", - "name": "clearInterval", - "docstrings": [ - "Clear an interval started by `Js.Global.setInterval`\n\n## Examples\n\n```rescript\n/* API for a somewhat aggressive snoozing alarm clock */\n\nlet punchSleepyGuy = () => Js.log(\"Punch\")\n\nlet interval = ref(Js.Nullable.null)\n\nlet remind = () => {\n Js.log(\"Wake Up!\")\n punchSleepyGuy()\n}\n\nlet snooze = mins =>\n interval := Js.Nullable.return(Js.Global.setInterval(remind, mins * 60 * 1000))\n\nlet cancel = () =>\n Js.Nullable.iter(interval.contents, (. intervalId) => Js.Global.clearInterval(intervalId))\n```" - ], - "signature": "let clearInterval: intervalId => unit" - }, - { - "id": "Js.Global.clearTimeout", - "kind": "value", - "name": "clearTimeout", - "docstrings": [ - "Clear a timeout started by `Js.Global.setTimeout`.\n\n## Examples\n\n```rescript\n/* A simple model of a code monkey's brain */\n\nlet closeHackerNewsTab = () => Js.log(\"close\")\n\nlet timer = ref(Js.Nullable.null)\n\nlet work = () => closeHackerNewsTab()\n\nlet procrastinate = mins => {\n Js.Nullable.iter(timer.contents, (. timer) => Js.Global.clearTimeout(timer))\n timer := Js.Nullable.return(Js.Global.setTimeout(work, mins * 60 * 1000))\n}\n```" - ], - "signature": "let clearTimeout: timeoutId => unit" - }, - { - "id": "Js.Global.setInterval", - "kind": "value", - "name": "setInterval", - "docstrings": [ - "Repeatedly executes a callback with a specified interval (in milliseconds)\nbetween calls. Returns a `Js.Global.intervalId` that can be passed to\n`Js.Global.clearInterval` to cancel the timeout.\n\n## Examples\n\n```rescript\n/* Will count up and print the count to the console every second */\n\nlet count = ref(0)\n\nlet tick = () => {\n count := count.contents + 1\n Js.log(Belt.Int.toString(count.contents))\n}\n\nJs.Global.setInterval(tick, 1000)\n```" - ], - "signature": "let setInterval: (unit => unit, int) => intervalId" - }, - { - "id": "Js.Global.setIntervalFloat", - "kind": "value", - "name": "setIntervalFloat", - "docstrings": [ - "Repeatedly executes a callback with a specified interval (in milliseconds)\nbetween calls. Returns a `Js.Global.intervalId` that can be passed to\n`Js.Global.clearInterval` to cancel the timeout.\n\n## Examples\n\n```rescript\n/* Will count up and print the count to the console every second */\n\nlet count = ref(0)\n\nlet tick = () => {\n count := count.contents + 1\n Js.log(Belt.Int.toString(count.contents))\n}\n\nJs.Global.setIntervalFloat(tick, 1000.0)\n```" - ], - "signature": "let setIntervalFloat: (unit => unit, float) => intervalId" - }, - { - "id": "Js.Global.setTimeout", - "kind": "value", - "name": "setTimeout", - "docstrings": [ - "Execute a callback after a specified delay (in milliseconds). Returns a\n`Js.Global.timeoutId` that can be passed to `Js.Global.clearTimeout` to cancel\nthe timeout.\n\n## Examples\n\n```rescript\n/* Prints \"Timed out!\" in the console after one second */\n\nlet message = \"Timed out!\"\n\nJs.Global.setTimeout(() => Js.log(message), 1000)\n```" - ], - "signature": "let setTimeout: (unit => unit, int) => timeoutId" - }, - { - "id": "Js.Global.setTimeoutFloat", - "kind": "value", - "name": "setTimeoutFloat", - "docstrings": [ - "Execute a callback after a specified delay (in milliseconds). Returns a\n`Js.Global.timeoutId` that can be passed to `Js.Global.clearTimeout` to cancel\nthe timeout.\n\n## Examples\n\n```rescript\n/* Prints \"Timed out!\" in the console after one second */\n\nlet message = \"Timed out!\"\n\nJs.Global.setTimeoutFloat(() => Js.log(message), 1000.0)\n```" - ], - "signature": "let setTimeoutFloat: (unit => unit, float) => timeoutId" - }, - { - "id": "Js.Global.encodeURI", - "kind": "value", - "name": "encodeURI", - "docstrings": [ - "URL-encodes a string.\n\nSee [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) on MDN." - ], - "signature": "let encodeURI: string => string" - }, - { - "id": "Js.Global.decodeURI", - "kind": "value", - "name": "decodeURI", - "docstrings": [ - "Decodes a URL-enmcoded string produced by `encodeURI`\n\nSee [`decodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI) on MDN." - ], - "signature": "let decodeURI: string => string" - }, - { - "id": "Js.Global.encodeURIComponent", - "kind": "value", - "name": "encodeURIComponent", - "docstrings": [ - "URL-encodes a string, including characters with special meaning in a URI.\n\nSee [`encodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) on MDN." - ], - "signature": "let encodeURIComponent: string => string" - }, - { - "id": "Js.Global.decodeURIComponent", - "kind": "value", - "name": "decodeURIComponent", - "docstrings": [ - "Decodes a URL-enmcoded string produced by `encodeURIComponent`\n\nSee [`decodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) on MDN." - ], - "signature": "let decodeURIComponent: string => string" - } - ] - }, - "js/dict": { - "id": "Js.Dict", - "name": "Dict", - "docstrings": [ - "Provide utilities for JS dictionary object", - "Provide utilities for JS dictionary object.\n\n**Note:** This module's examples will assume this predeclared dictionary:\n\n## Examples\n\n```rescript\nlet ages = Js.Dict.fromList(list{(\"Maria\", 30), (\"Vinh\", 22), (\"Fred\", 49)})\n```" - ], - "items": [ - { - "id": "Js.Dict.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = dict<'a>" - }, - { - "id": "Js.Dict.key", - "kind": "type", - "name": "key", - "docstrings": [ - "The type for dictionary keys. This means that dictionaries *must* use `string`s as their keys." - ], - "signature": "type key = string" - }, - { - "id": "Js.Dict.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`Js.Dict.get(key)` returns `None` if the key is not found in the dictionary,\n`Some(value)` otherwise.\n\n## Examples\n\n```rescript\nJs.Dict.get(ages, \"Vinh\") == Some(22)\nJs.Dict.get(ages, \"Paul\") == None\n```" - ], - "signature": "let get: (t<'a>, key) => option<'a>" - }, - { - "id": "Js.Dict.unsafeGet", - "kind": "value", - "name": "unsafeGet", - "docstrings": [ - "`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).\n\n## Examples\n\n```rescript\nJs.Dict.unsafeGet(ages, \"Fred\") == 49\nJs.Dict.unsafeGet(ages, \"Paul\") // returns undefined\n```" - ], - "signature": "let unsafeGet: (t<'a>, key) => 'a" - }, - { - "id": "Js.Dict.set", - "kind": "value", - "name": "set", - "docstrings": [ - "`Js.Dict.set(dict, key, value)` sets the key/value in the dictionary `dict`. If\nthe key does not exist, and entry will be created for it.\n\n*This function modifies the original dictionary.*\n\n## Examples\n\n```rescript\nJs.Dict.set(ages, \"Maria\", 31)\nJs.log(ages == Js.Dict.fromList(list{(\"Maria\", 31), (\"Vinh\", 22), (\"Fred\", 49)}))\n\nJs.Dict.set(ages, \"David\", 66)\nJs.log(ages == Js.Dict.fromList(list{(\"Maria\", 31), (\"Vinh\", 22), (\"Fred\", 49), (\"David\", 66)}))\n```" - ], - "signature": "let set: (t<'a>, key, 'a) => unit" - }, - { - "id": "Js.Dict.keys", - "kind": "value", - "name": "keys", - "docstrings": [ - "Returns all the keys in the dictionary `dict`.\n\n## Examples\n\n```rescript\nJs.Dict.keys(ages) == [\"Maria\", \"Vinh\", \"Fred\"]\n```" - ], - "signature": "let keys: t<'a> => array" - }, - { - "id": "Js.Dict.empty", - "kind": "value", - "name": "empty", - "docstrings": ["Returns an empty dictionary."], - "signature": "let empty: unit => t<'a>" - }, - { - "id": "Js.Dict.unsafeDeleteKey", - "kind": "value", - "name": "unsafeDeleteKey", - "docstrings": ["Experimental internal function"], - "signature": "let unsafeDeleteKey: (t, string) => unit" - }, - { - "id": "Js.Dict.entries", - "kind": "value", - "name": "entries", - "docstrings": [ - "Returns an array of key/value pairs in the given dictionary (ES2017).\n\n## Examples\n\n```rescript\nJs.Dict.entries(ages) == [(\"Maria\", 30), (\"Vinh\", 22), (\"Fred\", 49)]\n```" - ], - "signature": "let entries: t<'a> => array<(key, 'a)>" - }, - { - "id": "Js.Dict.values", - "kind": "value", - "name": "values", - "docstrings": [ - "Returns the values in the given dictionary (ES2017).\n\n## Examples\n\n```rescript\nJs.Dict.values(ages) == [30, 22, 49]\n```" - ], - "signature": "let values: t<'a> => array<'a>" - }, - { - "id": "Js.Dict.fromList", - "kind": "value", - "name": "fromList", - "docstrings": [ - "Creates a new dictionary containing each (key, value) pair in its list\nargument.\n\n## Examples\n\n```rescript\nlet capitals = Js.Dict.fromList(list{(\"Japan\", \"Tokyo\"), (\"France\", \"Paris\"), (\"Egypt\", \"Cairo\")})\n```" - ], - "signature": "let fromList: list<(key, 'a)> => t<'a>" - }, - { - "id": "Js.Dict.fromArray", - "kind": "value", - "name": "fromArray", - "docstrings": [ - "Creates a new dictionary containing each (key, value) pair in its array\nargument.\n\n## Examples\n\n```rescript\nlet capitals2 = Js.Dict.fromArray([(\"Germany\", \"Berlin\"), (\"Burkina Faso\", \"Ouagadougou\")])\n```" - ], - "signature": "let fromArray: array<(key, 'a)> => t<'a>" - }, - { - "id": "Js.Dict.map", - "kind": "value", - "name": "map", - "docstrings": [ - "`map(f, dict)` maps `dict` to a new dictionary with the same keys, using the\nfunction `f` to map each value.\n\n## Examples\n\n```rescript\nlet prices = Js.Dict.fromList(list{(\"pen\", 1.00), (\"book\", 5.00), (\"stapler\", 7.00)})\n\nlet discount = (. price) => price *. 0.90\nlet salePrices = Js.Dict.map(discount, prices)\n\nsalePrices == Js.Dict.fromList(list{(\"pen\", 0.90), (\"book\", 4.50), (\"stapler\", 6.30)})\n```" - ], - "signature": "let map: ('a => 'b, t<'a>) => t<'b>" - } - ] - }, - "js/date": { - "id": "Js.Date", - "name": "Date", - "docstrings": [ - "Provide bindings for JS Date", - "Provide bindings to JS date. (See\n[`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)\non MDN.) JavaScript stores dates as the number of milliseconds since the UNIX\n*epoch*, midnight 1 January 1970, UTC." - ], - "items": [ - { - "id": "Js.Date.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t" - }, - { - "id": "Js.Date.valueOf", - "kind": "value", - "name": "valueOf", - "docstrings": [ - "Returns the primitive value of this date, equivalent to `getTime()`. (See\n[`Date.valueOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)\non MDN.)\n\n## Examples\n\n```rescript\nJs.Date.valueOf(exampleDate) == 123456654321.0\n```" - ], - "signature": "let valueOf: t => float" - }, - { - "id": "Js.Date.make", - "kind": "value", - "name": "make", - "docstrings": [ - "Returns a date representing the current time. See [`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\non MDN.\n\n## Examples\n\n```rescript\nlet now = Js.Date.make()\n```" - ], - "signature": "let make: unit => t" - }, - { - "id": "Js.Date.fromFloat", - "kind": "value", - "name": "fromFloat", - "docstrings": [ - "Returns a date representing the given argument, which is a number of\nmilliseconds since the epoch. See [`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.fromFloat(123456654321.0) == exampleDate\n```" - ], - "signature": "let fromFloat: float => t" - }, - { - "id": "Js.Date.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "Returns a `Js.Date.t` represented by the given string. The string can be in\n“IETF-compliant RFC 2822 timestamps, and also strings in a version of ISO8601.”\nReturns `NaN` if given an invalid date string. According to the [`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\ndocumentation on MDN, its use is discouraged.\n\n## Examples\n\n```rescript\nJs.Date.fromString(\"Thu, 29 Nov 1973 21:30:54.321 GMT\") == exampleDate\nJs.Date.fromString(\"1973-11-29T21:30:54.321Z00:00\") == exampleDate\nJs.Date.fromString(\"Thor, 32 Lok -19 60:70:80 XYZ\") // returns NaN\n```" - ], - "signature": "let fromString: string => t" - }, - { - "id": "Js.Date.makeWithYM", - "kind": "value", - "name": "makeWithYM", - "docstrings": [ - "Returns a date representing midnight of the first day of the given month and\nyear in the current time zone. Fractional parts of arguments are ignored. See\n[`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\non MDN.\n\n## Examples\n\n```rescript\nlet november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ())\n```" - ], - "signature": "let makeWithYM: (~year: float, ~month: float, unit) => t" - }, - { - "id": "Js.Date.makeWithYMD", - "kind": "value", - "name": "makeWithYMD", - "docstrings": [ - "Returns a date representing midnight of the given date of the given month and\nyear in the current time zone. Fractional parts of arguments are ignored. See\n[`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\non MDN." - ], - "signature": "let makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t" - }, - { - "id": "Js.Date.makeWithYMDH", - "kind": "value", - "name": "makeWithYMDH", - "docstrings": [ - "Returns a date representing the given date of the given month and year, at zero\nminutes and zero seconds past the given `hours`, in the current time zone.\nFractional parts of arguments are ignored. See [`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\non MDN. Fractional parts of the arguments are ignored." - ], - "signature": "let makeWithYMDH: (\n ~year: float,\n ~month: float,\n ~date: float,\n ~hours: float,\n unit,\n) => t" - }, - { - "id": "Js.Date.makeWithYMDHM", - "kind": "value", - "name": "makeWithYMDHM", - "docstrings": [ - "Returns a date representing the given date of the given month and year, at zero\nseconds past the given time in hours and minutes in the current time zone.\nFractional parts of arguments are ignored. See [`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\non MDN." - ], - "signature": "let makeWithYMDHM: (\n ~year: float,\n ~month: float,\n ~date: float,\n ~hours: float,\n ~minutes: float,\n unit,\n) => t" - }, - { - "id": "Js.Date.makeWithYMDHMS", - "kind": "value", - "name": "makeWithYMDHMS", - "docstrings": [ - "Returns a date representing the given date of the given month and year, at the\ngiven time in hours, minutes, and seconds in the current time zone. Fractional\nparts of arguments are ignored. See [`Date()`\nConstructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.makeWithYMDHMS(\n ~year=1973.0,\n ~month=11.0,\n ~date=29.0,\n ~hours=21.0,\n ~minutes=30.0,\n ~seconds=54.321,\n (),\n) == exampleDate\n```" - ], - "signature": "let makeWithYMDHMS: (\n ~year: float,\n ~month: float,\n ~date: float,\n ~hours: float,\n ~minutes: float,\n ~seconds: float,\n unit,\n) => t" - }, - { - "id": "Js.Date.utcWithYM", - "kind": "value", - "name": "utcWithYM", - "docstrings": [ - "Returns a float representing the number of milliseconds past the epoch for\nmidnight of the first day of the given month and year in UTC. Fractional parts\nof arguments are ignored. See\n[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)\non MDN.\n\n## Examples\n\n```rescript\nlet november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ())\n```" - ], - "signature": "let utcWithYM: (~year: float, ~month: float, unit) => float" - }, - { - "id": "Js.Date.utcWithYMD", - "kind": "value", - "name": "utcWithYMD", - "docstrings": [ - "Returns a float representing the number of milliseconds past the epoch for\nmidnight of the given date of the given month and year in UTC. Fractional parts\nof arguments are ignored. See\n[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)\non MDN." - ], - "signature": "let utcWithYMD: (~year: float, ~month: float, ~date: float, unit) => float" - }, - { - "id": "Js.Date.utcWithYMDH", - "kind": "value", - "name": "utcWithYMDH", - "docstrings": [ - "Returns a float representing the number of milliseconds past the epoch for\nmidnight of the given date of the given month and year, at zero minutes and\nseconds past the given hours in UTC. Fractional parts of arguments are ignored.\nSee\n[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)\non MDN." - ], - "signature": "let utcWithYMDH: (\n ~year: float,\n ~month: float,\n ~date: float,\n ~hours: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.utcWithYMDHM", - "kind": "value", - "name": "utcWithYMDHM", - "docstrings": [ - "Returns a float representing the number of milliseconds past the epoch for\nmidnight of the given date of the given month and year, at zero seconds past\nthe given number of minutes past the given hours in UTC. Fractional parts of\narguments are ignored. See\n[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)\non MDN." - ], - "signature": "let utcWithYMDHM: (\n ~year: float,\n ~month: float,\n ~date: float,\n ~hours: float,\n ~minutes: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.utcWithYMDHMS", - "kind": "value", - "name": "utcWithYMDHMS", - "docstrings": [ - "Returns a float representing the number of milliseconds past the epoch for\nmidnight of the given date of the given month and year, at the given time in\nhours, minutes and seconds in UTC. Fractional parts of arguments are ignored.\n\nSee\n[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)\non MDN." - ], - "signature": "let utcWithYMDHMS: (\n ~year: float,\n ~month: float,\n ~date: float,\n ~hours: float,\n ~minutes: float,\n ~seconds: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.now", - "kind": "value", - "name": "now", - "docstrings": [ - "Returns the current time as number of milliseconds since Unix epoch." - ], - "signature": "let now: unit => float" - }, - { - "id": "Js.Date.parse", - "kind": "value", - "name": "parse", - "docstrings": [], - "signature": "let parse: string => t", - "deprecated": "Please use `fromString` instead" - }, - { - "id": "Js.Date.parseAsFloat", - "kind": "value", - "name": "parseAsFloat", - "docstrings": [ - "Returns a float with the number of milliseconds past the epoch represented by\nthe given string. The string can be in “IETF-compliant RFC 2822 timestamps, and\nalso strings in a version of ISO8601.” Returns `NaN` if given an invalid date\nstring. According to the\n[`Date.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)\ndocumentation on MDN, its use is discouraged. Returns `NaN` if passed invalid\ndate string." - ], - "signature": "let parseAsFloat: string => float" - }, - { - "id": "Js.Date.getDate", - "kind": "value", - "name": "getDate", - "docstrings": [ - "Returns the day of the month for its argument. The argument is evaluated in the\ncurrent time zone. See\n[`Date.getDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getDate(exampleDate) == 29.0\n```" - ], - "signature": "let getDate: t => float" - }, - { - "id": "Js.Date.getDay", - "kind": "value", - "name": "getDay", - "docstrings": [ - "Returns the day of the week (0.0-6.0) for its argument, where 0.0 represents\nSunday. The argument is evaluated in the current time zone. See\n[`Date.getDay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getDay(exampleDate) == 4.0\n```" - ], - "signature": "let getDay: t => float" - }, - { - "id": "Js.Date.getFullYear", - "kind": "value", - "name": "getFullYear", - "docstrings": [ - "Returns the full year (as opposed to the range 0-99) for its argument. The\nargument is evaluated in the current time zone. See\n[`Date.getFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getFullYear(exampleDate) == 1973.0\n```" - ], - "signature": "let getFullYear: t => float" - }, - { - "id": "Js.Date.getHours", - "kind": "value", - "name": "getHours", - "docstrings": [ - "Returns the hours for its argument, evaluated in the current time zone. See\n[`Date.getHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getHours(exampleDate) == 22.0 // Vienna is in GMT+01:00\n```" - ], - "signature": "let getHours: t => float" - }, - { - "id": "Js.Date.getMilliseconds", - "kind": "value", - "name": "getMilliseconds", - "docstrings": [ - "Returns the number of milliseconds for its argument, evaluated in the current\ntime zone. See\n[`Date.getMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getMilliseconds(exampleDate) == 321.0\n```" - ], - "signature": "let getMilliseconds: t => float" - }, - { - "id": "Js.Date.getMinutes", - "kind": "value", - "name": "getMinutes", - "docstrings": [ - "Returns the number of minutes for its argument, evaluated in the current time\nzone. See\n[`Date.getMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getMinutes(exampleDate) == 30.0\n```" - ], - "signature": "let getMinutes: t => float" - }, - { - "id": "Js.Date.getMonth", - "kind": "value", - "name": "getMonth", - "docstrings": [ - "Returns the month (0.0-11.0) for its argument, evaluated in the current time\nzone. January is month zero. See\n[`Date.getMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getMonth(exampleDate) == 10.0\n```" - ], - "signature": "let getMonth: t => float" - }, - { - "id": "Js.Date.getSeconds", - "kind": "value", - "name": "getSeconds", - "docstrings": [ - "Returns the seconds for its argument, evaluated in the current time zone. See\n[`Date.getSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getSeconds(exampleDate) == 54.0\n```" - ], - "signature": "let getSeconds: t => float" - }, - { - "id": "Js.Date.getTime", - "kind": "value", - "name": "getTime", - "docstrings": [ - "Returns the number of milliseconds since Unix epoch, evaluated in UTC. See\n[`Date.getTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getTime(exampleDate) == 123456654321.0\n```" - ], - "signature": "let getTime: t => float" - }, - { - "id": "Js.Date.getTimezoneOffset", - "kind": "value", - "name": "getTimezoneOffset", - "docstrings": [ - "Returns the time zone offset in minutes from the current time zone to UTC. See\n[`Date.getTimezoneOffset`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getTimezoneOffset(exampleDate) == -60.0\n```" - ], - "signature": "let getTimezoneOffset: t => float" - }, - { - "id": "Js.Date.getUTCDate", - "kind": "value", - "name": "getUTCDate", - "docstrings": [ - "Returns the day of the month of the argument, evaluated in UTC. See\n[`Date.getUTCDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCDate(exampleDate) == 29.0\n```" - ], - "signature": "let getUTCDate: t => float" - }, - { - "id": "Js.Date.getUTCDay", - "kind": "value", - "name": "getUTCDay", - "docstrings": [ - "Returns the day of the week of the argument, evaluated in UTC. The range of the\nreturn value is 0.0-6.0, where Sunday is zero. See\n[`Date.getUTCDay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCDay(exampleDate) == 4.0\n```" - ], - "signature": "let getUTCDay: t => float" - }, - { - "id": "Js.Date.getUTCFullYear", - "kind": "value", - "name": "getUTCFullYear", - "docstrings": [ - "Returns the full year (as opposed to the range 0-99) for its argument. The\nargument is evaluated in UTC. See\n[`Date.getUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCFullYear(exampleDate) == 1973.0\n```" - ], - "signature": "let getUTCFullYear: t => float" - }, - { - "id": "Js.Date.getUTCHours", - "kind": "value", - "name": "getUTCHours", - "docstrings": [ - "Returns the hours for its argument, evaluated in the current time zone. See\n[`Date.getUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCHours(exampleDate) == 21.0\n```" - ], - "signature": "let getUTCHours: t => float" - }, - { - "id": "Js.Date.getUTCMilliseconds", - "kind": "value", - "name": "getUTCMilliseconds", - "docstrings": [ - "Returns the number of milliseconds for its argument, evaluated in UTC. See\n[`Date.getUTCMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCMilliseconds(exampleDate) == 321.0\n```" - ], - "signature": "let getUTCMilliseconds: t => float" - }, - { - "id": "Js.Date.getUTCMinutes", - "kind": "value", - "name": "getUTCMinutes", - "docstrings": [ - "Returns the number of minutes for its argument, evaluated in UTC. See\n[`Date.getUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCMinutes(exampleDate) == 30.0\n```" - ], - "signature": "let getUTCMinutes: t => float" - }, - { - "id": "Js.Date.getUTCMonth", - "kind": "value", - "name": "getUTCMonth", - "docstrings": [ - "Returns the month (0.0-11.0) for its argument, evaluated in UTC. January is\nmonth zero. See\n[`Date.getUTCMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCMonth(exampleDate) == 10.0\n```" - ], - "signature": "let getUTCMonth: t => float" - }, - { - "id": "Js.Date.getUTCSeconds", - "kind": "value", - "name": "getUTCSeconds", - "docstrings": [ - "Returns the seconds for its argument, evaluated in UTC. See\n[`Date.getUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.getUTCSeconds(exampleDate) == 54.0\n```" - ], - "signature": "let getUTCSeconds: t => float" - }, - { - "id": "Js.Date.getYear", - "kind": "value", - "name": "getYear", - "docstrings": [], - "signature": "let getYear: t => float", - "deprecated": "Use `getFullYear` instead." - }, - { - "id": "Js.Date.setDate", - "kind": "value", - "name": "setDate", - "docstrings": [ - "Sets the given `Date`’s day of month to the value in the second argument\naccording to the current time zone. Returns the number of milliseconds since\nthe epoch of the updated `Date`. *This function modifies the original `Date`.*\nSee\n[`Date.setDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet twoWeeksBefore = Js.Date.setDate(date1, 15.0)\ndate1 == Js.Date.fromString(\"1973-11-15T21:30:54.321Z00:00\")\ntwoWeeksBefore == Js.Date.getTime(date1)\n```" - ], - "signature": "let setDate: (t, float) => float" - }, - { - "id": "Js.Date.setFullYear", - "kind": "value", - "name": "setFullYear", - "docstrings": [ - "Sets the given `Date`’s year to the value in the second argument according to\nthe current time zone. Returns the number of milliseconds since the epoch of\nthe updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet nextYear = Js.Date.setFullYear(date1, 1974.0)\ndate1 == Js.Date.fromString(\"1974-11-15T21:30:54.321Z00:00\")\nnextYear == Js.Date.getTime(date1)\n```" - ], - "signature": "let setFullYear: (t, float) => float" - }, - { - "id": "Js.Date.setFullYearM", - "kind": "value", - "name": "setFullYearM", - "docstrings": [ - "Sets the given `Date`’s year and month to the values in the labeled arguments\naccording to the current time zone. Returns the number of milliseconds since\nthe epoch of the updated `Date`. *This function modifies the original `Date`.*\nSee\n[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet future = Js.Date.setFullYearM(date1, ~year=1974.0, ~month=0.0, ())\ndate1 == Js.Date.fromString(\"1974-01-22T21:30:54.321Z00:00\")\nfuture == Js.Date.getTime(date1)\n```" - ], - "signature": "let setFullYearM: (t, ~year: float, ~month: float, unit) => float" - }, - { - "id": "Js.Date.setFullYearMD", - "kind": "value", - "name": "setFullYearMD", - "docstrings": [ - "Sets the given `Date`’s year, month, and day of month to the values in the\nlabeled arguments according to the current time zone. Returns the number of\nmilliseconds since the epoch of the updated `Date`. *This function modifies the\noriginal `Date`.* See\n[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet future = Js.Date.setFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ())\ndate1 == Js.Date.fromString(\"1974-01-07T21:30:54.321Z00:00\")\nfuture == Js.Date.getTime(date1)\n```" - ], - "signature": "let setFullYearMD: (\n t,\n ~year: float,\n ~month: float,\n ~date: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setHours", - "kind": "value", - "name": "setHours", - "docstrings": [ - "Sets the given `Date`’s hours to the value in the second argument according to\nthe current time zone. Returns the number of milliseconds since the epoch of\nthe updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet nextHour = Js.Date.setHours(date1, 22.0)\ndate1 == Js.Date.fromString(\"1973-11-29T22:30:54.321Z00:00\")\nnextHour == Js.Date.getTime(date1)\n```" - ], - "signature": "let setHours: (t, float) => float" - }, - { - "id": "Js.Date.setHoursM", - "kind": "value", - "name": "setHoursM", - "docstrings": [ - "Sets the given `Date`’s hours and minutes to the values in the labeled\narguments according to the current time zone. Returns the number of\nmilliseconds since the epoch of the updated `Date`. *This function modifies the\noriginal `Date`.* See\n[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setHoursM(date1, ~hours=22.0, ~minutes=46.0, ())\ndate1 == Js.Date.fromString(\"1973-11-29T22:46:54.321Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setHoursM: (t, ~hours: float, ~minutes: float, unit) => float" - }, - { - "id": "Js.Date.setHoursMS", - "kind": "value", - "name": "setHoursMS", - "docstrings": [ - "Sets the given `Date`’s hours, minutes, and seconds to the values in the\nlabeled arguments according to the current time zone. Returns the number of\nmilliseconds since the epoch of the updated `Date`. *This function modifies the\noriginal `Date`.* See\n[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setHoursMS(date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ())\ndate1 == Js.Date.fromString(\"1973-11-29T22:46:37.321Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setHoursMS: (\n t,\n ~hours: float,\n ~minutes: float,\n ~seconds: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setHoursMSMs", - "kind": "value", - "name": "setHoursMSMs", - "docstrings": [ - "Sets the given `Date`’s hours, minutes, seconds, and milliseconds to the values\nin the labeled arguments according to the current time zone. Returns the number\nof milliseconds since the epoch of the updated `Date`. *This function modifies\nthe original `Date`.* See\n[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setHoursMSMs(\n date1,\n ~hours=22.0,\n ~minutes=46.0,\n ~seconds=37.0,\n ~milliseconds=494.0,\n (),\n)\ndate1 == Js.Date.fromString(\"1973-11-29T22:46:37.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setHoursMSMs: (\n t,\n ~hours: float,\n ~minutes: float,\n ~seconds: float,\n ~milliseconds: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setMilliseconds", - "kind": "value", - "name": "setMilliseconds", - "docstrings": [ - "Sets the given `Date`’s milliseconds to the value in the second argument\naccording to the current time zone. Returns the number of milliseconds since\nthe epoch of the updated `Date`. *This function modifies the original `Date`.*\nSee\n[`Date.setMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setMilliseconds(date1, 494.0)\ndate1 == Js.Date.fromString(\"1973-11-29T21:30:54.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setMilliseconds: (t, float) => float" - }, - { - "id": "Js.Date.setMinutes", - "kind": "value", - "name": "setMinutes", - "docstrings": [ - "Sets the given `Date`’s minutes to the value in the second argument according\nto the current time zone. Returns the number of milliseconds since the epoch of\nthe updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setMinutes(date1, 34.0)\ndate1 == Js.Date.fromString(\"1973-11-29T21:34:54.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setMinutes: (t, float) => float" - }, - { - "id": "Js.Date.setMinutesS", - "kind": "value", - "name": "setMinutesS", - "docstrings": [ - "Sets the given `Date`’s minutes and seconds to the values in the labeled\narguments according to the current time zone. Returns the number of\nmilliseconds since the epoch of the updated `Date`. *This function modifies the\noriginal `Date`.* See\n[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setMinutesS(date1, ~minutes=34.0, ~seconds=56.0, ())\ndate1 == Js.Date.fromString(\"1973-11-29T21:34:56.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float" - }, - { - "id": "Js.Date.setMinutesSMs", - "kind": "value", - "name": "setMinutesSMs", - "docstrings": [ - "Sets the given `Date`’s minutes, seconds, and milliseconds to the values in the\nlabeled arguments according to the current time zone. Returns the number of\nmilliseconds since the epoch of the updated `Date`. *This function modifies the\noriginal `Date`.* See\n[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setMinutesSMs(\n date1,\n ~minutes=34.0,\n ~seconds=56.0,\n ~milliseconds=789.0,\n (),\n)\ndate1 == Js.Date.fromString(\"1973-11-29T21:34:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setMinutesSMs: (\n t,\n ~minutes: float,\n ~seconds: float,\n ~milliseconds: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setMonth", - "kind": "value", - "name": "setMonth", - "docstrings": [ - "Sets the given `Date`’s month to the value in the second argument according to\nthe current time zone. Returns the number of milliseconds since the epoch of\nthe updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setMonth(date1, 11.0)\ndate1 == Js.Date.fromString(\"1973-12-29T21:34:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setMonth: (t, float) => float" - }, - { - "id": "Js.Date.setMonthD", - "kind": "value", - "name": "setMonthD", - "docstrings": [ - "Sets the given `Date`’s month and day of month to the values in the labeled\narguments according to the current time zone. Returns the number of\nmilliseconds since the epoch of the updated `Date`. *This function modifies the\noriginal `Date`.* See\n[`Date.setMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setMonthD(date1, ~month=11.0, ~date=8.0, ())\ndate1 == Js.Date.fromString(\"1973-12-08T21:34:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setMonthD: (t, ~month: float, ~date: float, unit) => float" - }, - { - "id": "Js.Date.setSeconds", - "kind": "value", - "name": "setSeconds", - "docstrings": [ - "Sets the given `Date`’s seconds to the value in the second argument according\nto the current time zone. Returns the number of milliseconds since the epoch of\nthe updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setSeconds(date1, 56.0)\ndate1 == Js.Date.fromString(\"1973-12-29T21:30:56.321Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setSeconds: (t, float) => float" - }, - { - "id": "Js.Date.setSecondsMs", - "kind": "value", - "name": "setSecondsMs", - "docstrings": [ - "Sets the given `Date`’s seconds and milliseconds to the values in the labeled\narguments according to the current time zone. Returns the number of\nmilliseconds since the epoch of the updated `Date`. *This function modifies the\noriginal `Date`.* See\n[`Date.setSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setSecondsMs(date1, ~seconds=56.0, ~milliseconds=789.0, ())\ndate1 == Js.Date.fromString(\"1973-12-29T21:30:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float" - }, - { - "id": "Js.Date.setTime", - "kind": "value", - "name": "setTime", - "docstrings": [ - "Sets the given `Date`’s value in terms of milliseconds since the epoch. Returns\nthe number of milliseconds since the epoch of the updated `Date`. *This\nfunction modifies the original `Date`.* See\n[`Date.setTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setTime(date1, 198765432101.0)\n\ndate1 == Js.Date.fromString(\"1976-04-19T12:37:12.101Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setTime: (t, float) => float" - }, - { - "id": "Js.Date.setUTCDate", - "kind": "value", - "name": "setUTCDate", - "docstrings": [ - "Sets the given `Date`’s day of month to the value in the second argument\naccording to UTC. Returns the number of milliseconds since the epoch of the\nupdated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet twoWeeksBefore = Js.Date.setUTCDate(date1, 15.0)\ndate1 == Js.Date.fromString(\"1973-11-15T21:30:54.321Z00:00\")\ntwoWeeksBefore == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCDate: (t, float) => float" - }, - { - "id": "Js.Date.setUTCFullYear", - "kind": "value", - "name": "setUTCFullYear", - "docstrings": [ - "Sets the given `Date`’s year to the value in the second argument according to\nUTC. Returns the number of milliseconds since the epoch of the updated `Date`.\n*This function modifies the original `Date`.* See\n[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet nextYear = Js.Date.setUTCFullYear(date1, 1974.0)\ndate1 == Js.Date.fromString(\"1974-11-15T21:30:54.321Z00:00\")\nnextYear == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCFullYear: (t, float) => float" - }, - { - "id": "Js.Date.setUTCFullYearM", - "kind": "value", - "name": "setUTCFullYearM", - "docstrings": [ - "Sets the given `Date`’s year and month to the values in the labeled arguments\naccording to UTC. Returns the number of milliseconds since the epoch of the\nupdated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet future = Js.Date.setUTCFullYearM(date1, ~year=1974.0, ~month=0.0, ())\ndate1 == Js.Date.fromString(\"1974-01-22T21:30:54.321Z00:00\")\nfuture == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float" - }, - { - "id": "Js.Date.setUTCFullYearMD", - "kind": "value", - "name": "setUTCFullYearMD", - "docstrings": [ - "Sets the given `Date`’s year, month, and day of month to the values in the\nlabeled arguments according to UTC. Returns the number of milliseconds since\nthe epoch of the updated `Date`. *This function modifies the original `Date`.*\nSee\n[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet future = Js.Date.setUTCFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ())\ndate1 == Js.Date.fromString(\"1974-01-07T21:30:54.321Z00:00\")\nfuture == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCFullYearMD: (\n t,\n ~year: float,\n ~month: float,\n ~date: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setUTCHours", - "kind": "value", - "name": "setUTCHours", - "docstrings": [ - "Sets the given `Date`’s hours to the value in the second argument according to\nUTC. Returns the number of milliseconds since the epoch of the updated `Date`.\n*This function modifies the original `Date`.* See\n[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet nextHour = Js.Date.setUTCHours(date1, 22.0)\ndate1 == Js.Date.fromString(\"1973-11-29T22:30:54.321Z00:00\")\nnextHour == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCHours: (t, float) => float" - }, - { - "id": "Js.Date.setUTCHoursM", - "kind": "value", - "name": "setUTCHoursM", - "docstrings": [ - "Sets the given `Date`’s hours and minutes to the values in the labeled\narguments according to UTC. Returns the number of milliseconds since the epoch\nof the updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCHoursM(date1, ~hours=22.0, ~minutes=46.0, ())\ndate1 == Js.Date.fromString(\"1973-11-29T22:46:54.321Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCHoursM: (t, ~hours: float, ~minutes: float, unit) => float" - }, - { - "id": "Js.Date.setUTCHoursMS", - "kind": "value", - "name": "setUTCHoursMS", - "docstrings": [ - "Sets the given `Date`’s hours, minutes, and seconds to the values in the\nlabeled arguments according to UTC. Returns the number of milliseconds since\nthe epoch of the updated `Date`. *This function modifies the original `Date`.*\n\nSee\n[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCHoursMS(date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ())\ndate1 == Js.Date.fromString(\"1973-11-29T22:46:37.321Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCHoursMS: (\n t,\n ~hours: float,\n ~minutes: float,\n ~seconds: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setUTCHoursMSMs", - "kind": "value", - "name": "setUTCHoursMSMs", - "docstrings": [ - "Sets the given `Date`’s hours, minutes, seconds, and milliseconds to the values\nin the labeled arguments according to UTC. Returns the number of milliseconds\nsince the epoch of the updated `Date`. *This function modifies the original\n`Date`.* See\n[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCHoursMSMs(\n date1,\n ~hours=22.0,\n ~minutes=46.0,\n ~seconds=37.0,\n ~milliseconds=494.0,\n (),\n)\ndate1 == Js.Date.fromString(\"1973-11-29T22:46:37.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCHoursMSMs: (\n t,\n ~hours: float,\n ~minutes: float,\n ~seconds: float,\n ~milliseconds: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setUTCMilliseconds", - "kind": "value", - "name": "setUTCMilliseconds", - "docstrings": [ - "Sets the given `Date`’s milliseconds to the value in the second argument\naccording to UTC. Returns the number of milliseconds since the epoch of the\nupdated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCMilliseconds(date1, 494.0)\ndate1 == Js.Date.fromString(\"1973-11-29T21:30:54.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCMilliseconds: (t, float) => float" - }, - { - "id": "Js.Date.setUTCMinutes", - "kind": "value", - "name": "setUTCMinutes", - "docstrings": [ - "Sets the given `Date`’s minutes to the value in the second argument according\nto the current time zone. Returns the number of milliseconds since the epoch of\nthe updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCMinutes(date1, 34.0)\ndate1 == Js.Date.fromString(\"1973-11-29T21:34:54.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCMinutes: (t, float) => float" - }, - { - "id": "Js.Date.setUTCMinutesS", - "kind": "value", - "name": "setUTCMinutesS", - "docstrings": [ - "Sets the given `Date`’s minutes and seconds to the values in the labeled\narguments according to UTC. Returns the number of milliseconds since the epoch\nof the updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCMinutesS(date1, ~minutes=34.0, ~seconds=56.0, ())\ndate1 == Js.Date.fromString(\"1973-11-29T21:34:56.494Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float" - }, - { - "id": "Js.Date.setUTCMinutesSMs", - "kind": "value", - "name": "setUTCMinutesSMs", - "docstrings": [ - "Sets the given `Date`’s minutes, seconds, and milliseconds to the values in the\nlabeled arguments according to UTC. Returns the number of milliseconds since\nthe epoch of the updated `Date`. *This function modifies the original `Date`.*\nSee\n[`Date.setUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCMinutesSMs(\n date1,\n ~minutes=34.0,\n ~seconds=56.0,\n ~milliseconds=789.0,\n (),\n)\ndate1 == Js.Date.fromString(\"1973-11-29T21:34:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCMinutesSMs: (\n t,\n ~minutes: float,\n ~seconds: float,\n ~milliseconds: float,\n unit,\n) => float" - }, - { - "id": "Js.Date.setUTCMonth", - "kind": "value", - "name": "setUTCMonth", - "docstrings": [ - "Sets the given `Date`’s month to the value in the second argument according to\nUTC. Returns the number of milliseconds since the epoch of the updated `Date`.\n*This function modifies the original `Date`.* See\n[`Date.setUTCMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCMonth(date1, 11.0)\ndate1 == Js.Date.fromString(\"1973-12-29T21:34:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCMonth: (t, float) => float" - }, - { - "id": "Js.Date.setUTCMonthD", - "kind": "value", - "name": "setUTCMonthD", - "docstrings": [ - "Sets the given `Date`’s month and day of month to the values in the labeled\narguments according to UTC. Returns the number of milliseconds since the epoch\nof the updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCMonthD(date1, ~month=11.0, ~date=8.0, ())\ndate1 == Js.Date.fromString(\"1973-12-08T21:34:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCMonthD: (t, ~month: float, ~date: float, unit) => float" - }, - { - "id": "Js.Date.setUTCSeconds", - "kind": "value", - "name": "setUTCSeconds", - "docstrings": [ - "Sets the given `Date`’s seconds to the value in the second argument according\nto UTC. Returns the number of milliseconds since the epoch of the updated\n`Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCSeconds(date1, 56.0)\ndate1 == Js.Date.fromString(\"1973-12-29T21:30:56.321Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCSeconds: (t, float) => float" - }, - { - "id": "Js.Date.setUTCSecondsMs", - "kind": "value", - "name": "setUTCSecondsMs", - "docstrings": [ - "Sets the given `Date`’s seconds and milliseconds to the values in the labeled\narguments according to UTC. Returns the number of milliseconds since the epoch\nof the updated `Date`. *This function modifies the original `Date`.* See\n[`Date.setUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)\non MDN.\n\n## Examples\n\n```rescript\nlet date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT\nlet futureTime = Js.Date.setUTCSecondsMs(date1, ~seconds=56.0, ~milliseconds=789.0, ())\ndate1 == Js.Date.fromString(\"1973-12-29T21:30:56.789Z00:00\")\nfutureTime == Js.Date.getTime(date1)\n```" - ], - "signature": "let setUTCSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float" - }, - { - "id": "Js.Date.setUTCTime", - "kind": "value", - "name": "setUTCTime", - "docstrings": ["Same as [`setTime()`](#settime)."], - "signature": "let setUTCTime: (t, float) => float" - }, - { - "id": "Js.Date.setYear", - "kind": "value", - "name": "setYear", - "docstrings": [], - "signature": "let setYear: (t, float) => float", - "deprecated": "Use `setFullYear` instead" - }, - { - "id": "Js.Date.toDateString", - "kind": "value", - "name": "toDateString", - "docstrings": [ - "Returns the date (day of week, year, month, and day of month) portion of a\n`Date` in English. See\n[`Date.toDateString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toDateString(exampleDate) == \"Thu Nov 29 1973\"\n```" - ], - "signature": "let toDateString: t => string" - }, - { - "id": "Js.Date.toGMTString", - "kind": "value", - "name": "toGMTString", - "docstrings": [], - "signature": "let toGMTString: t => string", - "deprecated": "Use `toUTCString` instead" - }, - { - "id": "Js.Date.toISOString", - "kind": "value", - "name": "toISOString", - "docstrings": [ - "Returns a simplified version of the ISO 8601 format for the date. See\n[`Date.toISOString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toISOString(exampleDate) == \"1973-11-29T21:30:54.321Z\"\n```" - ], - "signature": "let toISOString: t => string" - }, - { - "id": "Js.Date.toJSON", - "kind": "value", - "name": "toJSON", - "docstrings": [], - "signature": "let toJSON: t => string", - "deprecated": "This method is unsafe. It will be changed to return option in a future \\\n release. Please use toJSONUnsafe instead." - }, - { - "id": "Js.Date.toJSONUnsafe", - "kind": "value", - "name": "toJSONUnsafe", - "docstrings": [ - "Returns a string representation of the given date. See\n[`Date.toJSON`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)\non MDN." - ], - "signature": "let toJSONUnsafe: t => string" - }, - { - "id": "Js.Date.toLocaleDateString", - "kind": "value", - "name": "toLocaleDateString", - "docstrings": [ - "Returns the year, month, and day for the given `Date` in the current locale\nformat. See\n[`Date.toLocaleDateString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toLocaleDateString(exampleDate) == \"11/29/1973\" // for en_US.utf8\nJs.Date.toLocaleDateString(exampleDate) == \"29.11.73\" // for de_DE.utf8\n```" - ], - "signature": "let toLocaleDateString: t => string" - }, - { - "id": "Js.Date.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "Returns the time and date for the given `Date` in the current locale format.\nSee\n[`Date.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toLocaleString(exampleDate) == \"11/29/1973, 10:30:54 PM\" // for en_US.utf8\nJs.Date.toLocaleString(exampleDate) == \"29.11.1973, 22:30:54\" // for de_DE.utf8\n```" - ], - "signature": "let toLocaleString: t => string" - }, - { - "id": "Js.Date.toLocaleTimeString", - "kind": "value", - "name": "toLocaleTimeString", - "docstrings": [ - "Returns the time of day for the given `Date` in the current locale format. See\n[`Date.toLocaleTimeString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toLocaleString(exampleDate) == \"10:30:54 PM\" // for en_US.utf8\nJs.Date.toLocaleString(exampleDate) == \"22:30:54\" // for de_DE.utf8\n```" - ], - "signature": "let toLocaleTimeString: t => string" - }, - { - "id": "Js.Date.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Returns a string representing the date and time of day for the given `Date` in\nthe current locale and time zone. See\n[`Date.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toString(\n exampleDate,\n) == \"Thu Nov 29 1973 22:30:54 GMT+0100 (Central European Standard Time)\"\n```" - ], - "signature": "let toString: t => string" - }, - { - "id": "Js.Date.toTimeString", - "kind": "value", - "name": "toTimeString", - "docstrings": [ - "Returns a string representing the time of day for the given `Date` in the\ncurrent locale and time zone. See\n[`Date.toTimeString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toTimeString(exampleDate) == \"22:30:54 GMT+0100 (Central European Standard Time)\"\n```" - ], - "signature": "let toTimeString: t => string" - }, - { - "id": "Js.Date.toUTCString", - "kind": "value", - "name": "toUTCString", - "docstrings": [ - "Returns a string representing the date and time of day for the given `Date` in\nthe current locale and UTC (GMT time zone). See\n[`Date.toUTCString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Date.toUTCString(exampleDate) == \"Thu, 29 Nov 1973 21:30:54 GMT\"\n```" - ], - "signature": "let toUTCString: t => string" - } - ] - }, - "js/promise2": { - "id": "Js.Promise2", - "name": "Promise2", - "docstrings": ["Provide bindings to JS Promise"], - "items": [ - { - "id": "Js.Promise2.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = promise<'a>" - }, - { - "id": "Js.Promise2.error", - "kind": "type", - "name": "error", - "docstrings": [], - "signature": "type error" - }, - { - "id": "Js.Promise2.then", - "kind": "value", - "name": "then", - "docstrings": ["Type-safe t-first then"], - "signature": "let then: (promise<'a>, 'a => promise<'b>) => promise<'b>" - }, - { - "id": "Js.Promise2.catch", - "kind": "value", - "name": "catch", - "docstrings": ["Type-safe t-first catch"], - "signature": "let catch: (promise<'a>, error => promise<'a>) => promise<'a>" - }, - { - "id": "Js.Promise2.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (\n (~resolve: 'a => unit, ~reject: exn => unit) => unit,\n) => promise<'a>" - }, - { - "id": "Js.Promise2.resolve", - "kind": "value", - "name": "resolve", - "docstrings": [], - "signature": "let resolve: 'a => promise<'a>" - }, - { - "id": "Js.Promise2.reject", - "kind": "value", - "name": "reject", - "docstrings": [], - "signature": "let reject: exn => promise<'a>" - }, - { - "id": "Js.Promise2.all", - "kind": "value", - "name": "all", - "docstrings": [], - "signature": "let all: array> => promise>" - }, - { - "id": "Js.Promise2.all2", - "kind": "value", - "name": "all2", - "docstrings": [], - "signature": "let all2: ((promise<'a0>, promise<'a1>)) => promise<('a0, 'a1)>" - }, - { - "id": "Js.Promise2.all3", - "kind": "value", - "name": "all3", - "docstrings": [], - "signature": "let all3: (\n (promise<'a0>, promise<'a1>, promise<'a2>),\n) => promise<('a0, 'a1, 'a2)>" - }, - { - "id": "Js.Promise2.all4", - "kind": "value", - "name": "all4", - "docstrings": [], - "signature": "let all4: (\n (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>),\n) => promise<('a0, 'a1, 'a2, 'a3)>" - }, - { - "id": "Js.Promise2.all5", - "kind": "value", - "name": "all5", - "docstrings": [], - "signature": "let all5: (\n (\n promise<'a0>,\n promise<'a1>,\n promise<'a2>,\n promise<'a3>,\n promise<'a4>,\n ),\n) => promise<('a0, 'a1, 'a2, 'a3, 'a4)>" - }, - { - "id": "Js.Promise2.all6", - "kind": "value", - "name": "all6", - "docstrings": [], - "signature": "let all6: (\n (\n promise<'a0>,\n promise<'a1>,\n promise<'a2>,\n promise<'a3>,\n promise<'a4>,\n promise<'a5>,\n ),\n) => promise<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)>" - }, - { - "id": "Js.Promise2.race", - "kind": "value", - "name": "race", - "docstrings": [], - "signature": "let race: array> => promise<'a>" - }, - { - "id": "Js.Promise2.unsafe_async", - "kind": "value", - "name": "unsafe_async", - "docstrings": [], - "signature": "let unsafe_async: 'a => promise<'a>" - }, - { - "id": "Js.Promise2.unsafe_await", - "kind": "value", - "name": "unsafe_await", - "docstrings": [], - "signature": "let unsafe_await: promise<'a> => 'a" - } - ] - }, - "js/promise": { - "id": "Js.Promise", - "name": "Promise", - "docstrings": [ - "Provide bindings to JS Promise", - "Deprecation note: These bindings are pretty outdated and cannot be used properly\nwith the `->` operator.\n\nMore details on proper Promise usage can be found here:\nhttps://rescript-lang.org/docs/manual/latest/promise#promise-legacy" - ], - "items": [ - { - "id": "Js.Promise.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t<'a> = promise<'a>" - }, - { - "id": "Js.Promise.error", - "kind": "type", - "name": "error", - "docstrings": [], - "signature": "type error = Js_promise2.error" - }, - { - "id": "Js.Promise.make", - "kind": "value", - "name": "make", - "docstrings": [], - "signature": "let make: (\n (~resolve: 'a => unit, ~reject: exn => unit) => unit,\n) => promise<'a>" - }, - { - "id": "Js.Promise.resolve", - "kind": "value", - "name": "resolve", - "docstrings": [], - "signature": "let resolve: 'a => promise<'a>" - }, - { - "id": "Js.Promise.reject", - "kind": "value", - "name": "reject", - "docstrings": [], - "signature": "let reject: exn => promise<'a>" - }, - { - "id": "Js.Promise.all", - "kind": "value", - "name": "all", - "docstrings": [], - "signature": "let all: array> => promise>" - }, - { - "id": "Js.Promise.all2", - "kind": "value", - "name": "all2", - "docstrings": [], - "signature": "let all2: ((promise<'a0>, promise<'a1>)) => promise<('a0, 'a1)>" - }, - { - "id": "Js.Promise.all3", - "kind": "value", - "name": "all3", - "docstrings": [], - "signature": "let all3: (\n (promise<'a0>, promise<'a1>, promise<'a2>),\n) => promise<('a0, 'a1, 'a2)>" - }, - { - "id": "Js.Promise.all4", - "kind": "value", - "name": "all4", - "docstrings": [], - "signature": "let all4: (\n (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>),\n) => promise<('a0, 'a1, 'a2, 'a3)>" - }, - { - "id": "Js.Promise.all5", - "kind": "value", - "name": "all5", - "docstrings": [], - "signature": "let all5: (\n (\n promise<'a0>,\n promise<'a1>,\n promise<'a2>,\n promise<'a3>,\n promise<'a4>,\n ),\n) => promise<('a0, 'a1, 'a2, 'a3, 'a4)>" - }, - { - "id": "Js.Promise.all6", - "kind": "value", - "name": "all6", - "docstrings": [], - "signature": "let all6: (\n (\n promise<'a0>,\n promise<'a1>,\n promise<'a2>,\n promise<'a3>,\n promise<'a4>,\n promise<'a5>,\n ),\n) => promise<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)>" - }, - { - "id": "Js.Promise.race", - "kind": "value", - "name": "race", - "docstrings": [], - "signature": "let race: array> => promise<'a>" - }, - { - "id": "Js.Promise.then_", - "kind": "value", - "name": "then_", - "docstrings": [], - "signature": "let then_: ('a => promise<'b>, promise<'a>) => promise<'b>" - }, - { - "id": "Js.Promise.catch", - "kind": "value", - "name": "catch", - "docstrings": [], - "signature": "let catch: (error => promise<'a>, promise<'a>) => promise<'a>" - }, - { - "id": "Js.Promise.unsafe_async", - "kind": "value", - "name": "unsafe_async", - "docstrings": [], - "signature": "let unsafe_async: 'a => promise<'a>" - }, - { - "id": "Js.Promise.unsafe_await", - "kind": "value", - "name": "unsafe_await", - "docstrings": [], - "signature": "let unsafe_await: promise<'a> => 'a" - } - ] - }, - "js/re": { - "id": "Js.Re", - "name": "Re", - "docstrings": [ - "Provide bindings to JS regex expression", - "Provide bindings to JS regular expressions (RegExp).\n\n**Note:** This is not an immutable API. A RegExp object with the `global` (\"g\")\nflag set will modify the [`lastIndex`]() property when the RegExp object is used,\nand subsequent uses will continue the search from the previous [`lastIndex`]()." - ], - "items": [ - { - "id": "Js.Re.t", - "kind": "type", - "name": "t", - "docstrings": ["The RegExp object."], - "signature": "type t" - }, - { - "id": "Js.Re.result", - "kind": "type", - "name": "result", - "docstrings": ["The result of a executing a RegExp on a string."], - "signature": "type result" - }, - { - "id": "Js.Re.captures", - "kind": "value", - "name": "captures", - "docstrings": [ - "An `array` of the match and captures, the first is the full match and the\nremaining are the substring captures." - ], - "signature": "let captures: result => array>" - }, - { - "id": "Js.Re.matches", - "kind": "value", - "name": "matches", - "docstrings": [], - "signature": "let matches: result => array", - "deprecated": "Use Js.Re.captures instead" - }, - { - "id": "Js.Re.index", - "kind": "value", - "name": "index", - "docstrings": ["0-based index of the match in the input string."], - "signature": "let index: result => int" - }, - { - "id": "Js.Re.input", - "kind": "value", - "name": "input", - "docstrings": ["The original input string."], - "signature": "let input: result => string" - }, - { - "id": "Js.Re.fromString", - "kind": "value", - "name": "fromString", - "docstrings": [ - "Constructs a RegExp object (Js.Re.t) from a `string`.\nRegex literals `%re(\"/.../\")` should generally be preferred, but `fromString`\nis useful when you need to dynamically construct a regex using strings,\nexactly like when you do so in JavaScript.\n\n## Examples\n\n```rescript\nlet firstReScriptFileExtension = (filename, content) => {\n let result = Js.Re.fromString(filename ++ \"\\.(res|resi)\")->Js.Re.exec_(content)\n switch result {\n | Some(r) => Js.Nullable.toOption(Js.Re.captures(r)[1])\n | None => None\n }\n}\n\n// outputs \"res\"\nfirstReScriptFileExtension(\"School\", \"School.res School.resi Main.js School.bs.js\")\n```" - ], - "signature": "let fromString: string => t" - }, - { - "id": "Js.Re.fromStringWithFlags", - "kind": "value", - "name": "fromStringWithFlags", - "docstrings": [ - "Constructs a RegExp object (`Js.Re.t`) from a string with the given flags.\nSee `Js.Re.fromString`.\n\nValid flags:\n\n- **g** global\n- **i** ignore case\n- **m** multiline\n- **u** unicode (es2015)\n- **y** sticky (es2015)" - ], - "signature": "let fromStringWithFlags: (string, ~flags: string) => t" - }, - { - "id": "Js.Re.flags", - "kind": "value", - "name": "flags", - "docstrings": ["Returns the enabled flags as a string."], - "signature": "let flags: t => string" - }, - { - "id": "Js.Re.global", - "kind": "value", - "name": "global", - "docstrings": [ - "Returns a `bool` indicating whether the global flag is set." - ], - "signature": "let global: t => bool" - }, - { - "id": "Js.Re.ignoreCase", - "kind": "value", - "name": "ignoreCase", - "docstrings": [ - "Returns a `bool` indicating whether the ignoreCase flag is set." - ], - "signature": "let ignoreCase: t => bool" - }, - { - "id": "Js.Re.lastIndex", - "kind": "value", - "name": "lastIndex", - "docstrings": [ - "Returns the index where the next match will start its search. This property\nwill be modified when the RegExp object is used, if the global (\"g\") flag is\nset.\n\n## Examples\n\n```rescript\nlet re = %re(\"/ab*TODO/g\")\nlet str = \"abbcdefabh\"\n\nlet break = ref(false)\nwhile !break.contents {\n switch Js.Re.exec_(re, str) {\n | Some(result) => Js.Nullable.iter(Js.Re.captures(result)[0], (. match_) => {\n let next = Belt.Int.toString(Js.Re.lastIndex(re))\n Js.log(\"Found \" ++ (match_ ++ (\". Next match starts at \" ++ next)))\n })\n | None => break := true\n }\n}\n```\n\nSee\n[`RegExp: lastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)\non MDN." - ], - "signature": "let lastIndex: t => int" - }, - { - "id": "Js.Re.setLastIndex", - "kind": "value", - "name": "setLastIndex", - "docstrings": [ - "Sets the index at which the next match will start its search from." - ], - "signature": "let setLastIndex: (t, int) => unit" - }, - { - "id": "Js.Re.multiline", - "kind": "value", - "name": "multiline", - "docstrings": [ - "Returns a `bool` indicating whether the multiline flag is set." - ], - "signature": "let multiline: t => bool" - }, - { - "id": "Js.Re.source", - "kind": "value", - "name": "source", - "docstrings": ["Returns the pattern as a `string`."], - "signature": "let source: t => string" - }, - { - "id": "Js.Re.sticky", - "kind": "value", - "name": "sticky", - "docstrings": [ - "Returns a `bool` indicating whether the sticky flag is set." - ], - "signature": "let sticky: t => bool" - }, - { - "id": "Js.Re.unicode", - "kind": "value", - "name": "unicode", - "docstrings": [ - "Returns a `bool` indicating whether the unicode flag is set." - ], - "signature": "let unicode: t => bool" - }, - { - "id": "Js.Re.exec_", - "kind": "value", - "name": "exec_", - "docstrings": [ - "Executes a search on a given string using the given RegExp object.\nReturns `Some(Js.Re.result)` if a match is found, `None` otherwise.\n\n## Examples\n\n```rescript\n/* Match \"quick brown\" followed by \"jumps\", ignoring characters in between\n * Remember \"brown\" and \"jumps\"\n * Ignore case\n */\n\nlet re = %re(\"/quick\\s(brown).+?(jumps)/ig\")\nlet result = Js.Re.exec_(re, \"The Quick Brown Fox Jumps Over The Lazy Dog\")\n```\n\nSee [`RegExp.prototype.exec()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)\non MDN." - ], - "signature": "let exec_: (t, string) => option" - }, - { - "id": "Js.Re.test_", - "kind": "value", - "name": "test_", - "docstrings": [ - "Tests whether the given RegExp object will match a given `string`.\nReturns true if a match is found, false otherwise.\n\n## Examples\n\n```rescript\n/* A simple implementation of Js.String.startsWith */\n\nlet str = \"hello world!\"\n\nlet startsWith = (target, substring) =>\n Js.Re.fromString(\"^\" ++ substring)->Js.Re.test_(target)\n\nJs.log(str->startsWith(\"hello\")) /* prints \"true\" */\n```\n\nSee [`RegExp.prototype.test()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\non MDN." - ], - "signature": "let test_: (t, string) => bool" - } - ] - }, - "js/string2": { - "id": "Js.String2", - "name": "String2", - "docstrings": [ - "Provide bindings to JS string", - "Provide bindings to JS string. Optimized for pipe-first." - ], - "items": [ - { - "id": "Js.String2.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = string" - }, - { - "id": "Js.String2.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(value)` converts the given value to a `string`.\n\n## Examples\n\n```rescript\nJs.String2.make(3.5) == \"3.5\"\nJs.String2.make([1, 2, 3]) == \"1,2,3\"\n```" - ], - "signature": "let make: 'a => t" - }, - { - "id": "Js.String2.fromCharCode", - "kind": "value", - "name": "fromCharCode", - "docstrings": [ - "`fromCharCode(n)` creates a `string` containing the character corresponding to\nthat number; `n` ranges from 0 to 65535.If out of range, the lower 16 bits of\nthe value are used. Thus, `fromCharCode(0x1F63A)` gives the same result as\n`fromCharCode(0xF63A)`.\n\nSee [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.fromCharCode(65) == \"A\"\nJs.String2.fromCharCode(0x3c8) == `ψ`\nJs.String2.fromCharCode(0xd55c) == `한`\nJs.String2.fromCharCode(-64568) == `ψ`\n```" - ], - "signature": "let fromCharCode: int => t" - }, - { - "id": "Js.String2.fromCharCodeMany", - "kind": "value", - "name": "fromCharCodeMany", - "docstrings": [ - "`fromCharCodeMany([n1, n2, n3])` creates a `string` from the characters\ncorresponding to the given numbers, using the same rules as `fromCharCode`.\n\nSee [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)\non MDN." - ], - "signature": "let fromCharCodeMany: array => t" - }, - { - "id": "Js.String2.fromCodePoint", - "kind": "value", - "name": "fromCodePoint", - "docstrings": [ - "`fromCodePoint(n)` creates a `string` containing the character corresponding to\nthat numeric code point. If the number is not a valid code point, it raises\n`RangeError`. Thus, `fromCodePoint(0x1F63A)` will produce a correct value,\nunlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a\n`RangeError`.\n\nSee [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.fromCodePoint(65) == \"A\"\nJs.String2.fromCodePoint(0x3c8) == `ψ`\nJs.String2.fromCodePoint(0xd55c) == `한`\nJs.String2.fromCodePoint(0x1f63a) == `😺`\n```" - ], - "signature": "let fromCodePoint: int => t" - }, - { - "id": "Js.String2.fromCodePointMany", - "kind": "value", - "name": "fromCodePointMany", - "docstrings": [ - "`fromCodePointMany([n1, n2, n3])` creates a `string` from the characters\ncorresponding to the given code point numbers, using the same rules as\n`fromCodePoint`.\n\nSee [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺`\n```" - ], - "signature": "let fromCodePointMany: array => t" - }, - { - "id": "Js.String2.length", - "kind": "value", - "name": "length", - "docstrings": [ - "`length(s)` returns the length of the given `string`.\n\nSee [`String.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.length(\"abcd\") == 4\n```" - ], - "signature": "let length: t => int" - }, - { - "id": "Js.String2.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`get(s, n)` returns as a `string` the character at the given index number. If\n`n` is out of range, this function returns `undefined`,so at some point this\nfunction may be modified to return `option`.\n\n## Examples\n\n```rescript\nJs.String2.get(\"Reason\", 0) == \"R\"\nJs.String2.get(\"Reason\", 4) == \"o\"\nJs.String2.get(`Rẽasöń`, 5) == `ń`\n```" - ], - "signature": "let get: (t, int) => t" - }, - { - "id": "Js.String2.charAt", - "kind": "value", - "name": "charAt", - "docstrings": [ - "`charAt(s, n)` gets the character at index `n` within string `s`. If `n` is\nnegative or greater than the length of `s`, it returns the empty string. If the\nstring contains characters outside the range \\u0000-\\uffff, it will return the\nfirst 16-bit value at that position in the string.\n\nSee [`String.charAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.charAt(\"Reason\", 0) == \"R\"\nJs.String2.charAt(\"Reason\", 12) == \"\"\nJs.String2.charAt(`Rẽasöń`, 5) == `ń`\n```" - ], - "signature": "let charAt: (t, int) => t" - }, - { - "id": "Js.String2.charCodeAt", - "kind": "value", - "name": "charCodeAt", - "docstrings": [ - "`charCodeAt(s, n)` returns the character code at position `n` in string `s`;\nthe result is in the range 0-65535, unlke `codePointAt`, so it will not work\ncorrectly for characters with code points greater than or equal to 0x10000. The\nreturn type is `float` because this function returns NaN if `n` is less than\nzero or greater than the length of the string.\n\nSee [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.charCodeAt(`😺`, 0) == 0xd83d->Belt.Int.toFloat\nJs.String2.codePointAt(`😺`, 0) == Some(0x1f63a)\n```" - ], - "signature": "let charCodeAt: (t, int) => float" - }, - { - "id": "Js.String2.codePointAt", - "kind": "value", - "name": "codePointAt", - "docstrings": [ - "`codePointAt(s, n)` returns the code point at position `n` within string `s` as\na `Some(value)`. The return value handles code points greater than or equal to\n0x10000. If there is no code point at the given position, the function returns\n`None`.\n\nSee [`String.codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.codePointAt(`¿😺?`, 1) == Some(0x1f63a)\nJs.String2.codePointAt(\"abc\", 5) == None\n```" - ], - "signature": "let codePointAt: (t, int) => option" - }, - { - "id": "Js.String2.concat", - "kind": "value", - "name": "concat", - "docstrings": [ - "`concat(original, append)` returns a new `string` with `append` added after\n`original`.\n\nSee [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.concat(\"cow\", \"bell\") == \"cowbell\"\n```" - ], - "signature": "let concat: (t, t) => t" - }, - { - "id": "Js.String2.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [ - "`concatMany(original, arr)` returns a new `string` consisting of each item of an\narray of strings added to the `original` string.\n\nSee [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.concatMany(\"1st\", [\"2nd\", \"3rd\", \"4th\"]) == \"1st2nd3rd4th\"\n```" - ], - "signature": "let concatMany: (t, array) => t" - }, - { - "id": "Js.String2.endsWith", - "kind": "value", - "name": "endsWith", - "docstrings": [ - "ES2015: `endsWith(str, substr)` returns `true` if the `str` ends with `substr`,\n`false` otherwise.\n\nSee [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.endsWith(\"ReScript\", \"Script\") == true\nJs.String2.endsWith(\"C++\", \"Script\") == false\n```" - ], - "signature": "let endsWith: (t, t) => bool" - }, - { - "id": "Js.String2.endsWithFrom", - "kind": "value", - "name": "endsWithFrom", - "docstrings": [ - "`endsWithFrom(str, ending, len)` returns `true` if the first len characters of\n`str` end with `ending`, `false` otherwise. If `len` is greater than or equal\nto the length of `str`, then it works like `endsWith`. (Honestly, this should\nhave been named endsWithAt, but oh well).\n\nSee [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.endsWithFrom(\"abcd\", \"cd\", 4) == true\nJs.String2.endsWithFrom(\"abcde\", \"cd\", 3) == false\nJs.String2.endsWithFrom(\"abcde\", \"cde\", 99) == true\nJs.String2.endsWithFrom(\"example.dat\", \"ple\", 7) == true\n```" - ], - "signature": "let endsWithFrom: (t, t, int) => bool" - }, - { - "id": "Js.String2.includes", - "kind": "value", - "name": "includes", - "docstrings": [ - "ES2015: `includes(str, searchValue)` returns `true` if `searchValue` is found\nanywhere within `str`, false otherwise.\n\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.includes(\"programmer\", \"gram\") == true\nJs.String2.includes(\"programmer\", \"er\") == true\nJs.String2.includes(\"programmer\", \"pro\") == true\nJs.String2.includes(\"programmer.dat\", \"xyz\") == false\n```" - ], - "signature": "let includes: (t, t) => bool" - }, - { - "id": "Js.String2.includesFrom", - "kind": "value", - "name": "includesFrom", - "docstrings": [ - "ES2015: `includes(str, searchValue start)` returns `true` if `searchValue` is\nfound anywhere within `str` starting at character number `start` (where 0 is\nthe first character), `false` otherwise.\n\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.includesFrom(\"programmer\", \"gram\", 1) == true\nJs.String2.includesFrom(\"programmer\", \"gram\", 4) == false\nJs.String2.includesFrom(`대한민국`, `한`, 1) == true\n```" - ], - "signature": "let includesFrom: (t, t, int) => bool" - }, - { - "id": "Js.String2.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [ - "ES2015: `indexOf(str, searchValue)` returns the position at which `searchValue`\nwas first found within `str`, or -1 if `searchValue` is not in `str`.\n\nSee [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.indexOf(\"bookseller\", \"ok\") == 2\nJs.String2.indexOf(\"bookseller\", \"sell\") == 4\nJs.String2.indexOf(\"beekeeper\", \"ee\") == 1\nJs.String2.indexOf(\"bookseller\", \"xyz\") == -1\n```" - ], - "signature": "let indexOf: (t, t) => int" - }, - { - "id": "Js.String2.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [ - "`indexOfFrom(str, searchValue, start)` returns the position at which\n`searchValue` was found within `str` starting at character position `start`, or\n-1 if `searchValue` is not found in that portion of `str`. The return value is\nrelative to the beginning of the string, no matter where the search started\nfrom.\n\nSee [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.indexOfFrom(\"bookseller\", \"ok\", 1) == 2\nJs.String2.indexOfFrom(\"bookseller\", \"sell\", 2) == 4\nJs.String2.indexOfFrom(\"bookseller\", \"sell\", 5) == -1\n```" - ], - "signature": "let indexOfFrom: (t, t, int) => int" - }, - { - "id": "Js.String2.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [ - "`lastIndexOf(str, searchValue)` returns the position of the last occurrence of\n`searchValue` within `str`, searching backwards from the end of the string.\nReturns -1 if `searchValue` is not in `str`. The return value is always\nrelative to the beginning of the string.\n\nSee [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.lastIndexOf(\"bookseller\", \"ok\") == 2\nJs.String2.lastIndexOf(\"beekeeper\", \"ee\") == 4\nJs.String2.lastIndexOf(\"abcdefg\", \"xyz\") == -1\n```" - ], - "signature": "let lastIndexOf: (t, t) => int" - }, - { - "id": "Js.String2.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [ - "`lastIndexOfFrom(str, searchValue, start)` returns the position of the last\noccurrence of `searchValue` within `str`, searching backwards from the given\nstart position. Returns -1 if `searchValue` is not in `str`. The return value\nis always relative to the beginning of the string.\n\nSee [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.lastIndexOfFrom(\"bookseller\", \"ok\", 6) == 2\nJs.String2.lastIndexOfFrom(\"beekeeper\", \"ee\", 8) == 4\nJs.String2.lastIndexOfFrom(\"beekeeper\", \"ee\", 3) == 1\nJs.String2.lastIndexOfFrom(\"abcdefg\", \"xyz\", 4) == -1\n```" - ], - "signature": "let lastIndexOfFrom: (t, t, int) => int" - }, - { - "id": "Js.String2.localeCompare", - "kind": "value", - "name": "localeCompare", - "docstrings": [ - "`localeCompare(reference, comparison)` returns\n- a negative value if reference comes before comparison in sort order\n- zero if reference and comparison have the same sort order\n- a positive value if reference comes after comparison in sort order\n\nSee [`String.localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare) on MDN.\n\n## Examples\n\n```rescript\nJs.String2.localeCompare(\"zebra\", \"ant\") > 0.0\nJs.String2.localeCompare(\"ant\", \"zebra\") < 0.0\nJs.String2.localeCompare(\"cat\", \"cat\") == 0.0\nJs.String2.localeCompare(\"CAT\", \"cat\") > 0.0\n```" - ], - "signature": "let localeCompare: (t, t) => float" - }, - { - "id": "Js.String2.match_", - "kind": "value", - "name": "match_", - "docstrings": [ - "`match(str, regexp)` matches a `string` against the given `regexp`. If there is\nno match, it returns `None`. For regular expressions without the g modifier, if\n there is a match, the return value is `Some(array)` where the array contains:\n- The entire matched string\n- Any capture groups if the regexp had parentheses\nFor regular expressions with the g modifier, a matched expression returns\n`Some(array)` with all the matched substrings and no capture groups.\n\nSee [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.match_(\"The better bats\", %re(\"/b[aeiou]t/\")) == Some([\"bet\"])\nJs.String2.match_(\"The better bats\", %re(\"/b[aeiou]t/g\")) == Some([\"bet\", \"bat\"])\nJs.String2.match_(\"Today is 2018-04-05.\", %re(\"/(\\d+)-(\\d+)-(\\d+)/\")) ==\n Some([\"2018-04-05\", \"2018\", \"04\", \"05\"])\nJs.String2.match_(\"The large container.\", %re(\"/b[aeiou]g/\")) == None\n```" - ], - "signature": "let match_: (t, Js_re.t) => option>>" - }, - { - "id": "Js.String2.normalize", - "kind": "value", - "name": "normalize", - "docstrings": [ - "`normalize(str)` returns the normalized Unicode string using Normalization Form\nCanonical (NFC) Composition. Consider the character ã, which can be represented\nas the single codepoint \\u00e3 or the combination of a lower case letter A\n\\u0061 and a combining tilde \\u0303. Normalization ensures that both can be\nstored in an equivalent binary representation.\n\nSee [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)\non MDN. See also [Unicode technical report\n#15](https://unicode.org/reports/tr15/) for details." - ], - "signature": "let normalize: t => t" - }, - { - "id": "Js.String2.normalizeByForm", - "kind": "value", - "name": "normalizeByForm", - "docstrings": [ - "ES2015: `normalize(str, form)` returns the normalized Unicode string using the\nspecified form of normalization, which may be one of:\n- \"NFC\" — Normalization Form Canonical Composition.\n- \"NFD\" — Normalization Form Canonical Decomposition.\n- \"NFKC\" — Normalization Form Compatibility Composition.\n- \"NFKD\" — Normalization Form Compatibility Decomposition.\n\nSee [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) on MDN.\nSee also [Unicode technical report #15](https://unicode.org/reports/tr15/) for details." - ], - "signature": "let normalizeByForm: (t, t) => t" - }, - { - "id": "Js.String2.repeat", - "kind": "value", - "name": "repeat", - "docstrings": [ - "`repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`.\nRaises `RangeError` if `n` is negative.\n\nSee [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.repeat(\"ha\", 3) == \"hahaha\"\nJs.String2.repeat(\"empty\", 0) == \"\"\n```" - ], - "signature": "let repeat: (t, int) => t" - }, - { - "id": "Js.String2.replace", - "kind": "value", - "name": "replace", - "docstrings": [ - "ES2015: `replace(str, substr, newSubstr)` returns a new `string` which is\nidentical to `str` except with the first matching instance of `substr` replaced\nby `newSubstr`. `substr` is treated as a verbatim string to match, not a\nregular expression.\n\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.replace(\"old string\", \"old\", \"new\") == \"new string\"\nJs.String2.replace(\"the cat and the dog\", \"the\", \"this\") == \"this cat and the dog\"\n```" - ], - "signature": "let replace: (t, t, t) => t" - }, - { - "id": "Js.String2.replaceByRe", - "kind": "value", - "name": "replaceByRe", - "docstrings": [ - "`replaceByRe(str, regex, replacement)` returns a new `string` where occurrences\nmatching regex have been replaced by `replacement`.\n\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.replaceByRe(\"vowels be gone\", %re(\"/[aeiou]/g\"), \"x\") == \"vxwxls bx gxnx\"\nJs.String2.replaceByRe(\"Juan Fulano\", %re(\"/(\\w+) (\\w+)/\"), \"$2, $1\") == \"Fulano, Juan\"\n```" - ], - "signature": "let replaceByRe: (t, Js_re.t, t) => t" - }, - { - "id": "Js.String2.unsafeReplaceBy0", - "kind": "value", - "name": "unsafeReplaceBy0", - "docstrings": [ - "Returns a new `string` with some or all matches of a pattern with no capturing\nparentheses replaced by the value returned from the given function. The\nfunction receives as its parameters the matched string, the offset at which the\nmatch begins, and the whole string being matched.\n\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)\non MDN.\n\n## Examples\n\n```rescript\nlet str = \"beautiful vowels\"\nlet re = %re(\"/[aeiou]/g\")\nlet matchFn = (matchPart, _offset, _wholeString) => Js.String2.toUpperCase(matchPart)\n\nJs.String2.unsafeReplaceBy0(str, re, matchFn) == \"bEAUtIfUl vOwEls\"\n```" - ], - "signature": "let unsafeReplaceBy0: (t, Js_re.t, (t, int, t) => t) => t" - }, - { - "id": "Js.String2.unsafeReplaceBy1", - "kind": "value", - "name": "unsafeReplaceBy1", - "docstrings": [ - "Returns a new `string` with some or all matches of a pattern with one set of\ncapturing parentheses replaced by the value returned from the given function.\nThe function receives as its parameters the matched string, the captured\nstring, the offset at which the match begins, and the whole string being\nmatched.\n\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)\non MDN.\n\n## Examples\n\n```rescript\nlet str = \"Jony is 40\"\nlet re = %re(\"/(Jony is )\\d+/g\")\nlet matchFn = (_match, part1, _offset, _wholeString) => {\n part1 ++ \"41\"\n}\n\nJs.String2.unsafeReplaceBy1(str, re, matchFn) == \"Jony is 41\"\n```" - ], - "signature": "let unsafeReplaceBy1: (t, Js_re.t, (t, t, int, t) => t) => t" - }, - { - "id": "Js.String2.unsafeReplaceBy2", - "kind": "value", - "name": "unsafeReplaceBy2", - "docstrings": [ - "Returns a new `string` with some or all matches of a pattern with two sets of\ncapturing parentheses replaced by the value returned from the given function.\nThe function receives as its parameters the matched string, the captured\nstrings, the offset at which the match begins, and the whole string being\nmatched.\n\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)\non MDN.\n\n## Examples\n\n```rescript\nlet str = \"7 times 6\"\nlet re = %re(\"/(\\d+) times (\\d+)/\")\nlet matchFn = (_match, p1, p2, _offset, _wholeString) => {\n switch (Belt.Int.fromString(p1), Belt.Int.fromString(p2)) {\n | (Some(x), Some(y)) => Belt.Int.toString(x * y)\n | _ => \"???\"\n }\n}\n\nJs.String2.unsafeReplaceBy2(str, re, matchFn) == \"42\"\n```" - ], - "signature": "let unsafeReplaceBy2: (t, Js_re.t, (t, t, t, int, t) => t) => t" - }, - { - "id": "Js.String2.unsafeReplaceBy3", - "kind": "value", - "name": "unsafeReplaceBy3", - "docstrings": [ - "Returns a new `string` with some or all matches of a pattern with three sets of\ncapturing parentheses replaced by the value returned from the given function.\nThe function receives as its parameters the matched string, the captured\nstrings, the offset at which the match begins, and the whole string being\nmatched.\n\nSee [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)\non MDN." - ], - "signature": "let unsafeReplaceBy3: (t, Js_re.t, (t, t, t, t, int, t) => t) => t" - }, - { - "id": "Js.String2.search", - "kind": "value", - "name": "search", - "docstrings": [ - "`search(str, regexp)` returns the starting position of the first match of\n`regexp` in the given `str`, or -1 if there is no match.\n\nSee [`String.search`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.search(\"testing 1 2 3\", %re(\"/\\d+/\")) == 8\nJs.String2.search(\"no numbers\", %re(\"/\\d+/\")) == -1\n```" - ], - "signature": "let search: (t, Js_re.t) => int" - }, - { - "id": "Js.String2.slice", - "kind": "value", - "name": "slice", - "docstrings": [ - "`slice(str, from:n1, to_:n2)` returns the substring of `str` starting at\ncharacter `n1` up to but not including `n2`.\n- If either `n1` or `n2` is negative, then it is evaluated as `length(str - n1)` or `length(str - n2)`.\n- If `n2` is greater than the length of `str`, then it is treated as `length(str)`.\n- If `n1` is greater than `n2`, slice returns the empty string.\n\nSee [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nJs.String2.slice(\"abcdefg\", ~from=2, ~to_=5) == \"cde\"\nJs.String2.slice(\"abcdefg\", ~from=2, ~to_=9) == \"cdefg\"\nJs.String2.slice(\"abcdefg\", ~from=-4, ~to_=-2) == \"de\"\nJs.String2.slice(\"abcdefg\", ~from=5, ~to_=1) == \"\"\n```" - ], - "signature": "let slice: (t, ~from: int, ~to_: int) => t" - }, - { - "id": "Js.String2.sliceToEnd", - "kind": "value", - "name": "sliceToEnd", - "docstrings": [ - "`sliceToEnd(str, from:n)` returns the substring of `str` starting at character\n`n` to the end of the string.\n- If `n` is negative, then it is evaluated as `length(str - n)`.\n- If `n` is greater than the length of `str`, then sliceToEnd returns the empty string.\n\nSee [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nJs.String2.sliceToEnd(\"abcdefg\", ~from=4) == \"efg\"\nJs.String2.sliceToEnd(\"abcdefg\", ~from=-2) == \"fg\"\nJs.String2.sliceToEnd(\"abcdefg\", ~from=7) == \"\"\n```" - ], - "signature": "let sliceToEnd: (t, ~from: int) => t" - }, - { - "id": "Js.String2.split", - "kind": "value", - "name": "split", - "docstrings": [ - "`split(str, delimiter)` splits the given `str` at every occurrence of\n`delimiter` and returns an array of the resulting substrings.\n\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.split(\"2018-01-02\", \"-\") == [\"2018\", \"01\", \"02\"]\nJs.String2.split(\"a,b,,c\", \",\") == [\"a\", \"b\", \"\", \"c\"]\nJs.String2.split(\"good::bad as great::awful\", \"::\") == [\"good\", \"bad as great\", \"awful\"]\nJs.String2.split(\"has-no-delimiter\", \";\") == [\"has-no-delimiter\"]\n```" - ], - "signature": "let split: (t, t) => array" - }, - { - "id": "Js.String2.splitAtMost", - "kind": "value", - "name": "splitAtMost", - "docstrings": [ - "`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.\n\n```\nsplitAtMost \"ant/bee/cat/dog/elk\" \"/\" ~limit: 3 = [|\"ant\"; \"bee\"; \"cat\"|];;\nsplitAtMost \"ant/bee/cat/dog/elk\" \"/\" ~limit: 0 = [| |];;\nsplitAtMost \"ant/bee/cat/dog/elk\" \"/\" ~limit: 9 = [|\"ant\"; \"bee\"; \"cat\"; \"dog\"; \"elk\"|];;\n```" - ], - "signature": "let splitAtMost: (t, t, ~limit: int) => array" - }, - { - "id": "Js.String2.splitByRe", - "kind": "value", - "name": "splitByRe", - "docstrings": [ - "`splitByRe(str, regex)` splits the given `str` at every occurrence of `regex`\nand returns an array of the resulting substrings.\n\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.splitByRe(\"art; bed , cog ;dad\", %re(\"/\\s*[,;]\\s*TODO/\")) == [\n Some(\"art\"),\n Some(\"bed\"),\n Some(\"cog\"),\n Some(\"dad\"),\n ]\n```" - ], - "signature": "let splitByRe: (t, Js_re.t) => array>" - }, - { - "id": "Js.String2.splitByReAtMost", - "kind": "value", - "name": "splitByReAtMost", - "docstrings": [ - "`splitByReAtMost(str, regex, ~limit:n)` splits the given `str` at every\noccurrence of `regex` and returns an array of the first `n` resulting\nsubstrings. If `n` is negative or greater than the number of substrings, the\narray will contain all the substrings.\n\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.splitByReAtMost(\"one: two: three: four\", %re(\"/\\s*:\\s*TODO/\"), ~limit=3) == [\n Some(\"one\"),\n Some(\"two\"),\n Some(\"three\"),\n ]\n\nJs.String2.splitByReAtMost(\"one: two: three: four\", %re(\"/\\s*:\\s*TODO/\"), ~limit=0) == []\n\nJs.String2.splitByReAtMost(\"one: two: three: four\", %re(\"/\\s*:\\s*TODO/\"), ~limit=8) == [\n Some(\"one\"),\n Some(\"two\"),\n Some(\"three\"),\n Some(\"four\"),\n ]\n```" - ], - "signature": "let splitByReAtMost: (t, Js_re.t, ~limit: int) => array>" - }, - { - "id": "Js.String2.startsWith", - "kind": "value", - "name": "startsWith", - "docstrings": [ - "ES2015: `startsWith(str, substr)` returns `true` if the `str` starts with\n`substr`, `false` otherwise.\n\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.startsWith(\"ReScript\", \"Re\") == true\nJs.String2.startsWith(\"ReScript\", \"\") == true\nJs.String2.startsWith(\"JavaScript\", \"Re\") == false\n```" - ], - "signature": "let startsWith: (t, t) => bool" - }, - { - "id": "Js.String2.startsWithFrom", - "kind": "value", - "name": "startsWithFrom", - "docstrings": [ - "ES2015: `startsWithFrom(str, substr, n)` returns `true` if the `str` starts\nwith `substr` starting at position `n`, false otherwise. If `n` is negative,\nthe search starts at the beginning of `str`.\n\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.startsWithFrom(\"ReScript\", \"Scri\", 2) == true\nJs.String2.startsWithFrom(\"ReScript\", \"\", 2) == true\nJs.String2.startsWithFrom(\"JavaScript\", \"Scri\", 2) == false\n```" - ], - "signature": "let startsWithFrom: (t, t, int) => bool" - }, - { - "id": "Js.String2.substr", - "kind": "value", - "name": "substr", - "docstrings": [ - "`substr(str, ~from:n)` returns the substring of `str` from position `n` to the\nend of the string.\n- If `n` is less than zero, the starting position is the length of `str - n`.\n- If `n` is greater than or equal to the length of `str`, returns the empty string.\n\nJavaScript’s `String.substr()` is a legacy function. When possible, use\n`substring()` instead.\n\nSee [`String.substr`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.substr(\"abcdefghij\", ~from=3) == \"defghij\"\nJs.String2.substr(\"abcdefghij\", ~from=-3) == \"hij\"\nJs.String2.substr(\"abcdefghij\", ~from=12) == \"\"\n```" - ], - "signature": "let substr: (t, ~from: int) => t" - }, - { - "id": "Js.String2.substrAtMost", - "kind": "value", - "name": "substrAtMost", - "docstrings": [ - "`substrAtMost(str, ~from: pos, ~length: n)` returns the substring of `str` of\nlength `n` starting at position `pos`.\n- If `pos` is less than zero, the starting position is the length of `str - pos`.\n- If `pos` is greater than or equal to the length of `str`, returns the empty string.\n- If `n` is less than or equal to zero, returns the empty string.\n\nJavaScript’s `String.substr()` is a legacy function. When possible, use\n`substring()` instead.\n\nSee [`String.substr`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.substrAtMost(\"abcdefghij\", ~from=3, ~length=4) == \"defg\"\nJs.String2.substrAtMost(\"abcdefghij\", ~from=-3, ~length=4) == \"hij\"\nJs.String2.substrAtMost(\"abcdefghij\", ~from=12, ~length=2) == \"\"\n```" - ], - "signature": "let substrAtMost: (t, ~from: int, ~length: int) => t" - }, - { - "id": "Js.String2.substring", - "kind": "value", - "name": "substring", - "docstrings": [ - "`substring(str, ~from: start, ~to_: finish)` returns characters `start` up to\nbut not including finish from `str`.\n- If `start` is less than zero, it is treated as zero.\n- If `finish` is zero or negative, the empty string is returned.\n- If `start` is greater than `finish`, the `start` and `finish` points are swapped.\n\nSee [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nJs.String2.substring(\"playground\", ~from=3, ~to_=6) == \"ygr\"\nJs.String2.substring(\"playground\", ~from=6, ~to_=3) == \"ygr\"\nJs.String2.substring(\"playground\", ~from=4, ~to_=12) == \"ground\"\n```" - ], - "signature": "let substring: (t, ~from: int, ~to_: int) => t" - }, - { - "id": "Js.String2.substringToEnd", - "kind": "value", - "name": "substringToEnd", - "docstrings": [ - "`substringToEnd(str, ~from: start)` returns the substring of `str` from\nposition `start` to the end.\n- If `start` is less than or equal to zero, the entire string is returned.\n- If `start` is greater than or equal to the length of `str`, the empty string is returned.\n\nSee [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nJs.String2.substringToEnd(\"playground\", ~from=4) == \"ground\"\nJs.String2.substringToEnd(\"playground\", ~from=-3) == \"playground\"\nJs.String2.substringToEnd(\"playground\", ~from=12) == \"\"\n```" - ], - "signature": "let substringToEnd: (t, ~from: int) => t" - }, - { - "id": "Js.String2.toLowerCase", - "kind": "value", - "name": "toLowerCase", - "docstrings": [ - "`toLowerCase(str)` converts `str` to lower case using the locale-insensitive\ncase mappings in the Unicode Character Database. Notice that the conversion can\ngive different results depending upon context, for example with the Greek\nletter sigma, which has two different lower case forms; one when it is the last\ncharacter in a string and another when it is not.\n\nSee [`String.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.toLowerCase(\"ABC\") == \"abc\"\nJs.String2.toLowerCase(`ΣΠ`) == `σπ`\nJs.String2.toLowerCase(`ΠΣ`) == `πς`\n```" - ], - "signature": "let toLowerCase: t => t" - }, - { - "id": "Js.String2.toLocaleLowerCase", - "kind": "value", - "name": "toLocaleLowerCase", - "docstrings": [ - "`toLocaleLowerCase(str)` converts `str` to lower case using the current locale.\nSee [`String.toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)\non MDN." - ], - "signature": "let toLocaleLowerCase: t => t" - }, - { - "id": "Js.String2.toUpperCase", - "kind": "value", - "name": "toUpperCase", - "docstrings": [ - "`toUpperCase(str)` converts `str` to upper case using the locale-insensitive\ncase mappings in the Unicode Character Database. Notice that the conversion can\nexpand the number of letters in the result; for example the German ß\ncapitalizes to two Ses in a row.\n\nSee [`String.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.toUpperCase(\"abc\") == \"ABC\"\nJs.String2.toUpperCase(`Straße`) == `STRASSE`\nJs.String2.toUpperCase(`πς`) == `ΠΣ`\n```" - ], - "signature": "let toUpperCase: t => t" - }, - { - "id": "Js.String2.toLocaleUpperCase", - "kind": "value", - "name": "toLocaleUpperCase", - "docstrings": [ - "`toLocaleUpperCase(str)` converts `str` to upper case using the current locale.\nSee [`String.to:LocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\non MDN." - ], - "signature": "let toLocaleUpperCase: t => t" - }, - { - "id": "Js.String2.trim", - "kind": "value", - "name": "trim", - "docstrings": [ - "`trim(str)` returns a string that is `str` with whitespace stripped from both\nends. Internal whitespace is not removed.\n\nSee [`String.trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.trim(\" abc def \") == \"abc def\"\nJs.String2.trim(\"\\n\\r\\t abc def \\n\\n\\t\\r \") == \"abc def\"\n```" - ], - "signature": "let trim: t => t" - }, - { - "id": "Js.String2.anchor", - "kind": "value", - "name": "anchor", - "docstrings": [ - "`anchor(anchorText, anchorName)` creates a string with an HTML `` element\nwith name attribute of `anchorName` and `anchorText` as its content. Please do\nnot use this method, as it has been removed from the relevant web standards.\n\nSee [`String.anchor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.anchor(\"Page One\", \"page1\") == \"Page One\"\n```" - ], - "signature": "let anchor: (t, t) => t" - }, - { - "id": "Js.String2.link", - "kind": "value", - "name": "link", - "docstrings": [ - "ES2015: `link(linkText, urlText)` creates a string with an HTML `` element\nwith href attribute of `urlText` and `linkText` as its content. Please do not\nuse this method, as it has been removed from the relevant web standards. See\n[`String.link`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.link(\"Go to page two\", \"page2.html\") == \"Go to page two\"\n```" - ], - "signature": "let link: (t, t) => t" - }, - { - "id": "Js.String2.castToArrayLike", - "kind": "value", - "name": "castToArrayLike", - "docstrings": [ - "Casts its argument to an `array_like` entity that can be processed by functions\nsuch as `Js.Array2.fromMap()`\n\n## Examples\n\n```rescript\nlet s = \"abcde\"\nlet arr = Js.Array2.fromMap(Js.String2.castToArrayLike(s), x => x)\narr == [\"a\", \"b\", \"c\", \"d\", \"e\"]\n```" - ], - "signature": "let castToArrayLike: t => Js_array2.array_like" - } - ] - }, - "js/string": { - "id": "Js.String", - "name": "String", - "docstrings": ["Provide bindings to JS string", "JavaScript String API"], - "items": [ - { - "id": "Js.String.t", - "kind": "type", - "name": "t", - "docstrings": [], - "signature": "type t = string" - }, - { - "id": "Js.String.make", - "kind": "value", - "name": "make", - "docstrings": [ - "`make(value)` converts the given value to a `string`.\n\n## Examples\n\n```rescript\nJs.String2.make(3.5) == \"3.5\"\nJs.String2.make([1, 2, 3]) == \"1,2,3\"\n```" - ], - "signature": "let make: 'a => t" - }, - { - "id": "Js.String.fromCharCode", - "kind": "value", - "name": "fromCharCode", - "docstrings": [ - "`fromCharCode(n)` creates a `string` containing the character corresponding to that number; `n` ranges from 0 to 65535.\nIf 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.\n\n## Examples\n\n```rescript\nJs.String2.fromCharCode(65) == \"A\"\nJs.String2.fromCharCode(0x3c8) == `ψ`\nJs.String2.fromCharCode(0xd55c) == `한`\nJs.String2.fromCharCode(-64568) == `ψ`\n```" - ], - "signature": "let fromCharCode: int => t" - }, - { - "id": "Js.String.fromCharCodeMany", - "kind": "value", - "name": "fromCharCodeMany", - "docstrings": [ - "`fromCharCodeMany([n1, n2, n3])` creates a `string` from the characters\ncorresponding to the given numbers, using the same rules as `fromCharCode`. See\n[`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)\non MDN." - ], - "signature": "let fromCharCodeMany: array => t" - }, - { - "id": "Js.String.fromCodePoint", - "kind": "value", - "name": "fromCodePoint", - "docstrings": [ - "`fromCodePoint(n)` creates a `string` containing the character corresponding to\nthat numeric code point. If the number is not a valid code point, it raises\n`RangeError`.Thus, `fromCodePoint(0x1F63A)` will produce a correct value,\nunlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a\n`RangeError`.\n\nSee [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.fromCodePoint(65) == \"A\"\nJs.String2.fromCodePoint(0x3c8) == `ψ`\nJs.String2.fromCodePoint(0xd55c) == `한`\nJs.String2.fromCodePoint(0x1f63a) == `😺`\n```" - ], - "signature": "let fromCodePoint: int => t" - }, - { - "id": "Js.String.fromCodePointMany", - "kind": "value", - "name": "fromCodePointMany", - "docstrings": [ - "`fromCodePointMany([n1, n2, n3])` creates a `string` from the characters\ncorresponding to the given code point numbers, using the same rules as\n`fromCodePoint`.\n\nSee [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺`\n```" - ], - "signature": "let fromCodePointMany: array => t" - }, - { - "id": "Js.String.length", - "kind": "value", - "name": "length", - "docstrings": [ - "`length(s)` returns the length of the given `string`. See\n[`String.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)\non MDN.\n\n## Examples\n\n```rescript\nJs.String2.length(\"abcd\") == 4\n```" - ], - "signature": "let length: t => int" - }, - { - "id": "Js.String.get", - "kind": "value", - "name": "get", - "docstrings": [ - "`get(s, n)` returns as a `string` the character at the given index number. If\n`n` is out of range, this function returns `undefined`, so at some point this\nfunction may be modified to return `option`.\n\n## Examples\n\n```rescript\nJs.String2.get(\"Reason\", 0) == \"R\"\nJs.String2.get(\"Reason\", 4) == \"o\"\nJs.String2.get(`Rẽasöń`, 5) == `ń`\n```" - ], - "signature": "let get: (t, int) => t" - }, - { - "id": "Js.String.charAt", - "kind": "value", - "name": "charAt", - "docstrings": [], - "signature": "let charAt: (int, t) => t" - }, - { - "id": "Js.String.charCodeAt", - "kind": "value", - "name": "charCodeAt", - "docstrings": [], - "signature": "let charCodeAt: (int, t) => float" - }, - { - "id": "Js.String.codePointAt", - "kind": "value", - "name": "codePointAt", - "docstrings": [], - "signature": "let codePointAt: (int, t) => option" - }, - { - "id": "Js.String.concat", - "kind": "value", - "name": "concat", - "docstrings": [], - "signature": "let concat: (t, t) => t" - }, - { - "id": "Js.String.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [], - "signature": "let concatMany: (array, t) => t" - }, - { - "id": "Js.String.endsWith", - "kind": "value", - "name": "endsWith", - "docstrings": [], - "signature": "let endsWith: (t, t) => bool" - }, - { - "id": "Js.String.endsWithFrom", - "kind": "value", - "name": "endsWithFrom", - "docstrings": [], - "signature": "let endsWithFrom: (t, int, t) => bool" - }, - { - "id": "Js.String.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: (t, t) => bool" - }, - { - "id": "Js.String.includesFrom", - "kind": "value", - "name": "includesFrom", - "docstrings": [], - "signature": "let includesFrom: (t, int, t) => bool" - }, - { - "id": "Js.String.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: (t, t) => int" - }, - { - "id": "Js.String.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: (t, int, t) => int" - }, - { - "id": "Js.String.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: (t, t) => int" - }, - { - "id": "Js.String.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: (t, int, t) => int" - }, - { - "id": "Js.String.localeCompare", - "kind": "value", - "name": "localeCompare", - "docstrings": [], - "signature": "let localeCompare: (t, t) => float" - }, - { - "id": "Js.String.match_", - "kind": "value", - "name": "match_", - "docstrings": [], - "signature": "let match_: (Js_re.t, t) => option>>" - }, - { - "id": "Js.String.normalize", - "kind": "value", - "name": "normalize", - "docstrings": [ - "`normalize(str)` returns the normalized Unicode string using Normalization Form\nCanonical (NFC) Composition. Consider the character ã, which can be represented\nas the single codepoint \\u00e3 or the combination of a lower case letter A\n\\u0061 and a combining tilde \\u0303. Normalization ensures that both can be\nstored in an equivalent binary representation.\n\nSee [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)\non MDN.\n\nSee also [Unicode technical report #15](https://unicode.org/reports/tr15/) for\ndetails." - ], - "signature": "let normalize: t => t" - }, - { - "id": "Js.String.normalizeByForm", - "kind": "value", - "name": "normalizeByForm", - "docstrings": [], - "signature": "let normalizeByForm: (t, t) => t" - }, - { - "id": "Js.String.repeat", - "kind": "value", - "name": "repeat", - "docstrings": [], - "signature": "let repeat: (int, t) => t" - }, - { - "id": "Js.String.replace", - "kind": "value", - "name": "replace", - "docstrings": [], - "signature": "let replace: (t, t, t) => t" - }, - { - "id": "Js.String.replaceByRe", - "kind": "value", - "name": "replaceByRe", - "docstrings": [], - "signature": "let replaceByRe: (Js_re.t, t, t) => t" - }, - { - "id": "Js.String.unsafeReplaceBy0", - "kind": "value", - "name": "unsafeReplaceBy0", - "docstrings": [], - "signature": "let unsafeReplaceBy0: (Js_re.t, (t, int, t) => t, t) => t" - }, - { - "id": "Js.String.unsafeReplaceBy1", - "kind": "value", - "name": "unsafeReplaceBy1", - "docstrings": [], - "signature": "let unsafeReplaceBy1: (Js_re.t, (t, t, int, t) => t, t) => t" - }, - { - "id": "Js.String.unsafeReplaceBy2", - "kind": "value", - "name": "unsafeReplaceBy2", - "docstrings": [], - "signature": "let unsafeReplaceBy2: (Js_re.t, (t, t, t, int, t) => t, t) => t" - }, - { - "id": "Js.String.unsafeReplaceBy3", - "kind": "value", - "name": "unsafeReplaceBy3", - "docstrings": [], - "signature": "let unsafeReplaceBy3: (Js_re.t, (t, t, t, t, int, t) => t, t) => t" - }, - { - "id": "Js.String.search", - "kind": "value", - "name": "search", - "docstrings": [], - "signature": "let search: (Js_re.t, t) => int" - }, - { - "id": "Js.String.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~from: int, ~to_: int, t) => t" - }, - { - "id": "Js.String.sliceToEnd", - "kind": "value", - "name": "sliceToEnd", - "docstrings": [], - "signature": "let sliceToEnd: (~from: int, t) => t" - }, - { - "id": "Js.String.split", - "kind": "value", - "name": "split", - "docstrings": [], - "signature": "let split: (t, t) => array" - }, - { - "id": "Js.String.splitAtMost", - "kind": "value", - "name": "splitAtMost", - "docstrings": [], - "signature": "let splitAtMost: (t, ~limit: int, t) => array" - }, - { - "id": "Js.String.splitByRe", - "kind": "value", - "name": "splitByRe", - "docstrings": [], - "signature": "let splitByRe: (Js_re.t, t) => array>" - }, - { - "id": "Js.String.splitByReAtMost", - "kind": "value", - "name": "splitByReAtMost", - "docstrings": [], - "signature": "let splitByReAtMost: (Js_re.t, ~limit: int, t) => array>" - }, - { - "id": "Js.String.startsWith", - "kind": "value", - "name": "startsWith", - "docstrings": [], - "signature": "let startsWith: (t, t) => bool" - }, - { - "id": "Js.String.startsWithFrom", - "kind": "value", - "name": "startsWithFrom", - "docstrings": [], - "signature": "let startsWithFrom: (t, int, t) => bool" - }, - { - "id": "Js.String.substr", - "kind": "value", - "name": "substr", - "docstrings": [], - "signature": "let substr: (~from: int, t) => t" - }, - { - "id": "Js.String.substrAtMost", - "kind": "value", - "name": "substrAtMost", - "docstrings": [], - "signature": "let substrAtMost: (~from: int, ~length: int, t) => t" - }, - { - "id": "Js.String.substring", - "kind": "value", - "name": "substring", - "docstrings": [], - "signature": "let substring: (~from: int, ~to_: int, t) => t" - }, - { - "id": "Js.String.substringToEnd", - "kind": "value", - "name": "substringToEnd", - "docstrings": [], - "signature": "let substringToEnd: (~from: int, t) => t" - }, - { - "id": "Js.String.toLowerCase", - "kind": "value", - "name": "toLowerCase", - "docstrings": [ - "`toLowerCase(str)` converts `str` to lower case using the locale-insensitive\ncase mappings in the Unicode Character Database. Notice that the conversion can\ngive different results depending upon context, for example with the Greek\nletter sigma, which has two different lower case forms; one when it is the last\ncharacter in a string and another when it is not.\n\nSee [`String.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\non MDN.\n\n## Examples\n\n```rescript\nJs.String.toLowerCase(\"ABC\") == \"abc\"\nJs.String.toLowerCase(`ΣΠ`) == `σπ`\nJs.String.toLowerCase(`ΠΣ`) == `πς`\n```" - ], - "signature": "let toLowerCase: t => t" - }, - { - "id": "Js.String.toLocaleLowerCase", - "kind": "value", - "name": "toLocaleLowerCase", - "docstrings": [ - "`toLocaleLowerCase(str)` converts `str` to lower case using the current locale.\n\nSee [`String.toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)\non MDN." - ], - "signature": "let toLocaleLowerCase: t => t" - }, - { - "id": "Js.String.toUpperCase", - "kind": "value", - "name": "toUpperCase", - "docstrings": [ - "`toUpperCase(str)` converts `str` to upper case using the locale-insensitive\ncase mappings in the Unicode Character Database. Notice that the conversion can\nexpand the number of letters in the result; for example the German ß\ncapitalizes to two Ses in a row.\n\nSee [`String.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)\non MDN.\n\n## Examples\n\n```rescript\nJs.String.toUpperCase(\"abc\") == \"ABC\"\nJs.String.toUpperCase(`Straße`) == `STRASSE`\nJs.String.toUpperCase(`πς`) == `ΠΣ`\n```" - ], - "signature": "let toUpperCase: t => t" - }, - { - "id": "Js.String.toLocaleUpperCase", - "kind": "value", - "name": "toLocaleUpperCase", - "docstrings": [ - "`toLocaleUpperCase(str)` converts `str` to upper case using the current locale.\n\nSee [`String.to:LocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\non MDN." - ], - "signature": "let toLocaleUpperCase: t => t" - }, - { - "id": "Js.String.trim", - "kind": "value", - "name": "trim", - "docstrings": [ - "`trim(str)` returns a string that is `str` with whitespace stripped from both\nends. Internal whitespace is not removed.\n\nSee [`String.trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)\non MDN.\n\n## Examples\n\n```rescript\nJs.String.trim(\" abc def \") == \"abc def\"\nJs.String.trim(\"\\n\\r\\t abc def \\n\\n\\t\\r \") == \"abc def\"\n```" - ], - "signature": "let trim: t => t" - }, - { - "id": "Js.String.anchor", - "kind": "value", - "name": "anchor", - "docstrings": [], - "signature": "let anchor: (t, t) => t" - }, - { - "id": "Js.String.link", - "kind": "value", - "name": "link", - "docstrings": [], - "signature": "let link: (t, t) => t" - }, - { - "id": "Js.String.castToArrayLike", - "kind": "value", - "name": "castToArrayLike", - "docstrings": [ - "Casts its argument to an `array_like` entity that can be processed by functions\nsuch as `Js.Array2.fromMap()`\n\n## Examples\n\n```rescript\nlet s = \"abcde\"\nlet arr = Js.Array2.fromMap(Js.String.castToArrayLike(s), x => x)\narr == [\"a\", \"b\", \"c\", \"d\", \"e\"]\n```" - ], - "signature": "let castToArrayLike: t => Js_array2.array_like" - } - ] - }, - "js/array2": { - "id": "Js.Array2", - "name": "Array2", - "docstrings": [ - "Provide bindings to JS array", - "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.\n\nHere is an example to find the sum of squares of all even numbers in an array.\nWithout pipe first, we must call the functions in reverse order:\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\nlet square = x => x * x\nlet result = {\n open Js.Array2\n reduce(map(filter([5, 2, 3, 4, 1], isEven), square), \"+\", 0)\n}\n```\n\nWith pipe first, we call the functions in the “natural” order:\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\nlet square = x => x * x\nlet result = {\n open Js.Array2\n [5, 2, 3, 4, 1]->filter(isEven)->map(square)->reduce(\"+\", 0)\n}\n```" - ], - "items": [ - { - "id": "Js.Array2.t", - "kind": "type", - "name": "t", - "docstrings": ["The type used to describe a JavaScript array."], - "signature": "type t<'a> = array<'a>" - }, - { - "id": "Js.Array2.array_like", - "kind": "type", - "name": "array_like", - "docstrings": [ - "A type used to describe JavaScript objects that are like an array or are iterable." - ], - "signature": "type array_like<'a>" - }, - { - "id": "Js.Array2.from", - "kind": "value", - "name": "from", - "docstrings": [ - "Creates a shallow copy of an array from an array-like object. See\n[`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)\non MDN.\n\n## Examples\n\n```rescript\nlet strArr = Js.String.castToArrayLike(\"abcd\")\nJs.Array2.from(strArr) == [\"a\", \"b\", \"c\", \"d\"]\n```" - ], - "signature": "let from: array_like<'a> => array<'a>" - }, - { - "id": "Js.Array2.fromMap", - "kind": "value", - "name": "fromMap", - "docstrings": [ - "Creates a new array by applying a function (the second argument) to each item\nin the `array_like` first argument. See\n[`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)\non MDN.\n\n## Examples\n\n```rescript\nlet strArr = Js.String.castToArrayLike(\"abcd\")\nlet code = s => Js.String.charCodeAt(0, s)\nJs.Array2.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0]\n```" - ], - "signature": "let fromMap: (array_like<'a>, 'a => 'b) => array<'b>" - }, - { - "id": "Js.Array2.isArray", - "kind": "value", - "name": "isArray", - "docstrings": [ - "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.\n\n## Examples\n\n```rescript\nJs.Array2.isArray([5, 2, 3, 1, 4]) == true\nJs.Array2.isArray(list{5, 2, 3, 1, 4}) == true\nJs.Array2.isArray(\"abcd\") == false\n```" - ], - "signature": "let isArray: 'a => bool" - }, - { - "id": "Js.Array2.length", - "kind": "value", - "name": "length", - "docstrings": [ - "Returns the number of elements in the array. See\n[`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)\non MDN." - ], - "signature": "let length: array<'a> => int" - }, - { - "id": "Js.Array2.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [ - "Copies from the first element in the given array to the designated `~to_`\nposition, returning the resulting array. *This function modifies the original\narray.* See\n[`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array2.copyWithin(arr, ~to_=2) == [100, 101, 100, 101, 102]\narr == [100, 101, 100, 101, 102]\n```" - ], - "signature": "let copyWithin: (t<'a>, ~to_: int) => t<'a>" - }, - { - "id": "Js.Array2.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [ - "Copies starting at element `~from` in the given array to the designated `~to_`\nposition, returning the resulting array. *This function modifies the original\narray.* See\n[`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array2.copyWithinFrom(arr, ~from=2, ~to_=0) == [102, 103, 104, 103, 104]\narr == [102, 103, 104, 103, 104]\n```" - ], - "signature": "let copyWithinFrom: (t<'a>, ~to_: int, ~from: int) => t<'a>" - }, - { - "id": "Js.Array2.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [ - "Copies starting at element `~start` in the given array up to but not including\n`~end_` to the designated `~to_` position, returning the resulting array. *This\nfunction modifies the original array.* See\n[`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104, 105]\nJs.Array2.copyWithinFromRange(arr, ~start=2, ~end_=5, ~to_=1) == [100, 102, 103, 104, 104, 105]\narr == [100, 102, 103, 104, 104, 105]\n```" - ], - "signature": "let copyWithinFromRange: (t<'a>, ~to_: int, ~start: int, ~end_: int) => t<'a>" - }, - { - "id": "Js.Array2.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [ - "Sets all elements of the given array (the first arumgent) to the designated\nvalue (the secon argument), returning the resulting array. *This function\n modifies the original array.*\n\nSee\n[`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array2.fillInPlace(arr, 99) == [99, 99, 99, 99, 99]\narr == [99, 99, 99, 99, 99]\n```" - ], - "signature": "let fillInPlace: (t<'a>, 'a) => t<'a>" - }, - { - "id": "Js.Array2.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [ - "Sets all elements of the given array (the first arumgent) from position `~from`\nto the end to the designated value (the second argument), returning the\nresulting array. *This function modifies the original array.* See\n[`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array2.fillFromInPlace(arr, 99, ~from=2) == [100, 101, 99, 99, 99]\narr == [100, 101, 99, 99, 99]\n```" - ], - "signature": "let fillFromInPlace: (t<'a>, 'a, ~from: int) => t<'a>" - }, - { - "id": "Js.Array2.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [ - "Sets the elements of the given array (the first arumgent) from position\n`~start` up to but not including position `~end_` to the designated value (the\nsecond argument), returning the resulting array. *This function modifies the\noriginal array.* See\n[`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array2.fillRangeInPlace(arr, 99, ~start=1, ~end_=4) == [100, 99, 99, 99, 104]\narr == [100, 99, 99, 99, 104]\n```" - ], - "signature": "let fillRangeInPlace: (t<'a>, 'a, ~start: int, ~end_: int) => t<'a>" - }, - { - "id": "Js.Array2.pop", - "kind": "value", - "name": "pop", - "docstrings": [ - "If the array is not empty, removes the last element and returns it as\n`Some(value)`; returns `None` if the array is empty. *This function modifies\nthe original array.* See\n[`Array.pop`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array2.pop(arr) == Some(104)\narr == [100, 101, 102, 103]\n\nlet empty: array = []\nJs.Array2.pop(empty) == None\n```" - ], - "signature": "let pop: t<'a> => option<'a>" - }, - { - "id": "Js.Array2.push", - "kind": "value", - "name": "push", - "docstrings": [ - "Appends the given value to the array, returning the number of elements in the\nupdated array. *This function modifies the original array.* See\n[`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"ant\", \"bee\", \"cat\"]\nJs.Array2.push(arr, \"dog\") == 4\narr == [\"ant\", \"bee\", \"cat\", \"dog\"]\n```" - ], - "signature": "let push: (t<'a>, 'a) => int" - }, - { - "id": "Js.Array2.pushMany", - "kind": "value", - "name": "pushMany", - "docstrings": [ - "Appends the values from one array (the second argument) to another (the first\nargument), returning the number of elements in the updated array. *This\nfunction modifies the original array.* See\n[`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"ant\", \"bee\", \"cat\"]\nJs.Array2.pushMany(arr, [\"dog\", \"elk\"]) == 5\narr == [\"ant\", \"bee\", \"cat\", \"dog\", \"elk\"]\n```" - ], - "signature": "let pushMany: (t<'a>, array<'a>) => int" - }, - { - "id": "Js.Array2.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [ - "Returns an array with the elements of the input array in reverse order. *This\nfunction modifies the original array.* See\n[`Array.reverse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"ant\", \"bee\", \"cat\"]\nJs.Array2.reverseInPlace(arr) == [\"cat\", \"bee\", \"ant\"]\narr == [\"cat\", \"bee\", \"ant\"]\n```" - ], - "signature": "let reverseInPlace: t<'a> => t<'a>" - }, - { - "id": "Js.Array2.shift", - "kind": "value", - "name": "shift", - "docstrings": [ - "If the array is not empty, removes the first element and returns it as\n`Some(value)`; returns `None` if the array is empty. *This function modifies\nthe original array.* See\n[`Array.shift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array2.shift(arr) == Some(100)\narr == [101, 102, 103, 104]\n\nlet empty: array = []\nJs.Array2.shift(empty) == None\n```" - ], - "signature": "let shift: t<'a> => option<'a>" - }, - { - "id": "Js.Array2.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [ - "Sorts the given array in place and returns the sorted array. JavaScript sorts\nthe array by converting the arguments to UTF-16 strings and sorting them. See\nthe second example with sorting numbers, which does not do a numeric sort.\n*This function modifies the original array.* See\n[`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\non MDN.\n\n## Examples\n\n```rescript\nlet words = [\"bee\", \"dog\", \"ant\", \"cat\"]\nJs.Array2.sortInPlace(words) == [\"ant\", \"bee\", \"cat\", \"dog\"]\nwords == [\"ant\", \"bee\", \"cat\", \"dog\"]\n\nlet numbers = [3, 30, 10, 1, 20, 2]\nJs.Array2.sortInPlace(numbers) == [1, 10, 2, 20, 3, 30]\nnumbers == [1, 10, 2, 20, 3, 30]\n```" - ], - "signature": "let sortInPlace: t<'a> => t<'a>" - }, - { - "id": "Js.Array2.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [ - "Sorts the given array in place and returns the sorted array. *This function\n modifies the original array.*\n\nThe first argument to `sortInPlaceWith()` is a function that compares two items\nfrom the array and returns:\n\n* an integer less than zero if the first item is less than the second item *\nzero if the items are equal * an integer greater than zero if the first item is\ngreater than the second item\n\nSee\n[`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\non MDN.\n\n## Examples\n\n```rescript\n// sort by word length\nlet words = [\"horse\", \"aardvark\", \"dog\", \"camel\"]\nlet byLength = (s1, s2) => Js.String.length(s1) - Js.String.length(s2)\n\nJs.Array2.sortInPlaceWith(words, byLength) == [\"dog\", \"horse\", \"camel\", \"aardvark\"]\n\n// sort in reverse numeric order\nlet numbers = [3, 30, 10, 1, 20, 2]\nlet reverseNumeric = (n1, n2) => n2 - n1\nJs.Array2.sortInPlaceWith(numbers, reverseNumeric) == [30, 20, 10, 3, 2, 1]\n```" - ], - "signature": "let sortInPlaceWith: (t<'a>, ('a, 'a) => int) => t<'a>" - }, - { - "id": "Js.Array2.spliceInPlace", - "kind": "value", - "name": "spliceInPlace", - "docstrings": [ - "Starting at position `~pos`, remove `~remove` elements and then add the\nelements from the `~add` array. Returns an array consisting of the removed\nitems. *This function modifies the original array.* See\n[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\nJs.Array2.spliceInPlace(arr, ~pos=2, ~remove=2, ~add=[\"x\", \"y\", \"z\"]) == [\"c\", \"d\"]\narr == [\"a\", \"b\", \"x\", \"y\", \"z\", \"e\", \"f\"]\n\nlet arr2 = [\"a\", \"b\", \"c\", \"d\"]\nJs.Array2.spliceInPlace(arr2, ~pos=3, ~remove=0, ~add=[\"x\", \"y\"]) == []\narr2 == [\"a\", \"b\", \"c\", \"x\", \"y\", \"d\"]\n\nlet arr3 = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\nJs.Array2.spliceInPlace(arr3, ~pos=9, ~remove=2, ~add=[\"x\", \"y\", \"z\"]) == []\narr3 == [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"x\", \"y\", \"z\"]\n```" - ], - "signature": "let spliceInPlace: (t<'a>, ~pos: int, ~remove: int, ~add: array<'a>) => t<'a>" - }, - { - "id": "Js.Array2.removeFromInPlace", - "kind": "value", - "name": "removeFromInPlace", - "docstrings": [ - "Removes elements from the given array starting at position `~pos` to the end of\nthe array, returning the removed elements. *This function modifies the original\narray.* See\n[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\nJs.Array2.removeFromInPlace(arr, ~pos=4) == [\"e\", \"f\"]\narr == [\"a\", \"b\", \"c\", \"d\"]\n```" - ], - "signature": "let removeFromInPlace: (t<'a>, ~pos: int) => t<'a>" - }, - { - "id": "Js.Array2.removeCountInPlace", - "kind": "value", - "name": "removeCountInPlace", - "docstrings": [ - "Removes `~count` elements from the given array starting at position `~pos`,\nreturning the removed elements. *This function modifies the original array.*\nSee\n[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\nJs.Array2.removeCountInPlace(arr, ~pos=2, ~count=3) == [\"c\", \"d\", \"e\"]\narr == [\"a\", \"b\", \"f\"]\n```" - ], - "signature": "let removeCountInPlace: (t<'a>, ~pos: int, ~count: int) => t<'a>" - }, - { - "id": "Js.Array2.unshift", - "kind": "value", - "name": "unshift", - "docstrings": [ - "Adds the given element to the array, returning the new number of elements in\nthe array. *This function modifies the original array.* See\n[`Array.unshift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"b\", \"c\", \"d\"]\nJs.Array2.unshift(arr, \"a\") == 4\narr == [\"a\", \"b\", \"c\", \"d\"]\n```" - ], - "signature": "let unshift: (t<'a>, 'a) => int" - }, - { - "id": "Js.Array2.unshiftMany", - "kind": "value", - "name": "unshiftMany", - "docstrings": [ - "Adds the elements in the second array argument at the beginning of the first\narray argument, returning the new number of elements in the array. *This\nfunction modifies the original array.* See\n[`Array.unshift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [\"d\", \"e\"]\nJs.Array2.unshiftMany(arr, [\"a\", \"b\", \"c\"]) == 5\narr == [\"a\", \"b\", \"c\", \"d\", \"e\"]\n```" - ], - "signature": "let unshiftMany: (t<'a>, array<'a>) => int" - }, - { - "id": "Js.Array2.append", - "kind": "value", - "name": "append", - "docstrings": [], - "signature": "let append: (t<'a>, 'a) => t<'a>", - "deprecated": "`append` is not type-safe. Use `concat` instead." - }, - { - "id": "Js.Array2.concat", - "kind": "value", - "name": "concat", - "docstrings": [ - "Concatenates the second array argument to the first array argument, returning a\nnew array. The original arrays are not modified. See\n[`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.concat([\"a\", \"b\"], [\"c\", \"d\", \"e\"]) == [\"a\", \"b\", \"c\", \"d\", \"e\"]\n```" - ], - "signature": "let concat: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Js.Array2.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [ - "The second argument to `concatMany()` is an array of arrays; these are added at\nthe end of the first argument, returning a new array. See\n[`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.concatMany([\"a\", \"b\", \"c\"], [[\"d\", \"e\"], [\"f\", \"g\", \"h\"]]) == [\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n ]\n```" - ], - "signature": "let concatMany: (t<'a>, array>) => t<'a>" - }, - { - "id": "Js.Array2.includes", - "kind": "value", - "name": "includes", - "docstrings": [ - "Returns true if the given value is in the array, `false` otherwise. See\n[`Array.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.includes([\"a\", \"b\", \"c\"], \"b\") == true\nJs.Array2.includes([\"a\", \"b\", \"c\"], \"x\") == false\n```" - ], - "signature": "let includes: (t<'a>, 'a) => bool" - }, - { - "id": "Js.Array2.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [ - "Returns the index of the first element in the array that has the given value.\nIf the value is not in the array, returns -1. See\n[`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.indexOf([100, 101, 102, 103], 102) == 2\nJs.Array2.indexOf([100, 101, 102, 103], 999) == -1\n```" - ], - "signature": "let indexOf: (t<'a>, 'a) => int" - }, - { - "id": "Js.Array2.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [ - "Returns the index of the first element in the array with the given value. The\nsearch starts at position `~from`. See\n[`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.indexOfFrom([\"a\", \"b\", \"a\", \"c\", \"a\"], \"a\", ~from=2) == 2\nJs.Array2.indexOfFrom([\"a\", \"b\", \"a\", \"c\", \"a\"], \"a\", ~from=3) == 4\nJs.Array2.indexOfFrom([\"a\", \"b\", \"a\", \"c\", \"a\"], \"b\", ~from=2) == -1\n```" - ], - "signature": "let indexOfFrom: (t<'a>, 'a, ~from: int) => int" - }, - { - "id": "Js.Array2.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [ - "This function converts each element of the array to a string (via JavaScript)\nand concatenates them, separated by the string given in the first argument,\ninto a single string. See\n[`Array.join`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.joinWith([\"ant\", \"bee\", \"cat\"], \"--\") == \"ant--bee--cat\"\nJs.Array2.joinWith([\"door\", \"bell\"], \"\") == \"doorbell\"\nJs.Array2.joinWith([2020, 9, 4], \"/\") == \"2020/9/4\"\nJs.Array2.joinWith([2.5, 3.6, 3e-2], \";\") == \"2.5;3.6;0.03\"\n```" - ], - "signature": "let joinWith: (t<'a>, string) => string" - }, - { - "id": "Js.Array2.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [ - "Returns the index of the last element in the array that has the given value. If\nthe value is not in the array, returns -1. See\n[`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.lastIndexOf([\"a\", \"b\", \"a\", \"c\"], \"a\") == 2\nJs.Array2.lastIndexOf([\"a\", \"b\", \"a\", \"c\"], \"x\") == -1\n```" - ], - "signature": "let lastIndexOf: (t<'a>, 'a) => int" - }, - { - "id": "Js.Array2.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [ - "Returns the index of the last element in the array that has the given value,\nsearching from position `~from` down to the start of the array. If the value is\nnot in the array, returns -1. See\n[`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.lastIndexOfFrom([\"a\", \"b\", \"a\", \"c\", \"a\", \"d\"], \"a\", ~from=3) == 2\nJs.Array2.lastIndexOfFrom([\"a\", \"b\", \"a\", \"c\", \"a\", \"d\"], \"c\", ~from=2) == -1\n```" - ], - "signature": "let lastIndexOfFrom: (t<'a>, 'a, ~from: int) => int" - }, - { - "id": "Js.Array2.slice", - "kind": "value", - "name": "slice", - "docstrings": [ - "Returns a shallow copy of the given array from the `~start` index up to but not\nincluding the `~end_` position. Negative numbers indicate an offset from the\nend of the array. See\n[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)\non MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104, 105, 106]\nJs.Array2.slice(arr, ~start=2, ~end_=5) == [102, 103, 104]\nJs.Array2.slice(arr, ~start=-3, ~end_=-1) == [104, 105]\nJs.Array2.slice(arr, ~start=9, ~end_=10) == []\n```" - ], - "signature": "let slice: (t<'a>, ~start: int, ~end_: int) => t<'a>" - }, - { - "id": "Js.Array2.copy", - "kind": "value", - "name": "copy", - "docstrings": [ - "Returns a copy of the entire array. Same as `Js.Array2.Slice(arr, ~start=0,\n~end_=Js.Array2.length(arr))`. See\n[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)\non MDN." - ], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Js.Array2.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [ - "Returns a shallow copy of the given array from the given index to the end. See\n[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)\non MDN." - ], - "signature": "let sliceFrom: (t<'a>, int) => t<'a>" - }, - { - "id": "Js.Array2.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Converts the array to a string. Each element is converted to a string using\nJavaScript. Unlike the JavaScript `Array.toString()`, all elements in a\nReasonML array must have the same type. See\n[`Array.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.toString([3.5, 4.6, 7.8]) == \"3.5,4.6,7.8\"\nJs.Array2.toString([\"a\", \"b\", \"c\"]) == \"a,b,c\"\n```" - ], - "signature": "let toString: t<'a> => string" - }, - { - "id": "Js.Array2.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "Converts the array to a string using the conventions of the current locale.\nEach element is converted to a string using JavaScript. Unlike the JavaScript\n`Array.toLocaleString()`, all elements in a ReasonML array must have the same\ntype. See\n[`Array.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.toLocaleString([Js.Date.make()])\n// returns \"3/19/2020, 10:52:11 AM\" for locale en_US.utf8\n// returns \"2020-3-19 10:52:11\" for locale de_DE.utf8\n```" - ], - "signature": "let toLocaleString: t<'a> => string" - }, - { - "id": "Js.Array2.every", - "kind": "value", - "name": "every", - "docstrings": [ - "The first argument to `every()` is an array. The second argument is a predicate\nfunction that returns a boolean. The `every()` function returns `true` if the\npredicate function is true for all items in the given array. If given an empty\narray, returns `true`. See\n[`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)\non MDN.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\nJs.Array2.every([6, 22, 8, 4], isEven) == true\nJs.Array2.every([6, 22, 7, 4], isEven) == false\n```" - ], - "signature": "let every: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Js.Array2.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [ - "The first argument to `everyi()` is an array. The second argument is a\npredicate function with two arguments: an array element and that element’s\nindex; it returns a boolean. The `everyi()` function returns `true` if the\npredicate function is true for all items in the given array. If given an empty\narray, returns `true`. See\n[`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)\non MDN.\n\n## Examples\n\n```rescript\n// determine if all even-index items are positive\nlet evenIndexPositive = (item, index) => mod(index, 2) == 0 ? item > 0 : true\n\nJs.Array2.everyi([6, -3, 5, 8], evenIndexPositive) == true\nJs.Array2.everyi([6, 3, -5, 8], evenIndexPositive) == false\n```" - ], - "signature": "let everyi: (t<'a>, ('a, int) => bool) => bool" - }, - { - "id": "Js.Array2.filter", - "kind": "value", - "name": "filter", - "docstrings": [ - "Applies the given predicate function (the second argument) to each element in\nthe array; the result is an array of those elements for which the predicate\nfunction returned `true`. See\n[`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)\non MDN.\n\n## Examples\n\n```rescript\nlet nonEmpty = s => s != \"\"\nJs.Array2.filter([\"abc\", \"\", \"\", \"def\", \"ghi\"], nonEmpty) == [\"abc\", \"def\", \"ghi\"]\n```" - ], - "signature": "let filter: (t<'a>, 'a => bool) => t<'a>" - }, - { - "id": "Js.Array2.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [ - "Each element of the given array are passed to the predicate function. The\nreturn value is an array of all those elements for which the predicate function\nreturned `true`.\n\nSee\n[`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)\non MDN.\n\n## Examples\n\n```rescript\n// keep only positive elements at odd indices\nlet positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0\n\nJs.Array2.filteri([6, 3, 5, 8, 7, -4, 1], positiveOddElement) == [3, 8]\n```" - ], - "signature": "let filteri: (t<'a>, ('a, int) => bool) => t<'a>" - }, - { - "id": "Js.Array2.find", - "kind": "value", - "name": "find", - "docstrings": [ - "Returns `Some(value)` for the first element in the array that satisifies the\ngiven predicate function, or `None` if no element satisifies the predicate. See\n[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)\non MDN.\n\n## Examples\n\n```rescript\n// find first negative element\nJs.Array2.find([33, 22, -55, 77, -44], x => x < 0) == Some(-55)\nJs.Array2.find([33, 22, 55, 77, 44], x => x < 0) == None\n```" - ], - "signature": "let find: (t<'a>, 'a => bool) => option<'a>" - }, - { - "id": "Js.Array2.findi", - "kind": "value", - "name": "findi", - "docstrings": [ - "Returns `Some(value)` for the first element in the array that satisifies the\ngiven predicate function, or `None` if no element satisifies the predicate. The\npredicate function takes an array element and an index as its parameters. See\n[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)\non MDN.\n\n## Examples\n\n```rescript\n// find first positive item at an odd index\nlet positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0\n\nJs.Array2.findi([66, -33, 55, 88, 22], positiveOddElement) == Some(88)\nJs.Array2.findi([66, -33, 55, -88, 22], positiveOddElement) == None\n```" - ], - "signature": "let findi: (t<'a>, ('a, int) => bool) => option<'a>" - }, - { - "id": "Js.Array2.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [ - "Returns the index of the first element in the array that satisifies the given\npredicate function, or -1 if no element satisifies the predicate. See\n[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.findIndex([33, 22, -55, 77, -44], x => x < 0) == 2\nJs.Array2.findIndex([33, 22, 55, 77, 44], x => x < 0) == -1\n```" - ], - "signature": "let findIndex: (t<'a>, 'a => bool) => int" - }, - { - "id": "Js.Array2.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [ - "Returns `Some(value)` for the first element in the array that satisifies the\ngiven predicate function, or `None` if no element satisifies the predicate. The\npredicate function takes an array element and an index as its parameters. See\n[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)\non MDN.\n\n## Examples\n\n```rescript\n// find index of first positive item at an odd index\nlet positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0\n\nJs.Array2.findIndexi([66, -33, 55, 88, 22], positiveOddElement) == 3\nJs.Array2.findIndexi([66, -33, 55, -88, 22], positiveOddElement) == -1\n```" - ], - "signature": "let findIndexi: (t<'a>, ('a, int) => bool) => int" - }, - { - "id": "Js.Array2.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [ - "The `forEach()` function applies the function given as the second argument to\neach element in the array. The function you provide returns `unit`, and the\n`forEach()` function also returns `unit`. You use `forEach()` when you need to\nprocess each element in the array but not return any new array or value; for\nexample, to print the items in an array. See\n[`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)\non MDN.\n\n## Examples\n\n```rescript\n// display all elements in an array\nJs.Array2.forEach([\"a\", \"b\", \"c\"], x => Js.log(x)) == ()\n```" - ], - "signature": "let forEach: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Js.Array2.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [ - "The `forEachi()` function applies the function given as the second argument to\neach element in the array. The function you provide takes an item in the array\nand its index number, and returns `unit`. The `forEachi()` function also\nreturns `unit`. You use `forEachi()` when you need to process each element in\nthe array but not return any new array or value; for example, to print the\nitems in an array. See\n[`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)\non MDN.\n\n## Examples\n\n```rescript\n// display all elements in an array as a numbered list\nJs.Array2.forEachi([\"a\", \"b\", \"c\"], (item, index) => Js.log2(index + 1, item)) == ()\n```" - ], - "signature": "let forEachi: (t<'a>, ('a, int) => unit) => unit" - }, - { - "id": "Js.Array2.map", - "kind": "value", - "name": "map", - "docstrings": [ - "Applies the function (the second argument) to each item in the array, returning\na new array. The result array does not have to have elements of the same type\nas the input array. See\n[`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array2.map([12, 4, 8], x => x * x) == [144, 16, 64]\nJs.Array2.map([\"animal\", \"vegetable\", \"mineral\"], Js.String.length) == [6, 9, 7]\n```" - ], - "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Js.Array2.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [ - "Applies the function (the second argument) to each item in the array, returning\na new array. The function acceps two arguments: an item from the array and its\nindex number. The result array does not have to have elements of the same type\nas the input array. See\n[`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)\non MDN.\n\n## Examples\n\n```rescript\n// multiply each item in array by its position\nlet product = (item, index) => item * index\nJs.Array2.mapi([10, 11, 12], product) == [0, 11, 24]\n```" - ], - "signature": "let mapi: (t<'a>, ('a, int) => 'b) => t<'b>" - }, - { - "id": "Js.Array2.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [ - "The `reduce()` function takes three parameters: an array, a *reducer function*,\nand a beginning accumulator value. The reducer function has two parameters: an\naccumulated value and an element of the array.\n\n`reduce()` first calls the reducer function with the beginning value and the\nfirst element in the array. The result becomes the new accumulator value, which\nis passed in to the reducer function along with the second element in the\narray. `reduce()` proceeds through the array, passing in the result of each\nstage as the accumulator to the reducer function.\n\nWhen all array elements are processed, the final value of the accumulator\nbecomes the return value of `reduce()`. See\n[`Array.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)\non MDN.\n\n## Examples\n\n```rescript\nlet sumOfSquares = (accumulator, item) => accumulator + item * item\n\nJs.Array2.reduce([10, 2, 4], sumOfSquares, 0) == 120\nJs.Array2.reduce([10, 2, 4], \"*\", 1) == 80\nJs.Array2.reduce(\n [\"animal\", \"vegetable\", \"mineral\"],\n (acc, item) => acc + Js.String.length(item),\n 0,\n) == 22 // 6 + 9 + 7\nJs.Array2.reduce([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 2.0 // 4.0 / (2.0 / 1.0)\n```" - ], - "signature": "let reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b" - }, - { - "id": "Js.Array2.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [ - "The `reducei()` function takes three parameters: an array, a *reducer\nfunction*, and a beginning accumulator value. The reducer function has three\nparameters: an accumulated value, an element of the array, and the index of\nthat element.\n\n`reducei()` first calls the reducer function with the beginning value, the\nfirst element in the array, and zero (its index). The result becomes the new\naccumulator value, which is passed to the reducer function along with the\nsecond element in the array and one (its index). `reducei()` proceeds from left\nto right through the array, passing in the result of each stage as the\naccumulator to the reducer function.\n\nWhen all array elements are processed, the final value of the accumulator\nbecomes the return value of `reducei()`. See\n[`Array.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)\non MDN.\n\n## Examples\n\n```rescript\n// find sum of even-index elements in array\nlet sumOfEvens = (accumulator, item, index) =>\n if mod(index, 2) == 0 {\n accumulator + item\n } else {\n accumulator\n }\n\nJs.Array2.reducei([2, 5, 1, 4, 3], sumOfEvens, 0) == 6\n```" - ], - "signature": "let reducei: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.Array2.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [ - "The `reduceRight()` function takes three parameters: an array, a *reducer\nfunction*, and a beginning accumulator value. The reducer function has two\nparameters: an accumulated value and an element of the array.\n\n`reduceRight()` first calls the reducer function with the beginning value and\nthe last element in the array. The result becomes the new accumulator value,\nwhich is passed in to the reducer function along with the next-to-last element\nin the array. `reduceRight()` proceeds from right to left through the array,\npassing in the result of each stage as the accumulator to the reducer function.\n\nWhen all array elements are processed, the final value of the accumulator\nbecomes the return value of `reduceRight()`. See\n[`Array.reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight)\non MDN.\n\n**NOTE:** In many cases, `reduce()` and `reduceRight()` give the same result.\nHowever, see the last example here and compare it to the example from\n`reduce()`, where order makes a difference.\n\n## Examples\n\n```rescript\nlet sumOfSquares = (accumulator, item) => accumulator + item * item\n\nJs.Array2.reduceRight([10, 2, 4], sumOfSquares, 0) == 120\nJs.Array2.reduceRight([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 0.5 // 2.0 / (4.0 / 1.0)\n```" - ], - "signature": "let reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b" - }, - { - "id": "Js.Array2.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [ - "The `reduceRighti()` function takes three parameters: an array, a *reducer\nfunction*, and a beginning accumulator value. The reducer function has three\nparameters: an accumulated value, an element of the array, and the index of\nthat element. `reduceRighti()` first calls the reducer function with the\nbeginning value, the last element in the array, and its index (length of array\nminus one). The result becomes the new accumulator value, which is passed in to\nthe reducer function along with the second element in the array and one (its\nindex). `reduceRighti()` proceeds from right to left through the array, passing\nin the result of each stage as the accumulator to the reducer function.\n\nWhen all array elements are processed, the final value of the accumulator\nbecomes the return value of `reduceRighti()`. See\n[`Array.reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight)\non MDN.\n\n**NOTE:** In many cases, `reducei()` and `reduceRighti()` give the same result.\nHowever, there are cases where the order in which items are processed makes a\ndifference.\n\n## Examples\n\n```rescript\n// find sum of even-index elements in array\nlet sumOfEvens = (accumulator, item, index) =>\n if mod(index, 2) == 0 {\n accumulator + item\n } else {\n accumulator\n }\n\nJs.Array2.reduceRighti([2, 5, 1, 4, 3], sumOfEvens, 0) == 6\n```" - ], - "signature": "let reduceRighti: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b" - }, - { - "id": "Js.Array2.some", - "kind": "value", - "name": "some", - "docstrings": [ - "Returns `true` if the predicate function given as the second argument to\n`some()` returns `true` for any element in the array; `false` otherwise.\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\n\nJs.Array2.some([3, 7, 5, 2, 9], isEven) == true\nJs.Array2.some([3, 7, 5, 1, 9], isEven) == false\n```" - ], - "signature": "let some: (t<'a>, 'a => bool) => bool" - }, - { - "id": "Js.Array2.somei", - "kind": "value", - "name": "somei", - "docstrings": [ - "Returns `true` if the predicate function given as the second argument to\n`somei()` returns `true` for any element in the array; `false` otherwise. The\npredicate function has two arguments: an item from the array and the index\nvalue\n\n## Examples\n\n```rescript\n// Does any string in the array\n// have the same length as its index?\n\nlet sameLength = (str, index) => Js.String.length(str) == index\n\n// \"ef\" has length 2 and is it at index 2\nJs.Array2.somei([\"ab\", \"cd\", \"ef\", \"gh\"], sameLength) == true\n// no item has the same length as its index\nJs.Array2.somei([\"a\", \"bc\", \"def\", \"gh\"], sameLength) == false\n```" - ], - "signature": "let somei: (t<'a>, ('a, int) => bool) => bool" - }, - { - "id": "Js.Array2.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [ - "Returns the value at the given position in the array if the position is in\nbounds; returns the JavaScript value `undefined` otherwise.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103]\nJs.Array2.unsafe_get(arr, 3) == 103\nJs.Array2.unsafe_get(arr, 4) // returns undefined\n```" - ], - "signature": "let unsafe_get: (array<'a>, int) => 'a" - }, - { - "id": "Js.Array2.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [ - "Sets the value at the given position in the array if the position is in bounds.\nIf the index is out of bounds, well, “here there be dragons.“\n\n*This function modifies the original array.*\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103]\nJs.Array2.unsafe_set(arr, 3, 99)\n// result is [100, 101, 102, 99];\n\nJs.Array2.unsafe_set(arr, 4, 88)\n// result is [100, 101, 102, 99, 88]\n\nJs.Array2.unsafe_set(arr, 6, 77)\n// result is [100, 101, 102, 99, 88, <1 empty item>, 77]\n\nJs.Array2.unsafe_set(arr, -1, 66)\n// you don't want to know.\n```" - ], - "signature": "let unsafe_set: (array<'a>, int, 'a) => unit" - } - ] - }, - "js/array": { - "id": "Js.Array", - "name": "Array", - "docstrings": [ - "Provide bindings to JS array", - "Provides bindings to JavaScript’s `Array` functions. These bindings are\noptimized for pipe-last (`|>`), where the array to be processed is the last\nparameter in the function.\n\nHere is an example to find the sum of squares of all even numbers in an array.\nWithout pipe last, we must call the functions in reverse order:\n\n## Examples\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\nlet square = x => x * x\nlet result = {\n open Js.Array\n reduce(\\\"+\", 0, map(square, filter(isEven, [5, 2, 3, 4, 1])))\n}\n```\n\nWith pipe last, we call the functions in the “natural” order:\n\n```rescript\nlet isEven = x => mod(x, 2) == 0\nlet square = x => x * x\nlet result = {\n open Js.Array\n [5, 2, 3, 4, 1] |> filter(isEven) |> map(square) |> reduce(\"+\", 0)\n}\n```" - ], - "items": [ - { - "id": "Js.Array.t", - "kind": "type", - "name": "t", - "docstrings": ["The type used to describe a JavaScript array."], - "signature": "type t<'a> = array<'a>" - }, - { - "id": "Js.Array.array_like", - "kind": "type", - "name": "array_like", - "docstrings": [ - "A type used to describe JavaScript objects that are like an array or are iterable." - ], - "signature": "type array_like<'a> = Js_array2.array_like<'a>" - }, - { - "id": "Js.Array.from", - "kind": "value", - "name": "from", - "docstrings": [ - "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.\n\n## Examples\n\n```rescript\nlet strArr = Js.String.castToArrayLike(\"abcd\")\nJs.Array.from(strArr) == [\"a\", \"b\", \"c\", \"d\"]\n```" - ], - "signature": "let from: array_like<'a> => array<'a>" - }, - { - "id": "Js.Array.fromMap", - "kind": "value", - "name": "fromMap", - "docstrings": [ - "Creates a new array by applying a function (the second argument) to each item\nin the `array_like` first argument. See\n[`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)\non MDN.\n\n## Examples\n\n```rescript\nlet strArr = Js.String.castToArrayLike(\"abcd\")\nlet code = s => Js.String.charCodeAt(0, s)\nJs.Array.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0]\n```" - ], - "signature": "let fromMap: (array_like<'a>, 'a => 'b) => array<'b>" - }, - { - "id": "Js.Array.isArray", - "kind": "value", - "name": "isArray", - "docstrings": [], - "signature": "let isArray: 'a => bool" - }, - { - "id": "Js.Array.length", - "kind": "value", - "name": "length", - "docstrings": [ - "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." - ], - "signature": "let length: array<'a> => int" - }, - { - "id": "Js.Array.copyWithin", - "kind": "value", - "name": "copyWithin", - "docstrings": [], - "signature": "let copyWithin: (~to_: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.copyWithinFrom", - "kind": "value", - "name": "copyWithinFrom", - "docstrings": [], - "signature": "let copyWithinFrom: (~to_: int, ~from: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.copyWithinFromRange", - "kind": "value", - "name": "copyWithinFromRange", - "docstrings": [], - "signature": "let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.fillInPlace", - "kind": "value", - "name": "fillInPlace", - "docstrings": [], - "signature": "let fillInPlace: ('a, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.fillFromInPlace", - "kind": "value", - "name": "fillFromInPlace", - "docstrings": [], - "signature": "let fillFromInPlace: ('a, ~from: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.fillRangeInPlace", - "kind": "value", - "name": "fillRangeInPlace", - "docstrings": [], - "signature": "let fillRangeInPlace: ('a, ~start: int, ~end_: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.pop", - "kind": "value", - "name": "pop", - "docstrings": [ - "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.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array.pop(arr) == Some(104)\narr == [100, 101, 102, 103]\n\nlet empty: array = []\nJs.Array.pop(empty) == None\n```" - ], - "signature": "let pop: t<'a> => option<'a>" - }, - { - "id": "Js.Array.push", - "kind": "value", - "name": "push", - "docstrings": [], - "signature": "let push: ('a, t<'a>) => int" - }, - { - "id": "Js.Array.pushMany", - "kind": "value", - "name": "pushMany", - "docstrings": [], - "signature": "let pushMany: (array<'a>, t<'a>) => int" - }, - { - "id": "Js.Array.reverseInPlace", - "kind": "value", - "name": "reverseInPlace", - "docstrings": [ - "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.\n\n## Examples\n\n```rescript\nlet arr = [\"ant\", \"bee\", \"cat\"]\nJs.Array.reverseInPlace(arr) == [\"cat\", \"bee\", \"ant\"]\narr == [\"cat\", \"bee\", \"ant\"]\n```" - ], - "signature": "let reverseInPlace: t<'a> => t<'a>" - }, - { - "id": "Js.Array.shift", - "kind": "value", - "name": "shift", - "docstrings": [ - "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.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\nJs.Array.shift(arr) == Some(100)\narr == [101, 102, 103, 104]\n\nlet empty: array = []\nJs.Array.shift(empty) == None\n```" - ], - "signature": "let shift: t<'a> => option<'a>" - }, - { - "id": "Js.Array.sortInPlace", - "kind": "value", - "name": "sortInPlace", - "docstrings": [ - "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.\n\n## Examples\n\n```rescript\nlet words = [\"bee\", \"dog\", \"ant\", \"cat\"]\nJs.Array.sortInPlace(words) == [\"ant\", \"bee\", \"cat\", \"dog\"]\nwords == [\"ant\", \"bee\", \"cat\", \"dog\"]\n\nlet numbers = [3, 30, 10, 1, 20, 2]\nJs.Array.sortInPlace(numbers) == [1, 10, 2, 20, 3, 30]\nnumbers == [1, 10, 2, 20, 3, 30]\n```" - ], - "signature": "let sortInPlace: t<'a> => t<'a>" - }, - { - "id": "Js.Array.sortInPlaceWith", - "kind": "value", - "name": "sortInPlaceWith", - "docstrings": [], - "signature": "let sortInPlaceWith: (('a, 'a) => int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.spliceInPlace", - "kind": "value", - "name": "spliceInPlace", - "docstrings": [], - "signature": "let spliceInPlace: (~pos: int, ~remove: int, ~add: array<'a>, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.removeFromInPlace", - "kind": "value", - "name": "removeFromInPlace", - "docstrings": [], - "signature": "let removeFromInPlace: (~pos: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.removeCountInPlace", - "kind": "value", - "name": "removeCountInPlace", - "docstrings": [], - "signature": "let removeCountInPlace: (~pos: int, ~count: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.unshift", - "kind": "value", - "name": "unshift", - "docstrings": [], - "signature": "let unshift: ('a, t<'a>) => int" - }, - { - "id": "Js.Array.unshiftMany", - "kind": "value", - "name": "unshiftMany", - "docstrings": [], - "signature": "let unshiftMany: (array<'a>, t<'a>) => int" - }, - { - "id": "Js.Array.concat", - "kind": "value", - "name": "concat", - "docstrings": [], - "signature": "let concat: (t<'a>, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.concatMany", - "kind": "value", - "name": "concatMany", - "docstrings": [], - "signature": "let concatMany: (array>, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.includes", - "kind": "value", - "name": "includes", - "docstrings": [], - "signature": "let includes: ('a, t<'a>) => bool" - }, - { - "id": "Js.Array.indexOf", - "kind": "value", - "name": "indexOf", - "docstrings": [], - "signature": "let indexOf: ('a, t<'a>) => int" - }, - { - "id": "Js.Array.indexOfFrom", - "kind": "value", - "name": "indexOfFrom", - "docstrings": [], - "signature": "let indexOfFrom: ('a, ~from: int, t<'a>) => int" - }, - { - "id": "Js.Array.join", - "kind": "value", - "name": "join", - "docstrings": [], - "signature": "let join: t<'a> => string", - "deprecated": "please use joinWith instead" - }, - { - "id": "Js.Array.joinWith", - "kind": "value", - "name": "joinWith", - "docstrings": [], - "signature": "let joinWith: (string, t<'a>) => string" - }, - { - "id": "Js.Array.lastIndexOf", - "kind": "value", - "name": "lastIndexOf", - "docstrings": [], - "signature": "let lastIndexOf: ('a, t<'a>) => int" - }, - { - "id": "Js.Array.lastIndexOfFrom", - "kind": "value", - "name": "lastIndexOfFrom", - "docstrings": [], - "signature": "let lastIndexOfFrom: ('a, ~from: int, t<'a>) => int" - }, - { - "id": "Js.Array.slice", - "kind": "value", - "name": "slice", - "docstrings": [], - "signature": "let slice: (~start: int, ~end_: int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.copy", - "kind": "value", - "name": "copy", - "docstrings": [ - "Returns a copy of the entire array. Same as `Js.Array.Slice(~start=0,\n~end_=Js.Array.length(arr), arr)`. See\n[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)\non MDN." - ], - "signature": "let copy: t<'a> => t<'a>" - }, - { - "id": "Js.Array.sliceFrom", - "kind": "value", - "name": "sliceFrom", - "docstrings": [], - "signature": "let sliceFrom: (int, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.toString", - "kind": "value", - "name": "toString", - "docstrings": [ - "Converts the array to a string. Each element is converted to a string using\nJavaScript. Unlike the JavaScript `Array.toString()`, all elements in a\nReasonML array must have the same type. See\n[`Array.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array.toString([3.5, 4.6, 7.8]) == \"3.5,4.6,7.8\"\nJs.Array.toString([\"a\", \"b\", \"c\"]) == \"a,b,c\"\n```" - ], - "signature": "let toString: t<'a> => string" - }, - { - "id": "Js.Array.toLocaleString", - "kind": "value", - "name": "toLocaleString", - "docstrings": [ - "Converts the array to a string using the conventions of the current locale.\nEach element is converted to a string using JavaScript. Unlike the JavaScript\n`Array.toLocaleString()`, all elements in a ReasonML array must have the same\ntype. See\n[`Array.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)\non MDN.\n\n## Examples\n\n```rescript\nJs.Array.toLocaleString([Js.Date.make()])\n// returns \"3/19/2020, 10:52:11 AM\" for locale en_US.utf8\n// returns \"2020-3-19 10:52:11\" for locale de_DE.utf8\n```" - ], - "signature": "let toLocaleString: t<'a> => string" - }, - { - "id": "Js.Array.every", - "kind": "value", - "name": "every", - "docstrings": [], - "signature": "let every: ('a => bool, t<'a>) => bool" - }, - { - "id": "Js.Array.everyi", - "kind": "value", - "name": "everyi", - "docstrings": [], - "signature": "let everyi: (('a, int) => bool, t<'a>) => bool" - }, - { - "id": "Js.Array.filter", - "kind": "value", - "name": "filter", - "docstrings": [], - "signature": "let filter: ('a => bool, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.filteri", - "kind": "value", - "name": "filteri", - "docstrings": [], - "signature": "let filteri: (('a, int) => bool, t<'a>) => t<'a>" - }, - { - "id": "Js.Array.find", - "kind": "value", - "name": "find", - "docstrings": [], - "signature": "let find: ('a => bool, t<'a>) => option<'a>" - }, - { - "id": "Js.Array.findi", - "kind": "value", - "name": "findi", - "docstrings": [], - "signature": "let findi: (('a, int) => bool, t<'a>) => option<'a>" - }, - { - "id": "Js.Array.findIndex", - "kind": "value", - "name": "findIndex", - "docstrings": [], - "signature": "let findIndex: ('a => bool, t<'a>) => int" - }, - { - "id": "Js.Array.findIndexi", - "kind": "value", - "name": "findIndexi", - "docstrings": [], - "signature": "let findIndexi: (('a, int) => bool, t<'a>) => int" - }, - { - "id": "Js.Array.forEach", - "kind": "value", - "name": "forEach", - "docstrings": [], - "signature": "let forEach: ('a => unit, t<'a>) => unit" - }, - { - "id": "Js.Array.forEachi", - "kind": "value", - "name": "forEachi", - "docstrings": [], - "signature": "let forEachi: (('a, int) => unit, t<'a>) => unit" - }, - { - "id": "Js.Array.map", - "kind": "value", - "name": "map", - "docstrings": [], - "signature": "let map: ('a => 'b, t<'a>) => t<'b>" - }, - { - "id": "Js.Array.mapi", - "kind": "value", - "name": "mapi", - "docstrings": [], - "signature": "let mapi: (('a, int) => 'b, t<'a>) => t<'b>" - }, - { - "id": "Js.Array.reduce", - "kind": "value", - "name": "reduce", - "docstrings": [], - "signature": "let reduce: (('a, 'b) => 'a, 'a, t<'b>) => 'a" - }, - { - "id": "Js.Array.reducei", - "kind": "value", - "name": "reducei", - "docstrings": [], - "signature": "let reducei: (('a, 'b, int) => 'a, 'a, t<'b>) => 'a" - }, - { - "id": "Js.Array.reduceRight", - "kind": "value", - "name": "reduceRight", - "docstrings": [], - "signature": "let reduceRight: (('a, 'b) => 'a, 'a, t<'b>) => 'a" - }, - { - "id": "Js.Array.reduceRighti", - "kind": "value", - "name": "reduceRighti", - "docstrings": [], - "signature": "let reduceRighti: (('a, 'b, int) => 'a, 'a, t<'b>) => 'a" - }, - { - "id": "Js.Array.some", - "kind": "value", - "name": "some", - "docstrings": [], - "signature": "let some: ('a => bool, t<'a>) => bool" - }, - { - "id": "Js.Array.somei", - "kind": "value", - "name": "somei", - "docstrings": [], - "signature": "let somei: (('a, int) => bool, t<'a>) => bool" - }, - { - "id": "Js.Array.unsafe_get", - "kind": "value", - "name": "unsafe_get", - "docstrings": [ - "Returns the value at the given position in the array if the position is in\nbounds; returns the JavaScript value `undefined` otherwise.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103]\nJs.Array.unsafe_get(arr, 3) == 103\nJs.Array.unsafe_get(arr, 4) // returns undefined\n```" - ], - "signature": "let unsafe_get: (array<'a>, int) => 'a" - }, - { - "id": "Js.Array.unsafe_set", - "kind": "value", - "name": "unsafe_set", - "docstrings": [ - "Sets the value at the given position in the array if the position is in bounds.\nIf the index is out of bounds, well, “here there be dragons.“ *This function\n modifies the original array.*\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103]\nJs.Array.unsafe_set(arr, 3, 99)\n// result is [100, 101, 102, 99]\n\nJs.Array.unsafe_set(arr, 4, 88)\n// result is [100, 101, 102, 99, 88]\n\nJs.Array.unsafe_set(arr, 6, 77)\n// result is [100, 101, 102, 99, 88, <1 empty item>, 77]\n\nJs.Array.unsafe_set(arr, -1, 66)\n// you don't want to know.\n```" - ], - "signature": "let unsafe_set: (array<'a>, int, 'a) => unit" - } - ] - }, - "js/exn": { - "id": "Js.Exn", - "name": "Exn", - "docstrings": [ - "Provide utilities for dealing with Js exceptions", - "Provide utilities for dealing with JS exceptions." - ], - "items": [ - { - "id": "Js.Exn.t", - "kind": "type", - "name": "t", - "docstrings": ["Represents a JS exception"], - "signature": "type t" - }, - { - "id": "Js.Exn.asJsExn", - "kind": "value", - "name": "asJsExn", - "docstrings": [], - "signature": "let asJsExn: exn => option" - }, - { - "id": "Js.Exn.stack", - "kind": "value", - "name": "stack", - "docstrings": [], - "signature": "let stack: t => option" - }, - { - "id": "Js.Exn.message", - "kind": "value", - "name": "message", - "docstrings": [], - "signature": "let message: t => option" - }, - { - "id": "Js.Exn.name", - "kind": "value", - "name": "name", - "docstrings": [], - "signature": "let name: t => option" - }, - { - "id": "Js.Exn.fileName", - "kind": "value", - "name": "fileName", - "docstrings": [], - "signature": "let fileName: t => option" - }, - { - "id": "Js.Exn.isCamlExceptionOrOpenVariant", - "kind": "value", - "name": "isCamlExceptionOrOpenVariant", - "docstrings": ["internal use only"], - "signature": "let isCamlExceptionOrOpenVariant: 'a => bool" - }, - { - "id": "Js.Exn.anyToExnInternal", - "kind": "value", - "name": "anyToExnInternal", - "docstrings": [ - "`anyToExnInternal(obj)` will take any value `obj` and wrap it\nin a Js.Exn.Error if given value is not an exn already. If\n`obj` is an exn, it will return `obj` without any changes.\n\nThis function is mostly useful for cases where you want to unify a type of a value\nthat potentially is either exn, a JS error, or any other JS value really (e.g. for\na value passed to a Promise.catch callback)\n\n**IMPORTANT**: This is an internal API and may be changed / removed any time in the future.\n\n## Examples\n\n```rescript\nswitch (Js.Exn.unsafeAnyToExn(\"test\")) {\n| Js.Exn.Error(v) =>\n switch(Js.Exn.message(v)) {\n | Some(str) => Js.log(\"We won't end up here\")\n | None => Js.log2(\"We will land here: \", v)\n }\n}\n```" - ], - "signature": "let anyToExnInternal: 'a => exn" - }, - { - "id": "Js.Exn.raiseError", - "kind": "value", - "name": "raiseError", - "docstrings": ["Raise Js exception Error object with stacktrace"], - "signature": "let raiseError: string => 'a" - }, - { - "id": "Js.Exn.raiseEvalError", - "kind": "value", - "name": "raiseEvalError", - "docstrings": [], - "signature": "let raiseEvalError: string => 'a" - }, - { - "id": "Js.Exn.raiseRangeError", - "kind": "value", - "name": "raiseRangeError", - "docstrings": [], - "signature": "let raiseRangeError: string => 'a" - }, - { - "id": "Js.Exn.raiseReferenceError", - "kind": "value", - "name": "raiseReferenceError", - "docstrings": [], - "signature": "let raiseReferenceError: string => 'a" - }, - { - "id": "Js.Exn.raiseSyntaxError", - "kind": "value", - "name": "raiseSyntaxError", - "docstrings": [], - "signature": "let raiseSyntaxError: string => 'a" - }, - { - "id": "Js.Exn.raiseTypeError", - "kind": "value", - "name": "raiseTypeError", - "docstrings": [], - "signature": "let raiseTypeError: string => 'a" - }, - { - "id": "Js.Exn.raiseUriError", - "kind": "value", - "name": "raiseUriError", - "docstrings": [], - "signature": "let raiseUriError: string => 'a" - } - ] - }, - "js/null_undefined": { - "id": "Js.Null_undefined", - "name": "Null_undefined", - "docstrings": [ - "Contains functionality for dealing with values that can be both `null` and `undefined`" - ], - "items": [ - { - "id": "Js.Null_undefined.t", - "kind": "type", - "name": "t", - "docstrings": ["Local alias for `Js.null_undefined<'a>`."], - "signature": "type t<'a> = Js.nullable<'a> = Value('a) | Null | Undefined" - }, - { - "id": "Js.Null_undefined.return", - "kind": "value", - "name": "return", - "docstrings": [ - "Constructs a value of `Js.null_undefined<'a>` containing a value of `'a`." - ], - "signature": "let return: 'a => t<'a>" - }, - { - "id": "Js.Null_undefined.isNullable", - "kind": "value", - "name": "isNullable", - "docstrings": [ - "Returns `true` if the given value is null or undefined, `false` otherwise." - ], - "signature": "let isNullable: t<'a> => bool" - }, - { - "id": "Js.Null_undefined.null", - "kind": "value", - "name": "null", - "docstrings": ["The null value of type `Js.null_undefined<'a>`."], - "signature": "let null: t<'a>" - }, - { - "id": "Js.Null_undefined.undefined", - "kind": "value", - "name": "undefined", - "docstrings": ["The undefined value of type `Js.null_undefined<'a>`."], - "signature": "let undefined: t<'a>" - }, - { - "id": "Js.Null_undefined.bind", - "kind": "value", - "name": "bind", - "docstrings": [ - "Maps the contained value using the given function.\n\nIf `Js.null_undefined<'a>` contains a value, that value is unwrapped, mapped to\na `'b` using the given function `a' => 'b`, then wrapped back up and returned\nas `Js.null_undefined<'b>`.\n\n## Examples\n\n```rescript\nlet maybeGreetWorld = (maybeGreeting: Js.null_undefined) =>\n Js.Null_undefined.bind(maybeGreeting, (. greeting) => greeting ++ \" world!\")\n```" - ], - "signature": "let bind: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Js.Null_undefined.iter", - "kind": "value", - "name": "iter", - "docstrings": [ - "Iterates over the contained value with the given function.\nIf `Js.null_undefined<'a>` contains a value, that value is unwrapped and applied to the given function.\n\n## Examples\n\n```rescript\nlet maybeSay = (maybeMessage: Js.null_undefined) =>\n Js.Null_undefined.iter(maybeMessage, (. message) => Js.log(message))\n```" - ], - "signature": "let iter: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Js.Null_undefined.fromOption", - "kind": "value", - "name": "fromOption", - "docstrings": [ - "Maps `option<'a>` to `Js.null_undefined<'a>`.\n`Some(a)` => `a`\n`None` => `undefined`" - ], - "signature": "let fromOption: option<'a> => t<'a>" - }, - { - "id": "Js.Null_undefined.from_opt", - "kind": "value", - "name": "from_opt", - "docstrings": [], - "signature": "let from_opt: option<'a> => t<'a>", - "deprecated": "Use fromOption instead" - }, - { - "id": "Js.Null_undefined.toOption", - "kind": "value", - "name": "toOption", - "docstrings": [ - "Maps `Js.null_undefined<'a>` to `option<'a>`.\n`a` => `Some(a)`\n`undefined` => `None`\n`null` => `None`" - ], - "signature": "let toOption: t<'a> => option<'a>" - }, - { - "id": "Js.Null_undefined.to_opt", - "kind": "value", - "name": "to_opt", - "docstrings": [], - "signature": "let to_opt: t<'a> => option<'a>", - "deprecated": "Use toOption instead" - } - ] - }, - "js/nullable": { - "id": "Js.Nullable", - "name": "Nullable", - "docstrings": [ - "Provide utilities for `Js.null_undefined`", - "Contains functionality for dealing with values that can be both `null` and `undefined`" - ], - "items": [ - { - "id": "Js.Nullable.t", - "kind": "type", - "name": "t", - "docstrings": ["Local alias for `Js.null_undefined<'a>`."], - "signature": "type t<'a> = Js.nullable<'a> = Value('a) | Null | Undefined" - }, - { - "id": "Js.Nullable.return", - "kind": "value", - "name": "return", - "docstrings": [ - "Constructs a value of `Js.null_undefined<'a>` containing a value of `'a`." - ], - "signature": "let return: 'a => t<'a>" - }, - { - "id": "Js.Nullable.isNullable", - "kind": "value", - "name": "isNullable", - "docstrings": [ - "Returns `true` if the given value is null or undefined, `false` otherwise." - ], - "signature": "let isNullable: t<'a> => bool" - }, - { - "id": "Js.Nullable.null", - "kind": "value", - "name": "null", - "docstrings": ["The null value of type `Js.null_undefined<'a>`."], - "signature": "let null: t<'a>" - }, - { - "id": "Js.Nullable.undefined", - "kind": "value", - "name": "undefined", - "docstrings": ["The undefined value of type `Js.null_undefined<'a>`."], - "signature": "let undefined: t<'a>" - }, - { - "id": "Js.Nullable.bind", - "kind": "value", - "name": "bind", - "docstrings": [ - "Maps the contained value using the given function.\n\nIf `Js.null_undefined<'a>` contains a value, that value is unwrapped, mapped to\na `'b` using the given function `a' => 'b`, then wrapped back up and returned\nas `Js.null_undefined<'b>`.\n\n## Examples\n\n```rescript\nlet maybeGreetWorld = (maybeGreeting: Js.null_undefined) =>\n Js.Null_undefined.bind(maybeGreeting, (. greeting) => greeting ++ \" world!\")\n```" - ], - "signature": "let bind: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Js.Nullable.iter", - "kind": "value", - "name": "iter", - "docstrings": [ - "Iterates over the contained value with the given function.\nIf `Js.null_undefined<'a>` contains a value, that value is unwrapped and applied to the given function.\n\n## Examples\n\n```rescript\nlet maybeSay = (maybeMessage: Js.null_undefined) =>\n Js.Null_undefined.iter(maybeMessage, (. message) => Js.log(message))\n```" - ], - "signature": "let iter: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Js.Nullable.fromOption", - "kind": "value", - "name": "fromOption", - "docstrings": [ - "Maps `option<'a>` to `Js.null_undefined<'a>`.\n`Some(a)` => `a`\n`None` => `undefined`" - ], - "signature": "let fromOption: option<'a> => t<'a>" - }, - { - "id": "Js.Nullable.from_opt", - "kind": "value", - "name": "from_opt", - "docstrings": [], - "signature": "let from_opt: option<'a> => t<'a>", - "deprecated": "Use fromOption instead" - }, - { - "id": "Js.Nullable.toOption", - "kind": "value", - "name": "toOption", - "docstrings": [ - "Maps `Js.null_undefined<'a>` to `option<'a>`.\n`a` => `Some(a)`\n`undefined` => `None`\n`null` => `None`" - ], - "signature": "let toOption: t<'a> => option<'a>" - }, - { - "id": "Js.Nullable.to_opt", - "kind": "value", - "name": "to_opt", - "docstrings": [], - "signature": "let to_opt: t<'a> => option<'a>", - "deprecated": "Use toOption instead" - } - ] - }, - "js/undefined": { - "id": "Js.Undefined", - "name": "Undefined", - "docstrings": [ - "Provide utilities for `Js.undefined<'a>`", - "Provides functionality for dealing with the `Js.undefined<'a>` type" - ], - "items": [ - { - "id": "Js.Undefined.t", - "kind": "type", - "name": "t", - "docstrings": ["Local alias for `Js.undefined<'a>`"], - "signature": "type t<'a> = Js.undefined<'a>" - }, - { - "id": "Js.Undefined.return", - "kind": "value", - "name": "return", - "docstrings": [ - "Constructs a value of `Js.undefined<'a>` containing a value of `'a`." - ], - "signature": "let return: 'a => t<'a>" - }, - { - "id": "Js.Undefined.test", - "kind": "value", - "name": "test", - "docstrings": [ - "Returns `true` if the given value is empty (undefined), `false` otherwise." - ], - "signature": "let test: t<'a> => bool", - "deprecated": "Use = Js.undefined directly" - }, - { - "id": "Js.Undefined.testAny", - "kind": "value", - "name": "testAny", - "docstrings": [ - "Returns `true` if the given value is empty (undefined).\n\n**since 1.6.1**" - ], - "signature": "let testAny: 'a => bool" - }, - { - "id": "Js.Undefined.empty", - "kind": "value", - "name": "empty", - "docstrings": ["The empty value, `undefined`"], - "signature": "let empty: t<'a>" - }, - { - "id": "Js.Undefined.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [], - "signature": "let getUnsafe: t<'a> => 'a" - }, - { - "id": "Js.Undefined.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: t<'a> => 'a" - }, - { - "id": "Js.Undefined.bind", - "kind": "value", - "name": "bind", - "docstrings": [ - "Maps the contained value using the given function.\nIf `Js.undefined<'a>` contains a value, that value is unwrapped, mapped to a\n`'b` using the given function `a' => 'b`, then wrapped back up and returned as\n`Js.undefined<'b>`.\n\n## Examples\n\n```rescript\nlet maybeGreetWorld = (maybeGreeting: Js.undefined) =>\n Js.Undefined.bind(maybeGreeting, (. greeting) => greeting ++ \" world!\")\n```" - ], - "signature": "let bind: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Js.Undefined.iter", - "kind": "value", - "name": "iter", - "docstrings": [ - "Iterates over the contained value with the given function. If\n`Js.undefined<'a>` contains a value, that value is unwrapped and applied to the\ngiven function.\n\n## Examples\n\n```rescript\nlet maybeSay = (maybeMessage: Js.undefined) =>\n Js.Undefined.iter(maybeMessage, (. message) => Js.log(message))\n```" - ], - "signature": "let iter: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Js.Undefined.fromOption", - "kind": "value", - "name": "fromOption", - "docstrings": [ - "Maps `option<'a>` to `Js.undefined<'a>`.\n`Some(a)` => `a`\n`None` => `empty`" - ], - "signature": "let fromOption: option<'a> => t<'a>" - }, - { - "id": "Js.Undefined.from_opt", - "kind": "value", - "name": "from_opt", - "docstrings": [], - "signature": "let from_opt: option<'a> => t<'a>", - "deprecated": "Use fromOption instead" - }, - { - "id": "Js.Undefined.toOption", - "kind": "value", - "name": "toOption", - "docstrings": [ - "Maps `Js.undefined<'a>` to `option<'a>`\n`a` => `Some(a)`\n`empty` => `None`" - ], - "signature": "let toOption: t<'a> => option<'a>" - }, - { - "id": "Js.Undefined.to_opt", - "kind": "value", - "name": "to_opt", - "docstrings": [], - "signature": "let to_opt: t<'a> => option<'a>", - "deprecated": "use toOption instead" - } - ] - }, - "js/null": { - "id": "Js.Null", - "name": "Null", - "docstrings": [ - "Provide utilities for `Js.null<'a>`", - "Provides functionality for dealing with the `Js.null<'a>` type" - ], - "items": [ - { - "id": "Js.Null.t", - "kind": "type", - "name": "t", - "docstrings": ["Local alias for `Js.null<'a>`"], - "signature": "type t<'a> = Js.null<'a> = Value('a) | Null" - }, - { - "id": "Js.Null.return", - "kind": "value", - "name": "return", - "docstrings": [ - "Constructs a value of `Js.null<'a>` containing a value of `'a`." - ], - "signature": "let return: 'a => t<'a>" - }, - { - "id": "Js.Null.test", - "kind": "value", - "name": "test", - "docstrings": [ - "Returns `true` if the given value is empty (`null`), `false` otherwise." - ], - "signature": "let test: t<'a> => bool", - "deprecated": "Use = Js.null directly " - }, - { - "id": "Js.Null.empty", - "kind": "value", - "name": "empty", - "docstrings": ["The empty value, `null`"], - "signature": "let empty: t<'a>" - }, - { - "id": "Js.Null.getUnsafe", - "kind": "value", - "name": "getUnsafe", - "docstrings": [], - "signature": "let getUnsafe: t<'a> => 'a" - }, - { - "id": "Js.Null.getExn", - "kind": "value", - "name": "getExn", - "docstrings": [], - "signature": "let getExn: t<'a> => 'a" - }, - { - "id": "Js.Null.bind", - "kind": "value", - "name": "bind", - "docstrings": [ - "Maps the contained value using the given function.\n\nIf `Js.null<'a>` contains a value, that value is unwrapped, mapped to a `'b`\nusing the given function `'a => 'b`, then wrapped back up and returned as\n`Js.null<'b>`.\n\n## Examples\n\n```rescript\nlet maybeGreetWorld = (maybeGreeting: Js.null) =>\n Js.Null.bind(maybeGreeting, (. greeting) => greeting ++ \" world!\")\n```" - ], - "signature": "let bind: (t<'a>, 'a => 'b) => t<'b>" - }, - { - "id": "Js.Null.iter", - "kind": "value", - "name": "iter", - "docstrings": [ - "Iterates over the contained value with the given function.\nIf `Js.null<'a>` contains a value, that value is unwrapped and applied to the given function.\n\n## Examples\n\n```rescript\nlet maybeSay = (maybeMessage: Js.null) =>\n Js.Null.iter(maybeMessage, (. message) => Js.log(message))\n```" - ], - "signature": "let iter: (t<'a>, 'a => unit) => unit" - }, - { - "id": "Js.Null.fromOption", - "kind": "value", - "name": "fromOption", - "docstrings": [ - "Maps `option<'a>` to `Js.null<'a>`.\n`Some(a)` => `a`\n`None` => `empty`" - ], - "signature": "let fromOption: option<'a> => t<'a>" - }, - { - "id": "Js.Null.from_opt", - "kind": "value", - "name": "from_opt", - "docstrings": [], - "signature": "let from_opt: option<'a> => t<'a>", - "deprecated": "Use fromOption instead" - }, - { - "id": "Js.Null.toOption", - "kind": "value", - "name": "toOption", - "docstrings": [ - "Maps `Js.null<'a>` to `option<'a>`.\n`a` => `Some(a)`\n`empty` => `None`" - ], - "signature": "let toOption: t<'a> => option<'a>" - }, - { - "id": "Js.Null.to_opt", - "kind": "value", - "name": "to_opt", - "docstrings": [], - "signature": "let to_opt: t<'a> => option<'a>", - "deprecated": "Use toOption instead" - } - ] - } -} diff --git a/data/api/v11.0.0/toc_tree.json b/data/api/v11.0.0/toc_tree.json deleted file mode 100644 index 74dff24b6..000000000 --- a/data/api/v11.0.0/toc_tree.json +++ /dev/null @@ -1,690 +0,0 @@ -{ - "js": { - "name": "Js", - "path": ["js"], - "children": [ - { "name": "WeakMap", "path": ["js", "weakmap"], "children": [] }, - { "name": "Map", "path": ["js", "map"], "children": [] }, - { "name": "WeakSet", "path": ["js", "weakset"], "children": [] }, - { "name": "Set", "path": ["js", "set"], "children": [] }, - { "name": "Console", "path": ["js", "console"], "children": [] }, - { "name": "Vector", "path": ["js", "vector"], "children": [] }, - { "name": "List", "path": ["js", "list"], "children": [] }, - { "name": "Result", "path": ["js", "result"], "children": [] }, - { "name": "Option", "path": ["js", "option"], "children": [] }, - { "name": "Blob", "path": ["js", "blob"], "children": [] }, - { "name": "File", "path": ["js", "file"], "children": [] }, - { "name": "BigInt", "path": ["js", "bigint"], "children": [] }, - { "name": "Int", "path": ["js", "int"], "children": [] }, - { "name": "Float", "path": ["js", "float"], "children": [] }, - { "name": "Types", "path": ["js", "types"], "children": [] }, - { - "name": "TypedArray2", - "path": ["js", "typedarray2"], - "children": [ - { - "name": "DataView", - "path": ["js", "typedarray2", "dataview"], - "children": [] - }, - { - "name": "Float64Array", - "path": ["js", "typedarray2", "float64array"], - "children": [] - }, - { - "name": "Float32Array", - "path": ["js", "typedarray2", "float32array"], - "children": [] - }, - { - "name": "Uint32Array", - "path": ["js", "typedarray2", "uint32array"], - "children": [] - }, - { - "name": "Int32Array", - "path": ["js", "typedarray2", "int32array"], - "children": [] - }, - { - "name": "Uint16Array", - "path": ["js", "typedarray2", "uint16array"], - "children": [] - }, - { - "name": "Int16Array", - "path": ["js", "typedarray2", "int16array"], - "children": [] - }, - { - "name": "Uint8ClampedArray", - "path": ["js", "typedarray2", "uint8clampedarray"], - "children": [] - }, - { - "name": "Uint8Array", - "path": ["js", "typedarray2", "uint8array"], - "children": [] - }, - { - "name": "Int8Array", - "path": ["js", "typedarray2", "int8array"], - "children": [] - }, - { - "name": "ArrayBuffer", - "path": ["js", "typedarray2", "arraybuffer"], - "children": [] - } - ] - }, - { - "name": "Typed_array", - "path": ["js", "typed_array"], - "children": [ - { - "name": "DataView", - "path": ["js", "typed_array", "dataview"], - "children": [] - }, - { - "name": "Float64_array", - "path": ["js", "typed_array", "float64_array"], - "children": [] - }, - { - "name": "Float64Array", - "path": ["js", "typed_array", "float64array"], - "children": [] - }, - { - "name": "Float32_array", - "path": ["js", "typed_array", "float32_array"], - "children": [] - }, - { - "name": "Float32Array", - "path": ["js", "typed_array", "float32array"], - "children": [] - }, - { - "name": "Uint32Array", - "path": ["js", "typed_array", "uint32array"], - "children": [] - }, - { - "name": "Int32_array", - "path": ["js", "typed_array", "int32_array"], - "children": [] - }, - { - "name": "Int32Array", - "path": ["js", "typed_array", "int32array"], - "children": [] - }, - { - "name": "Uint16Array", - "path": ["js", "typed_array", "uint16array"], - "children": [] - }, - { - "name": "Int16Array", - "path": ["js", "typed_array", "int16array"], - "children": [] - }, - { - "name": "Uint8ClampedArray", - "path": ["js", "typed_array", "uint8clampedarray"], - "children": [] - }, - { - "name": "Uint8Array", - "path": ["js", "typed_array", "uint8array"], - "children": [] - }, - { - "name": "Int8Array", - "path": ["js", "typed_array", "int8array"], - "children": [] - }, - { "name": "S", "path": ["js", "typed_array", "s"], "children": [] }, - { - "name": "ArrayBuffer", - "path": ["js", "typed_array", "arraybuffer"], - "children": [] - }, - { - "name": "Type", - "path": ["js", "typed_array", "type"], - "children": [] - } - ] - }, - { "name": "Obj", "path": ["js", "obj"], "children": [] }, - { "name": "Math", "path": ["js", "math"], "children": [] }, - { - "name": "Json", - "path": ["js", "json"], - "children": [ - { "name": "Kind", "path": ["js", "json", "kind"], "children": [] } - ] - }, - { "name": "Global", "path": ["js", "global"], "children": [] }, - { "name": "Dict", "path": ["js", "dict"], "children": [] }, - { "name": "Date", "path": ["js", "date"], "children": [] }, - { "name": "Promise2", "path": ["js", "promise2"], "children": [] }, - { "name": "Promise", "path": ["js", "promise"], "children": [] }, - { "name": "Re", "path": ["js", "re"], "children": [] }, - { "name": "String2", "path": ["js", "string2"], "children": [] }, - { "name": "String", "path": ["js", "string"], "children": [] }, - { "name": "Array2", "path": ["js", "array2"], "children": [] }, - { "name": "Array", "path": ["js", "array"], "children": [] }, - { "name": "Exn", "path": ["js", "exn"], "children": [] }, - { - "name": "Null_undefined", - "path": ["js", "null_undefined"], - "children": [] - }, - { "name": "Nullable", "path": ["js", "nullable"], "children": [] }, - { "name": "Undefined", "path": ["js", "undefined"], "children": [] }, - { "name": "Null", "path": ["js", "null"], "children": [] } - ] - }, - "belt": { - "name": "Belt", - "path": ["belt"], - "children": [ - { "name": "Float", "path": ["belt", "float"], "children": [] }, - { "name": "Int", "path": ["belt", "int"], "children": [] }, - { "name": "Result", "path": ["belt", "result"], "children": [] }, - { "name": "Option", "path": ["belt", "option"], "children": [] }, - { - "name": "HashMap", - "path": ["belt", "hashmap"], - "children": [ - { - "name": "String", - "path": ["belt", "hashmap", "string"], - "children": [] - }, - { "name": "Int", "path": ["belt", "hashmap", "int"], "children": [] } - ] - }, - { - "name": "HashSet", - "path": ["belt", "hashset"], - "children": [ - { - "name": "String", - "path": ["belt", "hashset", "string"], - "children": [] - }, - { "name": "Int", "path": ["belt", "hashset", "int"], "children": [] } - ] - }, - { - "name": "MutableMap", - "path": ["belt", "mutablemap"], - "children": [ - { - "name": "String", - "path": ["belt", "mutablemap", "string"], - "children": [] - }, - { - "name": "Int", - "path": ["belt", "mutablemap", "int"], - "children": [] - } - ] - }, - { - "name": "MutableSet", - "path": ["belt", "mutableset"], - "children": [ - { - "name": "String", - "path": ["belt", "mutableset", "string"], - "children": [] - }, - { - "name": "Int", - "path": ["belt", "mutableset", "int"], - "children": [] - } - ] - }, - { - "name": "Map", - "path": ["belt", "map"], - "children": [ - { "name": "Dict", "path": ["belt", "map", "dict"], "children": [] }, - { - "name": "String", - "path": ["belt", "map", "string"], - "children": [] - }, - { "name": "Int", "path": ["belt", "map", "int"], "children": [] } - ] - }, - { - "name": "Set", - "path": ["belt", "set"], - "children": [ - { "name": "Dict", "path": ["belt", "set", "dict"], "children": [] }, - { - "name": "String", - "path": ["belt", "set", "string"], - "children": [] - }, - { "name": "Int", "path": ["belt", "set", "int"], "children": [] } - ] - }, - { "name": "Range", "path": ["belt", "range"], "children": [] }, - { "name": "List", "path": ["belt", "list"], "children": [] }, - { - "name": "MutableStack", - "path": ["belt", "mutablestack"], - "children": [] - }, - { - "name": "MutableQueue", - "path": ["belt", "mutablequeue"], - "children": [] - }, - { - "name": "SortArray", - "path": ["belt", "sortarray"], - "children": [ - { - "name": "String", - "path": ["belt", "sortarray", "string"], - "children": [] - }, - { - "name": "Int", - "path": ["belt", "sortarray", "int"], - "children": [] - } - ] - }, - { "name": "Array", "path": ["belt", "array"], "children": [] }, - { - "name": "Id", - "path": ["belt", "id"], - "children": [ - { - "name": "MakeHashable", - "path": ["belt", "id", "makehashable"], - "children": [] - }, - { - "name": "MakeHashableU", - "path": ["belt", "id", "makehashableu"], - "children": [] - }, - { - "name": "MakeComparable", - "path": ["belt", "id", "makecomparable"], - "children": [] - }, - { - "name": "MakeComparableU", - "path": ["belt", "id", "makecomparableu"], - "children": [] - } - ] - } - ] - }, - "dom": { - "name": "Dom", - "path": ["dom"], - "children": [ - { "name": "Storage2", "path": ["dom", "storage2"], "children": [] }, - { "name": "Storage", "path": ["dom", "storage"], "children": [] } - ] - }, - "core": { - "name": "Core", - "path": ["core"], - "children": [ - { "name": "Result", "path": ["core", "result"], "children": [] }, - { "name": "List", "path": ["core", "list"], "children": [] }, - { "name": "Option", "path": ["core", "option"], "children": [] }, - { "name": "Exn", "path": ["core", "exn"], "children": [] }, - { - "name": "Intl", - "path": ["core", "intl"], - "children": [ - { - "name": "Segments", - "path": ["core", "intl", "segments"], - "children": [] - }, - { - "name": "Segmenter", - "path": ["core", "intl", "segmenter"], - "children": [] - }, - { - "name": "RelativeTimeFormat", - "path": ["core", "intl", "relativetimeformat"], - "children": [] - }, - { - "name": "PluralRules", - "path": ["core", "intl", "pluralrules"], - "children": [] - }, - { - "name": "NumberFormat", - "path": ["core", "intl", "numberformat"], - "children": [ - { - "name": "Grouping", - "path": ["core", "intl", "numberformat", "grouping"], - "children": [] - } - ] - }, - { - "name": "Locale", - "path": ["core", "intl", "locale"], - "children": [] - }, - { - "name": "ListFormat", - "path": ["core", "intl", "listformat"], - "children": [] - }, - { - "name": "DateTimeFormat", - "path": ["core", "intl", "datetimeformat"], - "children": [] - }, - { - "name": "Collator", - "path": ["core", "intl", "collator"], - "children": [] - }, - { - "name": "Common", - "path": ["core", "intl", "common"], - "children": [] - } - ] - }, - { - "name": "BigUint64Array", - "path": ["core", "biguint64array"], - "children": [ - { - "name": "Constants", - "path": ["core", "biguint64array", "constants"], - "children": [] - } - ] - }, - { - "name": "BigInt64Array", - "path": ["core", "bigint64array"], - "children": [ - { - "name": "Constants", - "path": ["core", "bigint64array", "constants"], - "children": [] - } - ] - }, - { - "name": "Uint8ClampedArray", - "path": ["core", "uint8clampedarray"], - "children": [ - { - "name": "Constants", - "path": ["core", "uint8clampedarray", "constants"], - "children": [] - } - ] - }, - { - "name": "Uint32Array", - "path": ["core", "uint32array"], - "children": [ - { - "name": "Constants", - "path": ["core", "uint32array", "constants"], - "children": [] - } - ] - }, - { - "name": "Uint16Array", - "path": ["core", "uint16array"], - "children": [ - { - "name": "Constants", - "path": ["core", "uint16array", "constants"], - "children": [] - } - ] - }, - { - "name": "Uint8Array", - "path": ["core", "uint8array"], - "children": [ - { - "name": "Constants", - "path": ["core", "uint8array", "constants"], - "children": [] - } - ] - }, - { - "name": "Int32Array", - "path": ["core", "int32array"], - "children": [ - { - "name": "Constants", - "path": ["core", "int32array", "constants"], - "children": [] - } - ] - }, - { - "name": "Int16Array", - "path": ["core", "int16array"], - "children": [ - { - "name": "Constants", - "path": ["core", "int16array", "constants"], - "children": [] - } - ] - }, - { - "name": "Int8Array", - "path": ["core", "int8array"], - "children": [ - { - "name": "Constants", - "path": ["core", "int8array", "constants"], - "children": [] - } - ] - }, - { - "name": "Float64Array", - "path": ["core", "float64array"], - "children": [ - { - "name": "Constants", - "path": ["core", "float64array", "constants"], - "children": [] - } - ] - }, - { - "name": "Float32Array", - "path": ["core", "float32array"], - "children": [ - { - "name": "Constants", - "path": ["core", "float32array", "constants"], - "children": [] - } - ] - }, - { "name": "TypedArray", "path": ["core", "typedarray"], "children": [] }, - { - "name": "ArrayBuffer", - "path": ["core", "arraybuffer"], - "children": [] - }, - { "name": "WeakSet", "path": ["core", "weakset"], "children": [] }, - { "name": "Set", "path": ["core", "set"], "children": [] }, - { "name": "WeakMap", "path": ["core", "weakmap"], "children": [] }, - { "name": "Map", "path": ["core", "map"], "children": [] }, - { - "name": "AsyncIterator", - "path": ["core", "asynciterator"], - "children": [] - }, - { "name": "Iterator", "path": ["core", "iterator"], "children": [] }, - { - "name": "JSON", - "path": ["core", "json"], - "children": [ - { - "name": "Decode", - "path": ["core", "json", "decode"], - "children": [] - }, - { - "name": "Encode", - "path": ["core", "json", "encode"], - "children": [] - }, - { - "name": "Classify", - "path": ["core", "json", "classify"], - "children": [] - } - ] - }, - { - "name": "Type", - "path": ["core", "type"], - "children": [ - { - "name": "Classify", - "path": ["core", "type", "classify"], - "children": [] - } - ] - }, - { "name": "Symbol", "path": ["core", "symbol"], "children": [] }, - { "name": "String", "path": ["core", "string"], "children": [] }, - { - "name": "RegExp", - "path": ["core", "regexp"], - "children": [ - { - "name": "Result", - "path": ["core", "regexp", "result"], - "children": [] - } - ] - }, - { "name": "Promise", "path": ["core", "promise"], "children": [] }, - { "name": "Ordering", "path": ["core", "ordering"], "children": [] }, - { "name": "Object", "path": ["core", "object"], "children": [] }, - { "name": "Nullable", "path": ["core", "nullable"], "children": [] }, - { "name": "Null", "path": ["core", "null"], "children": [] }, - { - "name": "Math", - "path": ["core", "math"], - "children": [ - { "name": "Int", "path": ["core", "math", "int"], "children": [] }, - { - "name": "Constants", - "path": ["core", "math", "constants"], - "children": [] - } - ] - }, - { "name": "BigInt", "path": ["core", "bigint"], "children": [] }, - { - "name": "Int", - "path": ["core", "int"], - "children": [ - { - "name": "Constants", - "path": ["core", "int", "constants"], - "children": [] - } - ] - }, - { - "name": "Float", - "path": ["core", "float"], - "children": [ - { - "name": "Constants", - "path": ["core", "float", "constants"], - "children": [] - } - ] - }, - { - "name": "Error", - "path": ["core", "error"], - "children": [ - { - "name": "URIError", - "path": ["core", "error", "urierror"], - "children": [] - }, - { - "name": "TypeError", - "path": ["core", "error", "typeerror"], - "children": [] - }, - { - "name": "SyntaxError", - "path": ["core", "error", "syntaxerror"], - "children": [] - }, - { - "name": "ReferenceError", - "path": ["core", "error", "referenceerror"], - "children": [] - }, - { - "name": "RangeError", - "path": ["core", "error", "rangeerror"], - "children": [] - }, - { - "name": "EvalError", - "path": ["core", "error", "evalerror"], - "children": [] - } - ] - }, - { "name": "Dict", "path": ["core", "dict"], "children": [] }, - { - "name": "Date", - "path": ["core", "date"], - "children": [ - { "name": "UTC", "path": ["core", "date", "utc"], "children": [] } - ] - }, - { "name": "DataView", "path": ["core", "dataview"], "children": [] }, - { "name": "Console", "path": ["core", "console"], "children": [] }, - { "name": "Array", "path": ["core", "array"], "children": [] } - ] - } -} diff --git a/data/api/v12.0.0/belt.json b/docs/api/belt.json similarity index 100% rename from data/api/v12.0.0/belt.json rename to docs/api/belt.json diff --git a/data/api/v12.0.0/dom.json b/docs/api/dom.json similarity index 100% rename from data/api/v12.0.0/dom.json rename to docs/api/dom.json diff --git a/data/api/v12.0.0/js.json b/docs/api/js.json similarity index 100% rename from data/api/v12.0.0/js.json rename to docs/api/js.json diff --git a/data/api/v12.0.0/stdlib.json b/docs/api/stdlib.json similarity index 100% rename from data/api/v12.0.0/stdlib.json rename to docs/api/stdlib.json diff --git a/data/api/v12.0.0/toc_tree.json b/docs/api/toc_tree.json similarity index 100% rename from data/api/v12.0.0/toc_tree.json rename to docs/api/toc_tree.json diff --git a/pages/docs/guidelines/publishing-packages.mdx b/docs/guidelines/publishing-packages.mdx similarity index 94% rename from pages/docs/guidelines/publishing-packages.mdx rename to docs/guidelines/publishing-packages.mdx index 44bb5dd44..9469b7dd1 100644 --- a/pages/docs/guidelines/publishing-packages.mdx +++ b/docs/guidelines/publishing-packages.mdx @@ -15,7 +15,7 @@ Whenever you publish a ReScript package to npm, please follow the following guid **Naming:** - Make sure to give a descriptive package name. We usually use `rescript-[name-of-js-lib]` for packages that bind to a specific JS library on npm. -- Use names that are self explanatory (no weird marketing terms / fantasy words if possible). +- Use names that are self explanatory (no weird marketing terms /pages/docs/guidelines fantasy words if possible). **Metadata:** diff --git a/pages/docs/manual/v12.0.0/api.mdx b/docs/manual/api.mdx similarity index 100% rename from pages/docs/manual/v12.0.0/api.mdx rename to docs/manual/api.mdx diff --git a/pages/docs/manual/v12.0.0/api/[...slug].js b/docs/manual/api/[...slug].js similarity index 100% rename from pages/docs/manual/v12.0.0/api/[...slug].js rename to docs/manual/api/[...slug].js diff --git a/pages/docs/manual/v12.0.0/array-and-list.mdx b/docs/manual/array-and-list.mdx similarity index 100% rename from pages/docs/manual/v12.0.0/array-and-list.mdx rename to docs/manual/array-and-list.mdx diff --git a/pages/docs/manual/v12.0.0/async-await.mdx b/docs/manual/async-await.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/async-await.mdx rename to docs/manual/async-await.mdx index f1510e4c7..67bf77bc4 100644 --- a/pages/docs/manual/v12.0.0/async-await.mdx +++ b/docs/manual/async-await.mdx @@ -1,12 +1,12 @@ --- title: "Async / Await" description: "Async / await for asynchronous operations" -canonical: "/docs/manual/v12.0.0/async-await" +canonical: "/docs/manual/async-await" section: "Language Features" order: 22 --- - +{/* This prelude is used in many different followup examples, so we use it to shorten the noise of the example code. */}
@@ -17,7 +17,7 @@ order: 22
- +{/* See https://github.com/cristianoc/rescript-compiler-experiments/pull/1#issuecomment-1131182023 for all async/await use-case examples */} # Async / Await diff --git a/pages/docs/manual/v12.0.0/attribute.mdx b/docs/manual/attribute.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/attribute.mdx rename to docs/manual/attribute.mdx index e3056a689..144e9d6a4 100644 --- a/pages/docs/manual/v12.0.0/attribute.mdx +++ b/docs/manual/attribute.mdx @@ -1,7 +1,7 @@ --- title: "Attribute (Decorator)" description: "Annotations in ReScript" -canonical: "/docs/manual/v12.0.0/attribute" +canonical: "/docs/manual/attribute" section: "Language Features" order: 26 --- diff --git a/pages/docs/manual/v12.0.0/bind-to-global-js-values.mdx b/docs/manual/bind-to-global-js-values.mdx similarity index 96% rename from pages/docs/manual/v12.0.0/bind-to-global-js-values.mdx rename to docs/manual/bind-to-global-js-values.mdx index 9154d8e59..7d5c03c53 100644 --- a/pages/docs/manual/v12.0.0/bind-to-global-js-values.mdx +++ b/docs/manual/bind-to-global-js-values.mdx @@ -1,7 +1,7 @@ --- title: "Bind to Global JS Values" description: "JS interop with global JS values in ReScript" -canonical: "/docs/manual/v12.0.0/bind-to-global-js-values" +canonical: "/docs/manual/bind-to-global-js-values" section: "JavaScript Interop" order: 8 --- @@ -150,4 +150,4 @@ if (match !== undefined) { - +{/* TODO: revamp this page. Not good. Tell to use globalThis["foo"], and look in our stdlib */} diff --git a/pages/docs/manual/v12.0.0/bind-to-js-function.mdx b/docs/manual/bind-to-js-function.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/bind-to-js-function.mdx rename to docs/manual/bind-to-js-function.mdx index c5b6152cc..dbfb571ad 100644 --- a/pages/docs/manual/v12.0.0/bind-to-js-function.mdx +++ b/docs/manual/bind-to-js-function.mdx @@ -1,7 +1,7 @@ --- title: "Bind to JS Function" description: "JS interop with functions in ReScript" -canonical: "/docs/manual/v12.0.0/bind-to-js-function" +canonical: "/docs/manual/bind-to-js-function" section: "JavaScript Interop" order: 6 --- @@ -342,7 +342,7 @@ function register(rl) { - +{/* TODO: GADT phantom type */} ## Fixed Arguments @@ -465,7 +465,7 @@ function test(dom) { Currently 4 directives are supported: `null_to_opt`, `undefined_to_opt`, `nullable` and `identity`. - +{/* When the return type is unit: the compiler will append its return value with an OCaml unit literal to make sure it does return unit. Its main purpose is to make the user consume FFI in idiomatic OCaml code, the cost is very very small and the compiler will do smart optimizations to remove it when the returned value is not used (mostly likely). */} `identity` will make sure that compiler will do nothing about the returned value. It is rarely used, but introduced here for debugging purpose. diff --git a/pages/docs/manual/v12.0.0/bind-to-js-object.mdx b/docs/manual/bind-to-js-object.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/bind-to-js-object.mdx rename to docs/manual/bind-to-js-object.mdx index eafa38f74..1cc382b11 100644 --- a/pages/docs/manual/v12.0.0/bind-to-js-object.mdx +++ b/docs/manual/bind-to-js-object.mdx @@ -1,7 +1,7 @@ --- title: "Bind to JS Object" description: "Interop with JS objects in ReScript" -canonical: "/docs/manual/v12.0.0/bind-to-js-object" +canonical: "/docs/manual/bind-to-js-object" section: "JavaScript Interop" order: 5 --- @@ -17,7 +17,7 @@ JavaScript objects are a combination of several use-cases: ReScript cleanly separates the binding methods for JS object based on these 4 use-cases. This page documents the first three. Binding to JS module objects is described in the [Import from/Export to JS](import-from-export-to-js.md) section. - +{/* TODO: mention scope here too? */} ## Bind to Record-like JS Objects diff --git a/pages/docs/manual/v12.0.0/browser-support-polyfills.mdx b/docs/manual/browser-support-polyfills.mdx similarity index 91% rename from pages/docs/manual/v12.0.0/browser-support-polyfills.mdx rename to docs/manual/browser-support-polyfills.mdx index ce21cd28c..1adf06d02 100644 --- a/pages/docs/manual/v12.0.0/browser-support-polyfills.mdx +++ b/docs/manual/browser-support-polyfills.mdx @@ -1,7 +1,7 @@ --- title: "Browser Support & Polyfills" description: "Note on browser support in ReScript" -canonical: "/docs/manual/v12.0.0/browser-support-polyfills" +canonical: "/docs/manual/browser-support-polyfills" section: "JavaScript Interop" order: 13 --- diff --git a/pages/docs/manual/v12.0.0/build-configuration-schema.mdx b/docs/manual/build-configuration-schema.mdx similarity index 87% rename from pages/docs/manual/v12.0.0/build-configuration-schema.mdx rename to docs/manual/build-configuration-schema.mdx index 76cb32eb1..3861d9573 100644 --- a/pages/docs/manual/v12.0.0/build-configuration-schema.mdx +++ b/docs/manual/build-configuration-schema.mdx @@ -2,11 +2,16 @@ title: "Configuration Schema" metaTitle: "Build System Configuration Schema" description: "Schema exploration widget for the ReScript configuration file" -canonical: "/docs/manual/v12.0.0/build-configuration-schema" +canonical: "/docs/manual/build-configuration-schema" section: "Build System" order: 3 --- + +{/* + +TODO: RR7 + import dynamic from "next/dynamic"; export const Docson = dynamic( @@ -23,3 +28,4 @@ export const Docson = dynamic( export default function BuildConfigurationSchemaPage() { return ; } +*/} \ No newline at end of file diff --git a/pages/docs/manual/v12.0.0/build-configuration.mdx b/docs/manual/build-configuration.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/build-configuration.mdx rename to docs/manual/build-configuration.mdx index fcd1be54a..60ba76512 100644 --- a/pages/docs/manual/v12.0.0/build-configuration.mdx +++ b/docs/manual/build-configuration.mdx @@ -2,7 +2,7 @@ title: "Configuration" metaTitle: "Build System Configuration" description: "Details about the configuration of the ReScript build system (rescript.json)" -canonical: "/docs/manual/v12.0.0/build-configuration" +canonical: "/docs/manual/build-configuration" section: "Build System" order: 2 --- diff --git a/pages/docs/manual/v12.0.0/build-external-stdlib.mdx b/docs/manual/build-external-stdlib.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/build-external-stdlib.mdx rename to docs/manual/build-external-stdlib.mdx index afcb466c8..e789a0b7e 100644 --- a/pages/docs/manual/v12.0.0/build-external-stdlib.mdx +++ b/docs/manual/build-external-stdlib.mdx @@ -2,7 +2,7 @@ title: "External Stdlib" metaTitle: "External Stdlib" description: "Configuring an external ReScript stdlib package" -canonical: "/docs/manual/v12.0.0/build-external-stdlib" +canonical: "/docs/manual/build-external-stdlib" section: "Build System" order: 4 --- diff --git a/pages/docs/manual/v12.0.0/build-monorepo-setup.mdx b/docs/manual/build-monorepo-setup.mdx similarity index 100% rename from pages/docs/manual/v12.0.0/build-monorepo-setup.mdx rename to docs/manual/build-monorepo-setup.mdx diff --git a/pages/docs/manual/v12.0.0/build-overview.mdx b/docs/manual/build-overview.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/build-overview.mdx rename to docs/manual/build-overview.mdx index cabc5256a..9d946c8e2 100644 --- a/pages/docs/manual/v12.0.0/build-overview.mdx +++ b/docs/manual/build-overview.mdx @@ -2,7 +2,7 @@ title: "Overview" metaTitle: "Build System Overview" description: "Documentation about the ReScript build system and its toolchain" -canonical: "/docs/manual/v12.0.0/build-overview" +canonical: "/docs/manual/build-overview" section: "Build System" order: 1 --- diff --git a/pages/docs/manual/v12.0.0/build-performance.mdx b/docs/manual/build-performance.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/build-performance.mdx rename to docs/manual/build-performance.mdx index d1674b736..d84312fc2 100644 --- a/pages/docs/manual/v12.0.0/build-performance.mdx +++ b/docs/manual/build-performance.mdx @@ -2,7 +2,7 @@ title: "Performance" metaTitle: "Build Performance" description: "ReScript build performance and measuring tools" -canonical: "/docs/manual/v12.0.0/build-performance" +canonical: "/docs/manual/build-performance" section: "Build System" order: 7 --- @@ -21,8 +21,6 @@ Sometime your build can be slow due to some confused infra setups. We provide an Run the above command at your ReScript project's root; it'll spit out a JSON file you can drag and drop into `chrome://tracing`. -import Image from "src/components/Image"; - +{/* TODO: better repro */} - No-op build of 10k files: `800ms` (the minimum amount of time required to check the mtimes of 10k files). - Clean build: \<3 minutes. diff --git a/pages/docs/manual/v12.0.0/control-flow.mdx b/docs/manual/control-flow.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/control-flow.mdx rename to docs/manual/control-flow.mdx index b25cd4f04..3bfc72b9d 100644 --- a/pages/docs/manual/v12.0.0/control-flow.mdx +++ b/docs/manual/control-flow.mdx @@ -1,7 +1,7 @@ --- title: "If-Else & Loops" description: "If, else, ternary, for, and while" -canonical: "/docs/manual/v12.0.0/control-flow" +canonical: "/docs/manual/control-flow" section: "Language Features" order: 14 --- diff --git a/pages/docs/manual/v12.0.0/converting-from-js.mdx b/docs/manual/converting-from-js.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/converting-from-js.mdx rename to docs/manual/converting-from-js.mdx index 190da5ae0..199183ba3 100644 --- a/pages/docs/manual/v12.0.0/converting-from-js.mdx +++ b/docs/manual/converting-from-js.mdx @@ -1,7 +1,7 @@ --- title: "Converting from JS" description: "How to convert to ReScript with an existing JS codebase" -canonical: "/docs/manual/v12.0.0/converting-from-js" +canonical: "/docs/manual/converting-from-js" section: "Guides" order: 1 --- diff --git a/pages/docs/manual/v12.0.0/dict.mdx b/docs/manual/dict.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/dict.mdx rename to docs/manual/dict.mdx index 30df94528..10db561b2 100644 --- a/pages/docs/manual/v12.0.0/dict.mdx +++ b/docs/manual/dict.mdx @@ -1,7 +1,7 @@ --- title: "Dictionary" description: "Dictionary data structure in ReScript" -canonical: "/docs/manual/v12.0.0/dict" +canonical: "/docs/manual/dict" section: "Language Features" order: 8 --- diff --git a/pages/docs/manual/v12.0.0/editor-code-analysis.mdx b/docs/manual/editor-code-analysis.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/editor-code-analysis.mdx rename to docs/manual/editor-code-analysis.mdx index acbcac463..db447fc01 100644 --- a/pages/docs/manual/v12.0.0/editor-code-analysis.mdx +++ b/docs/manual/editor-code-analysis.mdx @@ -2,7 +2,7 @@ title: "Dead Code Analysis in ReScript" metaTitle: "Dead Code Analysis in ReScript" description: "Documentation about ReScript editor plugins and code analysis" -canonical: "/docs/manual/v12.0.0/editor-plugins" +canonical: "/docs/manual/editor-plugins" section: "Guides" order: 2 --- diff --git a/pages/docs/manual/v12.0.0/editor-plugins.mdx b/docs/manual/editor-plugins.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/editor-plugins.mdx rename to docs/manual/editor-plugins.mdx index 4c6d7cd81..c33905940 100644 --- a/pages/docs/manual/v12.0.0/editor-plugins.mdx +++ b/docs/manual/editor-plugins.mdx @@ -2,7 +2,7 @@ title: "Editor" metaTitle: "Editor" description: "Documentation about ReScript editor plugins and code analysis" -canonical: "/docs/manual/v12.0.0/editor-plugins" +canonical: "/docs/manual/editor-plugins" section: "Overview" order: 3 --- diff --git a/pages/docs/manual/v12.0.0/embed-raw-javascript.mdx b/docs/manual/embed-raw-javascript.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/embed-raw-javascript.mdx rename to docs/manual/embed-raw-javascript.mdx index 68ebe09ef..2514a7c53 100644 --- a/pages/docs/manual/v12.0.0/embed-raw-javascript.mdx +++ b/docs/manual/embed-raw-javascript.mdx @@ -1,7 +1,7 @@ --- title: "Embed Raw JavaScript" description: "Utility syntax to for raw JS usage in ReScript" -canonical: "/docs/manual/v12.0.0/embed-raw-javascript" +canonical: "/docs/manual/embed-raw-javascript" section: "JavaScript Interop" order: 2 --- diff --git a/pages/docs/manual/v12.0.0/equality-comparison.mdx b/docs/manual/equality-comparison.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/equality-comparison.mdx rename to docs/manual/equality-comparison.mdx index 51af2d86c..3da8b2f68 100644 --- a/pages/docs/manual/v12.0.0/equality-comparison.mdx +++ b/docs/manual/equality-comparison.mdx @@ -1,7 +1,7 @@ --- title: "Equality and Comparison" description: "Handling equality and comparison checks" -canonical: "/docs/manual/v12.0.0/equality-comparison" +canonical: "/docs/manual/equality-comparison" section: "Language Features" order: 28 --- diff --git a/pages/docs/manual/v12.0.0/exception.mdx b/docs/manual/exception.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/exception.mdx rename to docs/manual/exception.mdx index 7fe02cdd5..2986e8fba 100644 --- a/pages/docs/manual/v12.0.0/exception.mdx +++ b/docs/manual/exception.mdx @@ -1,7 +1,7 @@ --- title: "Exception" description: "Exceptions and exception handling in ReScript" -canonical: "/docs/manual/v12.0.0/exception" +canonical: "/docs/manual/exception" section: "Language Features" order: 19 --- diff --git a/pages/docs/manual/v12.0.0/extensible-variant.mdx b/docs/manual/extensible-variant.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/extensible-variant.mdx rename to docs/manual/extensible-variant.mdx index e9613d8ef..7e1ddc992 100644 --- a/pages/docs/manual/v12.0.0/extensible-variant.mdx +++ b/docs/manual/extensible-variant.mdx @@ -1,7 +1,7 @@ --- title: "Extensible Variant" description: "Extensible Variants in ReScript" -canonical: "/docs/manual/v12.0.0/extensible-variant" +canonical: "/docs/manual/extensible-variant" section: "Advanced Features" order: 1 --- diff --git a/pages/docs/manual/v12.0.0/external.mdx b/docs/manual/external.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/external.mdx rename to docs/manual/external.mdx index bf8b78de0..46c3e106d 100644 --- a/pages/docs/manual/v12.0.0/external.mdx +++ b/docs/manual/external.mdx @@ -1,7 +1,7 @@ --- title: "External (Bind to Any JS Library)" description: "The external keyword" -canonical: "/docs/manual/v12.0.0/external" +canonical: "/docs/manual/external" section: "JavaScript Interop" order: 3 --- diff --git a/pages/docs/manual/v12.0.0/function.mdx b/docs/manual/function.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/function.mdx rename to docs/manual/function.mdx index d1bdeb09b..ee2a40bdc 100644 --- a/pages/docs/manual/v12.0.0/function.mdx +++ b/docs/manual/function.mdx @@ -1,7 +1,7 @@ --- title: "Function" description: "Function syntax in ReScript" -canonical: "/docs/manual/v12.0.0/function" +canonical: "/docs/manual/function" section: "Language Features" order: 13 --- diff --git a/pages/docs/manual/v12.0.0/generalized-algebraic-data-types.mdx b/docs/manual/generalized-algebraic-data-types.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/generalized-algebraic-data-types.mdx rename to docs/manual/generalized-algebraic-data-types.mdx index ed91abf8d..046d55d5d 100644 --- a/pages/docs/manual/v12.0.0/generalized-algebraic-data-types.mdx +++ b/docs/manual/generalized-algebraic-data-types.mdx @@ -1,7 +1,7 @@ --- title: "Generalized Algebraic Data Types" description: "Generalized Algebraic Data Types in ReScript" -canonical: "/docs/manual/v12.0.0/generalized-algebraic-data-types" +canonical: "/docs/manual/generalized-algebraic-data-types" section: "Advanced Features" order: 4 --- diff --git a/pages/docs/manual/v12.0.0/generate-converters-accessors.mdx b/docs/manual/generate-converters-accessors.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/generate-converters-accessors.mdx rename to docs/manual/generate-converters-accessors.mdx index 6ceb2bb5a..39d016f11 100644 --- a/pages/docs/manual/v12.0.0/generate-converters-accessors.mdx +++ b/docs/manual/generate-converters-accessors.mdx @@ -1,7 +1,7 @@ --- title: "Generate Converters & Helpers" description: "All about the @deriving decorator, and how to generate code from types" -canonical: "/docs/manual/v12.0.0/generate-converters-accessors" +canonical: "/docs/manual/generate-converters-accessors" section: "JavaScript Interop" order: 12 --- @@ -17,7 +17,7 @@ order: 12 These particular ones are no longer needed. Select a doc version lower than `9.0` in the sidebar to see their old docs. - +{/* TODO: genType */} When using ReScript, you will sometimes come into situations where you want to diff --git a/pages/docs/manual/v12.0.0/import-export.mdx b/docs/manual/import-export.mdx similarity index 96% rename from pages/docs/manual/v12.0.0/import-export.mdx rename to docs/manual/import-export.mdx index 9d4f80251..963eea891 100644 --- a/pages/docs/manual/v12.0.0/import-export.mdx +++ b/docs/manual/import-export.mdx @@ -1,7 +1,7 @@ --- title: "Import & Export" description: "Importing / exporting in ReScript modules" -canonical: "/docs/manual/v12.0.0/import-export" +canonical: "/docs/manual/import-export" section: "Language Features" order: 25 --- diff --git a/pages/docs/manual/v12.0.0/import-from-export-to-js.mdx b/docs/manual/import-from-export-to-js.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/import-from-export-to-js.mdx rename to docs/manual/import-from-export-to-js.mdx index c78d8f48c..5464aa8f9 100644 --- a/pages/docs/manual/v12.0.0/import-from-export-to-js.mdx +++ b/docs/manual/import-from-export-to-js.mdx @@ -1,7 +1,7 @@ --- title: "Import from / Export to JS" description: "Importing / exporting JS module content in ReScript" -canonical: "/docs/manual/v12.0.0/import-from-export-to-js" +canonical: "/docs/manual/import-from-export-to-js" section: "JavaScript Interop" order: 7 --- diff --git a/pages/docs/manual/v12.0.0/inlining-constants.mdx b/docs/manual/inlining-constants.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/inlining-constants.mdx rename to docs/manual/inlining-constants.mdx index e557413b8..9221dbb6e 100644 --- a/pages/docs/manual/v12.0.0/inlining-constants.mdx +++ b/docs/manual/inlining-constants.mdx @@ -1,7 +1,7 @@ --- title: "Inlining Constants" description: "Inlining constants" -canonical: "/docs/manual/v12.0.0/inlining-constants" +canonical: "/docs/manual/inlining-constants" section: "JavaScript Interop" order: 10 --- diff --git a/pages/docs/manual/v12.0.0/installation.mdx b/docs/manual/installation.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/installation.mdx rename to docs/manual/installation.mdx index b9cac0c5e..9fe712fd8 100644 --- a/pages/docs/manual/v12.0.0/installation.mdx +++ b/docs/manual/installation.mdx @@ -1,7 +1,7 @@ --- title: "Installation" description: "ReScript installation and setup instructions" -canonical: "/docs/manual/v12.0.0/installation" +canonical: "/docs/manual/installation" section: "Overview" order: 2 --- @@ -10,6 +10,7 @@ order: 2 ## Prerequisites +
- [Node.js](https://nodejs.org/) version >= 20 - One of the following package managers: - [npm](https://docs.npmjs.com/cli/) (comes with Node.js) @@ -19,6 +20,7 @@ order: 2 - [bun](https://bun.sh/) - [deno](http://deno.com/) - Configure `"nodeModulesDir": "auto"` in `deno.json` +
## New Project diff --git a/pages/docs/manual/v12.0.0/interop-cheatsheet.mdx b/docs/manual/interop-cheatsheet.mdx similarity index 96% rename from pages/docs/manual/v12.0.0/interop-cheatsheet.mdx rename to docs/manual/interop-cheatsheet.mdx index efb655bbf..141714e62 100644 --- a/pages/docs/manual/v12.0.0/interop-cheatsheet.mdx +++ b/docs/manual/interop-cheatsheet.mdx @@ -1,7 +1,7 @@ --- title: "Interop Cheatsheet" description: "Cheatsheet for various interop scenarios in ReScript" -canonical: "/docs/manual/v12.0.0/interop-cheatsheet" +canonical: "/docs/manual/interop-cheatsheet" section: "JavaScript Interop" order: 1 --- @@ -14,7 +14,7 @@ This is a glossary with examples. All the features are described by later pages. > **Note:** In ReScript < 8.3, all our attributes started with the `bs.` prefix. This is no longer needed and our formatter automatically removes them in newer ReScript versions. - +{/* Synced from https://github.com/rescript-lang/syntax/blob/123760c5a264da5288eeee5213ddd25eb86d62fe/src/res_printer.ml#L19-L51 */} ### Attributes @@ -22,10 +22,10 @@ This is a glossary with examples. All the features are described by later pages. - [`@deriving`](generate-converters-accessors#generate-functions--plain-values-for-variants) - [`@get`](bind-to-js-object#bind-using-special-bs-getters--setters) - [`@get_index`](bind-to-js-object#bind-using-special-bs-getters--setters) - +{/* - `@ignore` */} - [`@inline`](inlining-constants) - [`@int`](bind-to-js-function#constrain-arguments-better) - +{/* - `@meth` */} - [`@module`](import-from-export-to-js#import-a-javascript-modules-content) - [`@new`](bind-to-js-object#bind-to-a-js-object-thats-a-class) - [`@optional`](generate-converters-accessors#optional-labels) diff --git a/pages/docs/manual/v12.0.0/interop-with-js-build-systems.mdx b/docs/manual/interop-with-js-build-systems.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/interop-with-js-build-systems.mdx rename to docs/manual/interop-with-js-build-systems.mdx index adfa439f9..59b1cf897 100644 --- a/pages/docs/manual/v12.0.0/interop-with-js-build-systems.mdx +++ b/docs/manual/interop-with-js-build-systems.mdx @@ -1,7 +1,7 @@ --- title: "Interop with JS Build Systems" description: "Documentation on how to interact with existing JS build systems" -canonical: "/docs/manual/v12.0.0/interop-with-js-build-systems" +canonical: "/docs/manual/interop-with-js-build-systems" section: "Build System" order: 6 --- diff --git a/pages/docs/manual/v12.0.0/introduction.mdx b/docs/manual/introduction.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/introduction.mdx rename to docs/manual/introduction.mdx index 202e35e67..0cf19de7b 100644 --- a/pages/docs/manual/v12.0.0/introduction.mdx +++ b/docs/manual/introduction.mdx @@ -1,7 +1,7 @@ --- title: "Introduction" description: "Introduction to the ReScript programming language" -canonical: "/docs/manual/v12.0.0/introduction" +canonical: "/docs/manual/introduction" section: "Overview" order: 1 --- diff --git a/pages/docs/manual/v12.0.0/json.mdx b/docs/manual/json.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/json.mdx rename to docs/manual/json.mdx index 5a7e59ba2..bb9da86a2 100644 --- a/pages/docs/manual/v12.0.0/json.mdx +++ b/docs/manual/json.mdx @@ -1,7 +1,7 @@ --- title: "JSON" description: "Interacting with JSON in ReScript" -canonical: "/docs/manual/v12.0.0/json" +canonical: "/docs/manual/json" section: "JavaScript Interop" order: 9 --- diff --git a/pages/docs/manual/v12.0.0/jsx.mdx b/docs/manual/jsx.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/jsx.mdx rename to docs/manual/jsx.mdx index 8773c9ce1..791b435fd 100644 --- a/pages/docs/manual/v12.0.0/jsx.mdx +++ b/docs/manual/jsx.mdx @@ -1,7 +1,7 @@ --- title: "JSX" description: "JSX syntax in ReScript and React" -canonical: "/docs/manual/v12.0.0/jsx" +canonical: "/docs/manual/jsx" section: "Language Features" order: 18 --- diff --git a/pages/docs/manual/v12.0.0/lazy-values.mdx b/docs/manual/lazy-values.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/lazy-values.mdx rename to docs/manual/lazy-values.mdx index 25bdd8d08..6b68d0915 100644 --- a/pages/docs/manual/v12.0.0/lazy-values.mdx +++ b/docs/manual/lazy-values.mdx @@ -1,7 +1,7 @@ --- title: "Lazy Value" description: "Data type for deferred computation in ReScript" -canonical: "/docs/manual/v12.0.0/lazy-values" +canonical: "/docs/manual/lazy-values" section: "Language Features" order: 20 --- diff --git a/pages/docs/manual/v12.0.0/let-binding.mdx b/docs/manual/let-binding.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/let-binding.mdx rename to docs/manual/let-binding.mdx index bf2b05e5e..951f5fe44 100644 --- a/pages/docs/manual/v12.0.0/let-binding.mdx +++ b/docs/manual/let-binding.mdx @@ -1,7 +1,7 @@ --- title: "Let Binding" description: "Let binding syntax for binding to values in ReScript" -canonical: "/docs/manual/v12.0.0/let-binding" +canonical: "/docs/manual/let-binding" section: "Language Features" order: 2 --- diff --git a/pages/docs/manual/v12.0.0/libraries.mdx b/docs/manual/libraries.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/libraries.mdx rename to docs/manual/libraries.mdx index 1d70a3cf5..3659e395f 100644 --- a/pages/docs/manual/v12.0.0/libraries.mdx +++ b/docs/manual/libraries.mdx @@ -1,7 +1,7 @@ --- title: "Libraries & Publishing" description: "Install & publish ReScript packages" -canonical: "/docs/manual/v12.0.0/libraries" +canonical: "/docs/manual/libraries" section: "JavaScript Interop" order: 14 --- diff --git a/pages/docs/manual/v12.0.0/migrate-to-v11.mdx b/docs/manual/migrate-to-v11.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/migrate-to-v11.mdx rename to docs/manual/migrate-to-v11.mdx index 07bcb78f5..31eedba5b 100644 --- a/pages/docs/manual/v12.0.0/migrate-to-v11.mdx +++ b/docs/manual/migrate-to-v11.mdx @@ -1,7 +1,7 @@ --- title: "Migrate to v11" description: "Instructions on upgrading to ReScript 11" -canonical: "/docs/manual/v12.0.0/migrate-to-v11" +canonical: "/docs/manual/migrate-to-v11" --- # Migrate to ReScript 11 diff --git a/pages/docs/manual/v12.0.0/module-functions.mdx b/docs/manual/module-functions.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/module-functions.mdx rename to docs/manual/module-functions.mdx index e1e1029df..bcc52279e 100644 --- a/pages/docs/manual/v12.0.0/module-functions.mdx +++ b/docs/manual/module-functions.mdx @@ -1,7 +1,7 @@ --- title: "Module Functions" description: "Module Functions in ReScript" -canonical: "/docs/manual/v12.0.0/module-functions" +canonical: "/docs/manual/module-functions" section: "Advanced Features" order: 3 --- diff --git a/pages/docs/manual/v12.0.0/module.mdx b/docs/manual/module.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/module.mdx rename to docs/manual/module.mdx index e2f597dbd..52de4fe90 100644 --- a/pages/docs/manual/v12.0.0/module.mdx +++ b/docs/manual/module.mdx @@ -1,7 +1,7 @@ --- title: "Module" description: "ReScript modules, module signatures and interface files" -canonical: "/docs/manual/v12.0.0/module" +canonical: "/docs/manual/module" section: "Language Features" order: 24 --- diff --git a/pages/docs/manual/v12.0.0/mutation.mdx b/docs/manual/mutation.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/mutation.mdx rename to docs/manual/mutation.mdx index c0358104c..6deb1949c 100644 --- a/pages/docs/manual/v12.0.0/mutation.mdx +++ b/docs/manual/mutation.mdx @@ -1,7 +1,7 @@ --- title: "Mutation" description: "Imperative and mutative programming capabilities in ReScript" -canonical: "/docs/manual/v12.0.0/mutation" +canonical: "/docs/manual/mutation" section: "Language Features" order: 17 --- diff --git a/pages/docs/manual/v12.0.0/null-undefined-option.mdx b/docs/manual/null-undefined-option.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/null-undefined-option.mdx rename to docs/manual/null-undefined-option.mdx index b381ecc0a..955e93294 100644 --- a/pages/docs/manual/v12.0.0/null-undefined-option.mdx +++ b/docs/manual/null-undefined-option.mdx @@ -1,7 +1,7 @@ --- title: "Null, Undefined and Option" description: "JS interop with nullable and optional values in ReScript" -canonical: "/docs/manual/v12.0.0/null-undefined-option" +canonical: "/docs/manual/null-undefined-option" section: "Language Features" order: 11 --- diff --git a/pages/docs/manual/v12.0.0/object.mdx b/docs/manual/object.mdx similarity index 97% rename from pages/docs/manual/v12.0.0/object.mdx rename to docs/manual/object.mdx index 90ff0b422..eadc82e29 100644 --- a/pages/docs/manual/v12.0.0/object.mdx +++ b/docs/manual/object.mdx @@ -1,7 +1,7 @@ --- title: "Object" description: "Interoping with JS objects in ReScript" -canonical: "/docs/manual/v12.0.0/object" +canonical: "/docs/manual/object" section: "Language Features" order: 7 --- @@ -15,7 +15,7 @@ ReScript objects are like [records](record.md), but: - Doesn't support updates unless the object comes from the JS side. - Doesn't support [pattern matching](pattern-matching-destructuring). - +{/* TODO: support update man */} Although ReScript records compile to clean JavaScript objects, ReScript objects are a better candidate for emulating/binding to JS objects, as you'll see. @@ -40,7 +40,7 @@ type person = { Visually similar to record type's syntax, with the field names quoted. - +{/* TODO: document {.} and {..} */} ## Creation diff --git a/pages/docs/manual/v12.0.0/overview.mdx b/docs/manual/overview.mdx similarity index 100% rename from pages/docs/manual/v12.0.0/overview.mdx rename to docs/manual/overview.mdx diff --git a/pages/docs/manual/v12.0.0/pattern-matching-destructuring.mdx b/docs/manual/pattern-matching-destructuring.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/pattern-matching-destructuring.mdx rename to docs/manual/pattern-matching-destructuring.mdx index dc7fc7b1a..21ee30299 100644 --- a/pages/docs/manual/v12.0.0/pattern-matching-destructuring.mdx +++ b/docs/manual/pattern-matching-destructuring.mdx @@ -1,7 +1,7 @@ --- title: "Pattern Matching / Destructuring" description: "Pattern matching and destructuring complex data structures in ReScript" -canonical: "/docs/manual/v12.0.0/pattern-matching-destructuring" +canonical: "/docs/manual/pattern-matching-destructuring" section: "Language Features" order: 16 --- diff --git a/pages/docs/manual/v12.0.0/pipe.mdx b/docs/manual/pipe.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/pipe.mdx rename to docs/manual/pipe.mdx index 03713c844..81e3f9944 100644 --- a/pages/docs/manual/v12.0.0/pipe.mdx +++ b/docs/manual/pipe.mdx @@ -1,7 +1,7 @@ --- title: "Pipe" description: "The Pipe operator (->)" -canonical: "/docs/manual/v12.0.0/pipe" +canonical: "/docs/manual/pipe" section: "Language Features" order: 15 --- diff --git a/pages/docs/manual/v12.0.0/polymorphic-variant.mdx b/docs/manual/polymorphic-variant.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/polymorphic-variant.mdx rename to docs/manual/polymorphic-variant.mdx index 3b03940d5..725cdcb49 100644 --- a/pages/docs/manual/v12.0.0/polymorphic-variant.mdx +++ b/docs/manual/polymorphic-variant.mdx @@ -1,7 +1,7 @@ --- title: "Polymorphic Variant" description: "The Polymorphic Variant data structure in ReScript" -canonical: "/docs/manual/v12.0.0/polymorphic-variant" +canonical: "/docs/manual/polymorphic-variant" section: "Language Features" order: 10 --- diff --git a/pages/docs/manual/v12.0.0/primitive-types.mdx b/docs/manual/primitive-types.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/primitive-types.mdx rename to docs/manual/primitive-types.mdx index 8a9257d2e..d1428976b 100644 --- a/pages/docs/manual/v12.0.0/primitive-types.mdx +++ b/docs/manual/primitive-types.mdx @@ -1,7 +1,7 @@ --- title: "Primitive Types" description: "Primitive Data Types in ReScript" -canonical: "/docs/manual/v12.0.0/primitive-types" +canonical: "/docs/manual/primitive-types" section: "Language Features" order: 4 --- @@ -10,7 +10,7 @@ order: 4 ReScript comes with the familiar primitive types like `string`, `int`, `float`, etc. - +{/* TODO: doc unit */} ## String diff --git a/pages/docs/manual/v12.0.0/project-structure.mdx b/docs/manual/project-structure.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/project-structure.mdx rename to docs/manual/project-structure.mdx index 242ee51cd..00e2a7f05 100644 --- a/pages/docs/manual/v12.0.0/project-structure.mdx +++ b/docs/manual/project-structure.mdx @@ -1,7 +1,7 @@ --- title: "Project Structure" description: "Notes on project structure and other rough ReScript guidelines" -canonical: "/docs/manual/v12.0.0/project-structure" +canonical: "/docs/manual/project-structure" section: "Guides" order: 3 --- diff --git a/pages/docs/manual/v12.0.0/promise.mdx b/docs/manual/promise.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/promise.mdx rename to docs/manual/promise.mdx index b0bfd29ef..698e2dce7 100644 --- a/pages/docs/manual/v12.0.0/promise.mdx +++ b/docs/manual/promise.mdx @@ -1,7 +1,7 @@ --- title: "Promises" description: "JS Promise handling in ReScript" -canonical: "/docs/manual/v12.0.0/promise" +canonical: "/docs/manual/promise" section: "Language Features" order: 21 --- diff --git a/pages/docs/manual/v12.0.0/record.mdx b/docs/manual/record.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/record.mdx rename to docs/manual/record.mdx index 0965c6bfc..953af574e 100644 --- a/pages/docs/manual/v12.0.0/record.mdx +++ b/docs/manual/record.mdx @@ -1,7 +1,7 @@ --- title: "Record" description: "Record types in ReScript" -canonical: "/docs/manual/v12.0.0/record" +canonical: "/docs/manual/record" section: "Language Features" order: 6 --- diff --git a/pages/docs/manual/v12.0.0/reserved-keywords.mdx b/docs/manual/reserved-keywords.mdx similarity index 57% rename from pages/docs/manual/v12.0.0/reserved-keywords.mdx rename to docs/manual/reserved-keywords.mdx index d9e2dc3cf..e1ff9e39d 100644 --- a/pages/docs/manual/v12.0.0/reserved-keywords.mdx +++ b/docs/manual/reserved-keywords.mdx @@ -1,7 +1,7 @@ --- title: "Reserved Keywords" description: "All reserved keywords in ReScript" -canonical: "/docs/manual/v12.0.0/reserved-keywords" +canonical: "/docs/manual/reserved-keywords" section: "Language Features" order: 27 --- @@ -16,32 +16,32 @@ order: 27 - `as` - `assert` - +{/* - `begin` */} - +{/* - `class` */} - `constraint` - - +{/* - `do` */} +{/* - `done` */} - `else` - - + {/* - `end` */} + {/* - `esfun` */} - `exception` - `external` * `false` * `for` - - - + {/* - `fun` */} + {/* - `function` */} + {/* - `functor` */} - `if` - `in` - `include` - - + {/* - `inherit` */} + {/* - `initializer` */} * `lazy` * `let` @@ -49,33 +49,33 @@ order: 27 - `module` - `mutable` - - +{/* - `new` */} +{/* - `nonrec` */} - +{/* - `object` */} - `of` - `open` - + {/* - `or` */} - - +{/* - `pri` */} +{/* - `pub` */} - `rec` - - +{/* - `sig` */} +{/* - `struct` */} - `switch` - +{/* - `then` */} - `true` - `try` - `type` - - +{/* - `val` */} +{/* - `virtual` */} - `when` - `while` diff --git a/pages/docs/manual/v12.0.0/scoped-polymorphic-types.mdx b/docs/manual/scoped-polymorphic-types.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/scoped-polymorphic-types.mdx rename to docs/manual/scoped-polymorphic-types.mdx index f20f332df..c02addb64 100644 --- a/pages/docs/manual/v12.0.0/scoped-polymorphic-types.mdx +++ b/docs/manual/scoped-polymorphic-types.mdx @@ -1,7 +1,7 @@ --- title: "Scoped Polymorphic Types" description: "Scoped Polymorphic Types in ReScript" -canonical: "/docs/manual/v12.0.0/scoped-polymorphic-types" +canonical: "/docs/manual/scoped-polymorphic-types" section: "Advanced Features" order: 2 --- diff --git a/pages/docs/manual/v12.0.0/shared-data-types.mdx b/docs/manual/shared-data-types.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/shared-data-types.mdx rename to docs/manual/shared-data-types.mdx index ea2c3adbe..5c8cbe0f8 100644 --- a/pages/docs/manual/v12.0.0/shared-data-types.mdx +++ b/docs/manual/shared-data-types.mdx @@ -1,7 +1,7 @@ --- title: "Shared Data Types" description: "Data types that share runtime presentation between JS and ReScript" -canonical: "/docs/manual/v12.0.0/shared-data-types" +canonical: "/docs/manual/shared-data-types" section: "JavaScript Interop" order: 2 --- diff --git a/pages/docs/manual/v12.0.0/tagged-templates.mdx b/docs/manual/tagged-templates.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/tagged-templates.mdx rename to docs/manual/tagged-templates.mdx index 3ecbd9c5f..265be321b 100644 --- a/pages/docs/manual/v12.0.0/tagged-templates.mdx +++ b/docs/manual/tagged-templates.mdx @@ -1,7 +1,7 @@ --- title: "Tagged templates" description: "Using tagged templates in ReScript" -canonical: "/docs/manual/v12.0.0/tagged-templates" +canonical: "/docs/manual/tagged-templates" section: "Language Features" order: 23 --- diff --git a/pages/docs/manual/v12.0.0/try.mdx b/docs/manual/try.mdx similarity index 89% rename from pages/docs/manual/v12.0.0/try.mdx rename to docs/manual/try.mdx index e5d67824c..f4e09a206 100644 --- a/pages/docs/manual/v12.0.0/try.mdx +++ b/docs/manual/try.mdx @@ -1,7 +1,7 @@ --- title: "Try" description: "Try ReScript via Command Line" -canonical: "/docs/manual/v12.0.0/try" +canonical: "/docs/manual/try" --- ## Try Online diff --git a/pages/docs/manual/v12.0.0/tuple.mdx b/docs/manual/tuple.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/tuple.mdx rename to docs/manual/tuple.mdx index 8be179b57..4272a434d 100644 --- a/pages/docs/manual/v12.0.0/tuple.mdx +++ b/docs/manual/tuple.mdx @@ -1,7 +1,7 @@ --- title: "Tuple" description: "Tuple types and values in ReScript" -canonical: "/docs/manual/v12.0.0/tuple" +canonical: "/docs/manual/tuple" section: "Language Features" order: 5 --- diff --git a/pages/docs/manual/v12.0.0/type.mdx b/docs/manual/type.mdx similarity index 98% rename from pages/docs/manual/v12.0.0/type.mdx rename to docs/manual/type.mdx index 6e8328269..b71a32745 100644 --- a/pages/docs/manual/v12.0.0/type.mdx +++ b/docs/manual/type.mdx @@ -1,7 +1,7 @@ --- title: "Type" description: "Types and type definitions in ReScript" -canonical: "/docs/manual/v12.0.0/type" +canonical: "/docs/manual/type" section: "Language Features" order: 3 --- @@ -179,7 +179,7 @@ If types didn't accept parameters, the standard library would need to define the Types can receive many arguments, and be composable. - +{/* TODO: too early for this example */} diff --git a/pages/docs/manual/v12.0.0/typescript-integration.mdx b/docs/manual/typescript-integration.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/typescript-integration.mdx rename to docs/manual/typescript-integration.mdx index bfed28ff8..5b74b55c3 100644 --- a/pages/docs/manual/v12.0.0/typescript-integration.mdx +++ b/docs/manual/typescript-integration.mdx @@ -1,7 +1,7 @@ --- title: "TypeScript" description: "GenType - Interoperability between ReScript and TypeScript" -canonical: "/docs/manual/v12.0.0/typescript-integration" +canonical: "/docs/manual/typescript-integration" section: "JavaScript Interop" order: 15 --- diff --git a/pages/docs/manual/v12.0.0/use-illegal-identifier-names.mdx b/docs/manual/use-illegal-identifier-names.mdx similarity index 94% rename from pages/docs/manual/v12.0.0/use-illegal-identifier-names.mdx rename to docs/manual/use-illegal-identifier-names.mdx index 1bae9fc40..adc634c95 100644 --- a/pages/docs/manual/v12.0.0/use-illegal-identifier-names.mdx +++ b/docs/manual/use-illegal-identifier-names.mdx @@ -1,7 +1,7 @@ --- title: "Use Illegal Identifier Names" description: "Handling (JS) naming collisions in ReScript" -canonical: "/docs/manual/v12.0.0/use-illegal-identifier-names" +canonical: "/docs/manual/use-illegal-identifier-names" section: "JavaScript Interop" order: 11 --- diff --git a/pages/docs/manual/v12.0.0/variant.mdx b/docs/manual/variant.mdx similarity index 99% rename from pages/docs/manual/v12.0.0/variant.mdx rename to docs/manual/variant.mdx index 73375c624..4915d6fc4 100644 --- a/pages/docs/manual/v12.0.0/variant.mdx +++ b/docs/manual/variant.mdx @@ -1,7 +1,7 @@ --- title: "Variant" description: "Variant data structures in ReScript" -canonical: "/docs/manual/v12.0.0/variant" +canonical: "/docs/manual/variant" section: "Language Features" order: 9 --- diff --git a/pages/docs/manual/v12.0.0/warning-numbers.mdx b/docs/manual/warning-numbers.mdx similarity index 75% rename from pages/docs/manual/v12.0.0/warning-numbers.mdx rename to docs/manual/warning-numbers.mdx index 500e5af97..d84f4d4e1 100644 --- a/pages/docs/manual/v12.0.0/warning-numbers.mdx +++ b/docs/manual/warning-numbers.mdx @@ -1,12 +1,11 @@ --- title: "Warning Numbers" description: "Available compiler warning numbers in ReScript" -canonical: "/docs/manual/v12.0.0/warning-numbers" +canonical: "/docs/manual/warning-numbers" section: "Build System" order: 8 --- -import { make as WarningTable } from "src/components/WarningTable.mjs"; # Warning Numbers @@ -14,4 +13,4 @@ You can configure which warnings the ReScript compiler generates [in the build configuration](/docs/manual/next/build-configuration#warnings) or using the [`@warning()`](/syntax-lookup#expression-warning-decorator) or the [`@@warning()`](/syntax-lookup#module-warning-decorator) decorator. - +{/* TODO RR7 */} diff --git a/pages/docs/react/latest/arrays-and-keys.mdx b/docs/react/arrays-and-keys.mdx similarity index 100% rename from pages/docs/react/latest/arrays-and-keys.mdx rename to docs/react/arrays-and-keys.mdx diff --git a/pages/docs/react/latest/beyond-jsx.mdx b/docs/react/beyond-jsx.mdx similarity index 100% rename from pages/docs/react/latest/beyond-jsx.mdx rename to docs/react/beyond-jsx.mdx diff --git a/pages/docs/react/latest/components-and-props.mdx b/docs/react/components-and-props.mdx similarity index 100% rename from pages/docs/react/latest/components-and-props.mdx rename to docs/react/components-and-props.mdx diff --git a/pages/docs/react/latest/context.mdx b/docs/react/context.mdx similarity index 100% rename from pages/docs/react/latest/context.mdx rename to docs/react/context.mdx diff --git a/pages/docs/react/latest/elements-and-jsx.mdx b/docs/react/elements-and-jsx.mdx similarity index 100% rename from pages/docs/react/latest/elements-and-jsx.mdx rename to docs/react/elements-and-jsx.mdx diff --git a/pages/docs/react/latest/events.mdx b/docs/react/events.mdx similarity index 100% rename from pages/docs/react/latest/events.mdx rename to docs/react/events.mdx diff --git a/pages/docs/react/latest/extensions-of-props.mdx b/docs/react/extensions-of-props.mdx similarity index 100% rename from pages/docs/react/latest/extensions-of-props.mdx rename to docs/react/extensions-of-props.mdx diff --git a/pages/docs/react/latest/forwarding-refs.mdx b/docs/react/forwarding-refs.mdx similarity index 100% rename from pages/docs/react/latest/forwarding-refs.mdx rename to docs/react/forwarding-refs.mdx diff --git a/pages/docs/react/latest/hooks-context.mdx b/docs/react/hooks-context.mdx similarity index 100% rename from pages/docs/react/latest/hooks-context.mdx rename to docs/react/hooks-context.mdx diff --git a/pages/docs/react/latest/hooks-custom.mdx b/docs/react/hooks-custom.mdx similarity index 100% rename from pages/docs/react/latest/hooks-custom.mdx rename to docs/react/hooks-custom.mdx diff --git a/pages/docs/react/latest/hooks-effect.mdx b/docs/react/hooks-effect.mdx similarity index 100% rename from pages/docs/react/latest/hooks-effect.mdx rename to docs/react/hooks-effect.mdx diff --git a/pages/docs/react/latest/hooks-overview.mdx b/docs/react/hooks-overview.mdx similarity index 92% rename from pages/docs/react/latest/hooks-overview.mdx rename to docs/react/hooks-overview.mdx index bfdc58317..726e0bab2 100644 --- a/pages/docs/react/latest/hooks-overview.mdx +++ b/docs/react/hooks-overview.mdx @@ -95,11 +95,11 @@ This was just a quick example on our first hook usage. We will go into more deta ### Additional Hooks: - [useReducer](./hooks-reducer): An alternative to `useState`. Uses the state / action / reduce pattern. - - + {/* - [useCallback](./hooks-callback): Returns a memoized callback */} + {/* - [useMemo](./hooks-memo): Returns a memoized value */} - [useRef](./hooks-ref): Returns a mutable React-Ref value - - + {/* - [useImperativeHandle](./hooks-imperative-handle): Customizes the instance value that is exposed to parent components when using `ref` */} + {/* - [useLayoutEffect](./hooks-layout-effect): Identical to useEffect, but it fires synchronously after all DOM mutations. */} ## Rules of Hooks diff --git a/pages/docs/react/latest/hooks-reducer.mdx b/docs/react/hooks-reducer.mdx similarity index 100% rename from pages/docs/react/latest/hooks-reducer.mdx rename to docs/react/hooks-reducer.mdx diff --git a/pages/docs/react/latest/hooks-ref.mdx b/docs/react/hooks-ref.mdx similarity index 100% rename from pages/docs/react/latest/hooks-ref.mdx rename to docs/react/hooks-ref.mdx diff --git a/pages/docs/react/latest/hooks-state.mdx b/docs/react/hooks-state.mdx similarity index 100% rename from pages/docs/react/latest/hooks-state.mdx rename to docs/react/hooks-state.mdx diff --git a/pages/docs/react/latest/import-export-reactjs.mdx b/docs/react/import-export-reactjs.mdx similarity index 100% rename from pages/docs/react/latest/import-export-reactjs.mdx rename to docs/react/import-export-reactjs.mdx diff --git a/pages/docs/react/latest/installation.mdx b/docs/react/installation.mdx similarity index 100% rename from pages/docs/react/latest/installation.mdx rename to docs/react/installation.mdx diff --git a/pages/docs/react/latest/introduction.mdx b/docs/react/introduction.mdx similarity index 100% rename from pages/docs/react/latest/introduction.mdx rename to docs/react/introduction.mdx diff --git a/pages/docs/react/latest/lazy-components.mdx b/docs/react/lazy-components.mdx similarity index 100% rename from pages/docs/react/latest/lazy-components.mdx rename to docs/react/lazy-components.mdx diff --git a/docs/react/llms.mdx b/docs/react/llms.mdx new file mode 100644 index 000000000..b986e4ee1 --- /dev/null +++ b/docs/react/llms.mdx @@ -0,0 +1,24 @@ +--- +title: "LLMs" +description: "Documentation for LLMs" +canonical: "/docs/react/latest/llms" +section: "Extra" +--- + +# Documentation for LLMs + +We adhere to the [llms.txt convention](https://llmstxt.org/) to make documentation accessible to large language models and their applications. + +Currently, we have the following files... + +- [/docs/react/llms.txt](/llms/react/latest/llms.txt) — a list of the available files for ReScript React. +- [/docs/react/llms-full.txt](/llms/react/latest/llm-full.txt) — complete documentation for ReScript React. +- [/docs/react/llms-small.txt](/llms/react/latest/llm-small.txt) — compressed version of the former, without examples for ReScript React. + +...and the language documentation: + +- [/docs/manual/llms](/docs/manual/latest/llms) — the LLms documentation for ReScript. + +## Notes + +- The content is automatically generated from the same source as the official documentation for the specific version diff --git a/pages/docs/react/latest/memo.mdx b/docs/react/memo.mdx similarity index 100% rename from pages/docs/react/latest/memo.mdx rename to docs/react/memo.mdx diff --git a/pages/docs/react/latest/refs-and-the-dom.mdx b/docs/react/refs-and-the-dom.mdx similarity index 100% rename from pages/docs/react/latest/refs-and-the-dom.mdx rename to docs/react/refs-and-the-dom.mdx diff --git a/pages/docs/react/latest/rendering-elements.mdx b/docs/react/rendering-elements.mdx similarity index 100% rename from pages/docs/react/latest/rendering-elements.mdx rename to docs/react/rendering-elements.mdx diff --git a/pages/docs/react/latest/router.mdx b/docs/react/router.mdx similarity index 100% rename from pages/docs/react/latest/router.mdx rename to docs/react/router.mdx diff --git a/pages/docs/react/latest/server-components.mdx b/docs/react/server-components.mdx similarity index 100% rename from pages/docs/react/latest/server-components.mdx rename to docs/react/server-components.mdx diff --git a/pages/docs/react/latest/styling.mdx b/docs/react/styling.mdx similarity index 100% rename from pages/docs/react/latest/styling.mdx rename to docs/react/styling.mdx diff --git a/generate-route-types.mjs b/generate-route-types.mjs new file mode 100644 index 000000000..3c1693a79 --- /dev/null +++ b/generate-route-types.mjs @@ -0,0 +1,16 @@ +import fs from "fs/promises"; +import { init } from "react-router-mdx/server"; + +init({ paths: ["_blogposts", "docs"], aliases: ["blog", "docs"] }); + +const { default: routes } = await import("./app/routes.mjs"); + +const paths = routes.map((route) => `#"/${route.path}"`).join(" |\n"); + +await fs.writeFile( + "src/Path.res", + `type t = [ +${paths} +] +`, +); diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index 36aa1a4dc..000000000 --- a/jsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": "." - } -} diff --git a/mdx-manifest.json b/mdx-manifest.json new file mode 100644 index 000000000..6e8615207 --- /dev/null +++ b/mdx-manifest.json @@ -0,0 +1,1338 @@ +[ + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2025-04-11-introducing-unified-operators.mdx", + "slug": "2025-04-11-introducing-unified-operators", + "author": "rescript-team", + "date": "2025-04-11", + "title": "Rethinking Operators", + "badge": "roadmap", + "description": "Discover how unified operators in ReScript v12 simplify arithmetic, reduce syntax noise — plus, a glimpse into the future roadmap.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2025-03-17-retreats.mdx", + "slug": "2025-03-17-retreats", + "author": "rescript-association", + "date": "2025-03-17", + "previewImg": "/blog/rescript_retreat_2024.jpg", + "articleImg": "/blog/rescript_retreat_2024.jpg", + "title": "ReScript Retreat", + "description": "Accelerating ReScript development through meeting in-person.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2025-03-05-what-can-i-do-with-rescript.mdx", + "slug": "2025-03-05-what-can-i-do-with-rescript", + "author": "josh-derocher-vlk", + "date": "2025-03-05", + "title": "What can I do with ReScript?", + "badge": "community", + "description": "Can I use Vite, or Next.js? Is it only for React? Can I use Node or Deno?\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2024-02-01-release-11-1-0.mdx", + "slug": "2024-02-01-release-11-1-0", + "author": "rescript-team", + "date": "2024-04-19", + "previewImg": "/blog/compiler_release_11_1.jpg", + "title": "ReScript 11.1", + "badge": "release", + "description": "Unleashing ReScript from React\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2024-01-11-release-11-0-0.mdx", + "slug": "2024-01-11-release-11-0-0", + "author": "rescript-team", + "date": "2024-01-11", + "previewImg": "/blog/compiler_release_11_0.jpg", + "title": "ReScript 11.0", + "badge": "release", + "description": "The ReScript developer experience now goes up to eleven!\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2023-09-18-uncurried-mode.mdx", + "slug": "2023-09-18-uncurried-mode", + "author": "rescript-team", + "date": "2023-09-18", + "title": "Uncurried Mode", + "badge": "roadmap", + "description": "A tour of new capabilities coming to ReScript v11\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2023-06-05-first-class-dynamic-import-support.mdx", + "slug": "2023-06-05-first-class-dynamic-import-support", + "author": "rescript-team", + "date": "2023-06-05", + "title": "First-class Dynamic Import Support", + "badge": "roadmap", + "description": "A tour of new capabilities coming to ReScript v11\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2023-05-17-enhanced-ergonomics-for-record-types.mdx", + "slug": "2023-05-17-enhanced-ergonomics-for-record-types", + "author": "rescript-team", + "date": "2023-05-17", + "title": "Enhanced Ergonomics for Record Types", + "badge": "roadmap", + "description": "A tour of new capabilities coming to ReScript v11\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2023-04-17-improving-interop.mdx", + "slug": "2023-04-17-improving-interop", + "author": "rescript-team", + "date": "2023-04-17", + "title": "Better interop with customizable variants", + "badge": "roadmap", + "description": "A tour of new capabilities coming in ReScript v11\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2023-02-02-release-10-1.mdx", + "slug": "2023-02-02-release-10-1", + "author": "rescript-team", + "date": "2023-02-02", + "title": "ReScript 10.1", + "badge": "release", + "description": "Async/await & better Promise support, JSX v4, and more!\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2022-08-25-release-10-0-0.mdx", + "slug": "2022-08-25-release-10-0-0", + "author": "rescript-team", + "date": "2022-08-25", + "previewImg": "static/blog/grid_0.jpeg", + "title": "ReScript 10.0", + "badge": "release", + "description": "The first community powered release.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2021-06-25-roadmap-2021-and-new-landing-page.mdx", + "slug": "2021-06-25-roadmap-2021-and-new-landing-page", + "author": "rescript-team", + "date": "2021-06-25", + "title": "Roadmap 2021 & New Landing Page", + "badge": "roadmap", + "description": "Announcing our roadmap for 2021 / 2022, release cycle plans and new landing page.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2021-05-07-release-9-1.mdx", + "slug": "2021-05-07-release-9-1", + "author": "rescript-team", + "date": "2021-05-07", + "previewImg": "/blog/compiler_release_9_1.jpg", + "title": "ReScript 9.1", + "badge": "release", + "description": "Featuring a new npm package, a CLI revamp, polymorphic variant interop and object cleanup.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2021-03-03-rescript-association-rebranding.mdx", + "slug": "2021-03-03-rescript-association-rebranding", + "author": "rescript-association", + "date": "2021-03-03", + "previewImg": "/blog/rescript_assoc_rename_preview.jpg", + "title": "The ReScript Association", + "description": "After the rebranding of ReScript, its Reason Association has now followed through to become the ReScript Association.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2021-02-09-release-9-0.mdx", + "slug": "2021-02-09-release-9-0", + "author": "hongbo", + "date": "2021-02-09", + "previewImg": "/blog/compiler_release_9_0.jpg", + "title": "ReScript 9.0", + "badge": "release", + "description": "Featuring a new external stdlib configuration, some syntax improvements and a small breaking change for nested records.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2020-12-07-release-8-4.mdx", + "slug": "2020-12-07-release-8-4", + "author": "hongbo", + "date": "2020-12-07", + "previewImg": null, + "badge": "release", + "title": "ReScript 8.4", + "description": "bsb improvements\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2020-11-26-editor-support-release-1-0.mdx", + "slug": "2020-11-26-editor-support-release-1-0", + "author": "rescript-team", + "date": "2020-11-26", + "previewImg": "/blog/editor_support_preview.jpg", + "articleImg": "/blog/editor_support_article.jpg", + "badge": "release", + "title": "Editor Plugin for VSCode and Vim Officially Released!", + "description": "Type hints, jump to definition, error diagnostics, and more.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2020-11-17-editor-support-custom-operators-and-more.mdx", + "slug": "2020-11-17-editor-support-custom-operators-and-more", + "author": "maxim", + "date": "2020-11-17", + "previewImg": null, + "badge": "roadmap", + "title": "Editor Support, Custom Operators and More", + "description": "Update on what we're doing around the end of 2020 and early next year.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2020-09-25-release-8-3.mdx", + "slug": "2020-09-25-release-8-3", + "author": "hongbo", + "date": "2020-09-25", + "previewImg": null, + "title": "What's new in ReScript 8.3 (Part 1)", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2020-09-25-release-8-3-2.mdx", + "slug": "2020-09-25-release-8-3-2", + "author": "hongbo", + "date": "2020-09-26", + "previewImg": null, + "title": "What's new in ReScript 8.3 (Part 2)", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2020-08-28-new-rescript-logo.mdx", + "slug": "2020-08-28-new-rescript-logo", + "author": "made_by_betty", + "date": "2020-08-27", + "title": "A New Logo for ReScript", + "articleImg": "/blog/rescript-launch/ReScript-3.jpg", + "description": "Today, our resident designer Bettina is unveiling to us the fresh new ReScript branding we've been long waiting for. We hope you're as excited about the result as us!\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/2020-08-10-bucklescript-is-rebranding.mdx", + "slug": "2020-08-10-bucklescript-is-rebranding", + "author": "rescript-team", + "date": "2020-08-10", + "badge": "roadmap", + "title": "BuckleScript & Reason Rebranding", + "description": "A new unified experience for the platform" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-08-03-bucklescript-release-8-2.mdx", + "slug": "2020-08-03-bucklescript-release-8-2", + "author": "hongbo", + "date": "2020-08-03", + "badge": "release", + "title": "BuckleScript 8.2 released", + "description": "New release 8.2" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-07-28-string-literal-types-in-reason.mdx", + "slug": "2020-07-28-string-literal-types-in-reason", + "author": "hongbo", + "date": "2020-07-28", + "previewImg": null, + "title": "Introducing string literal types in BuckleScript version 8.2", + "description": "Highlights of our newest changes to the internal representation\nand how they will benefit our users.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-07-17-bucklescript-release-8-1-1.mdx", + "slug": "2020-07-17-bucklescript-release-8-1-1", + "author": "chenglou", + "date": "2020-07-17", + "badge": "release", + "title": "BuckleScript 8.1.1 released", + "description": "New Syntax Tweaks, Formatter and Converter" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-07-06-a-note-on-bucklescripts-future-commitments.mdx", + "slug": "2020-07-06-a-note-on-bucklescripts-future-commitments", + "author": "chenglou", + "co-authors": [ + "ryyppy" + ], + "date": "2020-07-06", + "title": "A Note on BuckleScript's New Syntax and Its Future Support Commitments", + "description": "This post clarifies the goals and commitments of the BuckleScript compiler toolchain\nand gives more context on what to expect in the future.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-07-01-bucklescript-8-1-new-syntax.mdx", + "slug": "2020-07-01-bucklescript-8-1-new-syntax", + "author": "chenglou", + "date": "2020-07-01", + "badge": "release", + "title": "A New Syntax for BuckleScript", + "description": "First announcements on our latest efforts for a better syntax parser.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-06-22-overview-of-new_encoding.mdx", + "slug": "2020-06-22-overview-of-new_encoding", + "author": "hongbo", + "date": "2020-06-22", + "previewImg": null, + "title": "Make generated JavaScript Inline Caching friendly using types in BuckleScript version 8", + "description": "Highlights of our newest changes to the internal representation\nand how they will benefit our users.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-05-15-state-of-reasonml-org-2020-q2-pt4.mdx", + "slug": "2020-05-15-state-of-reasonml-org-2020-q2-pt4", + "author": "ryyppy", + "date": "2020-05-15", + "previewImg": "/blog/archive/state-of-reasonml-org-q2-2020.jpg", + "title": "State of reasonml.org 2020-Q2 / Pt. 4", + "description": "A report on recent achievements in the reasonml.org project.\nThis is the final part of the series about our vision of a more accessible Reason platform.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-05-15-a-story-of-lazy-encoding.mdx", + "slug": "2020-05-15-a-story-of-lazy-encoding", + "author": "hongbo", + "date": "2020-05-15", + "previewImg": null, + "title": "New Lazy Encoding in BuckleScript", + "description": "Highlights of our newest changes to the internal representation of lazy values\nand how it will benefit our users.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-05-12-state-of-reasonml-org-2020-q2-pt3.mdx", + "slug": "2020-05-12-state-of-reasonml-org-2020-q2-pt3", + "author": "ryyppy", + "date": "2020-05-12", + "previewImg": "/blog/archive/state-of-reasonml-org-q2-2020.jpg", + "title": "State of reasonml.org 2020-Q2 / Pt. 3", + "description": "A report on recent achievements in the reasonml.org project. In this part we\ntalk about upcoming tools and features.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-05-11-state-of-reasonml-org-2020-q2-pt2.mdx", + "slug": "2020-05-11-state-of-reasonml-org-2020-q2-pt2", + "author": "ryyppy", + "date": "2020-05-11", + "previewImg": "/blog/archive/state-of-reasonml-org-q2-2020.jpg", + "articleImg": "/blog/archive/state-of-reasonml-2020-q2-pt2-articleimg.jpg", + "title": "State of reasonml.org 2020-Q2 / Pt. 2", + "description": "A report on recent achievements in the reasonml.org project. This part is all\nabout quality assurance and time commitment.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-05-06-state-of-reasonml-org-2020-q2-pt1.mdx", + "slug": "2020-05-06-state-of-reasonml-org-2020-q2-pt1", + "author": "ryyppy", + "date": "2020-05-06", + "previewImg": "/blog/archive/state-of-reasonml-org-q2-2020.jpg", + "articleImg": "/blog/archive/state-of-reasonml-pt1-hero.jpg", + "title": "State of reasonml.org 2020-Q2 / Pt. 1", + "description": "A report on recent achievements in the reasonml.org project and what\nto expect in the future. The first part is an introduction to our project.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-05-06-a-story-of-exception-encoding.mdx", + "slug": "2020-05-06-a-story-of-exception-encoding", + "author": "hongbo", + "date": "2020-05-06", + "previewImg": null, + "title": "New Exception Encoding in BuckleScript", + "description": "Highlights of our newest changes to the internal representation of exceptions\nand how it will provide better stacktraces to our users.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-04-13-bucklescript-release-7-3.mdx", + "slug": "2020-04-13-bucklescript-release-7-3", + "author": "hongbo", + "date": "2020-04-13", + "badge": "release", + "title": "Announcing BuckleScript 7.3", + "description": "Featuring major improvements like Generalized Uncurry Convention Support and\nunit value to undefined compilation.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-03-26-generalize-uncurry.mdx", + "slug": "2020-03-26-generalize-uncurry", + "author": "hongbo", + "date": "2020-03-26", + "previewImg": null, + "title": "Generalized Uncurry Support in 7.3", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-03-12-bucklescript-release-7-2.mdx", + "slug": "2020-03-12-bucklescript-release-7-2", + "author": "hongbo", + "date": "2020-03-12", + "previewImg": null, + "tags": [ + "Release" + ], + "title": "Announcing BuckleScript 7.2", + "description": "This release will give us some small quality of life improvements for tool\nbuilders, better performance, and a new let %private modifier for hiding\nmodule functionality.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-02-20-loading-stdlib-in-memory.mdx", + "slug": "2020-02-20-loading-stdlib-in-memory", + "author": "hongbo", + "date": "2020-02-20", + "previewImg": null, + "title": "Improving the Stdlib Loading mechanism", + "description": "We want to give you some insights on how we will improve the way BuckleScript\ncompiles and handles its stdlib modules.\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-02-07-union-types-in-bucklescript.mdx", + "slug": "2020-02-07-union-types-in-bucklescript", + "author": "hongbo", + "date": "2020-02-07", + "previewImg": null, + "title": "Union types in BuckleScript", + "description": "In our our 7.1.0 release we introduced the new [@unboxed] feature for better\nzero-cost interop with GADTs, Variants and single field records. Let's find\nout how this will help us expressing Union types with seamless interop!\n" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2020-02-04-bucklescript-release-7-1-0.mdx", + "slug": "2020-02-04-bucklescript-release-7-1-0", + "author": "hongbo", + "date": "2020-02-04", + "previewImg": null, + "tags": [ + "Release" + ], + "title": "Announcing BuckleScript 7.1.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-12-20-bucklescript-release-7-0-2.mdx", + "slug": "2019-12-20-bucklescript-release-7-0-2", + "author": "hongbo", + "date": "2019-12-20", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 7.0.2-dev.1", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-11-28-whats-new-in-7-pt2.mdx", + "slug": "2019-11-28-whats-new-in-7-pt2", + "author": "hongbo", + "date": "2019-11-28", + "previewImg": null, + "badge": "testing", + "title": "What's new in BuckleScript v7 (Part 2)", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-11-18-whats-new-in-7-pt1.mdx", + "slug": "2019-11-18-whats-new-in-7-pt1", + "author": "hongbo", + "date": "2019-11-18", + "previewImg": null, + "badge": "testing", + "title": "What's new in BuckleScript v7 (Part 1)", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-10-16-another-encoding.mdx", + "slug": "2019-10-16-another-encoding", + "author": "hongbo", + "date": "2019-10-16", + "previewImg": null, + "title": "Another way of encoding type identity for BuckleScript libraries without using big functor", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-09-23-bucklescript-release-5-2-0.mdx", + "slug": "2019-09-23-bucklescript-release-5-2-0", + "author": "hongbo", + "date": "2019-09-23", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 5.2.0 / 6.2.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-08-12-bucklescript-release-5-1-0.mdx", + "slug": "2019-08-12-bucklescript-release-5-1-0", + "author": "hongbo", + "date": "2019-08-12", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 5.1.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-06-26-bucklescript-release-5-0-5.mdx", + "slug": "2019-06-26-bucklescript-release-5-0-5", + "author": "hongbo", + "date": "2019-06-26", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 5.0.5 and 6.0.2", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-05-21-ffi-overview.mdx", + "slug": "2019-05-21-ffi-overview", + "author": "hongbo", + "date": "2019-05-21", + "previewImg": null, + "title": "A High Level Overview of BuckleScript Interop with JS", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-04-22-bucklescript-release-5-0-4.mdx", + "slug": "2019-04-22-bucklescript-release-5-0-4", + "author": "hongbo", + "date": "2019-04-22", + "previewImg": null, + "title": "Architectural Changes in BuckleScript 5.0.4 and 6.0.1", + "badge": "release", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-04-09-bucklescript-release-5-0-1.mdx", + "slug": "2019-04-09-bucklescript-release-5-0-1", + "author": "hongbo", + "date": "2019-04-09", + "previewImg": null, + "badge": "testing", + "title": "Announcing BuckleScript 5.0.1", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-03-31-bucklescript-release-6-0.mdx", + "slug": "2019-03-31-bucklescript-release-6-0", + "author": "hongbo", + "date": "2019-03-31", + "previewImg": null, + "badge": "testing", + "title": "Announcing BuckleScript 6.0.0-dev.1", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-03-21-bucklescript-release-5-0.mdx", + "slug": "2019-03-21-bucklescript-release-5-0", + "author": "hongbo", + "date": "2019-03-21", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 5.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-03-01-feature-preview-variadic.mdx", + "slug": "2019-03-01-feature-preview-variadic", + "author": "hongbo", + "date": "2019-03-01", + "previewImg": null, + "badge": "preview", + "title": "First-class bs.variadic Support in the Next Release", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-01-11-scalable.mdx", + "slug": "2019-01-11-scalable", + "author": "hongbo", + "date": "2019-01-11", + "previewImg": null, + "title": "In search of lightning feedback loop in a large codebase", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2019-01-07-bucklescript-release-4-0-17.mdx", + "slug": "2019-01-07-bucklescript-release-4-0-17", + "author": "hongbo", + "date": "2019-01-07", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 4.0.17", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-12-05-bucklescript-release-4-0-8.mdx", + "slug": "2018-12-05-bucklescript-release-4-0-8", + "author": "hongbo", + "date": "2018-12-05", + "previewImg": null, + "badge": "release", + "title": "BuckleScript 4.0.8 (Part One)", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-11-19-bucklescript-roadmap-q3-4-2018.mdx", + "slug": "2018-11-19-bucklescript-roadmap-q3-4-2018", + "author": "hongbo", + "date": "2018-11-19", + "previewImg": null, + "badge": "roadmap", + "title": "BuckleScript Plans for the Second Half of 2018", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-11-13-arity-zero.mdx", + "slug": "2018-11-13-arity-zero", + "author": "hongbo", + "date": "2018-11-13", + "previewImg": null, + "title": "A Change of Undefined Behavior in BuckleScript 4.0.7", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-07-17-bucklescript-release-4-0-0-pt2.mdx", + "slug": "2018-07-17-bucklescript-release-4-0-0-pt2", + "author": "hongbo", + "date": "2018-07-17", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 4.0 (Part Two)", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-07-17-bucklescript-release-4-0-0-pt1.mdx", + "slug": "2018-07-17-bucklescript-release-4-0-0-pt1", + "author": "hongbo", + "date": "2018-07-17", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 4.0 (Part One)", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-05-23-bucklescript-release-3-1-4.mdx", + "slug": "2018-05-23-bucklescript-release-3-1-4", + "author": "hongbo", + "date": "2018-05-23", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 3.1.4", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-05-21-bucklescript-release-3-1-0.mdx", + "slug": "2018-05-21-bucklescript-release-3-1-0", + "author": "hongbo", + "date": "2018-05-21", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 3.1", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-04-16-bucklescript-release-3-0-0.mdx", + "slug": "2018-04-16-bucklescript-release-3-0-0", + "author": "hongbo", + "date": "2018-04-16", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 3.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2018-03-13-a-small-step-for-bucklescript.mdx", + "slug": "2018-03-13-a-small-step-for-bucklescript", + "author": "hongbo", + "date": "2018-03-13", + "previewImg": null, + "title": "A Small Step for BuckleScript...", + "description": "...and a big one for the community!" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-09-bucklescript-release-1-7-5.mdx", + "slug": "2017-10-09-bucklescript-release-1-7-5", + "author": "hongbo", + "date": "2017-10-09", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.7.5", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-08-bucklescript-release-1-7-4.mdx", + "slug": "2017-10-08-bucklescript-release-1-7-4", + "author": "hongbo", + "date": "2017-10-08", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.7.4", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-07-bucklescript-release-1-7-0.mdx", + "slug": "2017-10-07-bucklescript-release-1-7-0", + "author": "hongbo", + "date": "2017-10-07", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.7.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-06-bucklescript-release-1-5-2.mdx", + "slug": "2017-10-06-bucklescript-release-1-5-2", + "author": "hongbo", + "date": "2017-10-06", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.5.2", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-05-bucklescript-release-1-5-1.mdx", + "slug": "2017-10-05-bucklescript-release-1-5-1", + "author": "hongbo", + "date": "2017-10-05", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.5.1", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-04-bucklescript-release-1-5-0.mdx", + "slug": "2017-10-04-bucklescript-release-1-5-0", + "author": "hongbo", + "date": "2017-10-04", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.5.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-03-bucklescript-release-1-4-3.mdx", + "slug": "2017-10-03-bucklescript-release-1-4-3", + "author": "hongbo", + "date": "2017-10-03", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.4.3", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-02-bucklescript-release-1-4-2.mdx", + "slug": "2017-10-02-bucklescript-release-1-4-2", + "author": "hongbo", + "date": "2017-10-02", + "previewImg": null, + "badge": "release", + "title": "Announcing BuckleScript 1.4.2", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/_blogposts/archive/2017-10-01-bucklescript-release-1-0.mdx", + "slug": "2017-10-01-bucklescript-release-1-0", + "author": "hongbo", + "date": "2017-10-01", + "previewImg": null, + "badge": "release", + "title": "Bloomberg announces BuckleScript 1.0", + "description": "" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/styling.mdx", + "slug": "styling", + "title": "Styling", + "description": "Styling in ReScript & React", + "canonical": "/docs/react/latest/styling" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/server-components.mdx", + "slug": "server-components", + "title": "Server Components", + "description": "Creating React components", + "canonical": "/docs/react/latest/server-components" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/router.mdx", + "slug": "router", + "title": "Router", + "description": "Basic concepts for navigation and routing in ReScript & React", + "canonical": "/docs/react/latest/router" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/rendering-elements.mdx", + "slug": "rendering-elements", + "title": "Rendering Elements", + "description": "How to render React elements to the DOM", + "canonical": "/docs/react/latest/rendering-elements" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/refs-and-the-dom.mdx", + "slug": "refs-and-the-dom", + "title": "Refs and the DOM", + "description": "Using Refs and DOM elements in ReScript and React", + "canonical": "/docs/react/latest/refs-and-the-dom" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/migrate-react.mdx", + "slug": "migrate-react", + "title": "Migrate from JSX v3", + "description": "Migrate from JSX v3", + "canonical": "/docs/react/latest/migrate-react" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/memo.mdx", + "slug": "memo", + "title": "memo", + "description": "Using React.memo", + "canonical": "/docs/react/latest/memo" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/lazy-components.mdx", + "slug": "lazy-components", + "title": "Lazy Components", + "description": "Details on how to use the React.lazy_ API to dynamically import components", + "canonical": "/docs/react/latest/lazy-components" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/introduction.mdx", + "slug": "introduction", + "title": "Introduction", + "description": "Introduction to ReScript & ReactJS", + "canonical": "/docs/react/latest/introduction" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/installation.mdx", + "slug": "installation", + "title": "Installation", + "description": "Installation and Setup", + "canonical": "/docs/react/latest/installation" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/import-export-reactjs.mdx", + "slug": "import-export-reactjs", + "title": "Import / Export ReactJS", + "description": "Reusing existing React components", + "canonical": "/docs/react/latest/import-export-reactjs" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/hooks-state.mdx", + "slug": "hooks-state", + "title": "useState Hook", + "description": "Details about the useState React hook in ReScript", + "canonical": "/docs/react/latest/hooks-state" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/hooks-ref.mdx", + "slug": "hooks-ref", + "title": "useRef Hook", + "description": "Details about the useRef React hook in ReScript", + "canonical": "/docs/react/latest/hooks-ref" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/hooks-reducer.mdx", + "slug": "hooks-reducer", + "title": "useReducer Hook", + "description": "Details about the useReducer React hook in ReScript", + "canonical": "/docs/react/latest/hooks-reducer" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/hooks-overview.mdx", + "slug": "hooks-overview", + "title": "Hooks & State Management Overview", + "description": "Overview state management and hooks in ReScript and React", + "canonical": "/docs/react/latest/hooks-overview" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/hooks-effect.mdx", + "slug": "hooks-effect", + "title": "useEffect Hook", + "description": "Details about the useEffect React hook in ReScript", + "canonical": "/docs/react/latest/hooks-effect" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/hooks-custom.mdx", + "slug": "hooks-custom", + "title": "Build A Custom Hook", + "description": "How to build your own hooks in ReScript & React", + "canonical": "/docs/react/latest/hooks-custom" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/hooks-context.mdx", + "slug": "hooks-context", + "title": "useContext Hook", + "description": "Details about the useContext React hook in ReScript", + "canonical": "/docs/react/latest/hooks-context" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/forwarding-refs.mdx", + "slug": "forwarding-refs", + "title": "Forwarding Refs", + "description": "Forwarding Ref values in ReScript and React", + "canonical": "/docs/react/latest/forwarding-refs" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/extensions-of-props.mdx", + "slug": "extensions-of-props", + "title": "Extensions of props", + "description": "Extensions of props in ReScript and React", + "canonical": "/docs/react/latest/spread-props" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/events.mdx", + "slug": "events", + "title": "Events", + "description": "Event handlers for React elements", + "canonical": "/docs/react/latest/events" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/elements-and-jsx.mdx", + "slug": "elements-and-jsx", + "title": "Elements & JSX", + "description": "Basic concepts for React elements and how to use them in JSX", + "canonical": "/docs/react/latest/elements-and-jsx" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/context.mdx", + "slug": "context", + "title": "Context", + "description": "Details about Context in ReScript and React", + "canonical": "/docs/react/latest/context" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/components-and-props.mdx", + "slug": "components-and-props", + "title": "Components and Props", + "description": "Basic concepts for components and props in ReScript & React", + "canonical": "/docs/react/latest/components-and-props" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/beyond-jsx.mdx", + "slug": "beyond-jsx", + "title": "Beyond JSX", + "description": "Details on how to use ReScript and React without JSX", + "canonical": "/docs/react/latest/beyond-jsx" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/react/arrays-and-keys.mdx", + "slug": "arrays-and-keys", + "title": "Arrays and Keys", + "description": "Rendering arrays and handling keys in ReScript and React", + "canonical": "/docs/react/latest/arrays-and-keys" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/warning-numbers.mdx", + "slug": "warning-numbers", + "title": "Warning Numbers", + "description": "Available compiler warning numbers in ReScript", + "canonical": "/docs/manual/v12.0.0/warning-numbers" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/variant.mdx", + "slug": "variant", + "title": "Variant", + "description": "Variant data structures in ReScript", + "canonical": "/docs/manual/v12.0.0/variant" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/use-illegal-identifier-names.mdx", + "slug": "use-illegal-identifier-names", + "title": "Use Illegal Identifier Names", + "description": "Handling (JS) naming collisions in ReScript", + "canonical": "/docs/manual/v12.0.0/use-illegal-identifier-names" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/typescript-integration.mdx", + "slug": "typescript-integration", + "title": "TypeScript", + "description": "GenType - Interoperability between ReScript and TypeScript", + "canonical": "/docs/manual/v12.0.0/typescript-integration" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/type.mdx", + "slug": "type", + "title": "Type", + "description": "Types and type definitions in ReScript", + "canonical": "/docs/manual/v12.0.0/type" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/tuple.mdx", + "slug": "tuple", + "title": "Tuple", + "description": "Tuple types and values in ReScript", + "canonical": "/docs/manual/v12.0.0/tuple" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/try.mdx", + "slug": "try", + "title": "Try", + "description": "Try ReScript via Command Line", + "canonical": "/docs/manual/v12.0.0/try" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/tagged-templates.mdx", + "slug": "tagged-templates", + "title": "Tagged templates", + "description": "Using tagged templates in ReScript", + "canonical": "/docs/manual/v12.0.0/tagged-templates" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/shared-data-types.mdx", + "slug": "shared-data-types", + "title": "Shared Data Types", + "description": "Data types that share runtime presentation between JS and ReScript", + "canonical": "/docs/manual/v12.0.0/shared-data-types" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/scoped-polymorphic-types.mdx", + "slug": "scoped-polymorphic-types", + "title": "Scoped Polymorphic Types", + "description": "Scoped Polymorphic Types in ReScript", + "canonical": "/docs/manual/v12.0.0/scoped-polymorphic-types" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/reserved-keywords.mdx", + "slug": "reserved-keywords", + "title": "Reserved Keywords", + "description": "All reserved keywords in ReScript", + "canonical": "/docs/manual/v12.0.0/reserved-keywords" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/record.mdx", + "slug": "record", + "title": "Record", + "description": "Record types in ReScript", + "canonical": "/docs/manual/v12.0.0/record" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/promise.mdx", + "slug": "promise", + "title": "Promises", + "description": "JS Promise handling in ReScript", + "canonical": "/docs/manual/v12.0.0/promise" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/project-structure.mdx", + "slug": "project-structure", + "title": "Project Structure", + "description": "Notes on project structure and other rough ReScript guidelines", + "canonical": "/docs/manual/v12.0.0/project-structure" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/primitive-types.mdx", + "slug": "primitive-types", + "title": "Primitive Types", + "description": "Primitive Data Types in ReScript", + "canonical": "/docs/manual/v12.0.0/primitive-types" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/polymorphic-variant.mdx", + "slug": "polymorphic-variant", + "title": "Polymorphic Variant", + "description": "The Polymorphic Variant data structure in ReScript", + "canonical": "/docs/manual/v12.0.0/polymorphic-variant" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/pipe.mdx", + "slug": "pipe", + "title": "Pipe", + "description": "The Pipe operator (->)", + "canonical": "/docs/manual/v12.0.0/pipe" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/pattern-matching-destructuring.mdx", + "slug": "pattern-matching-destructuring", + "title": "Pattern Matching / Destructuring", + "description": "Pattern matching and destructuring complex data structures in ReScript", + "canonical": "/docs/manual/v12.0.0/pattern-matching-destructuring" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/overview.mdx", + "slug": "overview", + "title": "Overview", + "metaTitle": "Language Features Overview", + "description": "A quick overview on ReScript's syntax", + "canonical": "/docs/manual/v12.0.0/overview" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/object.mdx", + "slug": "object", + "title": "Object", + "description": "Interoping with JS objects in ReScript", + "canonical": "/docs/manual/v12.0.0/object" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/null-undefined-option.mdx", + "slug": "null-undefined-option", + "title": "Null, Undefined and Option", + "description": "JS interop with nullable and optional values in ReScript", + "canonical": "/docs/manual/v12.0.0/null-undefined-option" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/mutation.mdx", + "slug": "mutation", + "title": "Mutation", + "description": "Imperative and mutative programming capabilities in ReScript", + "canonical": "/docs/manual/v12.0.0/mutation" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/module.mdx", + "slug": "module", + "title": "Module", + "description": "ReScript modules, module signatures and interface files", + "canonical": "/docs/manual/v12.0.0/module" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/migrate-to-v11.mdx", + "slug": "migrate-to-v11", + "title": "Migrate to v11", + "description": "Instructions on upgrading to ReScript 11", + "canonical": "/docs/manual/v12.0.0/migrate-to-v11" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/libraries.mdx", + "slug": "libraries", + "title": "Libraries & Publishing", + "description": "Install & publish ReScript packages", + "canonical": "/docs/manual/v12.0.0/libraries" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/let-binding.mdx", + "slug": "let-binding", + "title": "Let Binding", + "description": "Let binding syntax for binding to values in ReScript", + "canonical": "/docs/manual/v12.0.0/let-binding" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/lazy-values.mdx", + "slug": "lazy-values", + "title": "Lazy Value", + "description": "Data type for deferred computation in ReScript", + "canonical": "/docs/manual/v12.0.0/lazy-values" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/jsx.mdx", + "slug": "jsx", + "title": "JSX", + "description": "JSX syntax in ReScript and React", + "canonical": "/docs/manual/v12.0.0/jsx" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/json.mdx", + "slug": "json", + "title": "JSON", + "description": "Interacting with JSON in ReScript", + "canonical": "/docs/manual/v12.0.0/json" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/introduction.mdx", + "slug": "introduction", + "title": "Introduction", + "description": "Introduction to the ReScript programming language", + "category": "manual", + "section": "overview", + "order": 1 + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/interop-with-js-build-systems.mdx", + "slug": "interop-with-js-build-systems", + "title": "Interop with JS Build Systems", + "description": "Documentation on how to interact with existing JS build systems", + "canonical": "/docs/manual/v12.0.0/interop-with-js-build-systems" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/interop-cheatsheet.mdx", + "slug": "interop-cheatsheet", + "title": "Interop Cheatsheet", + "description": "Cheatsheet for various interop scenarios in ReScript", + "canonical": "/docs/manual/v12.0.0/interop-cheatsheet" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/installation.mdx", + "slug": "installation", + "title": "Installation", + "description": "ReScript installation and setup instructions", + "canonical": "/docs/manual/v12.0.0/installation" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/inlining-constants.mdx", + "slug": "inlining-constants", + "title": "Inlining Constants", + "description": "Inlining constants", + "canonical": "/docs/manual/v12.0.0/inlining-constants" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/import-from-export-to-js.mdx", + "slug": "import-from-export-to-js", + "title": "Import from / Export to JS", + "description": "Importing / exporting JS module content in ReScript", + "canonical": "/docs/manual/v12.0.0/import-from-export-to-js" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/import-export.mdx", + "slug": "import-export", + "title": "Import & Export", + "description": "Importing / exporting in ReScript modules", + "canonical": "/docs/manual/v12.0.0/import-export" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/generate-converters-accessors.mdx", + "slug": "generate-converters-accessors", + "title": "Generate Converters & Helpers", + "description": "All about the @deriving decorator, and how to generate code from types", + "canonical": "/docs/manual/v12.0.0/generate-converters-accessors" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/function.mdx", + "slug": "function", + "title": "Function", + "description": "Function syntax in ReScript", + "canonical": "/docs/manual/v12.0.0/function" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/external.mdx", + "slug": "external", + "title": "External (Bind to Any JS Library)", + "description": "The external keyword", + "canonical": "/docs/manual/v12.0.0/external" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/extensible-variant.mdx", + "slug": "extensible-variant", + "title": "Extensible Variant", + "description": "Extensible Variants in ReScript", + "canonical": "/docs/manual/v12.0.0/extensible-variant" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/exception.mdx", + "slug": "exception", + "title": "Exception", + "description": "Exceptions and exception handling in ReScript", + "canonical": "/docs/manual/v12.0.0/exception" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/equality-comparison.mdx", + "slug": "equality-comparison", + "title": "Equality and Comparison", + "description": "Handling equality and comparison checks", + "canonical": "/docs/manual/v12.0.0/equality-comparison" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/embed-raw-javascript.mdx", + "slug": "embed-raw-javascript", + "title": "Embed Raw JavaScript", + "description": "Utility syntax to for raw JS usage in ReScript", + "canonical": "/docs/manual/v12.0.0/embed-raw-javascript" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/editor-plugins.mdx", + "slug": "editor-plugins", + "title": "Editor", + "metaTitle": "Editor", + "description": "Documentation about ReScript editor plugins and code analysis", + "canonical": "/docs/manual/v12.0.0/editor-plugins" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/editor-code-analysis.mdx", + "slug": "editor-code-analysis", + "title": "Dead Code Analysis in ReScript", + "metaTitle": "Dead Code Analysis in ReScript", + "description": "Documentation about ReScript editor plugins and code analysis", + "canonical": "/docs/manual/v12.0.0/editor-plugins" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/dict.mdx", + "slug": "dict", + "title": "Dictionary", + "description": "Dictionary data structure in ReScript", + "canonical": "/docs/manual/v12.0.0/dict" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/converting-from-js.mdx", + "slug": "converting-from-js", + "title": "Converting from JS", + "description": "How to convert to ReScript with an existing JS codebase", + "canonical": "/docs/manual/v12.0.0/converting-from-js" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/control-flow.mdx", + "slug": "control-flow", + "title": "If-Else & Loops", + "description": "If, else, ternary, for, and while", + "canonical": "/docs/manual/v12.0.0/control-flow" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/build-pinned-dependencies.mdx", + "slug": "build-pinned-dependencies", + "title": "Pinned Dependencies", + "metaTitle": "Pinned Dependencies", + "description": "Handling multiple packages within one ReScript project with pinned dependencies", + "canonical": "/docs/manual/v12.0.0/build-pinned-dependencies" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/build-performance.mdx", + "slug": "build-performance", + "title": "Performance", + "metaTitle": "Build Performance", + "description": "ReScript build performance and measuring tools", + "canonical": "/docs/manual/v12.0.0/build-performance" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/build-overview.mdx", + "slug": "build-overview", + "title": "Overview", + "metaTitle": "Build System Overview", + "description": "Documentation about the ReScript build system and its toolchain", + "canonical": "/docs/manual/v12.0.0/build-overview" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/build-external-stdlib.mdx", + "slug": "build-external-stdlib", + "title": "External Stdlib", + "metaTitle": "External Stdlib", + "description": "Configuring an external ReScript stdlib package", + "canonical": "/docs/manual/v12.0.0/build-external-stdlib" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/build-configuration.mdx", + "slug": "build-configuration", + "title": "Configuration", + "metaTitle": "Build System Configuration", + "description": "Details about the configuration of the ReScript build system (rescript.json)", + "canonical": "/docs/manual/v12.0.0/build-configuration" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/build-configuration-schema.mdx", + "slug": "build-configuration-schema", + "title": "Configuration Schema", + "metaTitle": "Build System Configuration Schema", + "description": "Schema exploration widget for the ReScript configuration file", + "canonical": "/docs/manual/v12.0.0/build-configuration-schema" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/browser-support-polyfills.mdx", + "slug": "browser-support-polyfills", + "title": "Browser Support & Polyfills", + "description": "Note on browser support in ReScript", + "canonical": "/docs/manual/v12.0.0/browser-support-polyfills" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/bind-to-js-object.mdx", + "slug": "bind-to-js-object", + "title": "Bind to JS Object", + "description": "Interop with JS objects in ReScript", + "canonical": "/docs/manual/v12.0.0/bind-to-js-object" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/bind-to-js-function.mdx", + "slug": "bind-to-js-function", + "title": "Bind to JS Function", + "description": "JS interop with functions in ReScript", + "canonical": "/docs/manual/v12.0.0/bind-to-js-function" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/bind-to-global-js-values.mdx", + "slug": "bind-to-global-js-values", + "title": "Bind to Global JS Values", + "description": "JS interop with global JS values in ReScript", + "canonical": "/docs/manual/v12.0.0/bind-to-global-js-values" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/attribute.mdx", + "slug": "attribute", + "title": "Attribute (Decorator)", + "description": "Annotations in ReScript", + "canonical": "/docs/manual/v12.0.0/attribute" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/async-await.mdx", + "slug": "async-await", + "title": "Async / Await", + "description": "Async / await for asynchronous operations", + "canonical": "/docs/manual/v12.0.0/async-await" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/array-and-list.mdx", + "slug": "array-and-list", + "title": "Array & List", + "description": "Arrays and List data structures", + "canonical": "/docs/manual/v12.0.0/array-and-list" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/manual/api.mdx", + "slug": "api" + }, + { + "path": "/home/josh/Dev/rescript-lang.org/docs/guidelines/publishing-packages.mdx", + "slug": "publishing-packages", + "title": "Publishing ReScript packages", + "description": "Guidelines on publishing ReScript bindings and libraries to our Package Index", + "canonical": "/guidelines/publishing-npm-packages" + } +] \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs deleted file mode 100644 index 48a6a0287..000000000 --- a/next.config.mjs +++ /dev/null @@ -1,187 +0,0 @@ -// @ ts-check - -import * as assert from "node:assert/strict"; -import * as path from "node:path"; -import * as fs from "node:fs/promises"; -import webpack from "webpack"; -import rehypeSlug from "rehype-slug"; -import remarkGfm from "remark-gfm"; -import remarkComment from "remark-comment"; -import remarkFrontmatter from "remark-frontmatter"; -import remarkMdxFrontmatter from "remark-mdx-frontmatter"; -import { createLoader } from "simple-functional-loader"; - -const bsconfig = JSON.parse( - (await fs.readFile("./rescript.json", "utf8")).toString(), -); - -const { ProvidePlugin } = webpack; - -const transpileModules = ["rescript"].concat(bsconfig["dependencies"]); - -/** @type {import("next").NextConfig} */ -const config = { - output: process.env.NODE_ENV === "production" ? "export" : undefined, - pageExtensions: ["jsx", "js", "bs.js", "mdx", "mjs"], - env: { - ENV: process.env.NODE_ENV, - VERSION_LATEST: process.env.VERSION_LATEST, - VERSION_NEXT: process.env.VERSION_NEXT, - }, - webpack: (config, options) => { - const { isServer } = options; - if (!isServer) { - // We shim fs for things like the blog slugs component - // where we need fs access in the server-side part - config.resolve.fallback = { - fs: false, - path: false, - }; - } - // We need this additional rule to make sure that mjs files are - // correctly detected within our src/ folder - config.module.rules.push({ - test: /\.m?js$/, - // v-- currently using an experimental setting with esbuild-loader - //use: options.defaultLoaders.babel, - use: [{ loader: "esbuild-loader", options: { loader: "jsx" } }], - exclude: /node_modules/, - type: "javascript/auto", - resolve: { - fullySpecified: false, - }, - }); - - function mainMdxLoader(plugins) { - return [ - createLoader(function (source) { - const result = `${source}\n\nMDXContent.frontmatter = frontmatter`; - return result; - }), - ]; - } - - config.module.rules.push({ - test: /\.mdx?$/, - use: mainMdxLoader(), - }); - - config.module.rules.push({ - test: /\.mdx?$/, - use: [ - { - loader: "@mdx-js/loader", - /** @type {import('@mdx-js/loader').Options} */ - options: { - remarkPlugins: [ - remarkComment, - remarkGfm, - remarkFrontmatter, - remarkMdxFrontmatter, - ], - providerImportSource: "@mdx-js/react", - rehypePlugins: [rehypeSlug], - }, - }, - ], - }); - - config.plugins.push(new ProvidePlugin({ React: "react" })); - return config; - }, - async redirects() { - const redirects = [ - { - source: "/community", - destination: "/community/overview", - permanent: true, - }, - { - source: "/bucklescript-rebranding", - destination: "/blog/bucklescript-is-rebranding", - permanent: true, - }, - { - source: "/docs/manual/latest/migrate-from-bucklescript-reason", - destination: "/docs/manual/v10.0.0/migrate-from-bucklescript-reason", - permanent: true, - }, - { - source: "/docs/manual/latest/unboxed", - destination: "/docs/manual/v10.0.0/unboxed", - permanent: true, - }, - { - source: "/docs/gentype/latest/introduction", - destination: "/docs/manual/latest/typescript-integration", - permanent: true, - }, - { - source: "/docs/gentype/latest/getting-started", - destination: "/docs/manual/latest/typescript-integration", - permanent: true, - }, - { - source: "/docs/gentype/latest/usage", - destination: "/docs/manual/latest/typescript-integration", - permanent: true, - }, - { - source: "/docs/gentype/latest/supported-types", - destination: "/docs/manual/latest/typescript-integration", - permanent: true, - }, - ]; - const splatRedirects = [ - { - source: "/docs/manual/latest/:slug*", - destination: `/docs/manual/${process.env.VERSION_LATEST}/:slug*`, - permanent: false, - }, - { - source: "/docs/manual/next/:slug*", - destination: `/docs/manual/${process.env.VERSION_NEXT}/:slug*`, - permanent: false, - }, - { - source: "/llms/manual/latest/:file*", - destination: `/llms/manual/${process.env.VERSION_LATEST}/:file*`, - permanent: false, - }, - { - source: "/llms/manual/next/:file*", - destination: `/llms/manual/${process.env.VERSION_NEXT}/:file*`, - permanent: false, - }, - ]; - - if (process.env.NODE_ENV === "production") { - const redirectsFile = path.join(import.meta.dirname, "public/_redirects"); - await fs.writeFile( - redirectsFile, - redirects - .map(({ source, destination, permanent }) => { - return `${source} ${destination} ${permanent ? 308 : 307}`; - }) - .join("\n") + - "\n" + - splatRedirects - .map(({ source, destination, permanent }) => { - const splatPattern = /:(\w+)\*$/; - assert.match(source, splatPattern); - assert.match(destination, splatPattern); - return `${source.replace(splatPattern, "*")} ${destination.replace(splatPattern, ":splat")} ${permanent ? 308 : 307}`; - }) - .join("\n"), - "utf8", - ); - } - - return [...redirects, ...splatRedirects]; - }, -}; - -export default { - transpilePackages: transpileModules, - ...config, -}; diff --git a/package-lock.json b/package-lock.json index 7ee2e439a..c732d20a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,10 @@ "@docsearch/react": "^3.9.0", "@headlessui/react": "^2.2.4", "@mdx-js/loader": "^3.1.0", + "@node-cli/static-server": "^3.1.4", + "@react-router/node": "^7.8.1", "@rescript/react": "^0.14.0-rc.1", - "@rescript/webapi": "^0.1.0-experimental-0b87498", + "@rescript/webapi": "^0.1.0-experimental-ae90e53", "codemirror": "^5.54.0", "docson": "^2.1.0", "escodegen": "^2.1.0", @@ -25,21 +27,21 @@ "glob": "^7.1.4", "highlight.js": "^11.9.0", "highlightjs-rescript": "^0.2.2", + "isbot": "^5", "lz-string": "^1.4.4", - "next": "^15.4.7", - "next-mdx-remote": "^5.0.0", + "mdast-util-from-markdown": "^2.0.2", + "mdast-util-toc": "^7.1.0", "react": "^19.1.0", "react-dom": "^19.1.0", "react-markdown": "^10.1.0", + "react-router": "^7.8.1", + "react-router-dom": "^7.9.3", + "react-router-mdx": "^1.0.8", "rehype-slug": "^6.0.0", "rehype-stringify": "^10.0.1", "remark-comment": "^1.0.0", "remark-frontmatter": "^5.0.0", "remark-gfm": "^4.0.1", - "remark-mdx-frontmatter": "^5.0.0", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.1.1", - "remark-stringify": "^11.0.0", "request": "^2.88.0", "rescript": "^12.0.0-beta.6", "stringify-object": "^3.3.0", @@ -48,20 +50,19 @@ }, "devDependencies": { "@mdx-js/react": "^2.3.0", + "@mdx-js/rollup": "^3.1.0", "@prettier/plugin-oxc": "^0.0.4", - "@tailwindcss/postcss": "^4.1.11", - "autoprefixer": "^10.4.14", - "cssnano": "^6.0.1", + "@react-router/dev": "^7.8.1", + "@tailwindcss/vite": "^4.1.13", + "@vitejs/plugin-react": "^4.7.0", + "@vitejs/plugin-rsc": "^0.4.16", "dotenv": "^16.4.7", - "esbuild-loader": "^4.3.0", "jsdom": "^26.1.0", - "postcss": "^8.4.27", - "postcss-cli": "^8.3.0", - "postcss-nesting": "^12.1.1", + "lightningcss": "^1.30.1", "prettier": "^3.6.2", "reanalyze": "^2.16.0", - "simple-functional-loader": "^1.2.1", - "tailwindcss": "^4" + "tailwindcss": "^4", + "vite": "^7.0.6" }, "engines": { "node": ">=20" @@ -292,19 +293,6 @@ "node": ">= 14.0.0" } }, - "node_modules/@alloc/quick-lru": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", - "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -334,174 +322,346 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", - "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.24.7", - "picocolors": "^1.0.0" + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/generator": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.7.tgz", - "integrity": "sha512-oipXieGC3i45Y1A41t4tAqpnEZWgB/lC6Ehh6+rOviR5XWpTtMmLN+fGjz9vOiNRt0p6RtO6DtD0pdU3vpqdSA==", + "node_modules/@babel/compat-data": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.28.0.tgz", + "integrity": "sha512-60X7qkglvrap8mn1lh2ebxXdZYtUcpd7gsmy9kLaBJ4i/WdY8PqTSdxyA8qraikqKQK5C1KRBKXqznrVapyNaw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.0.tgz", + "integrity": "sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==", + "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.24.7", - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25", - "jsesc": "^2.5.1" + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.28.0", + "@babel/helper-compilation-targets": "^7.27.2", + "@babel/helper-module-transforms": "^7.27.3", + "@babel/helpers": "^7.27.6", + "@babel/parser": "^7.28.0", + "@babel/template": "^7.27.2", + "@babel/traverse": "^7.28.0", + "@babel/types": "^7.28.0", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/debug": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" } }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", - "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", + "node_modules/@babel/generator": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.3.tgz", + "integrity": "sha512-3lSpxGgvnmZznmBkCRnVREPUFJv2wrv9iAoFDvADJc0ypmdOxdUtcLeBgBJ6zE0PMeTKnxeQzyk0xTBq4Ep7zw==", + "license": "MIT", "dependencies": { - "@babel/types": "^7.24.7" + "@babel/parser": "^7.28.3", + "@babel/types": "^7.28.2", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-function-name": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz", - "integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==", + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.27.3", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz", + "integrity": "sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==", + "dev": true, + "license": "MIT", "dependencies": { - "@babel/template": "^7.24.7", - "@babel/types": "^7.24.7" + "@babel/types": "^7.27.3" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", - "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", + "node_modules/@babel/helper-compilation-targets": { + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz", + "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==", + "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.24.7" + "@babel/compat-data": "^7.27.2", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz", - "integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==", + "node_modules/@babel/helper-compilation-targets/node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-create-class-features-plugin": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.28.3.tgz", + "integrity": "sha512-V9f6ZFIYSLNEbuGA/92uOvYsGCJNsuA8ESZ4ldc09bWk/j8H8TKiPw8Mk1eG6olpnO0ALHJmYfZvF4MEE4gajg==", + "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.24.7" + "@babel/helper-annotate-as-pure": "^7.27.3", + "@babel/helper-member-expression-to-functions": "^7.27.1", + "@babel/helper-optimise-call-expression": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/traverse": "^7.28.3", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, - "node_modules/@babel/helper-string-parser": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.7.tgz", - "integrity": "sha512-7MbVt6xrwFQbunH2DNQsAP5sTGxfqQtErvBIvIMi6EQnbgUOuVYanvREcmFrOPhoXBrTtjhhP+lW+o5UfK+tDg==", + "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz", + "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", - "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", + "node_modules/@babel/helper-member-expression-to-functions": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.27.1.tgz", + "integrity": "sha512-E5chM8eWjTp/aNoVpcbfM7mLxu9XGLWYise2eBKGQomAk/Mb4XoxyqXTZbuTohbsl8EKqdlMhnDI2CCLfcs9wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", - "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", + "node_modules/@babel/helper-module-imports": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", + "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", + "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.24.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "node_modules/@babel/helper-module-transforms": { + "version": "7.27.3", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz", + "integrity": "sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==", + "dev": true, + "license": "MIT", "dependencies": { - "color-convert": "^1.9.0" + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1", + "@babel/traverse": "^7.27.3" }, "engines": { - "node": ">=4" + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "node_modules/@babel/helper-optimise-call-expression": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.27.1.tgz", + "integrity": "sha512-URMGH08NzYFhubNSGJrpUEphGKQwMQYBySzat5cAByY1/YgIRkULnIy3tAMeszlL/so2HbeilYloUmSpd7GdVw==", + "dev": true, + "license": "MIT", "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "@babel/types": "^7.27.1" }, "engines": { - "node": ">=4" + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz", + "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "node_modules/@babel/helper-replace-supers": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.27.1.tgz", + "integrity": "sha512-7EHz6qDZc8RYS5ElPoShMheWvEgERonFCs7IAonWLLUTXW59DP14bCZt89/GKyreYn8g3S83m21FelHKbeDCKA==", + "dev": true, + "license": "MIT", "dependencies": { - "color-name": "1.1.3" + "@babel/helper-member-expression-to-functions": "^7.27.1", + "@babel/helper-optimise-call-expression": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + "node_modules/@babel/helper-skip-transparent-expression-wrappers": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.27.1.tgz", + "integrity": "sha512-Tub4ZKEXqbPjXgWLl2+3JpQAYBJ8+ikpQ2Ocj/q/r0LwE3UhENh7EUabyHjz2kCEsrRY83ew2DQdHluuiDQFzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "license": "MIT", "engines": { - "node": ">=0.8.0" + "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "license": "MIT", "engines": { - "node": ">=4" + "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.28.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.2.tgz", + "integrity": "sha512-/V9771t+EgXz62aCcyofnQhGM8DQACbRhvzKFsXKC9QM+5MadF8ZmIm0crDMaz3+o0h0zXfJnd4EhbYbxsrcFw==", + "dev": true, + "license": "MIT", "dependencies": { - "has-flag": "^3.0.0" + "@babel/template": "^7.27.2", + "@babel/types": "^7.28.2" }, "engines": { - "node": ">=4" + "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.7.tgz", - "integrity": "sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==", + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.4.tgz", + "integrity": "sha512-yZbBqeM6TkpP9du/I2pUZnJsRMGGvOuIrhjzC1AwHwW+6he4mni6Bp/m8ijn0iOuZuPI2BfkCoSRunpyjnrQKg==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.4" + }, "bin": { "parser": "bin/babel-parser.js" }, @@ -509,6 +669,127 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.27.1.tgz", + "integrity": "sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz", + "integrity": "sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-commonjs": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.27.1.tgz", + "integrity": "sha512-OJguuwlTYlN0gBZFRPqwOGNWssZjfIUdS7HMYtN8c1KmwpwHFBwTeFZrg9XZa+DFTitWOW5iTAG7tyCUPsCCyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.27.1.tgz", + "integrity": "sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.27.1.tgz", + "integrity": "sha512-zbwoTsBruTeKB9hSq73ha66iFeJHuaFkUbwvqElnygoNbj/jHRsSeokowZFN3CZ64IvEqcmmkVe89OPXc7ldAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typescript": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.28.0.tgz", + "integrity": "sha512-4AEiDEBPIZvLQaWlc9liCavE0xRM0dNca41WtBeM3jgFptfUOSG9z0uteLhq6+3rq+WB6jIvUwKDTpXEHPJ2Vg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.3", + "@babel/helper-create-class-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/plugin-syntax-typescript": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-typescript": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.27.1.tgz", + "integrity": "sha512-l7WfQfX0WK4M0v2RudjuQK4u99BS6yLHYEmdtVPP7lKV013zr9DygFuWNlnbvQ9LR+LS0Egz/XAvGx5U9MX0fQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-validator-option": "^7.27.1", + "@babel/plugin-syntax-jsx": "^7.27.1", + "@babel/plugin-transform-modules-commonjs": "^7.27.1", + "@babel/plugin-transform-typescript": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/runtime": { "version": "7.26.10", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.10.tgz", @@ -522,33 +803,32 @@ } }, "node_modules/@babel/template": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.7.tgz", - "integrity": "sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==", + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/parser": "^7.24.7", - "@babel/types": "^7.24.7" + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.24.7.tgz", - "integrity": "sha512-yb65Ed5S/QAcewNPh0nZczy9JdYXkkAbIsEo+P7BE7yO3txAY30Y/oPa3QkQ5It3xVG2kpKMg9MsdxZaO31uKA==", + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.28.4.tgz", + "integrity": "sha512-YEzuboP2qvQavAcjgQNVgsvHIDv6ZpwXvcvjmyySP2DIMuByS/6ioU5G9pYrWHM6T2YDfc7xga9iNzYOs12CFQ==", + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.7", - "@babel/helper-environment-visitor": "^7.24.7", - "@babel/helper-function-name": "^7.24.7", - "@babel/helper-hoist-variables": "^7.24.7", - "@babel/helper-split-export-declaration": "^7.24.7", - "@babel/parser": "^7.24.7", - "@babel/types": "^7.24.7", - "debug": "^4.3.1", - "globals": "^11.1.0" + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.28.3", + "@babel/helper-globals": "^7.28.0", + "@babel/parser": "^7.28.4", + "@babel/template": "^7.27.2", + "@babel/types": "^7.28.4", + "debug": "^4.3.1" }, "engines": { "node": ">=6.9.0" @@ -570,32 +850,34 @@ } } }, - "node_modules/@babel/traverse/node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "engines": { - "node": ">=4" - } - }, "node_modules/@babel/traverse/node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/@babel/types": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.7.tgz", - "integrity": "sha512-XEFXSlxiG5td2EJRe8vOmRbaXVgfcBlszKujvVmWIK/UpywWljQCfzAv3RQCGujWQ1RD4YYWEAqDXfuJiy8f5Q==", + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.4.tgz", + "integrity": "sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==", + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.24.7", - "@babel/helper-validator-identifier": "^7.24.7", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/@csstools/color-helpers": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.2.tgz", @@ -711,50 +993,6 @@ "node": ">=18" } }, - "node_modules/@csstools/selector-resolve-nested": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@csstools/selector-resolve-nested/-/selector-resolve-nested-1.1.0.tgz", - "integrity": "sha512-uWvSaeRcHyeNenKg8tp17EVDRkpflmdyvbE0DHo6D/GdBb6PDnCYYU6gRpXhtICMGMcahQmj2zGxwFM/WC8hCg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "engines": { - "node": "^14 || ^16 || >=18" - }, - "peerDependencies": { - "postcss-selector-parser": "^6.0.13" - } - }, - "node_modules/@csstools/selector-specificity": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-3.0.3.tgz", - "integrity": "sha512-KEPNw4+WW5AVEIyzC80rTbWEUatTW2lXpN8+8ILC8PiPeWPjwUzrPZDIOZ2wwqDmeqOYTdSGyL3+vE5GC3FB3Q==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "engines": { - "node": "^14 || ^16 || >=18" - }, - "peerDependencies": { - "postcss-selector-parser": "^6.0.13" - } - }, "node_modules/@docsearch/css": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/@docsearch/css/-/css-3.9.0.tgz", @@ -809,6 +1047,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.5.0.tgz", "integrity": "sha512-97/BJ3iXHww3djw6hYIfErCZFee7qCtrneuLa20UXFCOTCfBM2cvQHjWJ2EG0s0MtdNwInarqCTz35i4wWXHsQ==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -843,656 +1082,592 @@ "node": ">=18" } }, - "node_modules/@eslint-community/eslint-utils": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz", - "integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==", - "license": "MIT", - "peer": true, - "dependencies": { - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - } - }, - "node_modules/@eslint-community/regexpp": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", - "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", - "license": "MIT", - "peer": true, - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } + "node_modules/@fastify/accept-negotiator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@fastify/accept-negotiator/-/accept-negotiator-2.0.1.tgz", + "integrity": "sha512-/c/TW2bO/v9JeEgoD/g1G5GxGeCF1Hafdf79WPmUlgYiBXummY0oX3VVq4yFkKKVBKDNlaDUYoab7g38RpPqCQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" }, - "node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "node_modules/@fastify/ajv-compiler": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-4.0.2.tgz", + "integrity": "sha512-Rkiu/8wIjpsf46Rr+Fitd3HRP+VsxUFDDeag0hs9L0ksfnwx2g7SPQQTFL0E8Qv+rfXzQOxBJnjUB9ITUDjfWQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT", - "peer": true, "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" + "ajv": "^8.12.0", + "ajv-formats": "^3.0.1", + "fast-uri": "^3.0.0" } }, - "node_modules/@eslint/eslintrc/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "node_modules/@fastify/ajv-compiler/node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "license": "MIT", - "peer": true, "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" }, "funding": { "type": "github", "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/@eslint/eslintrc/node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "node_modules/@fastify/ajv-compiler/node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", "license": "MIT", - "peer": true, "dependencies": { - "ms": "^2.1.3" + "ajv": "^8.0.0" }, - "engines": { - "node": ">=6.0" + "peerDependencies": { + "ajv": "^8.0.0" }, "peerDependenciesMeta": { - "supports-color": { + "ajv": { "optional": true } } }, - "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "license": "MIT", - "peer": true + "node_modules/@fastify/ajv-compiler/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" }, - "node_modules/@eslint/js": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", - "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "node_modules/@fastify/caching": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/@fastify/caching/-/caching-9.0.3.tgz", + "integrity": "sha512-5K/2shYpvWHWiSAs59SaCVBoFhHEF8Yz4TTiXZf8YWVDcxuIxw0Adn5eDQ7s132s7vwURNOnCKHBjUQSOI+PLA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT", - "peer": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "dependencies": { + "abstract-cache": "^1.0.1", + "fastify-plugin": "^5.0.0", + "uid-safe": "^2.1.5" } }, - "node_modules/@floating-ui/core": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.1.tgz", - "integrity": "sha512-azI0DrjMMfIug/ExbBaeDVJXcY0a7EPvPjb2xAJPa4HeimBX+Z18HK8QQR3jb6356SnDDdxx+hinMLcJEDdOjw==", + "node_modules/@fastify/compress": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@fastify/compress/-/compress-8.1.0.tgz", + "integrity": "sha512-wX3I5u/SYQXxbqjG7CysvzeaCe4Sv8y13MnvnaGTpqfKkJbTLpwvdIDgqrwp/+UGvXOW7OLDLoTAQCDMJJRjDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT", "dependencies": { - "@floating-ui/utils": "^0.2.9" + "@fastify/accept-negotiator": "^2.0.0", + "fastify-plugin": "^5.0.0", + "mime-db": "^1.52.0", + "minipass": "^7.0.4", + "peek-stream": "^1.1.3", + "pump": "^3.0.0", + "pumpify": "^2.0.1", + "readable-stream": "^4.5.2" } }, - "node_modules/@floating-ui/dom": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.1.tgz", - "integrity": "sha512-cwsmW/zyw5ltYTUeeYJ60CnQuPqmGwuGVhG9w0PRaRKkAyi38BT5CKrpIbb+jtahSwUl04cWzSx9ZOIxeS6RsQ==", + "node_modules/@fastify/compress/node_modules/readable-stream": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", "license": "MIT", "dependencies": { - "@floating-ui/core": "^1.7.1", - "@floating-ui/utils": "^0.2.9" + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@floating-ui/react": { - "version": "0.26.28", - "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.26.28.tgz", - "integrity": "sha512-yORQuuAtVpiRjpMhdc0wJj06b9JFjrYF4qp96j++v2NBpbi6SEGF7donUJ3TMieerQ6qVkAv1tgr7L4r5roTqw==", + "node_modules/@fastify/compress/node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "license": "MIT", "dependencies": { - "@floating-ui/react-dom": "^2.1.2", - "@floating-ui/utils": "^0.2.8", - "tabbable": "^6.0.0" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" + "safe-buffer": "~5.2.0" } }, - "node_modules/@floating-ui/react-dom": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.3.tgz", - "integrity": "sha512-huMBfiU9UnQ2oBwIhgzyIiSpVgvlDstU8CX0AF+wS+KzmYMs0J2a3GwuFHV1Lz+jlrQGeC1fF+Nv0QoumyV0bA==", + "node_modules/@fastify/cors": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@fastify/cors/-/cors-11.1.0.tgz", + "integrity": "sha512-sUw8ed8wP2SouWZTIbA7V2OQtMNpLj2W6qJOYhNdcmINTu6gsxVYXjQiM9mdi8UUDlcoDDJ/W2syPo1WB2QjYA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT", "dependencies": { - "@floating-ui/dom": "^1.0.0" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" + "fastify-plugin": "^5.0.0", + "toad-cache": "^3.7.0" } }, - "node_modules/@floating-ui/utils": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz", - "integrity": "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==", + "node_modules/@fastify/error": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@fastify/error/-/error-4.2.0.tgz", + "integrity": "sha512-RSo3sVDXfHskiBZKBPRgnQTtIqpi/7zhJOEmAxCiBcM7d0uwdGdxLlsCaLzGs8v8NnxIRlfG0N51p5yFaOentQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT" }, - "node_modules/@headlessui/react": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-2.2.4.tgz", - "integrity": "sha512-lz+OGcAH1dK93rgSMzXmm1qKOJkBUqZf1L4M8TWLNplftQD3IkoEDdUFNfAn4ylsN6WOTVtWaLmvmaHOUk1dTA==", + "node_modules/@fastify/fast-json-stringify-compiler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-5.0.3.tgz", + "integrity": "sha512-uik7yYHkLr6fxd8hJSZ8c+xF4WafPK+XzneQDPU+D10r5X19GW8lJcom2YijX2+qtFF1ENJlHXKFM9ouXNJYgQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT", "dependencies": { - "@floating-ui/react": "^0.26.16", - "@react-aria/focus": "^3.20.2", - "@react-aria/interactions": "^3.25.0", - "@tanstack/react-virtual": "^3.13.9", - "use-sync-external-store": "^1.5.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "react": "^18 || ^19 || ^19.0.0-rc", - "react-dom": "^18 || ^19 || ^19.0.0-rc" + "fast-json-stringify": "^6.0.0" } }, - "node_modules/@humanwhocodes/config-array": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", - "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", - "deprecated": "Use @eslint/config-array instead", - "license": "Apache-2.0", - "peer": true, - "dependencies": { - "@humanwhocodes/object-schema": "^2.0.3", - "debug": "^4.3.1", - "minimatch": "^3.0.5" - }, - "engines": { - "node": ">=10.10.0" - } + "node_modules/@fastify/forwarded": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@fastify/forwarded/-/forwarded-3.0.1.tgz", + "integrity": "sha512-JqDochHFqXs3C3Ml3gOY58zM7OqO9ENqPo0UqAjAjH8L01fRZqwX9iLeX34//kiJubF7r2ZQHtBRU36vONbLlw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" }, - "node_modules/@humanwhocodes/config-array/node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "node_modules/@fastify/merge-json-schemas": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.2.1.tgz", + "integrity": "sha512-OA3KGBCy6KtIvLf8DINC5880o5iBlDX4SxzLQS8HorJAbqluzLRn80UXU0bxZn7UOFhFgpRJDasfwn9nG4FG4A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT", - "peer": true, "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "dequal": "^2.0.3" } }, - "node_modules/@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "license": "Apache-2.0", - "peer": true, - "engines": { - "node": ">=12.22" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", - "deprecated": "Use @eslint/object-schema instead", - "license": "BSD-3-Clause", - "peer": true - }, - "node_modules/@img/sharp-darwin-arm64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.3.tgz", - "integrity": "sha512-ryFMfvxxpQRsgZJqBd4wsttYQbCxsJksrv9Lw/v798JcQ8+w84mBWuXwl+TT0WJ/WrYOLaYpwQXi3sA9nTIaIg==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" + "node_modules/@fastify/proxy-addr": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@fastify/proxy-addr/-/proxy-addr-5.1.0.tgz", + "integrity": "sha512-INS+6gh91cLUjB+PVHfu1UqcB76Sqtpyp7bnL+FYojhjygvOPA9ctiD/JDKsyD9Xgu4hUhCSJBPig/w7duNajw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.2.0" + "license": "MIT", + "dependencies": { + "@fastify/forwarded": "^3.0.0", + "ipaddr.js": "^2.1.0" } }, - "node_modules/@img/sharp-darwin-x64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.3.tgz", - "integrity": "sha512-yHpJYynROAj12TA6qil58hmPmAwxKKC7reUqtGLzsOHfP7/rniNGTL8tjWX6L3CTV4+5P4ypcS7Pp+7OB+8ihA==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], + "node_modules/@fastify/proxy-addr/node_modules/ipaddr.js": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz", + "integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==", + "license": "MIT", "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.2.0" - } - }, - "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.0.tgz", - "integrity": "sha512-sBZmpwmxqwlqG9ueWFXtockhsxefaV6O84BMOrhtg/YqbTaRdqDE7hxraVE3y6gVM4eExmfzW4a8el9ArLeEiQ==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.0.tgz", - "integrity": "sha512-M64XVuL94OgiNHa5/m2YvEQI5q2cl9d/wk0qFTDVXcYzi43lxuiFTftMR1tOnFQovVXNZJ5TURSDK2pNe9Yzqg==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.0.tgz", - "integrity": "sha512-mWd2uWvDtL/nvIzThLq3fr2nnGfyr/XMXlq8ZJ9WMR6PXijHlC3ksp0IpuhK6bougvQrchUAfzRLnbsen0Cqvw==", - "cpu": [ - "arm" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.0.tgz", - "integrity": "sha512-RXwd0CgG+uPRX5YYrkzKyalt2OJYRiJQ8ED/fi1tq9WQW2jsQIn0tqrlR5l5dr/rjqq6AHAxURhj2DVjyQWSOA==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-ppc64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.0.tgz", - "integrity": "sha512-Xod/7KaDDHkYu2phxxfeEPXfVXFKx70EAFZ0qyUdOjCcxbjqyJOEUpDe6RIyaunGxT34Anf9ue/wuWOqBW2WcQ==", - "cpu": [ - "ppc64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.0.tgz", - "integrity": "sha512-eMKfzDxLGT8mnmPJTNMcjfO33fLiTDsrMlUVcp6b96ETbnJmd4uvZxVJSKPQfS+odwfVaGifhsB07J1LynFehw==", - "cpu": [ - "s390x" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" + "node": ">= 10" } }, - "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.0.tgz", - "integrity": "sha512-ZW3FPWIc7K1sH9E3nxIGB3y3dZkpJlMnkk7z5tu1nSkBoCgw2nSRTFHI5pB/3CQaJM0pdzMF3paf9ckKMSE9Tg==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" + "node_modules/@fastify/send": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@fastify/send/-/send-4.1.0.tgz", + "integrity": "sha512-TMYeQLCBSy2TOFmV95hQWkiTYgC/SEx7vMdV+wnZVX4tt8VBLKzmH8vV9OzJehV0+XBfg+WxPMt5wp+JBUKsVw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } ], - "funding": { - "url": "https://opencollective.com/libvips" + "license": "MIT", + "dependencies": { + "@lukeed/ms": "^2.0.2", + "escape-html": "~1.0.3", + "fast-decode-uri-component": "^1.0.1", + "http-errors": "^2.0.0", + "mime": "^3" } }, - "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.0.tgz", - "integrity": "sha512-UG+LqQJbf5VJ8NWJ5Z3tdIe/HXjuIdo4JeVNADXBFuG7z9zjoegpzzGIyV5zQKi4zaJjnAd2+g2nna8TZvuW9Q==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" + "node_modules/@fastify/send/node_modules/mime": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=10.0.0" } }, - "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.0.tgz", - "integrity": "sha512-SRYOLR7CXPgNze8akZwjoGBoN1ThNZoqpOgfnOxmWsklTGVfJiGJoC/Lod7aNMGA1jSsKWM1+HRX43OP6p9+6Q==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" + "node_modules/@fastify/static": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@fastify/static/-/static-8.2.0.tgz", + "integrity": "sha512-PejC/DtT7p1yo3p+W7LiUtLMsV8fEvxAK15sozHy9t8kwo5r0uLYmhV/inURmGz1SkHZFz/8CNtHLPyhKcx4SQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } ], - "funding": { - "url": "https://opencollective.com/libvips" + "license": "MIT", + "dependencies": { + "@fastify/accept-negotiator": "^2.0.0", + "@fastify/send": "^4.0.0", + "content-disposition": "^0.5.4", + "fastify-plugin": "^5.0.0", + "fastq": "^1.17.1", + "glob": "^11.0.0" } }, - "node_modules/@img/sharp-linux-arm": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.3.tgz", - "integrity": "sha512-oBK9l+h6KBN0i3dC8rYntLiVfW8D8wH+NPNT3O/WBHeW0OQWCjfWksLUaPidsrDKpJgXp3G3/hkmhptAW0I3+A==", - "cpu": [ - "arm" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node_modules/@fastify/static/node_modules/glob": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "license": "ISC", + "dependencies": { + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" }, - "funding": { - "url": "https://opencollective.com/libvips" + "bin": { + "glob": "dist/esm/bin.mjs" }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.2.0" - } - }, - "node_modules/@img/sharp-linux-arm64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.3.tgz", - "integrity": "sha512-QdrKe3EvQrqwkDrtuTIjI0bu6YEJHTgEeqdzI3uWJOH6G1O8Nl1iEeVYRGdj1h5I21CqxSvQp1Yv7xeU3ZewbA==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": "20 || >=22" }, "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.2.0" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@img/sharp-linux-ppc64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.3.tgz", - "integrity": "sha512-GLtbLQMCNC5nxuImPR2+RgrviwKwVql28FWZIW1zWruy6zLgA5/x2ZXk3mxj58X/tszVF69KK0Is83V8YgWhLA==", - "cpu": [ - "ppc64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], + "node_modules/@fastify/static/node_modules/jackspeak": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", + "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": "20 || >=22" }, "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-ppc64": "1.2.0" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@img/sharp-linux-s390x": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.3.tgz", - "integrity": "sha512-3gahT+A6c4cdc2edhsLHmIOXMb17ltffJlxR0aC2VPZfwKoTGZec6u5GrFgdR7ciJSsHT27BD3TIuGcuRT0KmQ==", - "cpu": [ - "s390x" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], + "node_modules/@fastify/static/node_modules/lru-cache": { + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz", + "integrity": "sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==", + "license": "ISC", "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-s390x": "1.2.0" + "node": "20 || >=22" } }, - "node_modules/@img/sharp-linux-x64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.3.tgz", - "integrity": "sha512-8kYso8d806ypnSq3/Ly0QEw90V5ZoHh10yH0HnrzOCr6DKAPI6QVHvwleqMkVQ0m+fc7EH8ah0BB0QPuWY6zJQ==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], + "node_modules/@fastify/static/node_modules/minimatch": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", + "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", + "license": "ISC", + "dependencies": { + "@isaacs/brace-expansion": "^5.0.0" + }, "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": "20 || >=22" }, "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.2.0" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.3.tgz", - "integrity": "sha512-vAjbHDlr4izEiXM1OTggpCcPg9tn4YriK5vAjowJsHwdBIdx0fYRsURkxLG2RLm9gyBq66gwtWI8Gx0/ov+JKQ==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], + "node_modules/@fastify/static/node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": "20 || >=22" }, "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.2.0" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.3.tgz", - "integrity": "sha512-gCWUn9547K5bwvOn9l5XGAEjVTTRji4aPTqLzGXHvIr6bIDZKNTA34seMPgM0WmSf+RYBH411VavCejp3PkOeQ==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], + "node_modules/@floating-ui/core": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.1.tgz", + "integrity": "sha512-azI0DrjMMfIug/ExbBaeDVJXcY0a7EPvPjb2xAJPa4HeimBX+Z18HK8QQR3jb6356SnDDdxx+hinMLcJEDdOjw==", + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.9" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.1.tgz", + "integrity": "sha512-cwsmW/zyw5ltYTUeeYJ60CnQuPqmGwuGVhG9w0PRaRKkAyi38BT5CKrpIbb+jtahSwUl04cWzSx9ZOIxeS6RsQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.7.1", + "@floating-ui/utils": "^0.2.9" + } + }, + "node_modules/@floating-ui/react": { + "version": "0.26.28", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.26.28.tgz", + "integrity": "sha512-yORQuuAtVpiRjpMhdc0wJj06b9JFjrYF4qp96j++v2NBpbi6SEGF7donUJ3TMieerQ6qVkAv1tgr7L4r5roTqw==", + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "^2.1.2", + "@floating-ui/utils": "^0.2.8", + "tabbable": "^6.0.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/react-dom": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.3.tgz", + "integrity": "sha512-huMBfiU9UnQ2oBwIhgzyIiSpVgvlDstU8CX0AF+wS+KzmYMs0J2a3GwuFHV1Lz+jlrQGeC1fF+Nv0QoumyV0bA==", + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "^1.0.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz", + "integrity": "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==", + "license": "MIT" + }, + "node_modules/@headlessui/react": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-2.2.4.tgz", + "integrity": "sha512-lz+OGcAH1dK93rgSMzXmm1qKOJkBUqZf1L4M8TWLNplftQD3IkoEDdUFNfAn4ylsN6WOTVtWaLmvmaHOUk1dTA==", + "license": "MIT", + "dependencies": { + "@floating-ui/react": "^0.26.16", + "@react-aria/focus": "^3.20.2", + "@react-aria/interactions": "^3.25.0", + "@tanstack/react-virtual": "^3.13.9", + "use-sync-external-store": "^1.5.0" + }, "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": ">=10" }, - "funding": { - "url": "https://opencollective.com/libvips" + "peerDependencies": { + "react": "^18 || ^19 || ^19.0.0-rc", + "react-dom": "^18 || ^19 || ^19.0.0-rc" + } + }, + "node_modules/@isaacs/balanced-match": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", + "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", + "license": "MIT", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/brace-expansion": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", + "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "license": "MIT", + "dependencies": { + "@isaacs/balanced-match": "^4.0.1" }, - "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.2.0" + "engines": { + "node": "20 || >=22" } }, - "node_modules/@img/sharp-wasm32": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.3.tgz", - "integrity": "sha512-+CyRcpagHMGteySaWos8IbnXcHgfDn7pO2fiC2slJxvNq9gDipYBN42/RagzctVRKgxATmfqOSulgZv5e1RdMg==", - "cpu": [ - "wasm32" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", - "optional": true, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "license": "ISC", "dependencies": { - "@emnapi/runtime": "^1.4.4" + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" }, "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "license": "MIT", + "engines": { + "node": ">=12" }, "funding": { - "url": "https://opencollective.com/libvips" + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/@img/sharp-win32-arm64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.3.tgz", - "integrity": "sha512-MjnHPnbqMXNC2UgeLJtX4XqoVHHlZNd+nPt1kRPmj63wURegwBhZlApELdtxM2OIZDRv/DFtLcNhVbd1z8GYXQ==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", - "optional": true, - "os": [ - "win32" - ], + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "license": "MIT", "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": ">=12" }, "funding": { - "url": "https://opencollective.com/libvips" + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/@img/sharp-win32-ia32": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.3.tgz", - "integrity": "sha512-xuCdhH44WxuXgOM714hn4amodJMZl3OEvf0GVTm0BEyMeA2to+8HEdRPShH0SLYptJY1uBw+SCFP9WVQi1Q/cw==", - "cpu": [ - "ia32" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", - "optional": true, - "os": [ - "win32" - ], + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": ">=12" }, "funding": { - "url": "https://opencollective.com/libvips" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@img/sharp-win32-x64": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.3.tgz", - "integrity": "sha512-OWwz05d++TxzLEv4VnsTz5CmZ6mI6S05sfQGEMrNrQcOEERbX46332IvE7pO/EUiw7jUrrS40z/M7kPyjfl04g==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", - "optional": true, - "os": [ - "win32" - ], + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + "node": ">=12" }, "funding": { - "url": "https://opencollective.com/libvips" + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/@isaacs/fs-minipass": { @@ -1509,16 +1684,24 @@ } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "version": "0.3.12", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.12.tgz", + "integrity": "sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==", + "license": "MIT", "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" } }, "node_modules/@jridgewell/resolve-uri": { @@ -1529,40 +1712,31 @@ "node": ">=6.0.0" } }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.10.tgz", - "integrity": "sha512-0pPkgz9dY+bijgistcTTJ5mR+ocqRXLuhXHYdzoMmmoJ2C9S46RCm2GMUbatPEUK9Yjy26IrAy8D/M00lLkv+Q==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25" - } - }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz", - "integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==" + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "version": "0.3.29", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.29.tgz", + "integrity": "sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==", + "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@lukeed/ms": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz", + "integrity": "sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/@mdx-js/loader": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@mdx-js/loader/-/loader-3.1.0.tgz", @@ -1646,65 +1820,50 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/@mdx-js/mdx/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/@mdx-js/mdx/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "license": "MIT", + "node_modules/@mdx-js/react": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-2.3.0.tgz", + "integrity": "sha512-zQH//gdOmuu7nt2oJR29vFhDv88oGPmVw6BggmrHeMI+xgEkp1B2dX9/bMBSYtK0dyLX/aOmesKS09g222K1/g==", + "dev": true, "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" + "@types/mdx": "^2.0.0", + "@types/react": ">=16" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" - } - }, - "node_modules/@mdx-js/mdx/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "peerDependencies": { + "react": ">=16" } }, - "node_modules/@mdx-js/react": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-2.3.0.tgz", - "integrity": "sha512-zQH//gdOmuu7nt2oJR29vFhDv88oGPmVw6BggmrHeMI+xgEkp1B2dX9/bMBSYtK0dyLX/aOmesKS09g222K1/g==", + "node_modules/@mdx-js/rollup": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@mdx-js/rollup/-/rollup-3.1.0.tgz", + "integrity": "sha512-q4xOtUXpCzeouE8GaJ8StT4rDxm/U5j6lkMHL2srb2Q3Y7cobE0aXyPzXVVlbeIMBi+5R5MpbiaVE5/vJUdnHg==", "dev": true, + "license": "MIT", "dependencies": { - "@types/mdx": "^2.0.0", - "@types/react": ">=16" + "@mdx-js/mdx": "^3.0.0", + "@rollup/pluginutils": "^5.0.0", + "source-map": "^0.7.0", + "vfile": "^6.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" }, "peerDependencies": { - "react": ">=16" + "rollup": ">=2" } }, + "node_modules/@mjackson/node-fetch-server": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@mjackson/node-fetch-server/-/node-fetch-server-0.7.0.tgz", + "integrity": "sha512-un8diyEBKU3BTVj3GzlTPA1kIjCkGdD+AMYQy31Gf9JCkfoZzwgJ79GUtHrF2BN3XPNMLpubbzPcxys+a3uZEw==", + "dev": true, + "license": "MIT" + }, "node_modules/@napi-rs/wasm-runtime": { "version": "0.2.12", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz", @@ -1718,12 +1877,6 @@ "@tybys/wasm-util": "^0.10.0" } }, - "node_modules/@next/env": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/env/-/env-15.4.7.tgz", - "integrity": "sha512-PrBIpO8oljZGTOe9HH0miix1w5MUiGJ/q83Jge03mHEE0E3pyqzAy2+l5G6aJDbXoobmxPJTVhbCuwlLtjSHwg==", - "license": "MIT" - }, "node_modules/@next/eslint-plugin-next": { "version": "13.4.12", "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.12.tgz", @@ -1751,132 +1904,134 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@next/swc-darwin-arm64": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.4.7.tgz", - "integrity": "sha512-2Dkb+VUTp9kHHkSqtws4fDl2Oxms29HcZBwFIda1X7Ztudzy7M6XF9HDS2dq85TmdN47VpuhjE+i6wgnIboVzQ==", - "cpu": [ - "arm64" - ], + "node_modules/@node-cli/logger": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@node-cli/logger/-/logger-1.3.2.tgz", + "integrity": "sha512-LVu0m7N3skbXTQgRUpO5AEk87l8FHy0zfPJuspxozIaPp3zIXLSrgKG19I2ARD2C5cu7rzrjXMNrkbS69Spn1Q==", "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" + "dependencies": { + "boxen": "8.0.1", + "kleur": "4.1.5", + "ora": "8.2.0" } }, - "node_modules/@next/swc-darwin-x64": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.4.7.tgz", - "integrity": "sha512-qaMnEozKdWezlmh1OGDVFueFv2z9lWTcLvt7e39QA3YOvZHNpN2rLs/IQLwZaUiw2jSvxW07LxMCWtOqsWFNQg==", - "cpu": [ - "x64" - ], + "node_modules/@node-cli/parser": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/@node-cli/parser/-/parser-2.4.3.tgz", + "integrity": "sha512-S2zpuE2YLmToHLUlMxndkMHwAHhn2Yyr+p7TN66RKotiUoEToHyBgsiLl7QgHJdk41X6Lfpmg62uYT02s7hBYg==", "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" + "dependencies": { + "@node-cli/logger": "1.3.2", + "@node-cli/utilities": "1.0.4", + "cli-table3": "0.6.5", + "kleur": "4.1.5", + "meow": "13.2.0" } }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.4.7.tgz", - "integrity": "sha512-ny7lODPE7a15Qms8LZiN9wjNWIeI+iAZOFDOnv2pcHStncUr7cr9lD5XF81mdhrBXLUP9yT9RzlmSWKIazWoDw==", - "cpu": [ - "arm64" - ], + "node_modules/@node-cli/static-server": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@node-cli/static-server/-/static-server-3.1.4.tgz", + "integrity": "sha512-GnjUEn2Hq/1/FjOtX4ZioZCaVN4YGkYeEcY2NJ+a6h6rJzg+lpcuGmQPk97T+fEAAaedwJb7fwbq419exg0VNQ==", + "license": "MIT", + "dependencies": { + "@fastify/caching": "9.0.3", + "@fastify/compress": "8.1.0", + "@fastify/cors": "11.1.0", + "@fastify/static": "8.2.0", + "@node-cli/logger": "1.3.2", + "@node-cli/parser": "2.4.3", + "fastify": "5.5.0", + "fastify-plugin": "5.0.1", + "fs-extra": "11.3.1", + "kleur": "4.1.5", + "open": "10.2.0", + "pino-pretty": "13.1.1", + "portfinder": "1.0.37" + }, + "bin": { + "static-server": "dist/server.js" + } + }, + "node_modules/@node-cli/static-server/node_modules/bundle-name": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", + "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", "license": "MIT", - "optional": true, - "os": [ - "linux" - ], + "dependencies": { + "run-applescript": "^7.0.0" + }, "engines": { - "node": ">= 10" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.4.7.tgz", - "integrity": "sha512-4SaCjlFR/2hGJqZLLWycccy1t+wBrE/vyJWnYaZJhUVHccpGLG5q0C+Xkw4iRzUIkE+/dr90MJRUym3s1+vO8A==", - "cpu": [ - "arm64" - ], + "node_modules/@node-cli/static-server/node_modules/default-browser": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", + "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", "license": "MIT", - "optional": true, - "os": [ - "linux" - ], + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, "engines": { - "node": ">= 10" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.4.7.tgz", - "integrity": "sha512-2uNXjxvONyRidg00VwvlTYDwC9EgCGNzPAPYbttIATZRxmOZ3hllk/YYESzHZb65eyZfBR5g9xgCZjRAl9YYGg==", - "cpu": [ - "x64" - ], + "node_modules/@node-cli/static-server/node_modules/default-browser-id": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", + "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", "license": "MIT", - "optional": true, - "os": [ - "linux" - ], "engines": { - "node": ">= 10" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.4.7.tgz", - "integrity": "sha512-ceNbPjsFgLscYNGKSu4I6LYaadq2B8tcK116nVuInpHHdAWLWSwVK6CHNvCi0wVS9+TTArIFKJGsEyVD1H+4Kg==", - "cpu": [ - "x64" - ], + "node_modules/@node-cli/static-server/node_modules/open": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/open/-/open-10.2.0.tgz", + "integrity": "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==", "license": "MIT", - "optional": true, - "os": [ - "linux" - ], + "dependencies": { + "default-browser": "^5.2.1", + "define-lazy-prop": "^3.0.0", + "is-inside-container": "^1.0.0", + "wsl-utils": "^0.1.0" + }, "engines": { - "node": ">= 10" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.4.7.tgz", - "integrity": "sha512-pZyxmY1iHlZJ04LUL7Css8bNvsYAMYOY9JRwFA3HZgpaNKsJSowD09Vg2R9734GxAcLJc2KDQHSCR91uD6/AAw==", - "cpu": [ - "arm64" - ], + "node_modules/@node-cli/static-server/node_modules/run-applescript": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", + "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==", "license": "MIT", - "optional": true, - "os": [ - "win32" - ], "engines": { - "node": ">= 10" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.4.7.tgz", - "integrity": "sha512-HjuwPJ7BeRzgl3KrjKqD2iDng0eQIpIReyhpF5r4yeAHFwWRuAhfW92rWv/r3qeQHEwHsLRzFDvMqRjyM5DI6A==", - "cpu": [ - "x64" - ], + "node_modules/@node-cli/utilities": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@node-cli/utilities/-/utilities-1.0.4.tgz", + "integrity": "sha512-B1ejQdoPPO4/Q4PVmAMjeB3joH/0npCz5E1hx7OeLF+F9LogGKBRtKG70ZM2ehZoZOdEX57zH4HBRp9NVGSWxA==", "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" + "dependencies": { + "lodash-es": "4.17.21" } }, "node_modules/@nodelib/fs.scandir": { @@ -1911,6 +2066,157 @@ "node": ">= 8" } }, + "node_modules/@npmcli/git": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-4.1.0.tgz", + "integrity": "sha512-9hwoB3gStVfa0N31ymBmrX+GuDGdVA/QWShZVqE0HK2Af+7QGGrCTbZia/SW0ImUTjTne7SP91qxDmtXvDHRPQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "@npmcli/promise-spawn": "^6.0.0", + "lru-cache": "^7.4.4", + "npm-pick-manifest": "^8.0.0", + "proc-log": "^3.0.0", + "promise-inflight": "^1.0.1", + "promise-retry": "^2.0.1", + "semver": "^7.3.5", + "which": "^3.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@npmcli/git/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/@npmcli/git/node_modules/which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", + "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@npmcli/package-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-4.0.1.tgz", + "integrity": "sha512-lRCEGdHZomFsURroh522YvA/2cVb9oPIJrjHanCJZkiasz1BzcnLr3tBJhlV7S86MBJBuAQ33is2D60YitZL2Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "@npmcli/git": "^4.1.0", + "glob": "^10.2.2", + "hosted-git-info": "^6.1.1", + "json-parse-even-better-errors": "^3.0.0", + "normalize-package-data": "^5.0.0", + "proc-log": "^3.0.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@npmcli/package-json/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@npmcli/package-json/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@npmcli/package-json/node_modules/json-parse-even-better-errors": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-3.0.2.tgz", + "integrity": "sha512-fi0NG4bPjCHunUJffmLd0gxssIgkNmArMvis4iNah6Owg1MCJjWhEcDLmsK6iGkJq3tHwbDkTlce70/tmXN4cQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@npmcli/package-json/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@npmcli/promise-spawn": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-6.0.2.tgz", + "integrity": "sha512-gGq0NJkIGSwdbUt4yhdF8ZrmkGKVz9vAdVzpOfnom+V8PLSmSOVhZwbNvZZS1EYcJN5hzzKBxmmVVAInM6HQLg==", + "dev": true, + "license": "ISC", + "dependencies": { + "which": "^3.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@npmcli/promise-spawn/node_modules/which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", + "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/@oxc-parser/binding-android-arm64": { "version": "0.74.0", "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm64/-/binding-android-arm64-0.74.0.tgz", @@ -2176,6 +2482,17 @@ "url": "https://github.com/sponsors/Boshen" } }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@pkgr/utils": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.2.tgz", @@ -2278,70 +2595,232 @@ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, - "node_modules/@react-stately/flags": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@react-stately/flags/-/flags-3.1.2.tgz", - "integrity": "sha512-2HjFcZx1MyQXoPqcBGALwWWmgFVUk2TuKVIQxCbRq7fPyWXIl6VHcakCLurdtYC2Iks7zizvz0Idv48MQ38DWg==", - "license": "Apache-2.0", - "dependencies": { - "@swc/helpers": "^0.5.0" + "node_modules/@react-router/dev": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/@react-router/dev/-/dev-7.8.1.tgz", + "integrity": "sha512-ESFe7DbMvCvl7e8N7L9NmI64VJGNCc60/VX1DUZYw/jFfzA5098/6D1aUojcxyVYBbMbVTfw0xmEvD4CsJzy1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.27.7", + "@babel/generator": "^7.27.5", + "@babel/parser": "^7.27.7", + "@babel/plugin-syntax-jsx": "^7.27.1", + "@babel/preset-typescript": "^7.27.1", + "@babel/traverse": "^7.27.7", + "@babel/types": "^7.27.7", + "@npmcli/package-json": "^4.0.1", + "@react-router/node": "7.8.1", + "@vitejs/plugin-rsc": "0.4.11", + "arg": "^5.0.1", + "babel-dead-code-elimination": "^1.0.6", + "chokidar": "^4.0.0", + "dedent": "^1.5.3", + "es-module-lexer": "^1.3.1", + "exit-hook": "2.2.1", + "isbot": "^5.1.11", + "jsesc": "3.0.2", + "lodash": "^4.17.21", + "pathe": "^1.1.2", + "picocolors": "^1.1.1", + "prettier": "^3.6.2", + "react-refresh": "^0.14.0", + "semver": "^7.3.7", + "set-cookie-parser": "^2.6.0", + "tinyglobby": "^0.2.14", + "valibot": "^0.41.0", + "vite-node": "^3.2.2" + }, + "bin": { + "react-router": "bin.js" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@react-router/serve": "^7.8.1", + "react-router": "^7.8.1", + "typescript": "^5.1.0", + "vite": "^5.1.0 || ^6.0.0 || ^7.0.0", + "wrangler": "^3.28.2 || ^4.0.0" + }, + "peerDependenciesMeta": { + "@react-router/serve": { + "optional": true + }, + "typescript": { + "optional": true + }, + "wrangler": { + "optional": true + } } }, - "node_modules/@react-stately/utils": { - "version": "3.10.7", - "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.7.tgz", - "integrity": "sha512-cWvjGAocvy4abO9zbr6PW6taHgF24Mwy/LbQ4TC4Aq3tKdKDntxyD+sh7AkSRfJRT2ccMVaHVv2+FfHThd3PKQ==", - "license": "Apache-2.0", + "node_modules/@react-router/dev/node_modules/@vitejs/plugin-rsc": { + "version": "0.4.11", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-rsc/-/plugin-rsc-0.4.11.tgz", + "integrity": "sha512-+4H4wLi+Y9yF58znBfKgGfX8zcqUGt8ngnmNgzrdGdF1SVz7EO0sg7WnhK5fFVHt6fUxsVEjmEabsCWHKPL1Tw==", + "dev": true, + "license": "MIT", "dependencies": { - "@swc/helpers": "^0.5.0" + "@mjackson/node-fetch-server": "^0.7.0", + "es-module-lexer": "^1.7.0", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17", + "periscopic": "^4.0.2", + "turbo-stream": "^3.1.0", + "vitefu": "^1.1.1" }, "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + "react": "*", + "react-dom": "*", + "vite": "*" } }, - "node_modules/@react-types/shared": { - "version": "3.30.0", - "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.30.0.tgz", - "integrity": "sha512-COIazDAx1ncDg046cTJ8SFYsX8aS3lB/08LDnbkH/SkdYrFPWDlXMrO/sUam8j1WWM+PJ+4d1mj7tODIKNiFog==", - "license": "Apache-2.0", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + "node_modules/@react-router/dev/node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" } }, - "node_modules/@rescript/darwin-arm64": { - "version": "12.0.0-beta.6", - "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-12.0.0-beta.6.tgz", - "integrity": "sha512-/uKnelk0zfTLeckZXS+zIDV7QNSZ1gFEov57AIdNwFBUwaVxrNDheU9kwN4Dqk3Nv3fXuSkOoniLn8vdQE2zlw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], + "node_modules/@react-router/dev/node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, "engines": { - "node": ">=20.11.0" + "node": ">=6" } }, - "node_modules/@rescript/darwin-x64": { - "version": "12.0.0-beta.6", - "resolved": "https://registry.npmjs.org/@rescript/darwin-x64/-/darwin-x64-12.0.0-beta.6.tgz", - "integrity": "sha512-2W7EYHESETClXVhYan2pvEw2OsOEBZEEXmGuOSVYDhf/Pmi+z9ksKmf+omeJRlrV6SFyBzJ0opvAUwzMCietnw==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], + "node_modules/@react-router/dev/node_modules/react-refresh": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", + "integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@react-router/dev/node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@react-router/node": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/@react-router/node/-/node-7.8.1.tgz", + "integrity": "sha512-NC8eVQir2CRdcokzyyBsfxdq85Yu8B5XynDt581CzjBOreHAFfqIsNjGnqmg+aqBLiknQb2De9fH/TjyeYNeqw==", + "license": "MIT", + "dependencies": { + "@mjackson/node-fetch-server": "^0.2.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react-router": "7.8.1", + "typescript": "^5.1.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@react-router/node/node_modules/@mjackson/node-fetch-server": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@mjackson/node-fetch-server/-/node-fetch-server-0.2.0.tgz", + "integrity": "sha512-EMlH1e30yzmTpGLQjlFmaDAjyOeZhng1/XCd7DExR8PNAnG/G1tyruZxEoUe11ClnwGhGrtsdnyyUx1frSzjng==", + "license": "MIT" + }, + "node_modules/@react-stately/flags": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@react-stately/flags/-/flags-3.1.2.tgz", + "integrity": "sha512-2HjFcZx1MyQXoPqcBGALwWWmgFVUk2TuKVIQxCbRq7fPyWXIl6VHcakCLurdtYC2Iks7zizvz0Idv48MQ38DWg==", + "license": "Apache-2.0", + "dependencies": { + "@swc/helpers": "^0.5.0" + } + }, + "node_modules/@react-stately/utils": { + "version": "3.10.7", + "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.7.tgz", + "integrity": "sha512-cWvjGAocvy4abO9zbr6PW6taHgF24Mwy/LbQ4TC4Aq3tKdKDntxyD+sh7AkSRfJRT2ccMVaHVv2+FfHThd3PKQ==", + "license": "Apache-2.0", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-types/shared": { + "version": "3.30.0", + "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.30.0.tgz", + "integrity": "sha512-COIazDAx1ncDg046cTJ8SFYsX8aS3lB/08LDnbkH/SkdYrFPWDlXMrO/sUam8j1WWM+PJ+4d1mj7tODIKNiFog==", + "license": "Apache-2.0", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@rescript/darwin-arm64": { + "version": "12.0.0-beta.13", + "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-12.0.0-beta.13.tgz", + "integrity": "sha512-2cT13ELxFsnbEL3H9tzjOu5qzMbXrkxtb+RYgotVJyLdbQxlqPNqGhuZFT8QjZ86jpZgjZV29MKjjuh7JoXjmA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.11.0" + } + }, + "node_modules/@rescript/darwin-x64": { + "version": "12.0.0-beta.13", + "resolved": "https://registry.npmjs.org/@rescript/darwin-x64/-/darwin-x64-12.0.0-beta.13.tgz", + "integrity": "sha512-m/LqChC+11WIgPLTjtAbuhHzQjZ0yBN2/1px8uoACb0FQbGMznKPDZ39evBSa6dXcIKNXYEhmLLNTbeYJ5tlAQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], "engines": { "node": ">=20.11.0" } }, "node_modules/@rescript/linux-arm64": { - "version": "12.0.0-beta.6", - "resolved": "https://registry.npmjs.org/@rescript/linux-arm64/-/linux-arm64-12.0.0-beta.6.tgz", - "integrity": "sha512-J9hhbU1gwVkqXQMFv9tmmizZmry8u2JI8qep1i2g5fK5w8ijkB6YCOdIIk0aUzVJ5U7uNCPuTLAdf6GNb6T/ug==", + "version": "12.0.0-beta.13", + "resolved": "https://registry.npmjs.org/@rescript/linux-arm64/-/linux-arm64-12.0.0-beta.13.tgz", + "integrity": "sha512-LkXO1VqrphChZLeNCVOrIIk/tknh0GN6nbbwjmUU5381bmDde0WR81rKFA7/pR9W6hJT0J8/aZ2IaMuVQcFCww==", "cpu": [ "arm64" ], @@ -2354,9 +2833,9 @@ } }, "node_modules/@rescript/linux-x64": { - "version": "12.0.0-beta.6", - "resolved": "https://registry.npmjs.org/@rescript/linux-x64/-/linux-x64-12.0.0-beta.6.tgz", - "integrity": "sha512-vRnGVNYXJ0vNJRf1IbSVss3HGAxLqGrrNSzWdlVCAYp4wy03M2XET1cLaoPzsES6zxhCfzkGlPwJTKxGf3zlug==", + "version": "12.0.0-beta.13", + "resolved": "https://registry.npmjs.org/@rescript/linux-x64/-/linux-x64-12.0.0-beta.13.tgz", + "integrity": "sha512-IIBuRvQjRuLCvmmYbCv+uKxTPhu9a8TFR0vbIGpRMjF8HWrkWjTGB5Lq24dcFYyp+bdd2csWFedGpbk1nXm1+A==", "cpu": [ "x64" ], @@ -2378,19 +2857,24 @@ "react-dom": ">=19.0.0" } }, + "node_modules/@rescript/runtime": { + "version": "12.0.0-beta.13", + "resolved": "https://registry.npmjs.org/@rescript/runtime/-/runtime-12.0.0-beta.13.tgz", + "integrity": "sha512-PFwOsh9erOM6fn6Bo+3ewSqIyr1UOsRkOXJPo0IwO8hh1JoaBgtQDyjJqd7C2i1v7HvpW5JRjWebOezyFievEA==" + }, "node_modules/@rescript/webapi": { - "version": "0.1.0-experimental-0b87498", - "resolved": "https://registry.npmjs.org/@rescript/webapi/-/webapi-0.1.0-experimental-0b87498.tgz", - "integrity": "sha512-S5Mnp8S9muR8lSXQPcKD1F7gsVM+m6GbJptJZUHCjobQhEYhqcwS2elzgWkOcynsPNYMDXKJmtW/mtcjaGarPA==", + "version": "0.1.0-experimental-ae90e53", + "resolved": "https://registry.npmjs.org/@rescript/webapi/-/webapi-0.1.0-experimental-ae90e53.tgz", + "integrity": "sha512-wYnsm8TlUHGUgHCp6B3xtBZNs+SHdYbf6E8KdxJ/7iFPWlfhWepsoOUUG2f7yuWnI80N9gWEDQ9tE54rRroNqA==", "license": "MIT", "dependencies": { "rescript": "^12.0.0-beta.3" } }, "node_modules/@rescript/win32-x64": { - "version": "12.0.0-beta.6", - "resolved": "https://registry.npmjs.org/@rescript/win32-x64/-/win32-x64-12.0.0-beta.6.tgz", - "integrity": "sha512-aDNH0Q5j7GwXJpb3nF7PAriUjuzW0G2CT3X4SIxsJm51Yzc1T1p40VBKLOWFjQbE6o6kDNiGlUN1bYR6RvXRxw==", + "version": "12.0.0-beta.13", + "resolved": "https://registry.npmjs.org/@rescript/win32-x64/-/win32-x64-12.0.0-beta.13.tgz", + "integrity": "sha512-GYFyWNvabQf4F2wKcIPsvqxLJVefR73Eu9YnjGCGjgDPURLiD5tjHESCgUd6w5CKeA/DZFoPDtWTEmf0+9sbGw==", "cpu": [ "x64" ], @@ -2402,86 +2886,88 @@ "node": ">=20.11.0" } }, - "node_modules/@rushstack/eslint-patch": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.3.2.tgz", - "integrity": "sha512-V+MvGwaHH03hYhY+k6Ef/xKd6RYlc4q8WBx+2ANmipHJcKuktNcI/NgEsJgdSUF6Lw32njT6OnrRsKYCdgHjYw==" - }, - "node_modules/@swc/helpers": { - "version": "0.5.17", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz", - "integrity": "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==", - "license": "Apache-2.0", - "dependencies": { - "tslib": "^2.8.0" - } + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.27", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz", + "integrity": "sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==", + "dev": true, + "license": "MIT" }, - "node_modules/@tailwindcss/node": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.11.tgz", - "integrity": "sha512-yzhzuGRmv5QyU9qLNg4GTlYI6STedBWRE7NjxP45CsFYYq9taI0zJXZBMqIC/c8fViNLhmrbpSFS57EoxUmD6Q==", + "node_modules/@rollup/pluginutils": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.2.0.tgz", + "integrity": "sha512-qWJ2ZTbmumwiLFomfzTyt5Kng4hwPi9rwCYN4SHb6eaRU1KNO4ccxINHr/VhH4GgPlt1XfSTLX2LBTme8ne4Zw==", "dev": true, "license": "MIT", "dependencies": { - "@ampproject/remapping": "^2.3.0", - "enhanced-resolve": "^5.18.1", - "jiti": "^2.4.2", - "lightningcss": "1.30.1", - "magic-string": "^0.30.17", - "source-map-js": "^1.2.1", - "tailwindcss": "4.1.11" + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } } }, - "node_modules/@tailwindcss/oxide": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.1.11.tgz", - "integrity": "sha512-Q69XzrtAhuyfHo+5/HMgr1lAiPP/G40OMFAnws7xcFEYqcypZmdW8eGXaOUIeOl1dzPJBPENXgbjsOyhg2nkrg==", + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/pluginutils/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, - "hasInstallScript": true, "license": "MIT", - "dependencies": { - "detect-libc": "^2.0.4", - "tar": "^7.4.3" - }, "engines": { - "node": ">= 10" + "node": ">=12" }, - "optionalDependencies": { - "@tailwindcss/oxide-android-arm64": "4.1.11", - "@tailwindcss/oxide-darwin-arm64": "4.1.11", - "@tailwindcss/oxide-darwin-x64": "4.1.11", - "@tailwindcss/oxide-freebsd-x64": "4.1.11", - "@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.11", - "@tailwindcss/oxide-linux-arm64-gnu": "4.1.11", - "@tailwindcss/oxide-linux-arm64-musl": "4.1.11", - "@tailwindcss/oxide-linux-x64-gnu": "4.1.11", - "@tailwindcss/oxide-linux-x64-musl": "4.1.11", - "@tailwindcss/oxide-wasm32-wasi": "4.1.11", - "@tailwindcss/oxide-win32-arm64-msvc": "4.1.11", - "@tailwindcss/oxide-win32-x64-msvc": "4.1.11" - } - }, - "node_modules/@tailwindcss/oxide-android-arm64": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.1.11.tgz", - "integrity": "sha512-3IfFuATVRUMZZprEIx9OGDjG3Ou3jG4xQzNTvjDoKmU9JdmoCohQJ83MYd0GPnQIu89YoJqvMM0G3uqLRFtetg==", + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.46.2.tgz", + "integrity": "sha512-Zj3Hl6sN34xJtMv7Anwb5Gu01yujyE/cLBDB2gnHTAHaWS1Z38L7kuSG+oAh0giZMqG060f/YBStXtMH6FvPMA==", "cpu": [ - "arm64" + "arm" ], "dev": true, "license": "MIT", "optional": true, "os": [ "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.46.2.tgz", + "integrity": "sha512-nTeCWY83kN64oQ5MGz3CgtPx8NSOhC5lWtsjTs+8JAJNLcP3QbLCtDDgUKQc/Ro/frpMq4SHUaHN6AMltcEoLQ==", + "cpu": [ + "arm64" ], - "engines": { - "node": ">= 10" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] }, - "node_modules/@tailwindcss/oxide-darwin-arm64": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.1.11.tgz", - "integrity": "sha512-ESgStEOEsyg8J5YcMb1xl8WFOXfeBmrhAwGsFxxB2CxY9evy63+AtpbDLAyRkJnxLy2WsD1qF13E97uQyP1lfQ==", + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.46.2.tgz", + "integrity": "sha512-HV7bW2Fb/F5KPdM/9bApunQh68YVDU8sO8BvcW9OngQVN3HHHkw99wFupuUJfGR9pYLLAjcAOA6iO+evsbBaPQ==", "cpu": [ "arm64" ], @@ -2490,15 +2976,12 @@ "optional": true, "os": [ "darwin" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@tailwindcss/oxide-darwin-x64": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.1.11.tgz", - "integrity": "sha512-EgnK8kRchgmgzG6jE10UQNaH9Mwi2n+yw1jWmof9Vyg2lpKNX2ioe7CJdf9M5f8V9uaQxInenZkOxnTVL3fhAw==", + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.46.2.tgz", + "integrity": "sha512-SSj8TlYV5nJixSsm/y3QXfhspSiLYP11zpfwp6G/YDXctf3Xkdnk4woJIF5VQe0of2OjzTt8EsxnJDCdHd2xMA==", "cpu": [ "x64" ], @@ -2507,15 +2990,26 @@ "optional": true, "os": [ "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.46.2.tgz", + "integrity": "sha512-ZyrsG4TIT9xnOlLsSSi9w/X29tCbK1yegE49RYm3tu3wF1L/B6LVMqnEWyDB26d9Ecx9zrmXCiPmIabVuLmNSg==", + "cpu": [ + "arm64" ], - "engines": { - "node": ">= 10" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] }, - "node_modules/@tailwindcss/oxide-freebsd-x64": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.1.11.tgz", - "integrity": "sha512-xdqKtbpHs7pQhIKmqVpxStnY1skuNh4CtbcyOHeX1YBE0hArj2romsFGb6yUmzkq/6M24nkxDqU8GYrKrz+UcA==", + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.46.2.tgz", + "integrity": "sha512-pCgHFoOECwVCJ5GFq8+gR8SBKnMO+xe5UEqbemxBpCKYQddRQMgomv1104RnLSg7nNvgKy05sLsY51+OVRyiVw==", "cpu": [ "x64" ], @@ -2524,15 +3018,12 @@ "optional": true, "os": [ "freebsd" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.1.11.tgz", - "integrity": "sha512-ryHQK2eyDYYMwB5wZL46uoxz2zzDZsFBwfjssgB7pzytAeCCa6glsiJGjhTEddq/4OsIjsLNMAiMlHNYnkEEeg==", + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.46.2.tgz", + "integrity": "sha512-EtP8aquZ0xQg0ETFcxUbU71MZlHaw9MChwrQzatiE8U/bvi5uv/oChExXC4mWhjiqK7azGJBqU0tt5H123SzVA==", "cpu": [ "arm" ], @@ -2541,32 +3032,26 @@ "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.1.11.tgz", - "integrity": "sha512-mYwqheq4BXF83j/w75ewkPJmPZIqqP1nhoghS9D57CLjsh3Nfq0m4ftTotRYtGnZd3eCztgbSPJ9QhfC91gDZQ==", + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.46.2.tgz", + "integrity": "sha512-qO7F7U3u1nfxYRPM8HqFtLd+raev2K137dsV08q/LRKRLEc7RsiDWihUnrINdsWQxPR9jqZ8DIIZ1zJJAm5PjQ==", "cpu": [ - "arm64" + "arm" ], "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@tailwindcss/oxide-linux-arm64-musl": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.1.11.tgz", - "integrity": "sha512-m/NVRFNGlEHJrNVk3O6I9ggVuNjXHIPoD6bqay/pubtYC9QIdAMpS+cswZQPBLvVvEF6GtSNONbDkZrjWZXYNQ==", + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.46.2.tgz", + "integrity": "sha512-3dRaqLfcOXYsfvw5xMrxAk9Lb1f395gkoBYzSFcc/scgRFptRXL9DOaDpMiehf9CO8ZDRJW2z45b6fpU5nwjng==", "cpu": [ "arm64" ], @@ -2575,139 +3060,240 @@ "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@tailwindcss/oxide-linux-x64-gnu": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.1.11.tgz", - "integrity": "sha512-YW6sblI7xukSD2TdbbaeQVDysIm/UPJtObHJHKxDEcW2exAtY47j52f8jZXkqE1krdnkhCMGqP3dbniu1Te2Fg==", + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.46.2.tgz", + "integrity": "sha512-fhHFTutA7SM+IrR6lIfiHskxmpmPTJUXpWIsBXpeEwNgZzZZSg/q4i6FU4J8qOGyJ0TR+wXBwx/L7Ho9z0+uDg==", "cpu": [ - "x64" + "arm64" ], "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@tailwindcss/oxide-linux-x64-musl": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.1.11.tgz", - "integrity": "sha512-e3C/RRhGunWYNC3aSF7exsQkdXzQ/M+aYuZHKnw4U7KQwTJotnWsGOIVih0s2qQzmEzOFIJ3+xt7iq67K/p56Q==", + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.46.2.tgz", + "integrity": "sha512-i7wfGFXu8x4+FRqPymzjD+Hyav8l95UIZ773j7J7zRYc3Xsxy2wIn4x+llpunexXe6laaO72iEjeeGyUFmjKeA==", "cpu": [ - "x64" + "loong64" ], "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@tailwindcss/oxide-wasm32-wasi": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.1.11.tgz", - "integrity": "sha512-Xo1+/GU0JEN/C/dvcammKHzeM6NqKovG+6921MR6oadee5XPBaKOumrJCXvopJ/Qb5TH7LX/UAywbqrP4lax0g==", - "bundleDependencies": [ - "@napi-rs/wasm-runtime", - "@emnapi/core", - "@emnapi/runtime", - "@tybys/wasm-util", - "@emnapi/wasi-threads", - "tslib" - ], + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.46.2.tgz", + "integrity": "sha512-B/l0dFcHVUnqcGZWKcWBSV2PF01YUt0Rvlurci5P+neqY/yMKchGU8ullZvIv5e8Y1C6wOn+U03mrDylP5q9Yw==", "cpu": [ - "wasm32" + "ppc64" ], "dev": true, "license": "MIT", "optional": true, - "dependencies": { - "@emnapi/core": "^1.4.3", - "@emnapi/runtime": "^1.4.3", - "@emnapi/wasi-threads": "^1.0.2", - "@napi-rs/wasm-runtime": "^0.2.11", - "@tybys/wasm-util": "^0.9.0", - "tslib": "^2.8.0" - }, - "engines": { - "node": ">=14.0.0" - } + "os": [ + "linux" + ] }, - "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": { - "version": "1.4.3", + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.46.2.tgz", + "integrity": "sha512-32k4ENb5ygtkMwPMucAb8MtV8olkPT03oiTxJbgkJa7lJ7dZMr0GCFJlyvy+K8iq7F/iuOr41ZdUHaOiqyR3iQ==", + "cpu": [ + "riscv64" + ], "dev": true, - "inBundle": true, "license": "MIT", "optional": true, - "dependencies": { - "@emnapi/wasi-threads": "1.0.2", - "tslib": "^2.4.0" - } + "os": [ + "linux" + ] }, - "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": { - "version": "1.4.3", + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.46.2.tgz", + "integrity": "sha512-t5B2loThlFEauloaQkZg9gxV05BYeITLvLkWOkRXogP4qHXLkWSbSHKM9S6H1schf/0YGP/qNKtiISlxvfmmZw==", + "cpu": [ + "riscv64" + ], "dev": true, - "inBundle": true, "license": "MIT", "optional": true, - "dependencies": { - "tslib": "^2.4.0" - } + "os": [ + "linux" + ] }, - "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": { - "version": "1.0.2", + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.46.2.tgz", + "integrity": "sha512-YKjekwTEKgbB7n17gmODSmJVUIvj8CX7q5442/CK80L8nqOUbMtf8b01QkG3jOqyr1rotrAnW6B/qiHwfcuWQA==", + "cpu": [ + "s390x" + ], "dev": true, - "inBundle": true, "license": "MIT", "optional": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { - "version": "0.2.11", + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.46.2.tgz", + "integrity": "sha512-Jj5a9RUoe5ra+MEyERkDKLwTXVu6s3aACP51nkfnK9wJTraCC8IMe3snOfALkrjTYd2G1ViE1hICj0fZ7ALBPA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.46.2.tgz", + "integrity": "sha512-7kX69DIrBeD7yNp4A5b81izs8BqoZkCIaxQaOpumcJ1S/kmqNFjPhDu1LHeVXv0SexfHQv5cqHsxLOjETuqDuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.46.2.tgz", + "integrity": "sha512-wiJWMIpeaak/jsbaq2HMh/rzZxHVW1rU6coyeNNpMwk5isiPjSTx0a4YLSlYDwBH/WBvLz+EtsNqQScZTLJy3g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.46.2.tgz", + "integrity": "sha512-gBgaUDESVzMgWZhcyjfs9QFK16D8K6QZpwAaVNJxYDLHWayOta4ZMjGm/vsAEy3hvlS2GosVFlBlP9/Wb85DqQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.46.2.tgz", + "integrity": "sha512-CvUo2ixeIQGtF6WvuB87XWqPQkoFAFqW+HUo/WzHwuHDvIwZCtjdWXoYCcr06iKGydiqTclC4jU/TNObC/xKZg==", + "cpu": [ + "x64" + ], "dev": true, - "inBundle": true, "license": "MIT", "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rushstack/eslint-patch": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.3.2.tgz", + "integrity": "sha512-V+MvGwaHH03hYhY+k6Ef/xKd6RYlc4q8WBx+2ANmipHJcKuktNcI/NgEsJgdSUF6Lw32njT6OnrRsKYCdgHjYw==" + }, + "node_modules/@swc/helpers": { + "version": "0.5.17", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz", + "integrity": "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==", + "license": "Apache-2.0", "dependencies": { - "@emnapi/core": "^1.4.3", - "@emnapi/runtime": "^1.4.3", - "@tybys/wasm-util": "^0.9.0" + "tslib": "^2.8.0" } }, - "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": { - "version": "0.9.0", + "node_modules/@tailwindcss/vite": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.1.13.tgz", + "integrity": "sha512-0PmqLQ010N58SbMTJ7BVJ4I2xopiQn/5i6nlb4JmxzQf8zcS5+m2Cv6tqh+sfDwtIdjoEnOvwsGQ1hkUi8QEHQ==", "dev": true, - "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { - "tslib": "^2.4.0" + "@tailwindcss/node": "4.1.13", + "@tailwindcss/oxide": "4.1.13", + "tailwindcss": "4.1.13" + }, + "peerDependencies": { + "vite": "^5.2.0 || ^6 || ^7" } }, - "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": { - "version": "2.8.0", + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/node": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.13.tgz", + "integrity": "sha512-eq3ouolC1oEFOAvOMOBAmfCIqZBJuvWvvYWh5h5iOYfe1HFC6+GZ6EIL0JdM3/niGRJmnrOc+8gl9/HGUaaptw==", "dev": true, - "inBundle": true, - "license": "0BSD", - "optional": true + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.4", + "enhanced-resolve": "^5.18.3", + "jiti": "^2.5.1", + "lightningcss": "1.30.1", + "magic-string": "^0.30.18", + "source-map-js": "^1.2.1", + "tailwindcss": "4.1.13" + } }, - "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.11.tgz", - "integrity": "sha512-UgKYx5PwEKrac3GPNPf6HVMNhUIGuUh4wlDFR2jYYdkX6pL/rn73zTq/4pzUm8fOjAn5L8zDeHp9iXmUGOXZ+w==", + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.1.13.tgz", + "integrity": "sha512-CPgsM1IpGRa880sMbYmG1s4xhAy3xEt1QULgTJGQmZUeNgXFR7s1YxYygmJyBGtou4SyEosGAGEeYqY7R53bIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "detect-libc": "^2.0.4", + "tar": "^7.4.3" + }, + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.1.13", + "@tailwindcss/oxide-darwin-arm64": "4.1.13", + "@tailwindcss/oxide-darwin-x64": "4.1.13", + "@tailwindcss/oxide-freebsd-x64": "4.1.13", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.13", + "@tailwindcss/oxide-linux-arm64-gnu": "4.1.13", + "@tailwindcss/oxide-linux-arm64-musl": "4.1.13", + "@tailwindcss/oxide-linux-x64-gnu": "4.1.13", + "@tailwindcss/oxide-linux-x64-musl": "4.1.13", + "@tailwindcss/oxide-wasm32-wasi": "4.1.13", + "@tailwindcss/oxide-win32-arm64-msvc": "4.1.13", + "@tailwindcss/oxide-win32-x64-msvc": "4.1.13" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.1.13.tgz", + "integrity": "sha512-BrpTrVYyejbgGo57yc8ieE+D6VT9GOgnNdmh5Sac6+t0m+v+sKQevpFVpwX3pBrM2qKrQwJ0c5eDbtjouY/+ew==", "cpu": [ "arm64" ], @@ -2715,16 +3301,33 @@ "license": "MIT", "optional": true, "os": [ - "win32" + "android" ], "engines": { "node": ">= 10" } }, - "node_modules/@tailwindcss/oxide-win32-x64-msvc": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.1.11.tgz", - "integrity": "sha512-YfHoggn1j0LK7wR82TOucWc5LDCguHnoS879idHekmmiR7g9HUtMw9MI0NHatS28u/Xlkfi9w5RJWgz2Dl+5Qg==", + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.1.13.tgz", + "integrity": "sha512-YP+Jksc4U0KHcu76UhRDHq9bx4qtBftp9ShK/7UGfq0wpaP96YVnnjFnj3ZFrUAjc5iECzODl/Ts0AN7ZPOANQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.1.13.tgz", + "integrity": "sha512-aAJ3bbwrn/PQHDxCto9sxwQfT30PzyYJFG0u/BWZGeVXi5Hx6uuUOQEI2Fa43qvmUjTRQNZnGqe9t0Zntexeuw==", "cpu": [ "x64" ], @@ -2732,55 +3335,185 @@ "license": "MIT", "optional": true, "os": [ - "win32" + "darwin" ], "engines": { "node": ">= 10" } }, - "node_modules/@tailwindcss/postcss": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@tailwindcss/postcss/-/postcss-4.1.11.tgz", - "integrity": "sha512-q/EAIIpF6WpLhKEuQSEVMZNMIY8KhWoAemZ9eylNAih9jxMGAYPPWBn3I9QL/2jZ+e7OEz/tZkX5HwbBR4HohA==", + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.1.13.tgz", + "integrity": "sha512-Wt8KvASHwSXhKE/dJLCCWcTSVmBj3xhVhp/aF3RpAhGeZ3sVo7+NTfgiN8Vey/Fi8prRClDs6/f0KXPDTZE6nQ==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", - "dependencies": { - "@alloc/quick-lru": "^5.2.0", - "@tailwindcss/node": "4.1.11", - "@tailwindcss/oxide": "4.1.11", - "postcss": "^8.4.41", - "tailwindcss": "4.1.11" + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" } }, - "node_modules/@tailwindcss/postcss/node_modules/postcss": { - "version": "8.5.6", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", - "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.1.13.tgz", + "integrity": "sha512-mbVbcAsW3Gkm2MGwA93eLtWrwajz91aXZCNSkGTx/R5eb6KpKD5q8Ueckkh9YNboU8RH7jiv+ol/I7ZyQ9H7Bw==", + "cpu": [ + "arm" + ], "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.1.13.tgz", + "integrity": "sha512-wdtfkmpXiwej/yoAkrCP2DNzRXCALq9NVLgLELgLim1QpSfhQM5+ZxQQF8fkOiEpuNoKLp4nKZ6RC4kmeFH0HQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.1.13.tgz", + "integrity": "sha512-hZQrmtLdhyqzXHB7mkXfq0IYbxegaqTmfa1p9MBj72WPoDD3oNOh1Lnxf6xZLY9C3OV6qiCYkO1i/LrzEdW2mg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.1.13.tgz", + "integrity": "sha512-uaZTYWxSXyMWDJZNY1Ul7XkJTCBRFZ5Fo6wtjrgBKzZLoJNrG+WderJwAjPzuNZOnmdrVg260DKwXCFtJ/hWRQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.1.13.tgz", + "integrity": "sha512-oXiPj5mi4Hdn50v5RdnuuIms0PVPI/EG4fxAfFiIKQh5TgQgX7oSuDWntHW7WNIi/yVLAiS+CRGW4RkoGSSgVQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-wasm32-wasi": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.1.13.tgz", + "integrity": "sha512-+LC2nNtPovtrDwBc/nqnIKYh/W2+R69FA0hgoeOn64BdCX522u19ryLh3Vf3F8W49XBcMIxSe665kwy21FkhvA==", + "bundleDependencies": [ + "@napi-rs/wasm-runtime", + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util", + "@emnapi/wasi-threads", + "tslib" + ], + "cpu": [ + "wasm32" ], + "dev": true, "license": "MIT", + "optional": true, "dependencies": { - "nanoid": "^3.3.11", - "picocolors": "^1.1.1", - "source-map-js": "^1.2.1" + "@emnapi/core": "^1.4.5", + "@emnapi/runtime": "^1.4.5", + "@emnapi/wasi-threads": "^1.0.4", + "@napi-rs/wasm-runtime": "^0.2.12", + "@tybys/wasm-util": "^0.10.0", + "tslib": "^2.8.0" }, "engines": { - "node": "^10 || ^12 || >=14" + "node": ">=14.0.0" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.13.tgz", + "integrity": "sha512-dziTNeQXtoQ2KBXmrjCxsuPk3F3CQ/yb7ZNZNA+UkNTeiTGgfeh+gH5Pi7mRncVgcPD2xgHvkFCh/MhZWSgyQg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/vite/node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.1.13.tgz", + "integrity": "sha512-3+LKesjXydTkHk5zXX01b5KMzLV1xl2mcktBJkje7rhFUpUlYJy7IMOLqjIRQncLTa1WZZiFY/foAeB5nmaiTw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" } }, + "node_modules/@tailwindcss/vite/node_modules/tailwindcss": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.13.tgz", + "integrity": "sha512-i+zidfmTqtwquj4hMEwdjshYYgMbOrPzb9a0M3ZgNa0JMoZeFC6bxZvO8yr8ozS6ix2SDz0+mvryPeBs2TFE+w==", + "dev": true, + "license": "MIT" + }, "node_modules/@tanstack/react-virtual": { "version": "3.13.10", "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.13.10.tgz", @@ -2808,15 +3541,6 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, - "node_modules/@trysound/sax": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", - "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", - "dev": true, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/@tybys/wasm-util": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.0.tgz", @@ -2836,36 +3560,58 @@ "@types/estree": "*" } }, - "node_modules/@types/debug": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.8.tgz", - "integrity": "sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ==", + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", "dependencies": { - "@types/ms": "*" + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" } }, - "node_modules/@types/eslint": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz", - "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", - "devOptional": true, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" + "@babel/types": "^7.0.0" } }, - "node_modules/@types/eslint-scope": { - "version": "3.7.7", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz", - "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==", - "devOptional": true, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@types/eslint": "*", - "@types/estree": "*" + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz", + "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.2" + } + }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "license": "MIT", + "dependencies": { + "@types/ms": "*" } }, "node_modules/@types/estree": { @@ -2882,49 +3628,42 @@ "@types/estree": "*" } }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "devOptional": true, - "license": "MIT", - "peer": true - }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==" }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/mdx": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.5.tgz", "integrity": "sha512-76CqzuD6Q7LC+AtbPqrvD9AqsN0k8bsYo2bM2J8pmNldP1aIPAbzUQ7QbobyXL4eLr1wK5x8FZFe8eF/ubRuBg==" }, "node_modules/@types/ms": { - "version": "0.7.31", - "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", - "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" - }, - "node_modules/@types/node": { - "version": "24.1.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz", - "integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "undici-types": "~7.8.0" - } + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "license": "MIT" }, "node_modules/@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", - "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" + "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", + "dev": true }, "node_modules/@types/react": { "version": "18.0.15", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.15.tgz", "integrity": "sha512-iz3BtLuIYH1uWdsv6wXYdhozhqj20oD4/Hk2DNXIn1kFsmp9x8d9QB6FnPhfkbhd2PgEONt9Q1x/ebkwjfFLow==", + "dev": true, "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -2934,7 +3673,14 @@ "node_modules/@types/scheduler": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", - "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==" + "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", + "dev": true + }, + "node_modules/@types/ungap__structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/ungap__structured-clone/-/ungap__structured-clone-1.2.0.tgz", + "integrity": "sha512-ZoaihZNLeZSxESbk9PUAPZOlSpcKx81I1+4emtULDVmBLkYutTcMlCj2K9VNlf9EWODxdO6gkAqEaLorXwZQVA==", + "license": "MIT" }, "node_modules/@types/unist": { "version": "2.0.7", @@ -3084,197 +3830,76 @@ "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" }, - "node_modules/@webassemblyjs/ast": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", - "integrity": "sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@webassemblyjs/helper-numbers": "1.13.2", - "@webassemblyjs/helper-wasm-bytecode": "1.13.2" - } - }, - "node_modules/@webassemblyjs/floating-point-hex-parser": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz", - "integrity": "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==", - "devOptional": true, - "license": "MIT", - "peer": true - }, - "node_modules/@webassemblyjs/helper-api-error": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.13.2.tgz", - "integrity": "sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==", - "devOptional": true, - "license": "MIT", - "peer": true - }, - "node_modules/@webassemblyjs/helper-buffer": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.14.1.tgz", - "integrity": "sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA==", - "devOptional": true, - "license": "MIT", - "peer": true - }, - "node_modules/@webassemblyjs/helper-numbers": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.13.2.tgz", - "integrity": "sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@webassemblyjs/floating-point-hex-parser": "1.13.2", - "@webassemblyjs/helper-api-error": "1.13.2", - "@xtuc/long": "4.2.2" - } - }, - "node_modules/@webassemblyjs/helper-wasm-bytecode": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz", - "integrity": "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==", - "devOptional": true, - "license": "MIT", - "peer": true - }, - "node_modules/@webassemblyjs/helper-wasm-section": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.14.1.tgz", - "integrity": "sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@webassemblyjs/ast": "1.14.1", - "@webassemblyjs/helper-buffer": "1.14.1", - "@webassemblyjs/helper-wasm-bytecode": "1.13.2", - "@webassemblyjs/wasm-gen": "1.14.1" - } - }, - "node_modules/@webassemblyjs/ieee754": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.13.2.tgz", - "integrity": "sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@xtuc/ieee754": "^1.2.0" - } - }, - "node_modules/@webassemblyjs/leb128": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.13.2.tgz", - "integrity": "sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw==", - "devOptional": true, - "license": "Apache-2.0", - "peer": true, - "dependencies": { - "@xtuc/long": "4.2.2" - } - }, - "node_modules/@webassemblyjs/utf8": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.13.2.tgz", - "integrity": "sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ==", - "devOptional": true, - "license": "MIT", - "peer": true - }, - "node_modules/@webassemblyjs/wasm-edit": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.14.1.tgz", - "integrity": "sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@webassemblyjs/ast": "1.14.1", - "@webassemblyjs/helper-buffer": "1.14.1", - "@webassemblyjs/helper-wasm-bytecode": "1.13.2", - "@webassemblyjs/helper-wasm-section": "1.14.1", - "@webassemblyjs/wasm-gen": "1.14.1", - "@webassemblyjs/wasm-opt": "1.14.1", - "@webassemblyjs/wasm-parser": "1.14.1", - "@webassemblyjs/wast-printer": "1.14.1" - } - }, - "node_modules/@webassemblyjs/wasm-gen": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.14.1.tgz", - "integrity": "sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg==", - "devOptional": true, + "node_modules/@vitejs/plugin-react": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz", + "integrity": "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==", + "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@webassemblyjs/ast": "1.14.1", - "@webassemblyjs/helper-wasm-bytecode": "1.13.2", - "@webassemblyjs/ieee754": "1.13.2", - "@webassemblyjs/leb128": "1.13.2", - "@webassemblyjs/utf8": "1.13.2" + "@babel/core": "^7.28.0", + "@babel/plugin-transform-react-jsx-self": "^7.27.1", + "@babel/plugin-transform-react-jsx-source": "^7.27.1", + "@rolldown/pluginutils": "1.0.0-beta.27", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.17.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, - "node_modules/@webassemblyjs/wasm-opt": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.14.1.tgz", - "integrity": "sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw==", - "devOptional": true, + "node_modules/@vitejs/plugin-rsc": { + "version": "0.4.16", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-rsc/-/plugin-rsc-0.4.16.tgz", + "integrity": "sha512-QIURKHMpMiwWPi78/9nBzW6wN0PKt3rqNMsLw7NRz5ZuayQVq6hZlH0fP018m6/giFDDHKokb8Hy+bvHrtdrqw==", + "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@webassemblyjs/ast": "1.14.1", - "@webassemblyjs/helper-buffer": "1.14.1", - "@webassemblyjs/wasm-gen": "1.14.1", - "@webassemblyjs/wasm-parser": "1.14.1" + "@mjackson/node-fetch-server": "^0.7.0", + "es-module-lexer": "^1.7.0", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17", + "periscopic": "^4.0.2", + "turbo-stream": "^3.1.0", + "vitefu": "^1.1.1" + }, + "peerDependencies": { + "react": "*", + "react-dom": "*", + "vite": "*" } }, - "node_modules/@webassemblyjs/wasm-parser": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.14.1.tgz", - "integrity": "sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ==", - "devOptional": true, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", "license": "MIT", - "peer": true, "dependencies": { - "@webassemblyjs/ast": "1.14.1", - "@webassemblyjs/helper-api-error": "1.13.2", - "@webassemblyjs/helper-wasm-bytecode": "1.13.2", - "@webassemblyjs/ieee754": "1.13.2", - "@webassemblyjs/leb128": "1.13.2", - "@webassemblyjs/utf8": "1.13.2" + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" } }, - "node_modules/@webassemblyjs/wast-printer": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.14.1.tgz", - "integrity": "sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==", - "devOptional": true, + "node_modules/abstract-cache": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/abstract-cache/-/abstract-cache-1.0.1.tgz", + "integrity": "sha512-EfUeMhRUbG5bVVbrSY/ogLlFXoyfMAPxMlSP7wrEqH53d+59r2foVy9a5KjmprLKFLOfPQCNKEfpBN/nQ76chw==", "license": "MIT", - "peer": true, "dependencies": { - "@webassemblyjs/ast": "1.14.1", - "@xtuc/long": "4.2.2" + "clone": "^2.1.1", + "lru_map": "^0.3.3", + "merge-options": "^1.0.0" } }, - "node_modules/@xtuc/ieee754": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", - "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", - "devOptional": true, - "license": "BSD-3-Clause", - "peer": true - }, - "node_modules/@xtuc/long": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", - "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", - "devOptional": true, - "license": "Apache-2.0", - "peer": true + "node_modules/abstract-logging": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz", + "integrity": "sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==", + "license": "MIT" }, "node_modules/accepts": { "version": "1.3.8", @@ -3300,20 +3925,6 @@ "node": ">=0.4.0" } }, - "node_modules/acorn-import-phases": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz", - "integrity": "sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==", - "devOptional": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=10.13.0" - }, - "peerDependencies": { - "acorn": "^8.14.0" - } - }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", @@ -3333,56 +3944,20 @@ } }, "node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", - "devOptional": true, - "license": "MIT", - "peer": true, + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" }, "funding": { "type": "github", "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, - "node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, "node_modules/algoliasearch": { "version": "5.29.0", "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-5.29.0.tgz", @@ -3407,6 +3982,15 @@ "node": ">= 14.0.0" } }, + "node_modules/ansi-align": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", + "integrity": "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==", + "license": "ISC", + "dependencies": { + "string-width": "^4.1.0" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -3429,25 +4013,11 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "license": "Python-2.0", - "peer": true + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "dev": true }, "node_modules/aria-query": { "version": "5.3.0", @@ -3630,56 +4200,24 @@ "astring": "bin/astring" } }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, - "node_modules/at-least-node": { + "node_modules/atomic-sleep": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true, - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/autoprefixer": { - "version": "10.4.21", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.21.tgz", - "integrity": "sha512-O+A6LWV5LDHSJD3LjHYoNi4VLsj/Whi7k6zG12xTYaU4cQ8oxQGckXNX8cRHK5yOZ/ppVHe0ZBXGzSV9jXdVbQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/autoprefixer" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", "license": "MIT", - "dependencies": { - "browserslist": "^4.24.4", - "caniuse-lite": "^1.0.30001702", - "fraction.js": "^4.3.7", - "normalize-range": "^0.1.2", - "picocolors": "^1.1.1", - "postcss-value-parser": "^4.2.0" - }, - "bin": { - "autoprefixer": "bin/autoprefixer" - }, "engines": { - "node": "^10 || ^12 || >=14" - }, - "peerDependencies": { - "postcss": "^8.1.0" + "node": ">=8.0.0" } }, "node_modules/available-typed-arrays": { @@ -3693,6 +4231,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/avvio": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/avvio/-/avvio-9.1.0.tgz", + "integrity": "sha512-fYASnYi600CsH/j9EQov7lECAniYiBFiiAtBNuZYLA2leLe9qOvZzqYHFjtIj6gD2VMoMLP14834LFWvr4IfDw==", + "license": "MIT", + "dependencies": { + "@fastify/error": "^4.0.0", + "fastq": "^1.17.1" + } + }, "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -3722,6 +4270,19 @@ "dequal": "^2.0.3" } }, + "node_modules/babel-dead-code-elimination": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/babel-dead-code-elimination/-/babel-dead-code-elimination-1.0.10.tgz", + "integrity": "sha512-DV5bdJZTzZ0zn0DC24v3jD7Mnidh6xhKa4GfKCbq3sfW8kaWhDdZjP3i81geA8T33tdYqWKw4D3fVv0CwEgKVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.23.7", + "@babel/parser": "^7.23.6", + "@babel/traverse": "^7.23.7", + "@babel/types": "^7.23.6" + } + }, "node_modules/bail": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", @@ -3736,6 +4297,36 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/baseline-browser-mapping": { + "version": "2.8.11", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.11.tgz", + "integrity": "sha512-i+sRXGhz4+QW8aACZ3+r1GAKMt0wlFpeA8M5rOQd0HEYw9zhDrlx9Wc8uQ0IdXakjJRthzglEwfB/yqIjO6iDg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.js" + } + }, "node_modules/batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", @@ -3757,24 +4348,6 @@ "node": ">=0.6" } }, - "node_modules/big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/body-parser": { "version": "1.20.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", @@ -3811,33 +4384,134 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/boolbase": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", - "dev": true - }, - "node_modules/bplist-parser": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", - "integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==", + "node_modules/boxen": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-8.0.1.tgz", + "integrity": "sha512-F3PH5k5juxom4xktynS7MoFY+NUWH5LC4CnH11YB8NPew+HLpmBLCybSAEyb2F+4pRXhuhWqFesoQd6DAyc2hw==", + "license": "MIT", "dependencies": { - "big-integer": "^1.6.44" + "ansi-align": "^3.0.1", + "camelcase": "^8.0.0", + "chalk": "^5.3.0", + "cli-boxes": "^3.0.0", + "string-width": "^7.2.0", + "type-fest": "^4.21.0", + "widest-line": "^5.0.0", + "wrap-ansi": "^9.0.0" }, "engines": { - "node": ">= 5.10.0" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "node_modules/boxen/node_modules/ansi-regex": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/boxen/node_modules/camelcase": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-8.0.0.tgz", + "integrity": "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==", + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/boxen/node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/boxen/node_modules/emoji-regex": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", + "license": "MIT" + }, + "node_modules/boxen/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/boxen/node_modules/strip-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/boxen/node_modules/type-fest": { + "version": "4.41.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", + "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/bplist-parser": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", + "integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==", + "dependencies": { + "big-integer": "^1.6.44" + }, + "engines": { + "node": ">= 5.10.0" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/braces": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", @@ -3850,10 +4524,10 @@ } }, "node_modules/browserslist": { - "version": "4.25.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.25.1.tgz", - "integrity": "sha512-KGj0KoOMXLpSNkkEI6Z6mShmQy0bc1I+T7K9N81k4WWMrfz+6fQ6es80B/YLAeRoKvjYE1YSHHOW1qe9xIVzHw==", - "devOptional": true, + "version": "4.26.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.26.3.tgz", + "integrity": "sha512-lAUU+02RFBuCKQPj/P6NgjlbCnLBMp4UtgTx7vNHd3XSIJF87s9a5rA3aH2yw3GS9DqZAUbOtZdCCiZeVRqt0w==", + "dev": true, "funding": [ { "type": "opencollective", @@ -3870,9 +4544,10 @@ ], "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001726", - "electron-to-chromium": "^1.5.173", - "node-releases": "^2.0.19", + "baseline-browser-mapping": "^2.8.9", + "caniuse-lite": "^1.0.30001746", + "electron-to-chromium": "^1.5.227", + "node-releases": "^2.0.21", "update-browserslist-db": "^1.1.3" }, "bin": { @@ -3882,13 +4557,35 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "devOptional": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/bundle-name": { "version": "3.0.0", @@ -3912,6 +4609,16 @@ "node": ">= 0.8" } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", @@ -3930,32 +4637,11 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/caniuse-api": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", - "integrity": "sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==", - "dev": true, - "dependencies": { - "browserslist": "^4.0.0", - "caniuse-lite": "^1.0.0", - "lodash.memoize": "^4.1.2", - "lodash.uniq": "^4.5.0" - } - }, "node_modules/caniuse-lite": { - "version": "1.0.30001731", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001731.tgz", - "integrity": "sha512-lDdp2/wrOmTRWuoB5DpfNkC0rJDU8DqRa6nYL6HK6sytw70QMopt/NIc/9SM7ylItlBWfACXk0tEn37UWM/+mg==", + "version": "1.0.30001747", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001747.tgz", + "integrity": "sha512-mzFa2DGIhuc5490Nd/G31xN1pnBnYMadtkyTjefPI7wzypqgCEpeWu9bJr0OnDsyKrW75zA9ZAt7pbQFmwLsQg==", + "dev": true, "funding": [ { "type": "opencollective", @@ -3986,21 +4672,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "node_modules/character-entities": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", @@ -4037,43 +4708,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/chokidar/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/chownr": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", @@ -4084,32 +4718,52 @@ "node": ">=18" } }, - "node_modules/chrome-trace-event": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz", - "integrity": "sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==", - "devOptional": true, + "node_modules/cli-boxes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", + "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==", "license": "MIT", - "peer": true, "engines": { - "node": ">=6.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/client-only": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", - "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==", - "license": "MIT" + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, + "node_modules/cli-table3": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.5.tgz", + "integrity": "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==", + "license": "MIT", "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" + "string-width": "^4.2.0" + }, + "engines": { + "node": "10.* || >= 12.*" + }, + "optionalDependencies": { + "@colors/colors": "1.5.0" + } + }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "license": "MIT", + "engines": { + "node": ">=0.8" } }, "node_modules/clsx": { @@ -4136,20 +4790,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/color": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", - "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", - "license": "MIT", - "optional": true, - "dependencies": { - "color-convert": "^2.0.1", - "color-string": "^1.9.0" - }, - "engines": { - "node": ">=12.5.0" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -4166,22 +4806,11 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, - "node_modules/color-string": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", - "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", - "license": "MIT", - "optional": true, - "dependencies": { - "color-name": "^1.0.0", - "simple-swizzle": "^0.2.2" - } - }, - "node_modules/colord": { - "version": "2.9.3", - "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", - "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==", - "dev": true + "node_modules/colorette": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", + "license": "MIT" }, "node_modules/combined-stream": { "version": "1.0.8", @@ -4232,6 +4861,13 @@ "node": ">= 0.6" } }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, "node_modules/cookie": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", @@ -4264,234 +4900,71 @@ "node": ">= 8" } }, - "node_modules/css-declaration-sorter": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", - "integrity": "sha512-rtdthzxKuyq6IzqX6jEcIzQF/YqccluefyCYheovBOLhFT/drQA9zj/UbRAa9J7C0o6EG6u3E6g+vKkay7/k3g==", + "node_modules/cssstyle": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.5.0.tgz", + "integrity": "sha512-/7gw8TGrvH/0g564EnhgFZogTMVe+lifpB7LWU+PEsiq5o83TUXR3fDbzTRXOJhoJwck5IS9ez3Em5LNMMO2aw==", "dev": true, - "engines": { - "node": "^10 || ^12 || >=14" + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^3.2.0", + "rrweb-cssom": "^0.8.0" }, - "peerDependencies": { - "postcss": "^8.0.9" + "engines": { + "node": ">=18" } }, - "node_modules/css-select": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", - "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", - "dev": true, + "node_modules/csstype": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz", + "integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==", + "dev": true + }, + "node_modules/damerau-levenshtein": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", + "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==" + }, + "node_modules/dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.1.0", - "domhandler": "^5.0.2", - "domutils": "^3.0.1", - "nth-check": "^2.0.1" + "assert-plus": "^1.0.0" }, - "funding": { - "url": "https://github.com/sponsors/fb55" + "engines": { + "node": ">=0.10" } }, - "node_modules/css-tree": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", - "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", + "node_modules/data-urls": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", + "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", "dev": true, + "license": "MIT", "dependencies": { - "mdn-data": "2.0.30", - "source-map-js": "^1.0.1" + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0" }, "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + "node": ">=18" } }, - "node_modules/css-what": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", - "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", - "dev": true, + "node_modules/dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", + "license": "MIT", "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" + "node": "*" } }, - "node_modules/cssesc": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", - "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", - "dev": true, - "bin": { - "cssesc": "bin/cssesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/cssnano": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-6.0.1.tgz", - "integrity": "sha512-fVO1JdJ0LSdIGJq68eIxOqFpIJrZqXUsBt8fkrBcztCQqAjQD51OhZp7tc0ImcbwXD4k7ny84QTV90nZhmqbkg==", - "dev": true, - "dependencies": { - "cssnano-preset-default": "^6.0.1", - "lilconfig": "^2.1.0" - }, - "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/cssnano" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/cssnano-preset-default": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/cssnano-preset-default/-/cssnano-preset-default-6.0.1.tgz", - "integrity": "sha512-7VzyFZ5zEB1+l1nToKyrRkuaJIx0zi/1npjvZfbBwbtNTzhLtlvYraK/7/uqmX2Wb2aQtd983uuGw79jAjLSuQ==", - "dev": true, - "dependencies": { - "css-declaration-sorter": "^6.3.1", - "cssnano-utils": "^4.0.0", - "postcss-calc": "^9.0.0", - "postcss-colormin": "^6.0.0", - "postcss-convert-values": "^6.0.0", - "postcss-discard-comments": "^6.0.0", - "postcss-discard-duplicates": "^6.0.0", - "postcss-discard-empty": "^6.0.0", - "postcss-discard-overridden": "^6.0.0", - "postcss-merge-longhand": "^6.0.0", - "postcss-merge-rules": "^6.0.1", - "postcss-minify-font-values": "^6.0.0", - "postcss-minify-gradients": "^6.0.0", - "postcss-minify-params": "^6.0.0", - "postcss-minify-selectors": "^6.0.0", - "postcss-normalize-charset": "^6.0.0", - "postcss-normalize-display-values": "^6.0.0", - "postcss-normalize-positions": "^6.0.0", - "postcss-normalize-repeat-style": "^6.0.0", - "postcss-normalize-string": "^6.0.0", - "postcss-normalize-timing-functions": "^6.0.0", - "postcss-normalize-unicode": "^6.0.0", - "postcss-normalize-url": "^6.0.0", - "postcss-normalize-whitespace": "^6.0.0", - "postcss-ordered-values": "^6.0.0", - "postcss-reduce-initial": "^6.0.0", - "postcss-reduce-transforms": "^6.0.0", - "postcss-svgo": "^6.0.0", - "postcss-unique-selectors": "^6.0.0" - }, - "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/cssnano-utils": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-4.0.0.tgz", - "integrity": "sha512-Z39TLP+1E0KUcd7LGyF4qMfu8ZufI0rDzhdyAMsa/8UyNUU8wpS0fhdBxbQbv32r64ea00h4878gommRVg2BHw==", - "dev": true, - "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/csso": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz", - "integrity": "sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==", - "dev": true, - "dependencies": { - "css-tree": "~2.2.0" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/csso/node_modules/css-tree": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.2.1.tgz", - "integrity": "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==", - "dev": true, - "dependencies": { - "mdn-data": "2.0.28", - "source-map-js": "^1.0.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/csso/node_modules/mdn-data": { - "version": "2.0.28", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", - "integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==", - "dev": true - }, - "node_modules/cssstyle": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.5.0.tgz", - "integrity": "sha512-/7gw8TGrvH/0g564EnhgFZogTMVe+lifpB7LWU+PEsiq5o83TUXR3fDbzTRXOJhoJwck5IS9ez3Em5LNMMO2aw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@asamuzakjp/css-color": "^3.2.0", - "rrweb-cssom": "^0.8.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/csstype": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz", - "integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==" - }, - "node_modules/damerau-levenshtein": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", - "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==" - }, - "node_modules/dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", - "dependencies": { - "assert-plus": "^1.0.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/data-urls": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", - "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", - "dev": true, - "license": "MIT", - "dependencies": { - "whatwg-mimetype": "^4.0.0", - "whatwg-url": "^14.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" + "node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dependencies": { + "ms": "^2.1.1" } }, "node_modules/decimal.js": { @@ -4513,12 +4986,20 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "node_modules/dedent": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.6.0.tgz", + "integrity": "sha512-F1Z+5UCFpmQUzJa11agbyPVMbpgT/qA3/SKyJ1jyBgm7dUcUEa8v9JwDkerSQXfakBwFljIxhOJqGkjUwZ9FSA==", + "dev": true, "license": "MIT", - "peer": true + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } }, "node_modules/default-browser": { "version": "4.0.0", @@ -4610,15 +5091,6 @@ "node": ">= 0.8" } }, - "node_modules/dependency-graph": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-0.9.0.tgz", - "integrity": "sha512-9YLIBURXj4DJMFALxXw9K3Y3rwb5Fk0X5/8ipCzaN84+gKxoHK43tVKRNakCQbiEx07E8Uwhuq21BpUagFhZ8w==", - "dev": true, - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -4637,10 +5109,10 @@ } }, "node_modules/detect-libc": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz", - "integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==", - "devOptional": true, + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.1.tgz", + "integrity": "sha512-ecqj/sy1jcK1uWrwpR67UhYrIFQ+5WlGxth34WquCbamhFA6hkkwiu37o6J5xCHdo1oixJRfVRw+ywV+Hq/0Aw==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=8" @@ -4691,74 +5163,6 @@ "docson": "lib/docson-cli.js" } }, - "node_modules/doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "license": "Apache-2.0", - "peer": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "dev": true, - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ] - }, - "node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "dev": true, - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", - "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", - "dev": true, - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, "node_modules/dotenv": { "version": "16.4.7", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", @@ -4772,6 +5176,24 @@ "url": "https://dotenvx.com" } }, + "node_modules/duplexify": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", + "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "license": "MIT" + }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -4787,10 +5209,10 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.5.194", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.194.tgz", - "integrity": "sha512-SdnWJwSUot04UR51I2oPD8kuP2VI37/CADR1OHsFOUzZIvfWJBO6q11k5P/uKNyTT3cdOsnyjkrZ+DDShqYqJA==", - "devOptional": true, + "version": "1.5.230", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.230.tgz", + "integrity": "sha512-A6A6Fd3+gMdaed9wX83CvHYJb4UuapPD5X5SLq72VZJzxHSY0/LUweGXRWmQlh2ln7KV7iw7jnwXK7dlPoOnHQ==", + "dev": true, "license": "ISC" }, "node_modules/emoji-regex": { @@ -4798,15 +5220,6 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" }, - "node_modules/emojis-list": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", - "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -4815,10 +5228,20 @@ "node": ">= 0.8" } }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/enhanced-resolve": { - "version": "5.18.2", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.2.tgz", - "integrity": "sha512-6Jw4sE1maoRJo3q8MsSIn2onJFbLTOjY9hlx4DZXmOKvLRd1Ok2kXmAGXaafL2+ijsJZ1ClYbl/pmqr9+k4iUQ==", + "version": "5.18.3", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.3.tgz", + "integrity": "sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==", + "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -4827,17 +5250,12 @@ "node": ">=10.13.0" } }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "node_modules/err-code": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", + "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", "dev": true, - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } + "license": "MIT" }, "node_modules/es-abstract": { "version": "1.22.1", @@ -4919,9 +5337,8 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", - "devOptional": true, - "license": "MIT", - "peer": true + "dev": true, + "license": "MIT" }, "node_modules/es-set-tostringtag": { "version": "2.0.1", @@ -5033,30 +5450,11 @@ "@esbuild/win32-x64": "0.25.1" } }, - "node_modules/esbuild-loader": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esbuild-loader/-/esbuild-loader-4.3.0.tgz", - "integrity": "sha512-D7HeJNdkDKKMarPQO/3dlJT6RwN2YJO7ENU6RPlpOz5YxSHnUNi2yvW41Bckvi1EVwctIaLzlb0ni5ag2GINYA==", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "^0.25.0", - "get-tsconfig": "^4.7.0", - "loader-utils": "^2.0.4", - "webpack-sources": "^1.4.3" - }, - "funding": { - "url": "https://github.com/privatenumber/esbuild-loader?sponsor=1" - }, - "peerDependencies": { - "webpack": "^4.40.0 || ^5.0.0" - } - }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -5067,19 +5465,6 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/escodegen": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", @@ -5109,63 +5494,6 @@ "node": ">=0.10.0" } }, - "node_modules/eslint": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", - "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", - "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", - "license": "MIT", - "peer": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.1", - "@humanwhocodes/config-array": "^0.13.0", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", - "text-table": "^0.2.0" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/eslint-config-next": { "version": "13.4.12", "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.4.12.tgz", @@ -5453,32 +5781,6 @@ "semver": "bin/semver.js" } }, - "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "devOptional": true, - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-scope/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "devOptional": true, - "license": "BSD-2-Clause", - "peer": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/eslint-visitor-keys": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", @@ -5491,119 +5793,16 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "license": "MIT", - "peer": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/eslint/node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "license": "MIT", - "peer": true - }, - "node_modules/espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "acorn": "^8.9.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/esquery": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", - "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", - "license": "BSD-3-Clause", - "peer": true, - "dependencies": { - "estraverse": "^5.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "estraverse": "^5.2.0" - }, - "engines": { - "node": ">=4.0" + "engines": { + "node": ">=4" } }, "node_modules/estraverse": { @@ -5682,18 +5881,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/estree-util-value-to-estree": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/estree-util-value-to-estree/-/estree-util-value-to-estree-3.3.3.tgz", - "integrity": "sha512-Db+m1WSD4+mUO7UgMeKkAwdbfNWwIxLt48XF2oFU9emPfXkIu+k5/nlOj313v7wqtAPo0f9REhUvznFrPkG8CQ==", - "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/remcohaszing" - } - }, "node_modules/estree-util-visit": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/estree-util-visit/-/estree-util-visit-2.0.0.tgz", @@ -5715,9 +5902,13 @@ "license": "MIT" }, "node_modules/estree-walker": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.0.tgz", - "integrity": "sha512-s6ceX0NFiU/vKPiKvFdR83U1Zffu7upwZsGwpoqfg5rbbq1l50WQ5hCeIvM6E6oD4shUHCYMsiFPns4Jk0YfMQ==" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } }, "node_modules/esutils": { "version": "2.0.3", @@ -5735,13 +5926,20 @@ "node": ">= 0.6" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "devOptional": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.8.x" } @@ -5768,6 +5966,19 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/exit-hook": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-2.2.1.tgz", + "integrity": "sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/express": { "version": "4.21.2", "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", @@ -5839,6 +6050,18 @@ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, + "node_modules/extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "license": "MIT", + "dependencies": { + "is-extendable": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -5847,6 +6070,18 @@ "node >=0.6.0" ] }, + "node_modules/fast-copy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.2.tgz", + "integrity": "sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==", + "license": "MIT" + }, + "node_modules/fast-decode-uri-component": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", + "integrity": "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==", + "license": "MIT" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -5882,21 +6117,90 @@ "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "node_modules/fast-json-stringify": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-6.1.1.tgz", + "integrity": "sha512-DbgptncYEXZqDUOEl4krff4mUiVrTZZVI7BBrQR/T3BqMj/eM1flTC1Uk2uUoLcWCxjT95xKulV/Lc6hhOZsBQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "@fastify/merge-json-schemas": "^0.2.0", + "ajv": "^8.12.0", + "ajv-formats": "^3.0.1", + "fast-uri": "^3.0.0", + "json-schema-ref-resolver": "^3.0.0", + "rfdc": "^1.2.0" + } + }, + "node_modules/fast-json-stringify/node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/fast-json-stringify/node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/fast-json-stringify/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "license": "MIT" }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "node_modules/fast-querystring": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.2.tgz", + "integrity": "sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==", "license": "MIT", - "peer": true + "dependencies": { + "fast-decode-uri-component": "^1.0.1" + } + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "license": "MIT" }, "node_modules/fast-uri": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz", "integrity": "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==", - "devOptional": true, "funding": [ { "type": "github", @@ -5907,13 +6211,52 @@ "url": "https://opencollective.com/fastify" } ], - "license": "BSD-3-Clause", - "peer": true + "license": "BSD-3-Clause" + }, + "node_modules/fastify": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-5.5.0.tgz", + "integrity": "sha512-ZWSWlzj3K/DcULCnCjEiC2zn2FBPdlZsSA/pnPa/dbUfLvxkD/Nqmb0XXMXLrWkeM4uQPUvjdJpwtXmTfriXqw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "@fastify/ajv-compiler": "^4.0.0", + "@fastify/error": "^4.0.0", + "@fastify/fast-json-stringify-compiler": "^5.0.0", + "@fastify/proxy-addr": "^5.0.0", + "abstract-logging": "^2.0.1", + "avvio": "^9.0.0", + "fast-json-stringify": "^6.0.0", + "find-my-way": "^9.0.0", + "light-my-request": "^6.0.0", + "pino": "^9.0.0", + "process-warning": "^5.0.0", + "rfdc": "^1.3.1", + "secure-json-parse": "^4.0.0", + "semver": "^7.6.0", + "toad-cache": "^3.7.0" + } + }, + "node_modules/fastify-plugin": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-5.0.1.tgz", + "integrity": "sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==", + "license": "MIT" }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", + "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "license": "ISC", "dependencies": { "reusify": "^1.0.4" } @@ -5931,19 +6274,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "license": "MIT", - "peer": true, - "dependencies": { - "flat-cache": "^3.0.4" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -5997,45 +6327,20 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "license": "MIT", - "peer": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/flat-cache": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", - "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "node_modules/find-my-way": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-9.3.0.tgz", + "integrity": "sha512-eRoFWQw+Yv2tuYlK2pjFS2jGXSxSppAs3hSQjfxVKxM5amECzIgYYc1FEI8ZmhSh/Ig+FrKEz43NLRKJjYCZVg==", "license": "MIT", - "peer": true, "dependencies": { - "flatted": "^3.2.9", - "keyv": "^4.5.3", - "rimraf": "^3.0.2" + "fast-deep-equal": "^3.1.3", + "fast-querystring": "^1.0.0", + "safe-regex2": "^5.0.0" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": ">=20" } }, - "node_modules/flatted": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", - "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", - "license": "ISC", - "peer": true - }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -6044,6 +6349,34 @@ "is-callable": "^1.1.3" } }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -6081,20 +6414,6 @@ "node": ">= 0.6" } }, - "node_modules/fraction.js": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", - "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" - }, - "funding": { - "type": "patreon", - "url": "https://github.com/sponsors/rawify" - } - }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -6104,18 +6423,17 @@ } }, "node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, + "version": "11.3.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz", + "integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==", + "license": "MIT", "dependencies": { - "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" }, "engines": { - "node": ">=10" + "node": ">=14.14" } }, "node_modules/fs.realpath": { @@ -6164,13 +6482,26 @@ "node": ">=10" } }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-east-asian-width": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.4.0.tgz", + "integrity": "sha512-QZjmEOC+IT1uk6Rx0sX22V6uHWVwbdbxf1faPqJ1QhLdGgsRGCZoyaQBm/piRdJy/D2um6hM1UP7ZEeQ4EkP+Q==", + "license": "MIT", "engines": { - "node": "6.* || 8.* || >= 10.*" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/get-intrinsic": { @@ -6196,18 +6527,6 @@ "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==" }, - "node_modules/get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -6278,43 +6597,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "license": "ISC", - "peer": true, - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/glob-to-regexp": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", - "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", - "devOptional": true, - "license": "BSD-2-Clause", - "peer": true - }, - "node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/globalthis": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", @@ -6364,12 +6646,42 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, - "node_modules/graphemer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "node_modules/gray-matter": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz", + "integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==", + "license": "MIT", + "dependencies": { + "js-yaml": "^3.13.1", + "kind-of": "^6.0.2", + "section-matter": "^1.0.0", + "strip-bom-string": "^1.0.0" + }, + "engines": { + "node": ">=6.0" + } + }, + "node_modules/gray-matter/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/gray-matter/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "license": "MIT", - "peer": true + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } }, "node_modules/handlebars": { "version": "4.7.8", @@ -6420,28 +6732,6 @@ "node": ">=6" } }, - "node_modules/har-validator/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/har-validator/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "license": "MIT" - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -6461,14 +6751,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, "node_modules/has-property-descriptors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", @@ -6757,6 +7039,12 @@ "@types/unist": "*" } }, + "node_modules/help-me": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz", + "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==", + "license": "MIT" + }, "node_modules/highlight.js": { "version": "11.9.0", "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.9.0.tgz", @@ -6770,6 +7058,29 @@ "resolved": "https://registry.npmjs.org/highlightjs-rescript/-/highlightjs-rescript-0.2.2.tgz", "integrity": "sha512-4svMEPtDxxtoVW35DR6prREvo/4oTZfl/Ab1DSLzoZdMpjjuG8kaNkhKCd+1F083fKdlmoFNPCK8rykOxaZY1g==" }, + "node_modules/hosted-git-info": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.1.3.tgz", + "integrity": "sha512-HVJyzUrLIL1c0QmviVh5E8VGyUS7xCFPS6yydaVd1UegW+ibV/CohqTH9MkOLDp5o+rb82DMo77PTuc9F/8GKw==", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^7.5.1" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/hosted-git-info/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, "node_modules/html-encoding-sniffer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", @@ -6914,6 +7225,26 @@ "node": ">=0.10.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -6922,33 +7253,6 @@ "node": ">= 4" } }, - "node_modules/import-fresh": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", - "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=0.8.19" - } - }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -7019,13 +7323,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-arrayish": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", - "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", - "license": "MIT", - "optional": true - }, "node_modules/is-bigint": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", @@ -7037,18 +7334,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -7127,6 +7412,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -7139,7 +7433,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, "engines": { "node": ">=8" } @@ -7181,6 +7474,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-interactive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", + "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-negative-zero": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", @@ -7222,16 +7527,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=8" - } - }, "node_modules/is-plain-obj": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", @@ -7250,6 +7545,16 @@ "dev": true, "license": "MIT" }, + "node_modules/is-reference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.6" + } + }, "node_modules/is-regex": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", @@ -7342,6 +7647,18 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" }, + "node_modules/is-unicode-supported": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", + "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-weakref": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", @@ -7383,6 +7700,15 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" }, + "node_modules/isbot": { + "version": "5.1.29", + "resolved": "https://registry.npmjs.org/isbot/-/isbot-5.1.29.tgz", + "integrity": "sha512-DelDWWoa3mBoyWTq3wjp+GIWx/yZdN7zLUE7NFhKjAiJ+uJVRkbLlwykdduCE4sPUUy8mlTYTmdhBUYu91F+sw==", + "license": "Unlicense", + "engines": { + "node": ">=18" + } + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -7393,37 +7719,20 @@ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" }, - "node_modules/jest-worker": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", - "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^8.0.0" - }, - "engines": { - "node": ">= 10.13.0" - } - }, - "node_modules/jest-worker/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "devOptional": true, - "license": "MIT", - "peer": true, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" + "@isaacs/cliui": "^8.0.2" }, "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/jiti": { @@ -7436,6 +7745,15 @@ "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/jquery": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz", @@ -7446,19 +7764,6 @@ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "license": "MIT", - "peer": true, - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -7518,50 +7823,45 @@ } }, "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "license": "MIT", "bin": { "jsesc": "bin/jsesc" }, "engines": { - "node": ">=4" + "node": ">=6" } }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "license": "MIT", - "peer": true - }, - "node_modules/json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "devOptional": true, - "license": "MIT", - "peer": true - }, "node_modules/json-schema": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "devOptional": true, + "node_modules/json-schema-ref-resolver": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-schema-ref-resolver/-/json-schema-ref-resolver-3.0.0.tgz", + "integrity": "sha512-hOrZIVL5jyYFjzk7+y7n5JDzGlU8rfWDuYyHwGa2WA8/pcmMHezp2xsVwxrebD/Q9t8Nc5DboieySDpCp4WG4A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "license": "MIT", - "peer": true + "dependencies": { + "dequal": "^2.0.3" + } }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "license": "MIT", - "peer": true + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "node_modules/json-stringify-safe": { "version": "5.0.1", @@ -7581,10 +7881,10 @@ } }, "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", + "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", + "license": "MIT", "dependencies": { "universalify": "^2.0.0" }, @@ -7633,14 +7933,22 @@ "node": ">=4.0" } }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "license": "MIT", - "peer": true, - "dependencies": { - "json-buffer": "3.0.1" + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "license": "MIT", + "engines": { + "node": ">=6" } }, "node_modules/language-subtag-registry": { @@ -7656,22 +7964,54 @@ "language-subtag-registry": "~0.3.2" } }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/lightningcss": { - "version": "1.30.1", + "node_modules/light-my-request": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-6.6.0.tgz", + "integrity": "sha512-CHYbu8RtboSIoVsHZ6Ye4cj4Aw/yg2oAFimlF7mNvfDV192LR7nDiKtSIfCuLT7KokPSTn/9kfVLm5OGN0A28A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause", + "dependencies": { + "cookie": "^1.0.1", + "process-warning": "^4.0.0", + "set-cookie-parser": "^2.6.0" + } + }, + "node_modules/light-my-request/node_modules/cookie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", + "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/light-my-request/node_modules/process-warning": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-4.0.1.tgz", + "integrity": "sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, + "node_modules/lightningcss": { + "version": "1.30.1", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.30.1.tgz", "integrity": "sha512-xi6IyHML+c9+Q3W0S4fCQJOym42pyurFiJUHEcEyHS0CeKzia4yZDEsLlqOFykxOdHpNy0NmvVO31vcSqAxJCg==", "dev": true, @@ -7909,79 +8249,16 @@ "url": "https://opencollective.com/parcel" } }, - "node_modules/lilconfig": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", - "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/loader-runner": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", - "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", - "devOptional": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=6.11.5" - } - }, - "node_modules/loader-utils": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", - "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", - "dev": true, - "dependencies": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - }, - "engines": { - "node": ">=8.9.0" - } - }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "license": "MIT", - "peer": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", - "dev": true - }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "license": "MIT", - "peer": true - }, - "node_modules/lodash.uniq": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", - "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==", - "dev": true + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "license": "MIT" }, "node_modules/longest-streak": { "version": "3.1.0", @@ -8003,6 +8280,12 @@ "loose-envify": "cli.js" } }, + "node_modules/lru_map": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", + "integrity": "sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==", + "license": "MIT" + }, "node_modules/lru-cache": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", @@ -8019,13 +8302,13 @@ } }, "node_modules/magic-string": { - "version": "0.30.17", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", - "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "version": "0.30.19", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.19.tgz", + "integrity": "sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0" + "@jridgewell/sourcemap-codec": "^1.5.5" } }, "node_modules/markdown-extensions": { @@ -8077,15 +8360,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-find-and-replace/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" - } - }, "node_modules/mdast-util-find-and-replace/node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", @@ -8104,33 +8378,82 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mdast-util-find-and-replace/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", + "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0" + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "node_modules/mdast-util-from-markdown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", + "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", "license": "MIT", "dependencies": { + "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, + "node_modules/mdast-util-from-markdown/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/mdast-util-from-markdown/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/mdast-util-from-markdown/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, "node_modules/mdast-util-frontmatter": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/mdast-util-frontmatter/-/mdast-util-frontmatter-2.0.1.tgz", @@ -8149,38 +8472,12 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" - } - }, "node_modules/mdast-util-frontmatter/node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "license": "MIT" }, - "node_modules/mdast-util-frontmatter/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, "node_modules/mdast-util-frontmatter/node_modules/escape-string-regexp": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", @@ -8193,30 +8490,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mdast-util-frontmatter/node_modules/mdast-util-from-markdown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/mdast-util-frontmatter/node_modules/mdast-util-phrasing": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", @@ -8252,23 +8525,46 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "node_modules/mdast-util-gfm": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz", + "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==", "license": "MIT", "dependencies": { - "@types/mdast": "^4.0.0" + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-gfm-autolink-literal": "^2.0.0", + "mdast-util-gfm-footnote": "^2.0.0", + "mdast-util-gfm-strikethrough": "^2.0.0", + "mdast-util-gfm-table": "^2.0.0", + "mdast-util-gfm-task-list-item": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "node_modules/mdast-util-gfm-autolink-literal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz", + "integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "ccount": "^2.0.0", + "devlop": "^1.0.0", + "mdast-util-find-and-replace": "^3.0.0", + "micromark-util-character": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-autolink-literal/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -8281,29 +8577,14 @@ ], "license": "MIT", "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "node_modules/mdast-util-gfm-autolink-literal/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -8314,30 +8595,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-factory-destination": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "node_modules/mdast-util-gfm-autolink-literal/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -8348,578 +8611,433 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/mdast-util-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "devlop": "^1.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-footnote/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/mdast-util-gfm-footnote/node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-footnote/node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-strikethrough": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz", + "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==", "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-factory-whitespace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-strikethrough/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/mdast-util-gfm-strikethrough/node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-strikethrough/node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-table": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz", + "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-table/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/mdast-util-gfm-table/node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-decode-string": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-table/node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/mdast-util-gfm-task-list-item": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz", + "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==", "license": "MIT", "dependencies": { + "@types/mdast": "^4.0.0", "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-frontmatter/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-frontmatter/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "node_modules/mdast-util-gfm-task-list-item/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/mdast-util-gfm-task-list-item/node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-frontmatter/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "node_modules/mdast-util-gfm-task-list-item/node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", "license": "MIT", "dependencies": { + "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz", - "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==", + "node_modules/mdast-util-gfm/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/mdast-util-gfm/node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", "license": "MIT", "dependencies": { - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-gfm-autolink-literal": "^2.0.0", - "mdast-util-gfm-footnote": "^2.0.0", - "mdast-util-gfm-strikethrough": "^2.0.0", - "mdast-util-gfm-table": "^2.0.0", - "mdast-util-gfm-task-list-item": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-autolink-literal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz", - "integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==", + "node_modules/mdast-util-gfm/node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", "license": "MIT", "dependencies": { "@types/mdast": "^4.0.0", - "ccount": "^2.0.0", - "devlop": "^1.0.0", - "mdast-util-find-and-replace": "^3.0.0", - "micromark-util-character": "^2.0.0" + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-autolink-literal/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "node_modules/mdast-util-mdx": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-mdx/-/mdast-util-mdx-3.0.0.tgz", + "integrity": "sha512-JfbYLAW7XnYTTbUsmpu0kdBUVe+yKVJZBItEjwyYJiDJuZ9w4eeaqks4HQO+R7objWgS2ymV60GYpI14Ug554w==", "license": "MIT", "dependencies": { - "@types/unist": "*" + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-mdx-expression": "^2.0.0", + "mdast-util-mdx-jsx": "^3.0.0", + "mdast-util-mdxjs-esm": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-autolink-literal/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", + "node_modules/mdast-util-mdx-expression": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.0.tgz", + "integrity": "sha512-fGCu8eWdKUKNu5mohVGkhBXCXGnOTLuFqOvGMvdikr+J1w7lDJgxThOKpwRWzzbyXAU2hhSwsmssOY4yTokluw==", "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-autolink-literal/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" + "node_modules/mdast-util-mdx-expression/node_modules/@types/hast": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", + "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", + "dependencies": { + "@types/unist": "*" + } }, - "node_modules/mdast-util-gfm-autolink-literal/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" + "node_modules/mdast-util-mdx-expression/node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "node_modules/mdast-util-gfm-footnote": { + "node_modules/mdast-util-mdx-expression/node_modules/mdast-util-phrasing": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.0.0.tgz", + "integrity": "sha512-xadSsJayQIucJ9n053dfQwVu1kuXg7jCTdYsMK8rqzKZh52nLfSH/k0sAxE0u+pj/zKZX+o5wB+ML5mRayOxFA==", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdx-expression/node_modules/mdast-util-to-markdown": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz", - "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==", - "license": "MIT", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", + "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdx-jsx": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.0.0.tgz", + "integrity": "sha512-XZuPPzQNBPAlaqsTTgRrcJnyFbSOBovSadFgbFu8SnuNgm+6Bdx1K+IWoitsmj6Lq6MNtI+ytOqwN70n//NaBA==", "dependencies": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", "devlop": "^1.1.0", "mdast-util-from-markdown": "^2.0.0", "mdast-util-to-markdown": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0" + "parse-entities": "^4.0.0", + "stringify-entities": "^4.0.0", + "unist-util-remove-position": "^5.0.0", + "unist-util-stringify-position": "^4.0.0", + "vfile-message": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", + "node_modules/mdast-util-mdx-jsx/node_modules/@types/hast": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", + "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", "dependencies": { "@types/unist": "*" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", - "license": "MIT" + "node_modules/mdast-util-mdx-jsx/node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "node_modules/mdast-util-gfm-footnote/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", + "node_modules/mdast-util-mdx-jsx/node_modules/mdast-util-phrasing": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.0.0.tgz", + "integrity": "sha512-xadSsJayQIucJ9n053dfQwVu1kuXg7jCTdYsMK8rqzKZh52nLfSH/k0sAxE0u+pj/zKZX+o5wB+ML5mRayOxFA==", "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/mdast-util-from-markdown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", + "node_modules/mdast-util-mdx-jsx/node_modules/mdast-util-to-markdown": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", + "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/mdast-util-phrasing": { + "node_modules/mdast-util-mdx/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/mdast-util-mdx/node_modules/mdast-util-phrasing": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", @@ -8933,7 +9051,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/mdast-util-to-markdown": { + "node_modules/mdast-util-mdx/node_modules/mdast-util-to-markdown": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", @@ -8954,20 +9072,203 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "license": "MIT", + "node_modules/mdast-util-mdxjs-esm": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-2.0.1.tgz", + "integrity": "sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==", "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdxjs-esm/node_modules/@types/hast": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", + "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/mdast-util-mdxjs-esm/node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" + }, + "node_modules/mdast-util-mdxjs-esm/node_modules/mdast-util-phrasing": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.0.0.tgz", + "integrity": "sha512-xadSsJayQIucJ9n053dfQwVu1kuXg7jCTdYsMK8rqzKZh52nLfSH/k0sAxE0u+pj/zKZX+o5wB+ML5mRayOxFA==", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdxjs-esm/node_modules/mdast-util-to-markdown": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", + "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.0.2.tgz", + "integrity": "sha512-U5I+500EOOw9e3ZrclN3Is3fRpw8c19SMyNZlZ2IS+7vLsNzb2Om11VpIVOR+/0137GhZsFEF6YiKD5+0Hr2Og==", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", + "devlop": "^1.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "trim-lines": "^3.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-hast/node_modules/@types/hast": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", + "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/mdast-util-to-hast/node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" + }, + "node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-toc": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-toc/-/mdast-util-toc-7.1.0.tgz", + "integrity": "sha512-2TVKotOQzqdY7THOdn2gGzS9d1Sdd66bvxUyw3aNpWfcPXCLYSJCCgfPy30sEtuzkDraJgqF35dzgmz6xlvH/w==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/ungap__structured-clone": "^1.0.0", + "@ungap/structured-clone": "^1.0.0", + "github-slugger": "^2.0.0", + "mdast-util-to-string": "^4.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark": { + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/meow": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz", + "integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/merge-options": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-1.0.1.tgz", + "integrity": "sha512-iuPV41VWKWBIOpBsjoxjDZw8/GbSfZ2mk7N1453bwMrfzdrIk7EzBd+8UVR6rkw67th7xnk9Dytl3J+lHPdxvg==", + "license": "MIT", + "dependencies": { + "is-plain-obj": "^1.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/merge-options/node_modules/is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/micromark": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", @@ -9002,7 +9303,7 @@ "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-core-commonmark": { + "node_modules/micromark-core-commonmark": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", @@ -9036,10 +9337,10 @@ "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-factory-destination": { + "node_modules/micromark-core-commonmark/node_modules/micromark-factory-space": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", "funding": [ { "type": "GitHub Sponsors", @@ -9053,14 +9354,13 @@ "license": "MIT", "dependencies": { "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "node_modules/micromark-core-commonmark/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9073,16 +9373,14 @@ ], "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-factory-space": { + "node_modules/micromark-core-commonmark/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9093,16 +9391,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "node_modules/micromark-core-commonmark/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9113,37 +9407,25 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-factory-whitespace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/micromark-extension-frontmatter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-frontmatter/-/micromark-extension-frontmatter-2.0.0.tgz", + "integrity": "sha512-C4AkuM3dA58cgZha7zVnuVxBhDsbttIMiytjgsM2XbHAB2faRVaHRle40558FBN+DJcrLNCoqG5mlrpdU4cRtg==", "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", + "fault": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-character": { + "node_modules/micromark-extension-frontmatter/node_modules/micromark-util-character": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", @@ -9163,10 +9445,10 @@ "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-chunked": { + "node_modules/micromark-extension-frontmatter/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9177,15 +9459,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "node_modules/micromark-extension-frontmatter/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9196,17 +9475,48 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/micromark-extension-gfm": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz", + "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", + "micromark-extension-gfm-autolink-literal": "^2.0.0", + "micromark-extension-gfm-footnote": "^2.0.0", + "micromark-extension-gfm-strikethrough": "^2.0.0", + "micromark-extension-gfm-table": "^2.0.0", + "micromark-extension-gfm-tagfilter": "^2.0.0", + "micromark-extension-gfm-task-list-item": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "node_modules/micromark-extension-gfm-autolink-literal": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz", + "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==", + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9219,14 +9529,30 @@ ], "license": "MIT", "dependencies": { - "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-decode-numeric-character-reference": { + "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-types": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9237,15 +9563,32 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/micromark-extension-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-decode-string": { + "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-factory-space": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", "funding": [ { "type": "GitHub Sponsors", @@ -9258,16 +9601,14 @@ ], "license": "MIT", "dependencies": { - "decode-named-character-reference": "^1.0.0", "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9278,12 +9619,16 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT" + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-html-tag-name": { + "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9296,10 +9641,10 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9310,15 +9655,46 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/micromark-extension-gfm-strikethrough": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz", + "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-resolve-all": { + "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9329,15 +9705,29 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/micromark-extension-gfm-table": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz", + "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==", "license": "MIT", "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-sanitize-uri": { + "node_modules/micromark-extension-gfm-table/node_modules/micromark-factory-space": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", "funding": [ { "type": "GitHub Sponsors", @@ -9351,14 +9741,13 @@ "license": "MIT", "dependencies": { "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "node_modules/micromark-extension-gfm-table/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9371,13 +9760,11 @@ ], "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-symbol": { + "node_modules/micromark-extension-gfm-table/node_modules/micromark-util-symbol": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", @@ -9393,7 +9780,7 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-footnote/node_modules/micromark-util-types": { + "node_modules/micromark-extension-gfm-table/node_modules/micromark-util-types": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", @@ -9409,171 +9796,128 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-footnote/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "node_modules/micromark-extension-gfm-tagfilter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz", + "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==", "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0" + "micromark-util-types": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "node_modules/micromark-extension-gfm-tagfilter/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-extension-gfm-task-list-item": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz", + "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==", "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-footnote/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz", - "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT", "dependencies": { - "@types/unist": "*" + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true + "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" } - } + ], + "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/mdast-util-from-markdown": { + "node_modules/micromark-extension-gfm/node_modules/micromark-util-types": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/mdast-util-phrasing": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", - "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/mdast-util-to-markdown": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", - "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9584,31 +9928,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "node_modules/micromark-extension-mdx-expression": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-mdx-expression/-/micromark-extension-mdx-expression-3.0.0.tgz", + "integrity": "sha512-sI0nwhUDz97xyzqJAbHQhp5TfaxEvZZZ2JDqUo+7NvyIYG6BZ5CPPqj2ogUoPJlmXHBnyZUzISg9+oUmU6tUjQ==", "funding": [ { "type": "GitHub Sponsors", @@ -9621,28 +9946,20 @@ ], "license": "MIT", "dependencies": { - "decode-named-character-reference": "^1.0.0", + "@types/estree": "^1.0.0", "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", + "micromark-factory-mdx-expression": "^2.0.0", "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", + "micromark-util-events-to-acorn": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-factory-destination": { + "node_modules/micromark-extension-mdx-expression/node_modules/micromark-factory-space": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", "funding": [ { "type": "GitHub Sponsors", @@ -9656,14 +9973,13 @@ "license": "MIT", "dependencies": { "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "node_modules/micromark-extension-mdx-expression/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9676,16 +9992,14 @@ ], "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-factory-space": { + "node_modules/micromark-extension-mdx-expression/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9696,16 +10010,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "node_modules/micromark-extension-mdx-expression/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9716,18 +10026,45 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/micromark-extension-mdx-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/micromark-extension-mdx-jsx/-/micromark-extension-mdx-jsx-3.0.1.tgz", + "integrity": "sha512-vNuFb9czP8QCtAQcEJn0UJQJZA8Dk6DXKBqx+bg/w0WGuSxDxNr7hErW89tHUY31dUW4NqEOWwmEUNhjTFmHkg==", "license": "MIT", "dependencies": { + "@types/acorn": "^4.0.0", + "@types/estree": "^1.0.0", + "devlop": "^1.0.0", + "estree-util-is-identifier-name": "^3.0.0", + "micromark-factory-mdx-expression": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", + "micromark-util-events-to-acorn": "^2.0.0", "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "micromark-util-types": "^2.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-mdx-jsx/node_modules/estree-util-is-identifier-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz", + "integrity": "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-factory-whitespace": { + "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-factory-space": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", "funding": [ { "type": "GitHub Sponsors", @@ -9740,13 +10077,11 @@ ], "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-character": { + "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-util-character": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", @@ -9766,10 +10101,10 @@ "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-chunked": { + "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9780,15 +10115,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9799,17 +10131,25 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/micromark-extension-mdx-md": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-mdx-md/-/micromark-extension-mdx-md-2.0.0.tgz", + "integrity": "sha512-EpAiszsB3blw4Rpba7xTOUptcFeBFi+6PY8VnJ2hhimH+vCQDirWgsMpz7w1XcZE7LVrSAUGb9VJpG9ghlYvYQ==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "node_modules/micromark-extension-mdx-md/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9820,16 +10160,53 @@ "url": "https://opencollective.com/unified" } ], + "license": "MIT" + }, + "node_modules/micromark-extension-mdxjs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-mdxjs/-/micromark-extension-mdxjs-3.0.0.tgz", + "integrity": "sha512-A873fJfhnJ2siZyUrJ31l34Uqwy4xIFmvPY1oj+Ean5PHcPBYzEsvqvWGaWcfEIr11O5Dlw3p2y0tZWpKHDejQ==", "license": "MIT", "dependencies": { - "micromark-util-chunked": "^2.0.0", + "acorn": "^8.0.0", + "acorn-jsx": "^5.0.0", + "micromark-extension-mdx-expression": "^3.0.0", + "micromark-extension-mdx-jsx": "^3.0.0", + "micromark-extension-mdx-md": "^2.0.0", + "micromark-extension-mdxjs-esm": "^3.0.0", + "micromark-util-combine-extensions": "^2.0.0", "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "node_modules/micromark-extension-mdxjs-esm": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-mdxjs-esm/-/micromark-extension-mdxjs-esm-3.0.0.tgz", + "integrity": "sha512-DJFl4ZqkErRpq/dAPyeWp15tGrcrrJho1hKK5uBS70BCtfrIFg81sqcTVu3Ta+KD1Tk5vAtBNElWxtAa+m8K9A==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-events-to-acorn": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-position-from-estree": "^2.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9842,13 +10219,14 @@ ], "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-decode-string": { + "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9859,18 +10237,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9883,10 +10255,10 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "node_modules/micromark-extension-mdxjs/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -9899,10 +10271,10 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-normalize-identifier": { + "node_modules/micromark-factory-destination": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", "funding": [ { "type": "GitHub Sponsors", @@ -9915,13 +10287,15 @@ ], "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "node_modules/micromark-factory-destination/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9934,13 +10308,46 @@ ], "license": "MIT", "dependencies": { + "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-sanitize-uri": { + "node_modules/micromark-factory-destination/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-factory-destination/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", "funding": [ { "type": "GitHub Sponsors", @@ -9953,15 +10360,16 @@ ], "license": "MIT", "dependencies": { + "devlop": "^1.0.0", "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "node_modules/micromark-factory-label/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -9974,13 +10382,11 @@ ], "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-symbol": { + "node_modules/micromark-factory-label/node_modules/micromark-util-symbol": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", @@ -9996,7 +10402,7 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/micromark-util-types": { + "node_modules/micromark-factory-label/node_modules/micromark-util-types": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", @@ -10012,173 +10418,77 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "node_modules/micromark-factory-mdx-expression": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-factory-mdx-expression/-/micromark-factory-mdx-expression-2.0.2.tgz", + "integrity": "sha512-5E5I2pFzJyg2CtemqAbcyCktpHXuJbABnsb32wX2U8IQKhhVFBqkcZR5LRm1WVoFqa4kTueZK4abep7wdo9nrw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "@types/estree": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-events-to-acorn": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-position-from-estree": "^2.0.0", + "vfile-message": "^4.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "node_modules/micromark-factory-mdx-expression/node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-strikethrough/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "node_modules/micromark-factory-mdx-expression/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz", - "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "markdown-table": "^3.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-table/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-gfm-table/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", - "license": "MIT" - }, - "node_modules/mdast-util-gfm-table/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mdast-util-gfm-table/node_modules/mdast-util-from-markdown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-table/node_modules/mdast-util-phrasing": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", - "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-table/node_modules/mdast-util-to-markdown": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", - "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-table/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-table/node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "node_modules/micromark-factory-mdx-expression/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10189,31 +10499,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "node_modules/micromark-factory-mdx-expression/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -10224,30 +10515,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-factory-destination": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "node_modules/micromark-factory-space": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-1.1.0.tgz", + "integrity": "sha512-cRzEj7c0OL4Mw2v6nwzttyOZe8XY/Z8G0rzmWQZTBi/jjwyw/U4uqKtUORXQrR5bAZZnbTI/feRV/R7hc4jQYQ==", "funding": [ { "type": "GitHub Sponsors", @@ -10258,17 +10531,15 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "micromark-util-character": "^1.0.0", + "micromark-util-types": "^1.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-factory-label": { + "node_modules/micromark-factory-title": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", "funding": [ { "type": "GitHub Sponsors", @@ -10281,13 +10552,13 @@ ], "license": "MIT", "dependencies": { - "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-factory-space": { + "node_modules/micromark-factory-title/node_modules/micromark-factory-space": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", @@ -10307,10 +10578,10 @@ "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "node_modules/micromark-factory-title/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10323,16 +10594,14 @@ ], "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-factory-whitespace": { + "node_modules/micromark-factory-title/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10343,18 +10612,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "node_modules/micromark-factory-title/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -10365,16 +10628,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-chunked": { + "node_modules/micromark-factory-whitespace": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", "funding": [ { "type": "GitHub Sponsors", @@ -10387,13 +10646,16 @@ ], "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-classify-character": { + "node_modules/micromark-factory-whitespace/node_modules/micromark-factory-space": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", "funding": [ { "type": "GitHub Sponsors", @@ -10407,14 +10669,13 @@ "license": "MIT", "dependencies": { "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "node_modules/micromark-factory-whitespace/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10427,14 +10688,14 @@ ], "license": "MIT", "dependencies": { - "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "node_modules/micromark-factory-whitespace/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10445,16 +10706,48 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-decode-string": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", - "funding": [ + "node_modules/micromark-factory-whitespace/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-character": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-1.2.0.tgz", + "integrity": "sha512-lXraTwcX3yH/vMDaFWCQJP1uIszLVebzUa3ZHdrgxr7KEU/9mL4mVgCpGbyhvNLNlauROiNUq7WN5u7ndbY6xg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "funding": [ { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" @@ -10466,16 +10759,13 @@ ], "license": "MIT", "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-symbol": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-encode": { + "node_modules/micromark-util-chunked/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10488,10 +10778,10 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-html-tag-name": { + "node_modules/micromark-util-classify-character": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10502,12 +10792,17 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT" + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "node_modules/micromark-util-classify-character/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10520,13 +10815,46 @@ ], "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-resolve-all": { + "node_modules/micromark-util-classify-character/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-classify-character/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", "funding": [ { "type": "GitHub Sponsors", @@ -10539,13 +10867,65 @@ ], "license": "MIT", "dependencies": { + "micromark-util-chunked": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-sanitize-uri": { + "node_modules/micromark-util-combine-extensions/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", + "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", "funding": [ { "type": "GitHub Sponsors", @@ -10558,15 +10938,16 @@ ], "license": "MIT", "dependencies": { + "decode-named-character-reference": "^1.0.0", "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-symbol": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "node_modules/micromark-util-decode-string/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10579,13 +10960,11 @@ ], "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-symbol": { + "node_modules/micromark-util-decode-string/node_modules/micromark-util-symbol": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", @@ -10601,7 +10980,7 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/micromark-util-types": { + "node_modules/micromark-util-decode-string/node_modules/micromark-util-types": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", @@ -10617,172 +10996,74 @@ ], "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-table/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" }, - "node_modules/mdast-util-gfm-table/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "node_modules/micromark-util-events-to-acorn": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-events-to-acorn/-/micromark-util-events-to-acorn-2.0.2.tgz", + "integrity": "sha512-Fk+xmBrOv9QZnEDguL9OI9/NQQp6Hz4FuQ4YmCb/5V7+9eAh1s6AYSvL20kHkD67YIg7EpE54TiSlcsf3vyZgA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT", "dependencies": { + "@types/acorn": "^4.0.0", + "@types/estree": "^1.0.0", "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz", - "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", "devlop": "^1.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" + "estree-util-visit": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "vfile-message": "^4.0.0" } }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/@types/unist": { + "node_modules/micromark-util-events-to-acorn/node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true + "node_modules/micromark-util-events-to-acorn/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" } - } + ], + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/mdast-util-from-markdown": { + "node_modules/micromark-util-events-to-acorn/node_modules/micromark-util-types": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/mdast-util-phrasing": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", - "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/mdast-util-to-markdown": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", - "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -10793,31 +11074,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", "funding": [ { "type": "GitHub Sponsors", @@ -10828,30 +11090,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-factory-destination": { + "node_modules/micromark-util-normalize-identifier": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10864,15 +11108,13 @@ ], "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "micromark-util-symbol": "^2.0.0" } }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-factory-label": { + "node_modules/micromark-util-normalize-identifier/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10883,18 +11125,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-factory-space": { + "node_modules/micromark-util-resolve-all": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", "funding": [ { "type": "GitHub Sponsors", @@ -10907,14 +11143,13 @@ ], "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "node_modules/micromark-util-resolve-all/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -10925,18 +11160,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-factory-whitespace": { + "node_modules/micromark-util-sanitize-uri": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", "funding": [ { "type": "GitHub Sponsors", @@ -10949,13 +11178,12 @@ ], "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" } }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-character": { + "node_modules/micromark-util-sanitize-uri/node_modules/micromark-util-character": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", @@ -10975,10 +11203,10 @@ "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-chunked": { + "node_modules/micromark-util-sanitize-uri/node_modules/micromark-util-symbol": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -10989,15 +11217,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "node_modules/micromark-util-sanitize-uri/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -11008,17 +11233,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", "funding": [ { "type": "GitHub Sponsors", @@ -11031,14 +11251,16 @@ ], "license": "MIT", "dependencies": { + "devlop": "^1.0.0", "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "node_modules/micromark-util-subtokenize/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", "funding": [ { "type": "GitHub Sponsors", @@ -11049,15 +11271,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-decode-string": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "node_modules/micromark-util-subtokenize/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", "funding": [ { "type": "GitHub Sponsors", @@ -11068,18 +11287,12 @@ "url": "https://opencollective.com/unified" } ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } + "license": "MIT" }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "node_modules/micromark-util-symbol": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-1.1.0.tgz", + "integrity": "sha512-uEjpEYY6KMs1g7QfJ2eX1SQEV+ZT4rUD3UcF6l57acZvLNK7PBZL+ty82Z1qhK1/yXIY4bdx04FKMgR0g4IAag==", "funding": [ { "type": "GitHub Sponsors", @@ -11089,126 +11302,12 @@ "type": "OpenCollective", "url": "https://opencollective.com/unified" } - ], - "license": "MIT" - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" + ] }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "node_modules/micromark-util-types": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-1.1.0.tgz", + "integrity": "sha512-ukRBgie8TIAcacscVHSiddHjO4k/q3pnedmzMQ4iwDcK0FtFCohKOlFbaOL/mPgfnPsL3C1ZyxJa4sbWrBl3jg==", "funding": [ { "type": "GitHub Sponsors", @@ -11218,7472 +11317,1790 @@ "type": "OpenCollective", "url": "https://opencollective.com/unified" } - ], - "license": "MIT" - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-gfm/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", - "license": "MIT" - }, - "node_modules/mdast-util-gfm/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mdast-util-gfm/node_modules/mdast-util-from-markdown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm/node_modules/mdast-util-phrasing": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", - "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm/node_modules/mdast-util-to-markdown": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", - "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } + ] }, - "node_modules/mdast-util-gfm/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "node_modules/micromark/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", "license": "MIT", "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-factory-destination": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-factory-whitespace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-decode-string": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-gfm/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-gfm/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-mdx/-/mdast-util-mdx-3.0.0.tgz", - "integrity": "sha512-JfbYLAW7XnYTTbUsmpu0kdBUVe+yKVJZBItEjwyYJiDJuZ9w4eeaqks4HQO+R7objWgS2ymV60GYpI14Ug554w==", - "license": "MIT", - "dependencies": { - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-mdx-expression": "^2.0.0", - "mdast-util-mdx-jsx": "^3.0.0", - "mdast-util-mdxjs-esm": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.0.tgz", - "integrity": "sha512-fGCu8eWdKUKNu5mohVGkhBXCXGnOTLuFqOvGMvdikr+J1w7lDJgxThOKpwRWzzbyXAU2hhSwsmssOY4yTokluw==", - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/@types/hast": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", - "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/@types/mdast": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", - "integrity": "sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" - }, - "node_modules/mdast-util-mdx-expression/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/mdast-util-from-markdown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.0.tgz", - "integrity": "sha512-n7MTOr/z+8NAX/wmhhDji8O3bRvPTV/U0oTCaZJkjhPSKTPhS3xufVhKGF8s1pJ7Ox4QgoIU7KHseh09S+9rTA==", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/mdast-util-phrasing": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.0.0.tgz", - "integrity": "sha512-xadSsJayQIucJ9n053dfQwVu1kuXg7jCTdYsMK8rqzKZh52nLfSH/k0sAxE0u+pj/zKZX+o5wB+ML5mRayOxFA==", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/mdast-util-to-markdown": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", - "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.0.tgz", - "integrity": "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-core-commonmark": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.0.tgz", - "integrity": "sha512-jThOz/pVmAYUtkroV3D5c1osFXAMv9e0ypGDOIZuCeAe91/sD6BoE2Sjzt30yuXtwOYUmySOhMas/PVyh02itA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-factory-destination": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.0.tgz", - "integrity": "sha512-j9DGrQLm/Uhl2tCzcbLhy5kXsgkHUrjJHg4fFAeoMRwJmJerT9aw4FEhIbZStWN8A3qMwOp1uzHr4UL8AInxtA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-factory-label": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.0.tgz", - "integrity": "sha512-RR3i96ohZGde//4WSe/dJsxOX6vxIg9TimLAS3i4EhBAFx8Sm5SmqVfR8E87DPSR31nEAjZfbt91OMZWcNgdZw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-factory-space": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.0.tgz", - "integrity": "sha512-TKr+LIDX2pkBJXFLzpyPyljzYK3MtmllMUMODTQJIUfDGncESaqB90db9IAUcz4AZAJFdd8U9zOp9ty1458rxg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-factory-title": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.0.tgz", - "integrity": "sha512-jY8CSxmpWLOxS+t8W+FG3Xigc0RDQA9bKMY/EwILvsesiRniiVMejYTE4wumNc2f4UbAa4WsHqe3J1QS1sli+A==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-factory-whitespace": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.0.tgz", - "integrity": "sha512-28kbwaBjc5yAI1XadbdPYHX/eDnqaUFVikLwrO7FDnKG7lpgxnvk/XGRhX/PN0mOZ+dBSZ+LgunHS+6tYQAzhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.0.1.tgz", - "integrity": "sha512-3wgnrmEAJ4T+mGXAUfMvMAbxU9RDG43XmGce4j6CwPtVxB3vfwXSZ6KhFwDzZ3mZHhmPimMAXg71veiBGzeAZw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-chunked": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.0.tgz", - "integrity": "sha512-anK8SWmNphkXdaKgz5hJvGa7l00qmcaUQoMYsBwDlSKFKjc6gjGXPDw3FNL3Nbwq5L8gE+RCbGqTw49FK5Qyvg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-classify-character": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.0.tgz", - "integrity": "sha512-S0ze2R9GH+fu41FA7pbSqNWObo/kzwf8rN/+IGlW/4tC6oACOs8B++bh+i9bVyNnwCcuksbFwsBme5OCKXCwIw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-combine-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.0.tgz", - "integrity": "sha512-vZZio48k7ON0fVS3CUgFatWHoKbbLTK/rT7pzpJ4Bjp5JjkZeasRfrS9wsBdDJK2cJLHMckXZdzPSSr1B8a4oQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.1.tgz", - "integrity": "sha512-bmkNc7z8Wn6kgjZmVHOX3SowGmVdhYS7yBpMnuMnPzDq/6xwVA604DuOXMZTO1lvq01g+Adfa0pE2UKGlxL1XQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-decode-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.0.tgz", - "integrity": "sha512-r4Sc6leeUTn3P6gk20aFMj2ntPwn6qpDZqWvYmAG6NgvFTIlj4WtrAudLi65qYoaGdXYViXYw2pkmn7QnIFasA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", - "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-html-tag-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.0.tgz", - "integrity": "sha512-xNn4Pqkj2puRhKdKTm8t1YHC/BAjx6CEwRFXntTaRf/x16aqka6ouVoutm+QdkISTlT7e2zU7U4ZdlDLJd2Mcw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.0.tgz", - "integrity": "sha512-2xhYT0sfo85FMrUPtHcPo2rrp1lwbDEEzpx7jiH2xXJLqBuy4H0GgXk5ToU8IEwoROtXuL8ND0ttVa4rNqYK3w==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-resolve-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.0.tgz", - "integrity": "sha512-6KU6qO7DZ7GJkaCgwBNtplXCvGkJToU86ybBAUdavvgsCiG8lSSvYxr9MhwmQ+udpzywHsl4RpGJsYWG1pDOcA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", - "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-subtokenize": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.0.tgz", - "integrity": "sha512-vc93L1t+gpR3p8jxeVdaYlbV2jTYteDje19rNSS/H5dlhxUYll5Fy6vJ2cDwP8RnsXi818yGty1ayP55y3W6fg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-symbol": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", - "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-expression/node_modules/micromark-util-types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", - "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-expression/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/mdast-util-mdx-expression/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.0.0.tgz", - "integrity": "sha512-XZuPPzQNBPAlaqsTTgRrcJnyFbSOBovSadFgbFu8SnuNgm+6Bdx1K+IWoitsmj6Lq6MNtI+ytOqwN70n//NaBA==", - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "ccount": "^2.0.0", - "devlop": "^1.1.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0", - "parse-entities": "^4.0.0", - "stringify-entities": "^4.0.0", - "unist-util-remove-position": "^5.0.0", - "unist-util-stringify-position": "^4.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/@types/hast": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", - "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/@types/mdast": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", - "integrity": "sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" - }, - "node_modules/mdast-util-mdx-jsx/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/mdast-util-from-markdown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.0.tgz", - "integrity": "sha512-n7MTOr/z+8NAX/wmhhDji8O3bRvPTV/U0oTCaZJkjhPSKTPhS3xufVhKGF8s1pJ7Ox4QgoIU7KHseh09S+9rTA==", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/mdast-util-phrasing": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.0.0.tgz", - "integrity": "sha512-xadSsJayQIucJ9n053dfQwVu1kuXg7jCTdYsMK8rqzKZh52nLfSH/k0sAxE0u+pj/zKZX+o5wB+ML5mRayOxFA==", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/mdast-util-to-markdown": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", - "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.0.tgz", - "integrity": "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-core-commonmark": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.0.tgz", - "integrity": "sha512-jThOz/pVmAYUtkroV3D5c1osFXAMv9e0ypGDOIZuCeAe91/sD6BoE2Sjzt30yuXtwOYUmySOhMas/PVyh02itA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-factory-destination": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.0.tgz", - "integrity": "sha512-j9DGrQLm/Uhl2tCzcbLhy5kXsgkHUrjJHg4fFAeoMRwJmJerT9aw4FEhIbZStWN8A3qMwOp1uzHr4UL8AInxtA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-factory-label": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.0.tgz", - "integrity": "sha512-RR3i96ohZGde//4WSe/dJsxOX6vxIg9TimLAS3i4EhBAFx8Sm5SmqVfR8E87DPSR31nEAjZfbt91OMZWcNgdZw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-factory-space": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.0.tgz", - "integrity": "sha512-TKr+LIDX2pkBJXFLzpyPyljzYK3MtmllMUMODTQJIUfDGncESaqB90db9IAUcz4AZAJFdd8U9zOp9ty1458rxg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-factory-title": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.0.tgz", - "integrity": "sha512-jY8CSxmpWLOxS+t8W+FG3Xigc0RDQA9bKMY/EwILvsesiRniiVMejYTE4wumNc2f4UbAa4WsHqe3J1QS1sli+A==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-factory-whitespace": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.0.tgz", - "integrity": "sha512-28kbwaBjc5yAI1XadbdPYHX/eDnqaUFVikLwrO7FDnKG7lpgxnvk/XGRhX/PN0mOZ+dBSZ+LgunHS+6tYQAzhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.0.1.tgz", - "integrity": "sha512-3wgnrmEAJ4T+mGXAUfMvMAbxU9RDG43XmGce4j6CwPtVxB3vfwXSZ6KhFwDzZ3mZHhmPimMAXg71veiBGzeAZw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-chunked": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.0.tgz", - "integrity": "sha512-anK8SWmNphkXdaKgz5hJvGa7l00qmcaUQoMYsBwDlSKFKjc6gjGXPDw3FNL3Nbwq5L8gE+RCbGqTw49FK5Qyvg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-classify-character": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.0.tgz", - "integrity": "sha512-S0ze2R9GH+fu41FA7pbSqNWObo/kzwf8rN/+IGlW/4tC6oACOs8B++bh+i9bVyNnwCcuksbFwsBme5OCKXCwIw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-combine-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.0.tgz", - "integrity": "sha512-vZZio48k7ON0fVS3CUgFatWHoKbbLTK/rT7pzpJ4Bjp5JjkZeasRfrS9wsBdDJK2cJLHMckXZdzPSSr1B8a4oQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.1.tgz", - "integrity": "sha512-bmkNc7z8Wn6kgjZmVHOX3SowGmVdhYS7yBpMnuMnPzDq/6xwVA604DuOXMZTO1lvq01g+Adfa0pE2UKGlxL1XQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-decode-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.0.tgz", - "integrity": "sha512-r4Sc6leeUTn3P6gk20aFMj2ntPwn6qpDZqWvYmAG6NgvFTIlj4WtrAudLi65qYoaGdXYViXYw2pkmn7QnIFasA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", - "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-html-tag-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.0.tgz", - "integrity": "sha512-xNn4Pqkj2puRhKdKTm8t1YHC/BAjx6CEwRFXntTaRf/x16aqka6ouVoutm+QdkISTlT7e2zU7U4ZdlDLJd2Mcw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.0.tgz", - "integrity": "sha512-2xhYT0sfo85FMrUPtHcPo2rrp1lwbDEEzpx7jiH2xXJLqBuy4H0GgXk5ToU8IEwoROtXuL8ND0ttVa4rNqYK3w==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-resolve-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.0.tgz", - "integrity": "sha512-6KU6qO7DZ7GJkaCgwBNtplXCvGkJToU86ybBAUdavvgsCiG8lSSvYxr9MhwmQ+udpzywHsl4RpGJsYWG1pDOcA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", - "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-subtokenize": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.0.tgz", - "integrity": "sha512-vc93L1t+gpR3p8jxeVdaYlbV2jTYteDje19rNSS/H5dlhxUYll5Fy6vJ2cDwP8RnsXi818yGty1ayP55y3W6fg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-symbol": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", - "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-jsx/node_modules/micromark-util-types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", - "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdx-jsx/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/mdast-util-mdx-jsx/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-mdx/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", - "license": "MIT" - }, - "node_modules/mdast-util-mdx/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mdast-util-mdx/node_modules/mdast-util-from-markdown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx/node_modules/mdast-util-phrasing": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", - "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx/node_modules/mdast-util-to-markdown": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", - "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-factory-destination": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-factory-whitespace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-decode-string": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-mdx/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/mdast-util-mdx/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-2.0.1.tgz", - "integrity": "sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==", - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/@types/hast": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", - "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/@types/mdast": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", - "integrity": "sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/mdast-util-from-markdown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.0.tgz", - "integrity": "sha512-n7MTOr/z+8NAX/wmhhDji8O3bRvPTV/U0oTCaZJkjhPSKTPhS3xufVhKGF8s1pJ7Ox4QgoIU7KHseh09S+9rTA==", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/mdast-util-phrasing": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.0.0.tgz", - "integrity": "sha512-xadSsJayQIucJ9n053dfQwVu1kuXg7jCTdYsMK8rqzKZh52nLfSH/k0sAxE0u+pj/zKZX+o5wB+ML5mRayOxFA==", - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/mdast-util-to-markdown": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", - "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.0.tgz", - "integrity": "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-core-commonmark": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.0.tgz", - "integrity": "sha512-jThOz/pVmAYUtkroV3D5c1osFXAMv9e0ypGDOIZuCeAe91/sD6BoE2Sjzt30yuXtwOYUmySOhMas/PVyh02itA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-factory-destination": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.0.tgz", - "integrity": "sha512-j9DGrQLm/Uhl2tCzcbLhy5kXsgkHUrjJHg4fFAeoMRwJmJerT9aw4FEhIbZStWN8A3qMwOp1uzHr4UL8AInxtA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-factory-label": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.0.tgz", - "integrity": "sha512-RR3i96ohZGde//4WSe/dJsxOX6vxIg9TimLAS3i4EhBAFx8Sm5SmqVfR8E87DPSR31nEAjZfbt91OMZWcNgdZw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-factory-space": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.0.tgz", - "integrity": "sha512-TKr+LIDX2pkBJXFLzpyPyljzYK3MtmllMUMODTQJIUfDGncESaqB90db9IAUcz4AZAJFdd8U9zOp9ty1458rxg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-factory-title": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.0.tgz", - "integrity": "sha512-jY8CSxmpWLOxS+t8W+FG3Xigc0RDQA9bKMY/EwILvsesiRniiVMejYTE4wumNc2f4UbAa4WsHqe3J1QS1sli+A==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-factory-whitespace": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.0.tgz", - "integrity": "sha512-28kbwaBjc5yAI1XadbdPYHX/eDnqaUFVikLwrO7FDnKG7lpgxnvk/XGRhX/PN0mOZ+dBSZ+LgunHS+6tYQAzhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.0.1.tgz", - "integrity": "sha512-3wgnrmEAJ4T+mGXAUfMvMAbxU9RDG43XmGce4j6CwPtVxB3vfwXSZ6KhFwDzZ3mZHhmPimMAXg71veiBGzeAZw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-chunked": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.0.tgz", - "integrity": "sha512-anK8SWmNphkXdaKgz5hJvGa7l00qmcaUQoMYsBwDlSKFKjc6gjGXPDw3FNL3Nbwq5L8gE+RCbGqTw49FK5Qyvg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-classify-character": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.0.tgz", - "integrity": "sha512-S0ze2R9GH+fu41FA7pbSqNWObo/kzwf8rN/+IGlW/4tC6oACOs8B++bh+i9bVyNnwCcuksbFwsBme5OCKXCwIw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-combine-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.0.tgz", - "integrity": "sha512-vZZio48k7ON0fVS3CUgFatWHoKbbLTK/rT7pzpJ4Bjp5JjkZeasRfrS9wsBdDJK2cJLHMckXZdzPSSr1B8a4oQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.1.tgz", - "integrity": "sha512-bmkNc7z8Wn6kgjZmVHOX3SowGmVdhYS7yBpMnuMnPzDq/6xwVA604DuOXMZTO1lvq01g+Adfa0pE2UKGlxL1XQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-decode-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.0.tgz", - "integrity": "sha512-r4Sc6leeUTn3P6gk20aFMj2ntPwn6qpDZqWvYmAG6NgvFTIlj4WtrAudLi65qYoaGdXYViXYw2pkmn7QnIFasA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", - "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-html-tag-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.0.tgz", - "integrity": "sha512-xNn4Pqkj2puRhKdKTm8t1YHC/BAjx6CEwRFXntTaRf/x16aqka6ouVoutm+QdkISTlT7e2zU7U4ZdlDLJd2Mcw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.0.tgz", - "integrity": "sha512-2xhYT0sfo85FMrUPtHcPo2rrp1lwbDEEzpx7jiH2xXJLqBuy4H0GgXk5ToU8IEwoROtXuL8ND0ttVa4rNqYK3w==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-resolve-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.0.tgz", - "integrity": "sha512-6KU6qO7DZ7GJkaCgwBNtplXCvGkJToU86ybBAUdavvgsCiG8lSSvYxr9MhwmQ+udpzywHsl4RpGJsYWG1pDOcA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", - "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-subtokenize": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.0.tgz", - "integrity": "sha512-vc93L1t+gpR3p8jxeVdaYlbV2jTYteDje19rNSS/H5dlhxUYll5Fy6vJ2cDwP8RnsXi818yGty1ayP55y3W6fg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-symbol": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", - "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/micromark-util-types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", - "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-hast": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.0.2.tgz", - "integrity": "sha512-U5I+500EOOw9e3ZrclN3Is3fRpw8c19SMyNZlZ2IS+7vLsNzb2Om11VpIVOR+/0137GhZsFEF6YiKD5+0Hr2Og==", - "dependencies": { - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "@ungap/structured-clone": "^1.0.0", - "devlop": "^1.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "trim-lines": "^3.0.0", - "unist-util-position": "^5.0.0", - "unist-util-visit": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-hast/node_modules/@types/hast": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", - "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-to-hast/node_modules/@types/mdast": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", - "integrity": "sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==", - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/mdast-util-to-hast/node_modules/@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" - }, - "node_modules/mdast-util-to-hast/node_modules/micromark-util-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.0.1.tgz", - "integrity": "sha512-3wgnrmEAJ4T+mGXAUfMvMAbxU9RDG43XmGce4j6CwPtVxB3vfwXSZ6KhFwDzZ3mZHhmPimMAXg71veiBGzeAZw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/mdast-util-to-hast/node_modules/micromark-util-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", - "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-to-hast/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", - "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/mdast-util-to-hast/node_modules/micromark-util-symbol": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", - "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-to-hast/node_modules/micromark-util-types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", - "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/mdast-util-to-hast/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-hast/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-hast/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdn-data": { - "version": "2.0.30", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", - "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", - "dev": true - }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/merge-descriptors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", - "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/micromark-extension-frontmatter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-frontmatter/-/micromark-extension-frontmatter-2.0.0.tgz", - "integrity": "sha512-C4AkuM3dA58cgZha7zVnuVxBhDsbttIMiytjgsM2XbHAB2faRVaHRle40558FBN+DJcrLNCoqG5mlrpdU4cRtg==", - "license": "MIT", - "dependencies": { - "fault": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-frontmatter/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-frontmatter/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-frontmatter/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz", - "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==", - "license": "MIT", - "dependencies": { - "micromark-extension-gfm-autolink-literal": "^2.0.0", - "micromark-extension-gfm-footnote": "^2.0.0", - "micromark-extension-gfm-strikethrough": "^2.0.0", - "micromark-extension-gfm-table": "^2.0.0", - "micromark-extension-gfm-tagfilter": "^2.0.0", - "micromark-extension-gfm-task-list-item": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-autolink-literal": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz", - "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==", - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-autolink-literal/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-footnote": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz", - "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==", - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-factory-destination": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-factory-whitespace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-footnote/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-strikethrough": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz", - "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==", - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-strikethrough/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-table": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz", - "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==", - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-table/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-table/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-table/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-table/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-tagfilter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz", - "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==", - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-tagfilter/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-task-list-item": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz", - "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==", - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm-task-list-item/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-gfm/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-gfm/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdx-expression": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdx-expression/-/micromark-extension-mdx-expression-3.0.0.tgz", - "integrity": "sha512-sI0nwhUDz97xyzqJAbHQhp5TfaxEvZZZ2JDqUo+7NvyIYG6BZ5CPPqj2ogUoPJlmXHBnyZUzISg9+oUmU6tUjQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-mdx-expression": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdx-expression/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdx-expression/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdx-expression/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdx-expression/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdx-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/micromark-extension-mdx-jsx/-/micromark-extension-mdx-jsx-3.0.1.tgz", - "integrity": "sha512-vNuFb9czP8QCtAQcEJn0UJQJZA8Dk6DXKBqx+bg/w0WGuSxDxNr7hErW89tHUY31dUW4NqEOWwmEUNhjTFmHkg==", - "license": "MIT", - "dependencies": { - "@types/acorn": "^4.0.0", - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "estree-util-is-identifier-name": "^3.0.0", - "micromark-factory-mdx-expression": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdx-jsx/node_modules/estree-util-is-identifier-name": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz", - "integrity": "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdx-jsx/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdx-md": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdx-md/-/micromark-extension-mdx-md-2.0.0.tgz", - "integrity": "sha512-EpAiszsB3blw4Rpba7xTOUptcFeBFi+6PY8VnJ2hhimH+vCQDirWgsMpz7w1XcZE7LVrSAUGb9VJpG9ghlYvYQ==", - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdx-md/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdxjs": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdxjs/-/micromark-extension-mdxjs-3.0.0.tgz", - "integrity": "sha512-A873fJfhnJ2siZyUrJ31l34Uqwy4xIFmvPY1oj+Ean5PHcPBYzEsvqvWGaWcfEIr11O5Dlw3p2y0tZWpKHDejQ==", - "license": "MIT", - "dependencies": { - "acorn": "^8.0.0", - "acorn-jsx": "^5.0.0", - "micromark-extension-mdx-expression": "^3.0.0", - "micromark-extension-mdx-jsx": "^3.0.0", - "micromark-extension-mdx-md": "^2.0.0", - "micromark-extension-mdxjs-esm": "^3.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdxjs-esm": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdxjs-esm/-/micromark-extension-mdxjs-esm-3.0.0.tgz", - "integrity": "sha512-DJFl4ZqkErRpq/dAPyeWp15tGrcrrJho1hKK5uBS70BCtfrIFg81sqcTVu3Ta+KD1Tk5vAtBNElWxtAa+m8K9A==", - "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-position-from-estree": "^2.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-factory-destination": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-factory-whitespace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdxjs-esm/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdxjs/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdxjs/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-extension-mdxjs/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-factory-mdx-expression": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-factory-mdx-expression/-/micromark-factory-mdx-expression-2.0.2.tgz", - "integrity": "sha512-5E5I2pFzJyg2CtemqAbcyCktpHXuJbABnsb32wX2U8IQKhhVFBqkcZR5LRm1WVoFqa4kTueZK4abep7wdo9nrw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-position-from-estree": "^2.0.0", - "vfile-message": "^4.0.0" - } - }, - "node_modules/micromark-factory-mdx-expression/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-factory-mdx-expression/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-factory-mdx-expression/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-factory-mdx-expression/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-factory-space": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-1.1.0.tgz", - "integrity": "sha512-cRzEj7c0OL4Mw2v6nwzttyOZe8XY/Z8G0rzmWQZTBi/jjwyw/U4uqKtUORXQrR5bAZZnbTI/feRV/R7hc4jQYQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^1.0.0", - "micromark-util-types": "^1.0.0" - } - }, - "node_modules/micromark-util-character": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-1.2.0.tgz", - "integrity": "sha512-lXraTwcX3yH/vMDaFWCQJP1uIszLVebzUa3ZHdrgxr7KEU/9mL4mVgCpGbyhvNLNlauROiNUq7WN5u7ndbY6xg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^1.0.0", - "micromark-util-types": "^1.0.0" - } - }, - "node_modules/micromark-util-events-to-acorn": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-events-to-acorn/-/micromark-util-events-to-acorn-2.0.2.tgz", - "integrity": "sha512-Fk+xmBrOv9QZnEDguL9OI9/NQQp6Hz4FuQ4YmCb/5V7+9eAh1s6AYSvL20kHkD67YIg7EpE54TiSlcsf3vyZgA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "@types/acorn": "^4.0.0", - "@types/estree": "^1.0.0", - "@types/unist": "^3.0.0", - "devlop": "^1.0.0", - "estree-util-visit": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "vfile-message": "^4.0.0" - } - }, - "node_modules/micromark-util-events-to-acorn/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", - "license": "MIT" - }, - "node_modules/micromark-util-events-to-acorn/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-util-events-to-acorn/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/micromark-util-symbol": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-1.1.0.tgz", - "integrity": "sha512-uEjpEYY6KMs1g7QfJ2eX1SQEV+ZT4rUD3UcF6l57acZvLNK7PBZL+ty82Z1qhK1/yXIY4bdx04FKMgR0g4IAag==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/micromark-util-types": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-1.1.0.tgz", - "integrity": "sha512-ukRBgie8TIAcacscVHSiddHjO4k/q3pnedmzMQ4iwDcK0FtFCohKOlFbaOL/mPgfnPsL3C1ZyxJa4sbWrBl3jg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/micromatch": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", - "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", - "dependencies": { - "braces": "^3.0.3", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mimic-fn": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", - "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/minizlib": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.2.tgz", - "integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==", - "dev": true, - "license": "MIT", - "dependencies": { - "minipass": "^7.1.2" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/mkdirp": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", - "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", - "dev": true, - "license": "MIT", - "bin": { - "mkdirp": "dist/cjs/src/bin.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, - "node_modules/nanoid": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", - "license": "MIT", - "peer": true - }, - "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" - }, - "node_modules/next": { - "version": "15.4.7", - "resolved": "https://registry.npmjs.org/next/-/next-15.4.7.tgz", - "integrity": "sha512-OcqRugwF7n7mC8OSYjvsZhhG1AYSvulor1EIUsIkbbEbf1qoE5EbH36Swj8WhF4cHqmDgkiam3z1c1W0J1Wifg==", - "license": "MIT", - "dependencies": { - "@next/env": "15.4.7", - "@swc/helpers": "0.5.15", - "caniuse-lite": "^1.0.30001579", - "postcss": "8.4.31", - "styled-jsx": "5.1.6" - }, - "bin": { - "next": "dist/bin/next" - }, - "engines": { - "node": "^18.18.0 || ^19.8.0 || >= 20.0.0" - }, - "optionalDependencies": { - "@next/swc-darwin-arm64": "15.4.7", - "@next/swc-darwin-x64": "15.4.7", - "@next/swc-linux-arm64-gnu": "15.4.7", - "@next/swc-linux-arm64-musl": "15.4.7", - "@next/swc-linux-x64-gnu": "15.4.7", - "@next/swc-linux-x64-musl": "15.4.7", - "@next/swc-win32-arm64-msvc": "15.4.7", - "@next/swc-win32-x64-msvc": "15.4.7", - "sharp": "^0.34.3" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.1.0", - "@playwright/test": "^1.51.1", - "babel-plugin-react-compiler": "*", - "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", - "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", - "sass": "^1.3.0" - }, - "peerDependenciesMeta": { - "@opentelemetry/api": { - "optional": true - }, - "@playwright/test": { - "optional": true - }, - "babel-plugin-react-compiler": { - "optional": true - }, - "sass": { - "optional": true - } - } - }, - "node_modules/next-mdx-remote": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/next-mdx-remote/-/next-mdx-remote-5.0.0.tgz", - "integrity": "sha512-RNNbqRpK9/dcIFZs/esQhuLA8jANqlH694yqoDBK8hkVdJUndzzGmnPHa2nyi90N4Z9VmzuSWNRpr5ItT3M7xQ==", - "license": "MPL-2.0", - "dependencies": { - "@babel/code-frame": "^7.23.5", - "@mdx-js/mdx": "^3.0.1", - "@mdx-js/react": "^3.0.1", - "unist-util-remove": "^3.1.0", - "vfile": "^6.0.1", - "vfile-matter": "^5.0.0" - }, - "engines": { - "node": ">=14", - "npm": ">=7" - }, - "peerDependencies": { - "react": ">=16" - } - }, - "node_modules/next-mdx-remote/node_modules/@mdx-js/react": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-3.1.0.tgz", - "integrity": "sha512-QjHtSaoameoalGnKDT3FoIl4+9RwyTmo9ZJGBdLOks/YOiWHoRDI3PUwEzOE7kEmGcV3AFcp9K6dYu9rEuKLAQ==", - "license": "MIT", - "dependencies": { - "@types/mdx": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - }, - "peerDependencies": { - "@types/react": ">=16", - "react": ">=16" - } - }, - "node_modules/next/node_modules/@swc/helpers": { - "version": "0.5.15", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", - "integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==", - "license": "Apache-2.0", - "dependencies": { - "tslib": "^2.8.0" - } - }, - "node_modules/node-releases": { - "version": "2.0.19", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz", - "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", - "devOptional": true, - "license": "MIT" - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/normalize-range": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", - "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/npm-run-path": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", - "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", - "dependencies": { - "path-key": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/npm-run-path/node_modules/path-key": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", - "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/nth-check": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", - "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", - "dev": true, - "dependencies": { - "boolbase": "^1.0.0" - }, - "funding": { - "url": "https://github.com/fb55/nth-check?sponsor=1" - } - }, - "node_modules/nwsapi": { - "version": "2.2.20", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.20.tgz", - "integrity": "sha512-/ieB+mDe4MrrKMT8z+mQL8klXydZWGR5Dowt4RAGKbJ3kIGEx3X4ljUo+6V73IXtUPWgfOlU5B9MlGxFO5T+cA==", - "dev": true, - "license": "MIT" - }, - "node_modules/oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "engines": { - "node": "*" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", - "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.assign": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", - "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "has-symbols": "^1.0.3", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.entries": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.6.tgz", - "integrity": "sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==", - "dependencies": { - "array.prototype.reduce": "^1.0.4", - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.fromentries": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.6.tgz", - "integrity": "sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.groupby": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.0.tgz", - "integrity": "sha512-70MWG6NfRH9GnbZOikuhPPYzpUpof9iW2J9E4dW7FXTqPNb6rllE6u39SKwwiNh8lCwX3DDb5OgcKGiEBrTTyw==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.21.2", - "get-intrinsic": "^1.2.1" - } - }, - "node_modules/object.hasown": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.2.tgz", - "integrity": "sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw==", - "dependencies": { - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.values": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz", - "integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" + "ms": "^2.1.3" }, "engines": { - "node": ">= 0.4" + "node": ">=6.0" }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "node_modules/micromark/node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "node_modules/micromark/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", "dependencies": { - "wrappy": "1" + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/onetime": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", - "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "node_modules/micromark/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark/node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dependencies": { - "mimic-fn": "^4.0.0" + "braces": "^3.0.3", + "picomatch": "^2.3.1" }, "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8.6" } }, - "node_modules/open": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/open/-/open-9.1.0.tgz", - "integrity": "sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==", - "dependencies": { - "default-browser": "^4.0.0", - "define-lazy-prop": "^3.0.0", - "is-inside-container": "^1.0.0", - "is-wsl": "^2.2.0" + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" }, "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=4" } }, - "node_modules/optionator": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", - "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", - "license": "MIT", - "peer": true, - "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.5" - }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "engines": { - "node": ">= 0.8.0" + "node": ">= 0.6" } }, - "node_modules/oxc-parser": { - "version": "0.74.0", - "resolved": "https://registry.npmjs.org/oxc-parser/-/oxc-parser-0.74.0.tgz", - "integrity": "sha512-2tDN/ttU8WE6oFh8EzKNam7KE7ZXSG5uXmvX85iNzxdJfMssDWcj3gpYzZi1E04XuE7m3v1dVWl/8BE886vPGw==", - "dev": true, - "license": "MIT", + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dependencies": { - "@oxc-project/types": "^0.74.0" + "mime-db": "1.52.0" }, "engines": { - "node": ">=20.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/Boshen" - }, - "optionalDependencies": { - "@oxc-parser/binding-android-arm64": "0.74.0", - "@oxc-parser/binding-darwin-arm64": "0.74.0", - "@oxc-parser/binding-darwin-x64": "0.74.0", - "@oxc-parser/binding-freebsd-x64": "0.74.0", - "@oxc-parser/binding-linux-arm-gnueabihf": "0.74.0", - "@oxc-parser/binding-linux-arm-musleabihf": "0.74.0", - "@oxc-parser/binding-linux-arm64-gnu": "0.74.0", - "@oxc-parser/binding-linux-arm64-musl": "0.74.0", - "@oxc-parser/binding-linux-riscv64-gnu": "0.74.0", - "@oxc-parser/binding-linux-s390x-gnu": "0.74.0", - "@oxc-parser/binding-linux-x64-gnu": "0.74.0", - "@oxc-parser/binding-linux-x64-musl": "0.74.0", - "@oxc-parser/binding-wasm32-wasi": "0.74.0", - "@oxc-parser/binding-win32-arm64-msvc": "0.74.0", - "@oxc-parser/binding-win32-x64-msvc": "0.74.0" + "node": ">= 0.6" } }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, + "node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "node_modules/mimic-function": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", "license": "MIT", - "peer": true, - "dependencies": { - "p-limit": "^3.0.2" - }, "engines": { - "node": ">=10" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "license": "MIT", - "peer": true, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dependencies": { - "callsites": "^3.0.0" + "brace-expansion": "^1.1.7" }, "engines": { - "node": ">=6" - } - }, - "node_modules/parse-entities": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.1.tgz", - "integrity": "sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==", - "dependencies": { - "@types/unist": "^2.0.0", - "character-entities": "^2.0.0", - "character-entities-legacy": "^3.0.0", - "character-reference-invalid": "^2.0.0", - "decode-named-character-reference": "^1.0.0", - "is-alphanumerical": "^2.0.0", - "is-decimal": "^2.0.0", - "is-hexadecimal": "^2.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/parse5": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", - "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "entities": "^6.0.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" + "node": "*" } }, - "node_modules/parse5/node_modules/entities": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", - "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "engines": { - "node": ">=0.10.0" + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "license": "ISC", "engines": { - "node": ">=8" + "node": ">=16 || 14 >=14.17" } }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "node_modules/path-to-regexp": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", - "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" - }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "node_modules/minizlib": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.2.tgz", + "integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minipass": "^7.1.2" + }, "engines": { - "node": ">=8" + "node": ">= 18" } }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" - }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "license": "ISC" - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, "engines": { - "node": ">=8.6" + "node": ">=10" }, "funding": { - "url": "https://github.com/sponsors/jonschlinkert" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, - "node_modules/postcss": { - "version": "8.4.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", - "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, { "type": "github", "url": "https://github.com/sponsors/ai" } ], - "dependencies": { - "nanoid": "^3.3.6", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" }, "engines": { - "node": "^10 || ^12 || >=14" + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" } }, - "node_modules/postcss-calc": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-9.0.1.tgz", - "integrity": "sha512-TipgjGyzP5QzEhsOZUaIkeO5mKeMFpebWzRogWG/ysonUlnHcq5aJe0jOjpfzUU8PeSaBQnrE8ehR0QA5vs8PQ==", + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" + }, + "node_modules/node-releases": { + "version": "2.0.21", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.21.tgz", + "integrity": "sha512-5b0pgg78U3hwXkCM8Z9b2FJdPZlr9Psr9V2gQPESdGHqbntyFJKFW4r5TeWGFzafGY3hzs1JC62VEQMbl1JFkw==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-package-data": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-5.0.0.tgz", + "integrity": "sha512-h9iPVIfrVZ9wVYQnxFgtw1ugSvGEMOlyPWWtm8BMJhnwyEL/FLbYbTY3V3PpjI/BUK67n9PEWDu6eHzu1fB15Q==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "postcss-selector-parser": "^6.0.11", - "postcss-value-parser": "^4.2.0" + "hosted-git-info": "^6.0.0", + "is-core-module": "^2.8.1", + "semver": "^7.3.5", + "validate-npm-package-license": "^3.0.4" }, "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.2" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/postcss-cli": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/postcss-cli/-/postcss-cli-8.3.1.tgz", - "integrity": "sha512-leHXsQRq89S3JC9zw/tKyiVV2jAhnfQe0J8VI4eQQbUjwIe0XxVqLrR+7UsahF1s9wi4GlqP6SJ8ydf44cgF2Q==", + "node_modules/npm-install-checks": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-6.3.0.tgz", + "integrity": "sha512-W29RiK/xtpCGqn6f3ixfRYGk+zRyr+Ew9F2E20BfXxT5/euLdA/Nm7fO7OeTGuAmTs30cpgInyJ0cYe708YTZw==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "chalk": "^4.0.0", - "chokidar": "^3.3.0", - "dependency-graph": "^0.9.0", - "fs-extra": "^9.0.0", - "get-stdin": "^8.0.0", - "globby": "^11.0.0", - "postcss-load-config": "^3.0.0", - "postcss-reporter": "^7.0.0", - "pretty-hrtime": "^1.0.3", - "read-cache": "^1.0.0", - "slash": "^3.0.0", - "yargs": "^16.0.0" - }, - "bin": { - "postcss": "bin/postcss" + "semver": "^7.1.1" }, "engines": { - "node": ">=10" - }, - "peerDependencies": { - "postcss": "^8.0.0" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/postcss-colormin": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-colormin/-/postcss-colormin-6.0.0.tgz", - "integrity": "sha512-EuO+bAUmutWoZYgHn2T1dG1pPqHU6L4TjzPlu4t1wZGXQ/fxV16xg2EJmYi0z+6r+MGV1yvpx1BHkUaRrPa2bw==", + "node_modules/npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", "dev": true, - "dependencies": { - "browserslist": "^4.21.4", - "caniuse-api": "^3.0.0", - "colord": "^2.9.1", - "postcss-value-parser": "^4.2.0" - }, + "license": "ISC", "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/postcss-convert-values": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-convert-values/-/postcss-convert-values-6.0.0.tgz", - "integrity": "sha512-U5D8QhVwqT++ecmy8rnTb+RL9n/B806UVaS3m60lqle4YDFcpbS3ae5bTQIh3wOGUSDHSEtMYLs/38dNG7EYFw==", + "node_modules/npm-package-arg": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.1.0.tgz", + "integrity": "sha512-uFyyCEmgBfZTtrKk/5xDfHp6+MdrqGotX/VoOyEEl3mBwiEE5FlBaePanazJSVMPT7vKepcjYBY2ztg9A3yPIA==", "dev": true, + "license": "ISC", "dependencies": { - "browserslist": "^4.21.4", - "postcss-value-parser": "^4.2.0" + "hosted-git-info": "^6.0.0", + "proc-log": "^3.0.0", + "semver": "^7.3.5", + "validate-npm-package-name": "^5.0.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/postcss-discard-comments": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-6.0.0.tgz", - "integrity": "sha512-p2skSGqzPMZkEQvJsgnkBhCn8gI7NzRH2683EEjrIkoMiwRELx68yoUJ3q3DGSGuQ8Ug9Gsn+OuDr46yfO+eFw==", + "node_modules/npm-pick-manifest": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-8.0.2.tgz", + "integrity": "sha512-1dKY+86/AIiq1tkKVD3l0WI+Gd3vkknVGAggsFeBkTvbhMQ1OND/LKkYv4JtXPKUJ8bOTCyLiqEg2P6QNdK+Gg==", "dev": true, - "engines": { - "node": "^14 || ^16 || >=18.0" + "license": "ISC", + "dependencies": { + "npm-install-checks": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "npm-package-arg": "^10.0.0", + "semver": "^7.3.5" }, - "peerDependencies": { - "postcss": "^8.2.15" + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/postcss-discard-duplicates": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-6.0.0.tgz", - "integrity": "sha512-bU1SXIizMLtDW4oSsi5C/xHKbhLlhek/0/yCnoMQany9k3nPBq+Ctsv/9oMmyqbR96HYHxZcHyK2HR5P/mqoGA==", - "dev": true, + "node_modules/npm-run-path": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", + "dependencies": { + "path-key": "^4.0.0" + }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-discard-empty": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-6.0.0.tgz", - "integrity": "sha512-b+h1S1VT6dNhpcg+LpyiUrdnEZfICF0my7HAKgJixJLW7BnNmpRH34+uw/etf5AhOlIhIAuXApSzzDzMI9K/gQ==", - "dev": true, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=12" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-discard-overridden": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-6.0.0.tgz", - "integrity": "sha512-4VELwssYXDFigPYAZ8vL4yX4mUepF/oCBeeIT4OXsJPYOtvJumyz9WflmJWTfDwCUcpDR+z0zvCWBXgTx35SVw==", + "node_modules/nwsapi": { + "version": "2.2.20", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.20.tgz", + "integrity": "sha512-/ieB+mDe4MrrKMT8z+mQL8klXydZWGR5Dowt4RAGKbJ3kIGEx3X4ljUo+6V73IXtUPWgfOlU5B9MlGxFO5T+cA==", "dev": true, + "license": "MIT" + }, + "node_modules/oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "node": "*" } }, - "node_modules/postcss-load-config": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", - "integrity": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==", - "dev": true, - "dependencies": { - "lilconfig": "^2.0.5", - "yaml": "^1.10.2" - }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "engines": { - "node": ">= 10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - "peerDependencies": { - "postcss": ">=8.0.9", - "ts-node": ">=9.0.0" - }, - "peerDependenciesMeta": { - "postcss": { - "optional": true - }, - "ts-node": { - "optional": true - } + "node": ">=0.10.0" } }, - "node_modules/postcss-merge-longhand": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-merge-longhand/-/postcss-merge-longhand-6.0.0.tgz", - "integrity": "sha512-4VSfd1lvGkLTLYcxFuISDtWUfFS4zXe0FpF149AyziftPFQIWxjvFSKhA4MIxMe4XM3yTDgQMbSNgzIVxChbIg==", - "dev": true, - "dependencies": { - "postcss-value-parser": "^4.2.0", - "stylehacks": "^6.0.0" - }, + "node_modules/object-inspect": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">= 0.4" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/postcss-merge-rules": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/postcss-merge-rules/-/postcss-merge-rules-6.0.1.tgz", - "integrity": "sha512-a4tlmJIQo9SCjcfiCcCMg/ZCEe0XTkl/xK0XHBs955GWg9xDX3NwP9pwZ78QUOWB8/0XCjZeJn98Dae0zg6AAw==", - "dev": true, - "dependencies": { - "browserslist": "^4.21.4", - "caniuse-api": "^3.0.0", - "cssnano-utils": "^4.0.0", - "postcss-selector-parser": "^6.0.5" - }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "node": ">= 0.4" } }, - "node_modules/postcss-minify-font-values": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-minify-font-values/-/postcss-minify-font-values-6.0.0.tgz", - "integrity": "sha512-zNRAVtyh5E8ndZEYXA4WS8ZYsAp798HiIQ1V2UF/C/munLp2r1UGHwf1+6JFu7hdEhJFN+W1WJQKBrtjhFgEnA==", - "dev": true, + "node_modules/object.assign": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", "dependencies": { - "postcss-value-parser": "^4.2.0" + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">= 0.4" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/postcss-minify-gradients": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-minify-gradients/-/postcss-minify-gradients-6.0.0.tgz", - "integrity": "sha512-wO0F6YfVAR+K1xVxF53ueZJza3L+R3E6cp0VwuXJQejnNUH0DjcAFe3JEBeTY1dLwGa0NlDWueCA1VlEfiKgAA==", - "dev": true, + "node_modules/object.entries": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.6.tgz", + "integrity": "sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==", "dependencies": { - "colord": "^2.9.1", - "cssnano-utils": "^4.0.0", - "postcss-value-parser": "^4.2.0" + "array.prototype.reduce": "^1.0.4", + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" }, "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "node": ">= 0.4" } }, - "node_modules/postcss-minify-params": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-minify-params/-/postcss-minify-params-6.0.0.tgz", - "integrity": "sha512-Fz/wMQDveiS0n5JPcvsMeyNXOIMrwF88n7196puSuQSWSa+/Ofc1gDOSY2xi8+A4PqB5dlYCKk/WfqKqsI+ReQ==", - "dev": true, + "node_modules/object.fromentries": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.6.tgz", + "integrity": "sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg==", "dependencies": { - "browserslist": "^4.21.4", - "cssnano-utils": "^4.0.0", - "postcss-value-parser": "^4.2.0" + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">= 0.4" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/postcss-minify-selectors": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-minify-selectors/-/postcss-minify-selectors-6.0.0.tgz", - "integrity": "sha512-ec/q9JNCOC2CRDNnypipGfOhbYPuUkewGwLnbv6omue/PSASbHSU7s6uSQ0tcFRVv731oMIx8k0SP4ZX6be/0g==", - "dev": true, + "node_modules/object.groupby": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.0.tgz", + "integrity": "sha512-70MWG6NfRH9GnbZOikuhPPYzpUpof9iW2J9E4dW7FXTqPNb6rllE6u39SKwwiNh8lCwX3DDb5OgcKGiEBrTTyw==", "dependencies": { - "postcss-selector-parser": "^6.0.5" - }, - "engines": { - "node": "^14 || ^16 || >=18.0" + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.21.2", + "get-intrinsic": "^1.2.1" + } + }, + "node_modules/object.hasown": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.2.tgz", + "integrity": "sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw==", + "dependencies": { + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/postcss-nesting": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-12.1.1.tgz", - "integrity": "sha512-qc74KvIAQNa5ujZKG1UV286dhaDW6basbUy2i9AzNU/T8C9hpvGu9NZzm1SfePe2yP7sPYgpA8d4sPVopn2Hhw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], + "node_modules/object.values": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz", + "integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==", "dependencies": { - "@csstools/selector-resolve-nested": "^1.1.0", - "@csstools/selector-specificity": "^3.0.3", - "postcss-selector-parser": "^6.0.13" + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" }, "engines": { - "node": "^14 || ^16 || >=18" + "node": ">= 0.4" }, - "peerDependencies": { - "postcss": "^8.4" + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/postcss-normalize-charset": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-6.0.0.tgz", - "integrity": "sha512-cqundwChbu8yO/gSWkuFDmKrCZ2vJzDAocheT2JTd0sFNA4HMGoKMfbk2B+J0OmO0t5GUkiAkSM5yF2rSLUjgQ==", - "dev": true, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "license": "MIT", "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "node": ">=14.0.0" } }, - "node_modules/postcss-normalize-display-values": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-display-values/-/postcss-normalize-display-values-6.0.0.tgz", - "integrity": "sha512-Qyt5kMrvy7dJRO3OjF7zkotGfuYALETZE+4lk66sziWSPzlBEt7FrUshV6VLECkI4EN8Z863O6Nci4NXQGNzYw==", - "dev": true, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dependencies": { - "postcss-value-parser": "^4.2.0" + "ee-first": "1.1.1" }, "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "node": ">= 0.8" } }, - "node_modules/postcss-normalize-positions": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-positions/-/postcss-normalize-positions-6.0.0.tgz", - "integrity": "sha512-mPCzhSV8+30FZyWhxi6UoVRYd3ZBJgTRly4hOkaSifo0H+pjDYcii/aVT4YE6QpOil15a5uiv6ftnY3rm0igPg==", - "dev": true, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" + "wrappy": "1" } }, - "node_modules/postcss-normalize-repeat-style": { + "node_modules/onetime": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-repeat-style/-/postcss-normalize-repeat-style-6.0.0.tgz", - "integrity": "sha512-50W5JWEBiOOAez2AKBh4kRFm2uhrT3O1Uwdxz7k24aKtbD83vqmcVG7zoIwo6xI2FZ/HDlbrCopXhLeTpQib1A==", - "dev": true, + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", "dependencies": { - "postcss-value-parser": "^4.2.0" + "mimic-fn": "^4.0.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=12" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-normalize-string": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-string/-/postcss-normalize-string-6.0.0.tgz", - "integrity": "sha512-KWkIB7TrPOiqb8ZZz6homet2KWKJwIlysF5ICPZrXAylGe2hzX/HSf4NTX2rRPJMAtlRsj/yfkrWGavFuB+c0w==", - "dev": true, + "node_modules/open": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/open/-/open-9.1.0.tgz", + "integrity": "sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==", "dependencies": { - "postcss-value-parser": "^4.2.0" + "default-browser": "^4.0.0", + "define-lazy-prop": "^3.0.0", + "is-inside-container": "^1.0.0", + "is-wsl": "^2.2.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=14.16" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-normalize-timing-functions": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-timing-functions/-/postcss-normalize-timing-functions-6.0.0.tgz", - "integrity": "sha512-tpIXWciXBp5CiFs8sem90IWlw76FV4oi6QEWfQwyeREVwUy39VSeSqjAT7X0Qw650yAimYW5gkl2Gd871N5SQg==", - "dev": true, + "node_modules/ora": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz", + "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==", + "license": "MIT", "dependencies": { - "postcss-value-parser": "^4.2.0" + "chalk": "^5.3.0", + "cli-cursor": "^5.0.0", + "cli-spinners": "^2.9.2", + "is-interactive": "^2.0.0", + "is-unicode-supported": "^2.0.0", + "log-symbols": "^6.0.0", + "stdin-discarder": "^0.2.2", + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=18" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-normalize-unicode": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-unicode/-/postcss-normalize-unicode-6.0.0.tgz", - "integrity": "sha512-ui5crYkb5ubEUDugDc786L/Me+DXp2dLg3fVJbqyAl0VPkAeALyAijF2zOsnZyaS1HyfPuMH0DwyY18VMFVNkg==", - "dev": true, - "dependencies": { - "browserslist": "^4.21.4", - "postcss-value-parser": "^4.2.0" - }, + "node_modules/ora/node_modules/ansi-regex": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "license": "MIT", "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=12" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/postcss-normalize-url": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-url/-/postcss-normalize-url-6.0.0.tgz", - "integrity": "sha512-98mvh2QzIPbb02YDIrYvAg4OUzGH7s1ZgHlD3fIdTHLgPLRpv1ZTKJDnSAKr4Rt21ZQFzwhGMXxpXlfrUBKFHw==", - "dev": true, - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, + "node_modules/ora/node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", "engines": { - "node": "^14 || ^16 || >=18.0" + "node": "^12.17.0 || ^14.13 || >=16.0.0" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/postcss-normalize-whitespace": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-whitespace/-/postcss-normalize-whitespace-6.0.0.tgz", - "integrity": "sha512-7cfE1AyLiK0+ZBG6FmLziJzqQCpTQY+8XjMhMAz8WSBSCsCNNUKujgIgjCAmDT3cJ+3zjTXFkoD15ZPsckArVw==", - "dev": true, + "node_modules/ora/node_modules/cli-cursor": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", + "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", + "license": "MIT", "dependencies": { - "postcss-value-parser": "^4.2.0" + "restore-cursor": "^5.0.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=18" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-ordered-values": { + "node_modules/ora/node_modules/emoji-regex": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", + "license": "MIT" + }, + "node_modules/ora/node_modules/log-symbols": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-ordered-values/-/postcss-ordered-values-6.0.0.tgz", - "integrity": "sha512-K36XzUDpvfG/nWkjs6d1hRBydeIxGpKS2+n+ywlKPzx1nMYDYpoGbcjhj5AwVYJK1qV2/SDoDEnHzlPD6s3nMg==", - "dev": true, + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", + "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", + "license": "MIT", "dependencies": { - "cssnano-utils": "^4.0.0", - "postcss-value-parser": "^4.2.0" + "chalk": "^5.3.0", + "is-unicode-supported": "^1.3.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=18" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-reduce-initial": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-reduce-initial/-/postcss-reduce-initial-6.0.0.tgz", - "integrity": "sha512-s2UOnidpVuXu6JiiI5U+fV2jamAw5YNA9Fdi/GRK0zLDLCfXmSGqQtzpUPtfN66RtCbb9fFHoyZdQaxOB3WxVA==", - "dev": true, - "dependencies": { - "browserslist": "^4.21.4", - "caniuse-api": "^3.0.0" - }, + "node_modules/ora/node_modules/log-symbols/node_modules/is-unicode-supported": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", + "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", + "license": "MIT", "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=12" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-reduce-transforms": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-reduce-transforms/-/postcss-reduce-transforms-6.0.0.tgz", - "integrity": "sha512-FQ9f6xM1homnuy1wLe9lP1wujzxnwt1EwiigtWwuyf8FsqqXUDUp2Ulxf9A5yjlUOTdCJO6lonYjg1mgqIIi2w==", - "dev": true, + "node_modules/ora/node_modules/onetime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", + "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", + "license": "MIT", "dependencies": { - "postcss-value-parser": "^4.2.0" + "mimic-function": "^5.0.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=18" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-reporter": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/postcss-reporter/-/postcss-reporter-7.0.5.tgz", - "integrity": "sha512-glWg7VZBilooZGOFPhN9msJ3FQs19Hie7l5a/eE6WglzYqVeH3ong3ShFcp9kDWJT1g2Y/wd59cocf9XxBtkWA==", - "dev": true, + "node_modules/ora/node_modules/restore-cursor": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", + "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", + "license": "MIT", "dependencies": { - "picocolors": "^1.0.0", - "thenby": "^1.3.4" + "onetime": "^7.0.0", + "signal-exit": "^4.1.0" }, "engines": { - "node": ">=10" + "node": ">=18" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" }, - "peerDependencies": { - "postcss": "^8.1.0" + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/postcss-selector-parser": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", - "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", - "dev": true, + "node_modules/ora/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", "license": "MIT", "dependencies": { - "cssesc": "^3.0.0", - "util-deprecate": "^1.0.2" + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/postcss-svgo": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-6.0.0.tgz", - "integrity": "sha512-r9zvj/wGAoAIodn84dR/kFqwhINp5YsJkLoujybWG59grR/IHx+uQ2Zo+IcOwM0jskfYX3R0mo+1Kip1VSNcvw==", - "dev": true, + "node_modules/ora/node_modules/strip-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "license": "MIT", "dependencies": { - "postcss-value-parser": "^4.2.0", - "svgo": "^3.0.2" + "ansi-regex": "^6.0.1" }, "engines": { - "node": "^14 || ^16 || >= 18" + "node": ">=12" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "node_modules/postcss-unique-selectors": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/postcss-unique-selectors/-/postcss-unique-selectors-6.0.0.tgz", - "integrity": "sha512-EPQzpZNxOxP7777t73RQpZE5e9TrnCrkvp7AH7a0l89JmZiPnS82y216JowHXwpBCQitfyxrof9TK3rYbi7/Yw==", + "node_modules/oxc-parser": { + "version": "0.74.0", + "resolved": "https://registry.npmjs.org/oxc-parser/-/oxc-parser-0.74.0.tgz", + "integrity": "sha512-2tDN/ttU8WE6oFh8EzKNam7KE7ZXSG5uXmvX85iNzxdJfMssDWcj3gpYzZi1E04XuE7m3v1dVWl/8BE886vPGw==", "dev": true, + "license": "MIT", "dependencies": { - "postcss-selector-parser": "^6.0.5" + "@oxc-project/types": "^0.74.0" }, "engines": { - "node": "^14 || ^16 || >=18.0" + "node": ">=20.0.0" }, - "peerDependencies": { - "postcss": "^8.2.15" + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxc-parser/binding-android-arm64": "0.74.0", + "@oxc-parser/binding-darwin-arm64": "0.74.0", + "@oxc-parser/binding-darwin-x64": "0.74.0", + "@oxc-parser/binding-freebsd-x64": "0.74.0", + "@oxc-parser/binding-linux-arm-gnueabihf": "0.74.0", + "@oxc-parser/binding-linux-arm-musleabihf": "0.74.0", + "@oxc-parser/binding-linux-arm64-gnu": "0.74.0", + "@oxc-parser/binding-linux-arm64-musl": "0.74.0", + "@oxc-parser/binding-linux-riscv64-gnu": "0.74.0", + "@oxc-parser/binding-linux-s390x-gnu": "0.74.0", + "@oxc-parser/binding-linux-x64-gnu": "0.74.0", + "@oxc-parser/binding-linux-x64-musl": "0.74.0", + "@oxc-parser/binding-wasm32-wasi": "0.74.0", + "@oxc-parser/binding-win32-arm64-msvc": "0.74.0", + "@oxc-parser/binding-win32-x64-msvc": "0.74.0" } }, - "node_modules/postcss-value-parser": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", - "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", - "dev": true + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "license": "BlueOak-1.0.0" }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">= 0.8.0" + "node_modules/parse-entities": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.1.tgz", + "integrity": "sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==", + "dependencies": { + "@types/unist": "^2.0.0", + "character-entities": "^2.0.0", + "character-entities-legacy": "^3.0.0", + "character-reference-invalid": "^2.0.0", + "decode-named-character-reference": "^1.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0", + "is-hexadecimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/prettier": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", - "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", "dev": true, "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" + "dependencies": { + "entities": "^6.0.0" }, "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" + "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "node_modules/pretty-hrtime": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==", + "node_modules/parse5/node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", "dev": true, + "license": "BSD-2-Clause", "engines": { - "node": ">= 0.8" - } - }, - "node_modules/prop-types": { - "version": "15.8.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", - "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dependencies": { - "loose-envify": "^1.4.0", - "object-assign": "^4.1.1", - "react-is": "^16.13.1" - } - }, - "node_modules/property-information": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.4.0.tgz", - "integrity": "sha512-9t5qARVofg2xQqKtytzt+lZ4d1Qvj8t5B8fEwXK6qOfgRLgH/b13QlgEyDh033NOS31nXeFbYv7CLUDG1CeifQ==", + "node": ">=0.12" + }, "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "engines": { - "node": ">= 0.10" + "node": ">= 0.8" } }, - "node_modules/psl": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "license": "MIT", + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "engines": { - "node": ">=6" + "node": ">=8" } }, - "node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", - "license": "BSD-3-Clause", + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", "dependencies": { - "side-channel": "^1.0.6" + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { - "node": ">=0.6" + "node": ">=16 || 14 >=14.18" }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "safe-buffer": "^5.1.0" - } + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" }, - "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "engines": { - "node": ">= 0.6" + "node": ">=8" } }, - "node_modules/raw-body": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", - "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true, + "license": "MIT" }, - "node_modules/react": { - "version": "19.1.0", - "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", - "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", + "node_modules/peek-stream": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/peek-stream/-/peek-stream-1.1.3.tgz", + "integrity": "sha512-FhJ+YbOSBb9/rIl2ZeE/QHEsWn7PqNYt8ARAY3kIgNGOk13g9FGyIY6JIl/xB/3TFRVoTv5as0l11weORrTekA==", "license": "MIT", - "engines": { - "node": ">=0.10.0" + "dependencies": { + "buffer-from": "^1.0.0", + "duplexify": "^3.5.0", + "through2": "^2.0.3" } }, - "node_modules/react-dom": { - "version": "19.1.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", - "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" + }, + "node_modules/periscopic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-4.0.2.tgz", + "integrity": "sha512-sqpQDUy8vgB7ycLkendSKS6HnVz1Rneoc3Rc+ZBUCe2pbqlVuCC5vF52l0NJ1aiMg/r1qfYF9/myz8CZeI2rjA==", + "dev": true, "license": "MIT", "dependencies": { - "scheduler": "^0.26.0" - }, - "peerDependencies": { - "react": "^19.1.0" + "@types/estree": "*", + "is-reference": "^3.0.2", + "zimmerframe": "^1.0.0" } }, - "node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" }, - "node_modules/react-markdown": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz", - "integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==", - "license": "MIT", - "dependencies": { - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "hast-util-to-jsx-runtime": "^2.0.0", - "html-url-attributes": "^3.0.0", - "mdast-util-to-hast": "^13.0.0", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.0.0", - "unified": "^11.0.0", - "unist-util-visit": "^5.0.0", - "vfile": "^6.0.0" + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - }, - "peerDependencies": { - "@types/react": ">=18", - "react": ">=18" + "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/react-markdown/node_modules/@types/hast": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", - "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", + "node_modules/pino": { + "version": "9.13.1", + "resolved": "https://registry.npmjs.org/pino/-/pino-9.13.1.tgz", + "integrity": "sha512-Szuj+ViDTjKPQYiKumGmEn3frdl+ZPSdosHyt9SnUevFosOkMY2b7ipxlEctNKPmMD/VibeBI+ZcZCJK+4DPuw==", + "license": "MIT", "dependencies": { - "@types/unist": "*" + "atomic-sleep": "^1.0.0", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^2.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^5.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "slow-redact": "^0.3.0", + "sonic-boom": "^4.0.1", + "thread-stream": "^3.0.0" + }, + "bin": { + "pino": "bin.js" } }, - "node_modules/react-markdown/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "node_modules/pino-abstract-transport": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz", + "integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==", "license": "MIT", "dependencies": { - "@types/unist": "*" + "split2": "^4.0.0" } }, - "node_modules/react-markdown/node_modules/@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" - }, - "node_modules/react-markdown/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "node_modules/pino-pretty": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.1.1.tgz", + "integrity": "sha512-TNNEOg0eA0u+/WuqH0MH0Xui7uqVk9D74ESOpjtebSQYbNWJk/dIxCXIxFsNfeN53JmtWqYHP2OrIZjT/CBEnA==", + "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0" + "colorette": "^2.0.7", + "dateformat": "^4.6.3", + "fast-copy": "^3.0.2", + "fast-safe-stringify": "^2.1.1", + "help-me": "^5.0.0", + "joycon": "^3.1.1", + "minimist": "^1.2.6", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^2.0.0", + "pump": "^3.0.0", + "secure-json-parse": "^4.0.0", + "sonic-boom": "^4.0.1", + "strip-json-comments": "^5.0.2" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "bin": { + "pino-pretty": "bin.js" } }, - "node_modules/react-markdown/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" + "node_modules/pino-pretty/node_modules/strip-json-comments": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz", + "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==", + "license": "MIT", + "engines": { + "node": ">=14.16" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/react-markdown/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "node_modules/pino-std-serializers": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.0.0.tgz", + "integrity": "sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==", + "license": "MIT" + }, + "node_modules/portfinder": { + "version": "1.0.37", + "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.37.tgz", + "integrity": "sha512-yuGIEjDAYnnOex9ddMnKZEMFE0CcGo6zbfzDklkmT1m5z734ss6JMzN9rNB3+RR7iS+F10D4/BVIaXOyh8PQKw==", + "license": "MIT", + "dependencies": { + "async": "^3.2.6", + "debug": "^4.3.6" + }, + "engines": { + "node": ">= 10.12" } }, - "node_modules/read-cache": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", - "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", - "dev": true, + "node_modules/portfinder/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", "dependencies": { - "pify": "^2.3.0" + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, - "dependencies": { - "picomatch": "^2.2.1" + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=8.10.0" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/reanalyze": { - "version": "2.23.0", - "resolved": "https://registry.npmjs.org/reanalyze/-/reanalyze-2.23.0.tgz", - "integrity": "sha512-5pkH13pX1PrZFkIfmZUjKtYCqzFY2jTaEjBsqyR9SM3HLexAtkHTa4vLHTwuYk167KuO1uwWyEppo8NJIjfkOw==", + "node_modules/proc-log": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", + "integrity": "sha512-++Vn7NS4Xf9NacaU9Xq3URUuqZETPsf8L4j5/ckhaRYsfPeRyzGw+iDjFhV/Jr3uNmTvvddEJFWh5R1gRgUH8A==", "dev": true, - "hasInstallScript": true, - "bin": { - "reanalyze": "reanalyze.exe" + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/recma-build-jsx": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/recma-build-jsx/-/recma-build-jsx-1.0.0.tgz", - "integrity": "sha512-8GtdyqaBcDfva+GUKDr3nev3VpKAhup1+RvkMvUxURHpW7QyIvk9F5wz7Vzo06CEMSilw6uArgRqhpiUcWp8ew==", + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0", - "estree-util-build-jsx": "^3.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">= 0.6.0" } }, - "node_modules/recma-jsx": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/recma-jsx/-/recma-jsx-1.0.0.tgz", - "integrity": "sha512-5vwkv65qWwYxg+Atz95acp8DMu1JDSqdGkA2Of1j6rCreyFUE/gp15fC8MnGEuG1W68UKjM6x6+YTWIh7hZM/Q==", + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, + "node_modules/process-warning": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz", + "integrity": "sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, + "node_modules/promise-inflight": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", + "integrity": "sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/promise-retry": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", + "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", + "dev": true, "license": "MIT", "dependencies": { - "acorn-jsx": "^5.0.0", - "estree-util-to-js": "^2.0.0", - "recma-parse": "^1.0.0", - "recma-stringify": "^1.0.0", - "unified": "^11.0.0" + "err-code": "^2.0.2", + "retry": "^0.12.0" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">=10" } }, - "node_modules/recma-parse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/recma-parse/-/recma-parse-1.0.0.tgz", - "integrity": "sha512-OYLsIGBB5Y5wjnSnQW6t3Xg7q3fQ7FWbw/vcXtORTnyaSFscOtABg+7Pnz6YZ6c27fG1/aN8CjfwoUEUIdwqWQ==", - "license": "MIT", + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", "dependencies": { - "@types/estree": "^1.0.0", - "esast-util-from-js": "^2.0.0", - "unified": "^11.0.0", - "vfile": "^6.0.0" - }, + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/property-information": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.4.0.tgz", + "integrity": "sha512-9t5qARVofg2xQqKtytzt+lZ4d1Qvj8t5B8fEwXK6qOfgRLgH/b13QlgEyDh033NOS31nXeFbYv7CLUDG1CeifQ==", "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/recma-stringify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/recma-stringify/-/recma-stringify-1.0.0.tgz", - "integrity": "sha512-cjwII1MdIIVloKvC9ErQ+OgAtwHBmcZ0Bg4ciz78FtbT8In39aAYbaA7zvxQ61xVMSPE8WxhLwLbhif4Js2C+g==", - "license": "MIT", + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", "dependencies": { - "@types/estree": "^1.0.0", - "estree-util-to-js": "^2.0.0", - "unified": "^11.0.0", - "vfile": "^6.0.0" + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">= 0.10" } }, - "node_modules/regenerator-runtime": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", - "license": "MIT" + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" }, - "node_modules/regexp.prototype.flags": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", - "integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==", + "node_modules/pump": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz", + "integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==", + "license": "MIT", "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "functions-have-names": "^1.2.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } }, - "node_modules/rehype-recma": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/rehype-recma/-/rehype-recma-1.0.0.tgz", - "integrity": "sha512-lqA4rGUf1JmacCNWWZx0Wv1dHqMwxzsDWYMTowuplHF3xH0N/MmrZ/G3BDZnzAkRmxDadujCjaKM2hqYdCBOGw==", + "node_modules/pumpify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-2.0.1.tgz", + "integrity": "sha512-m7KOje7jZxrmutanlkS1daj1dS6z6BgslzOXmcSEpIlCxM3VJH7lG5QLeck/6hgF6F4crFf01UtQmNsJfweTAw==", "license": "MIT", "dependencies": { - "@types/estree": "^1.0.0", - "@types/hast": "^3.0.0", - "hast-util-to-estree": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "duplexify": "^4.1.1", + "inherits": "^2.0.3", + "pump": "^3.0.0" } }, - "node_modules/rehype-recma/node_modules/@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "node_modules/pumpify/node_modules/duplexify": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz", + "integrity": "sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==", "license": "MIT", "dependencies": { - "@types/unist": "*" + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.2" } }, - "node_modules/rehype-slug": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/rehype-slug/-/rehype-slug-6.0.0.tgz", - "integrity": "sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==", + "node_modules/pumpify/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "license": "MIT", "dependencies": { - "@types/hast": "^3.0.0", - "github-slugger": "^2.0.0", - "hast-util-heading-rank": "^3.0.0", - "hast-util-to-string": "^3.0.0", - "unist-util-visit": "^5.0.0" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">= 6" } }, - "node_modules/rehype-slug/node_modules/@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "license": "BSD-3-Clause", "dependencies": { - "@types/unist": "*" + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/rehype-slug/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", "license": "MIT" }, - "node_modules/rehype-slug/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "node_modules/random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==", "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { - "@types/unist": "^3.0.0" + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">= 0.8" } }, - "node_modules/rehype-slug/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "node_modules/react": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", + "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">=0.10.0" } }, - "node_modules/rehype-slug/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "node_modules/react-dom": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", + "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", "license": "MIT", "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" + "scheduler": "^0.26.0" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "peerDependencies": { + "react": "^19.1.0" } }, - "node_modules/rehype-stringify": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-10.0.1.tgz", - "integrity": "sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==", + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + }, + "node_modules/react-markdown": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz", + "integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==", "license": "MIT", "dependencies": { "@types/hast": "^3.0.0", - "hast-util-to-html": "^9.0.0", - "unified": "^11.0.0" + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "hast-util-to-jsx-runtime": "^2.0.0", + "html-url-attributes": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.0.0", + "unified": "^11.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" + }, + "peerDependencies": { + "@types/react": ">=18", + "react": ">=18" } }, - "node_modules/rehype-stringify/node_modules/@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", - "license": "MIT", + "node_modules/react-markdown/node_modules/@types/hast": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", + "integrity": "sha512-2fYGlaDy/qyLlhidX42wAH0KBi2TCjKMH8CHmBXgRlJ3Y+OXTiqsPQ6IWarZKwF1JoUcAJdPogv1d4b0COTpmQ==", "dependencies": { "@types/unist": "*" } }, - "node_modules/remark-comment": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/remark-comment/-/remark-comment-1.0.0.tgz", - "integrity": "sha512-k8YPo5MGvl8l4gGxOH6Zk4Fa2AhDACN5eqKnKZcHDORZQS15hlnezlBHj2lqyDiqzApNmYOMTibkEJbMSKU25w==", - "dependencies": { - "micromark-factory-space": "^1.0.0", - "micromark-util-character": "^1.1.0", - "micromark-util-symbol": "^1.0.1" - } + "node_modules/react-markdown/node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "node_modules/remark-frontmatter": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/remark-frontmatter/-/remark-frontmatter-5.0.0.tgz", - "integrity": "sha512-XTFYvNASMe5iPN0719nPrdItC9aU0ssC4v14mH1BCi1u0n1gAocqcujWUrByftZTbLhRtiKRyjYTSIOcr69UVQ==", + "node_modules/react-refresh": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz", + "integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==", + "dev": true, "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-frontmatter": "^2.0.0", - "micromark-extension-frontmatter": "^2.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">=0.10.0" } }, - "node_modules/remark-frontmatter/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", + "node_modules/react-router": { + "version": "7.9.3", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.9.3.tgz", + "integrity": "sha512-4o2iWCFIwhI/eYAIL43+cjORXYn/aRQPgtFRRZb3VzoyQ5Uej0Bmqj7437L97N9NJW4wnicSwLOLS+yCXfAPgg==", "dependencies": { - "@types/unist": "*" + "cookie": "^1.0.1", + "set-cookie-parser": "^2.6.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } } }, - "node_modules/remark-gfm": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz", - "integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==", + "node_modules/react-router-dom": { + "version": "7.9.3", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.9.3.tgz", + "integrity": "sha512-1QSbA0TGGFKTAc/aWjpfW/zoEukYfU4dc1dLkT/vvf54JoGMkW+fNA+3oyo2gWVW1GM7BxjJVHz5GnPJv40rvg==", "license": "MIT", "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-gfm": "^3.0.0", - "micromark-extension-gfm": "^3.0.0", - "remark-parse": "^11.0.0", - "remark-stringify": "^11.0.0", - "unified": "^11.0.0" + "react-router": "7.9.3" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" } }, - "node_modules/remark-gfm/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", + "node_modules/react-router-mdx": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/react-router-mdx/-/react-router-mdx-1.0.8.tgz", + "integrity": "sha512-idaBLd/GIWqEdsktNSli339KvznEdqAXN18QAkIVzCXBbGvTtbgDVTNgfvG4HinfHsTPzorw0h2RnL/2ozO34g==", + "license": "ISC", "dependencies": { - "@types/unist": "*" + "@mdx-js/mdx": "^3.1.0", + "@mdx-js/react": "^3.1.0", + "glob": "^11.0.2", + "gray-matter": "^4.0.3", + "remark-frontmatter": "^5.0.0", + "slash": "^5.1.0" + }, + "peerDependencies": { + "@react-router/dev": "^7.6.2", + "react": "^19.1.0", + "react-router": "^7.0.0" } }, - "node_modules/remark-mdx": { + "node_modules/react-router-mdx/node_modules/@mdx-js/react": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-3.1.0.tgz", - "integrity": "sha512-Ngl/H3YXyBV9RcRNdlYsZujAmhsxwzxpDzpDEhFBVAGthS4GDgnctpDjgFl/ULx5UEDzqtW1cyBSNKqYYrqLBA==", + "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-3.1.0.tgz", + "integrity": "sha512-QjHtSaoameoalGnKDT3FoIl4+9RwyTmo9ZJGBdLOks/YOiWHoRDI3PUwEzOE7kEmGcV3AFcp9K6dYu9rEuKLAQ==", "license": "MIT", "dependencies": { - "mdast-util-mdx": "^3.0.0", - "micromark-extension-mdxjs": "^3.0.0" + "@types/mdx": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" + }, + "peerDependencies": { + "@types/react": ">=16", + "react": ">=16" } }, - "node_modules/remark-mdx-frontmatter": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/remark-mdx-frontmatter/-/remark-mdx-frontmatter-5.0.0.tgz", - "integrity": "sha512-kI75pshe27TM71R+0iX7C3p4MbGMdygkvSbrk1WYSar88WAwR2JfQilofcDGgDNFAWUo5IwTPyq9XvGpifTwqQ==", - "license": "MIT", + "node_modules/react-router-mdx/node_modules/glob": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "license": "ISC", "dependencies": { - "@types/mdast": "^4.0.0", - "estree-util-is-identifier-name": "^3.0.0", - "estree-util-value-to-estree": "^3.0.0", - "toml": "^3.0.0", - "unified": "^11.0.0", - "yaml": "^2.0.0" + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" }, "funding": { - "url": "https://github.com/sponsors/remcohaszing" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/remark-mdx-frontmatter/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", + "node_modules/react-router-mdx/node_modules/jackspeak": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", + "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", + "license": "BlueOak-1.0.0", "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/remark-mdx-frontmatter/node_modules/estree-util-is-identifier-name": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz", - "integrity": "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-mdx-frontmatter/node_modules/yaml": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", - "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", + "@isaacs/cliui": "^8.0.2" + }, "engines": { - "node": ">= 14" - } - }, - "node_modules/remark-parse": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz", - "integrity": "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-from-markdown": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unified": "^11.0.0" + "node": "20 || >=22" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/remark-parse/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" + "node_modules/react-router-mdx/node_modules/lru-cache": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.1.0.tgz", + "integrity": "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==", + "license": "ISC", + "engines": { + "node": "20 || >=22" } }, - "node_modules/remark-parse/node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", - "license": "MIT" - }, - "node_modules/remark-parse/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", + "node_modules/react-router-mdx/node_modules/minimatch": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", + "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", + "license": "ISC", "dependencies": { - "ms": "^2.1.3" + "@isaacs/brace-expansion": "^5.0.0" }, "engines": { - "node": ">=6.0" + "node": "20 || >=22" }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/remark-parse/node_modules/mdast-util-from-markdown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", - "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/react-router-mdx/node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/remark-parse/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "node_modules/react-router-mdx/node_modules/slash": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", + "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0" + "engines": { + "node": ">=14.16" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/remark-parse/node_modules/micromark": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", - "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/react-router/node_modules/cookie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", + "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", "license": "MIT", - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "engines": { + "node": ">=18" } }, - "node_modules/remark-parse/node_modules/micromark-core-commonmark": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", - "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", "license": "MIT", "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, - "node_modules/remark-parse/node_modules/micromark-factory-destination": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", - "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/readable-stream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/real-require": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", + "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "engines": { + "node": ">= 12.13.0" } }, - "node_modules/remark-parse/node_modules/micromark-factory-label": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", - "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/reanalyze": { + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/reanalyze/-/reanalyze-2.23.0.tgz", + "integrity": "sha512-5pkH13pX1PrZFkIfmZUjKtYCqzFY2jTaEjBsqyR9SM3HLexAtkHTa4vLHTwuYk167KuO1uwWyEppo8NJIjfkOw==", + "dev": true, + "hasInstallScript": true, + "bin": { + "reanalyze": "reanalyze.exe" + } + }, + "node_modules/recma-build-jsx": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/recma-build-jsx/-/recma-build-jsx-1.0.0.tgz", + "integrity": "sha512-8GtdyqaBcDfva+GUKDr3nev3VpKAhup1+RvkMvUxURHpW7QyIvk9F5wz7Vzo06CEMSilw6uArgRqhpiUcWp8ew==", "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/estree": "^1.0.0", + "estree-util-build-jsx": "^3.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-factory-space": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", - "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/recma-jsx": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/recma-jsx/-/recma-jsx-1.0.0.tgz", + "integrity": "sha512-5vwkv65qWwYxg+Atz95acp8DMu1JDSqdGkA2Of1j6rCreyFUE/gp15fC8MnGEuG1W68UKjM6x6+YTWIh7hZM/Q==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" + "acorn-jsx": "^5.0.0", + "estree-util-to-js": "^2.0.0", + "recma-parse": "^1.0.0", + "recma-stringify": "^1.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-factory-title": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", - "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/recma-parse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/recma-parse/-/recma-parse-1.0.0.tgz", + "integrity": "sha512-OYLsIGBB5Y5wjnSnQW6t3Xg7q3fQ7FWbw/vcXtORTnyaSFscOtABg+7Pnz6YZ6c27fG1/aN8CjfwoUEUIdwqWQ==", "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/estree": "^1.0.0", + "esast-util-from-js": "^2.0.0", + "unified": "^11.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-factory-whitespace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", - "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/recma-stringify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/recma-stringify/-/recma-stringify-1.0.0.tgz", + "integrity": "sha512-cjwII1MdIIVloKvC9ErQ+OgAtwHBmcZ0Bg4ciz78FtbT8In39aAYbaA7zvxQ61xVMSPE8WxhLwLbhif4Js2C+g==", "license": "MIT", "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/estree": "^1.0.0", + "estree-util-to-js": "^2.0.0", + "unified": "^11.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "license": "MIT" + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", + "integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==", + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "functions-have-names": "^1.2.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/remark-parse/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/rehype-recma": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/rehype-recma/-/rehype-recma-1.0.0.tgz", + "integrity": "sha512-lqA4rGUf1JmacCNWWZx0Wv1dHqMwxzsDWYMTowuplHF3xH0N/MmrZ/G3BDZnzAkRmxDadujCjaKM2hqYdCBOGw==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/estree": "^1.0.0", + "@types/hast": "^3.0.0", + "hast-util-to-estree": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-util-chunked": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", - "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/rehype-recma/node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "@types/unist": "*" } }, - "node_modules/remark-parse/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/rehype-slug": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/rehype-slug/-/rehype-slug-6.0.0.tgz", + "integrity": "sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/hast": "^3.0.0", + "github-slugger": "^2.0.0", + "hast-util-heading-rank": "^3.0.0", + "hast-util-to-string": "^3.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-util-combine-extensions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", - "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/rehype-slug/node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", "license": "MIT", "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/unist": "*" } }, - "node_modules/remark-parse/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/rehype-slug/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/rehype-stringify": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-10.0.1.tgz", + "integrity": "sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "@types/hast": "^3.0.0", + "hast-util-to-html": "^9.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-util-decode-string": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/rehype-stringify/node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", "license": "MIT", "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" + "@types/unist": "*" } }, - "node_modules/remark-parse/node_modules/micromark-util-encode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/remark-parse/node_modules/micromark-util-html-tag-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", - "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" + "node_modules/remark-comment": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/remark-comment/-/remark-comment-1.0.0.tgz", + "integrity": "sha512-k8YPo5MGvl8l4gGxOH6Zk4Fa2AhDACN5eqKnKZcHDORZQS15hlnezlBHj2lqyDiqzApNmYOMTibkEJbMSKU25w==", + "dependencies": { + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.1.0", + "micromark-util-symbol": "^1.0.1" + } }, - "node_modules/remark-parse/node_modules/micromark-util-normalize-identifier": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", - "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/remark-frontmatter": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/remark-frontmatter/-/remark-frontmatter-5.0.0.tgz", + "integrity": "sha512-XTFYvNASMe5iPN0719nPrdItC9aU0ssC4v14mH1BCi1u0n1gAocqcujWUrByftZTbLhRtiKRyjYTSIOcr69UVQ==", "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0" + "@types/mdast": "^4.0.0", + "mdast-util-frontmatter": "^2.0.0", + "micromark-extension-frontmatter": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-util-resolve-all": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", - "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/remark-gfm": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz", + "integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==", "license": "MIT", "dependencies": { - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "mdast-util-gfm": "^3.0.0", + "micromark-extension-gfm": "^3.0.0", + "remark-parse": "^11.0.0", + "remark-stringify": "^11.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-util-sanitize-uri": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/remark-mdx": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-3.1.0.tgz", + "integrity": "sha512-Ngl/H3YXyBV9RcRNdlYsZujAmhsxwzxpDzpDEhFBVAGthS4GDgnctpDjgFl/ULx5UEDzqtW1cyBSNKqYYrqLBA==", "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" + "mdast-util-mdx": "^3.0.0", + "micromark-extension-mdxjs": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-util-subtokenize": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", - "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], + "node_modules/remark-parse": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz", + "integrity": "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==", "license": "MIT", "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/remark-parse/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, "node_modules/remark-parse/node_modules/micromark-util-types": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", @@ -18725,14 +13142,6 @@ "@types/unist": "*" } }, - "node_modules/remark-rehype/node_modules/@types/mdast": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", - "integrity": "sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==", - "dependencies": { - "@types/unist": "*" - } - }, "node_modules/remark-rehype/node_modules/@types/unist": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", @@ -18753,15 +13162,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-stringify/node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "license": "MIT", - "dependencies": { - "@types/unist": "*" - } - }, "node_modules/remark-stringify/node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", @@ -18803,175 +13203,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-stringify/node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "license": "MIT", - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-stringify/node_modules/micromark-util-character": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/remark-stringify/node_modules/micromark-util-classify-character": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", - "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/remark-stringify/node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", - "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/remark-stringify/node_modules/micromark-util-decode-string": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", - "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT", - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/remark-stringify/node_modules/micromark-util-symbol": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/remark-stringify/node_modules/micromark-util-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" - }, - "node_modules/remark-stringify/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-stringify/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-stringify/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -19011,33 +13242,22 @@ "node": ">=0.6" } }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "devOptional": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } }, "node_modules/rescript": { - "version": "12.0.0-beta.6", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-12.0.0-beta.6.tgz", - "integrity": "sha512-y6xc09gIP/YRNNKvOgOACE+H1mE/MbP6GlIvjMol/U7rQ2VQWYWkxFs+UsAUdcHaHkPaY/ZyusL7EFGFIuO92A==", + "version": "12.0.0-beta.13", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-12.0.0-beta.13.tgz", + "integrity": "sha512-il1KAB0PVEs3y/IiE6CnxFUMakv5VXTXT60wGVcGjNaY4Gj5d1G1uePWCc7UtpjRwYjF9OQFMyN/MzLkRuo6CA==", "license": "SEE LICENSE IN LICENSE", "workspaces": [ - "packages/*", + "packages/playground", "packages/@rescript/*", "tests/dependencies/**", "tests/analysis_tests/**", @@ -19046,6 +13266,9 @@ "tests/tools_tests", "scripts/res" ], + "dependencies": { + "@rescript/runtime": "12.0.0-beta.13" + }, "bin": { "bsc": "cli/bsc.js", "bstracing": "cli/bstracing.js", @@ -19057,11 +13280,11 @@ "node": ">=20.11.0" }, "optionalDependencies": { - "@rescript/darwin-arm64": "12.0.0-beta.6", - "@rescript/darwin-x64": "12.0.0-beta.6", - "@rescript/linux-arm64": "12.0.0-beta.6", - "@rescript/linux-x64": "12.0.0-beta.6", - "@rescript/win32-x64": "12.0.0-beta.6" + "@rescript/darwin-arm64": "12.0.0-beta.13", + "@rescript/darwin-x64": "12.0.0-beta.13", + "@rescript/linux-arm64": "12.0.0-beta.13", + "@rescript/linux-x64": "12.0.0-beta.13", + "@rescript/win32-x64": "12.0.0-beta.13" } }, "node_modules/resolve": { @@ -19084,16 +13307,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=4" - } - }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", @@ -19102,6 +13315,16 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, + "node_modules/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -19111,21 +13334,65 @@ "node": ">=0.10.0" } }, - "node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "license": "ISC", - "peer": true, + "node_modules/rfdc": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", + "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", + "license": "MIT" + }, + "node_modules/rollup": { + "version": "4.46.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.46.2.tgz", + "integrity": "sha512-WMmLFI+Boh6xbop+OAGo9cQ3OgX9MIg7xOQjn+pTCwOkk+FNDAeAemXkJ3HzDJrVXleLOFVa1ipuc1AmEx1Dwg==", + "dev": true, + "license": "MIT", "dependencies": { - "glob": "^7.1.3" + "@types/estree": "1.0.8" }, "bin": { - "rimraf": "bin.js" + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.46.2", + "@rollup/rollup-android-arm64": "4.46.2", + "@rollup/rollup-darwin-arm64": "4.46.2", + "@rollup/rollup-darwin-x64": "4.46.2", + "@rollup/rollup-freebsd-arm64": "4.46.2", + "@rollup/rollup-freebsd-x64": "4.46.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.46.2", + "@rollup/rollup-linux-arm-musleabihf": "4.46.2", + "@rollup/rollup-linux-arm64-gnu": "4.46.2", + "@rollup/rollup-linux-arm64-musl": "4.46.2", + "@rollup/rollup-linux-loongarch64-gnu": "4.46.2", + "@rollup/rollup-linux-ppc64-gnu": "4.46.2", + "@rollup/rollup-linux-riscv64-gnu": "4.46.2", + "@rollup/rollup-linux-riscv64-musl": "4.46.2", + "@rollup/rollup-linux-s390x-gnu": "4.46.2", + "@rollup/rollup-linux-x64-gnu": "4.46.2", + "@rollup/rollup-linux-x64-musl": "4.46.2", + "@rollup/rollup-win32-arm64-msvc": "4.46.2", + "@rollup/rollup-win32-ia32-msvc": "4.46.2", + "@rollup/rollup-win32-x64-msvc": "4.46.2", + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup/node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, "node_modules/rrweb-cssom": { @@ -19302,6 +13569,43 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-regex2": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-5.0.0.tgz", + "integrity": "sha512-YwJwe5a51WlK7KbOJREPdjNrpViQBI3p4T50lfwPuDhZnE3XGVTlGvi+aolc5+RvxDD6bnUmjVsU9n1eboLUYw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "ret": "~0.5.0" + } + }, + "node_modules/safe-regex2/node_modules/ret": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.5.0.tgz", + "integrity": "sha512-I1XxrZSQ+oErkRR4jYbAyEEu2I0avBvvMM5JN+6EBprOGRCs63ENqZ3vjavq8fBw2+62G5LF5XelKwuJpcvcxw==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -19326,33 +13630,34 @@ "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==", "license": "MIT" }, - "node_modules/schema-utils": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.3.2.tgz", - "integrity": "sha512-Gn/JaSk/Mt9gYubxTtSn/QCV4em9mpAPiR1rqy/Ocu19u/G9J5WWdNoUT4SiV6mFC3y6cxyFcFwdzPM3FgxGAQ==", - "devOptional": true, + "node_modules/section-matter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz", + "integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==", "license": "MIT", - "peer": true, "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" + "extend-shallow": "^2.0.1", + "kind-of": "^6.0.0" }, "engines": { - "node": ">= 10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" + "node": ">=4" } }, - "node_modules/search-insights": { - "version": "2.17.3", - "resolved": "https://registry.npmjs.org/search-insights/-/search-insights-2.17.3.tgz", - "integrity": "sha512-RQPdCYTa8A68uM2jwxoY842xDhvx3E5LFL1LxvxCNMev4o5mLuokczhzjAgGwUZBAmOKZknArSxLKmXtIi2AxQ==", - "license": "MIT", - "peer": true + "node_modules/secure-json-parse": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-4.0.0.tgz", + "integrity": "sha512-dxtLJO6sc35jWidmLxo7ij+Eg48PM/kleBsxpC8QJE0qJICe+KawkDQmvCMZUr9u7WKVHgMW6vy3fQ7zMiFZMA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" }, "node_modules/semver": { "version": "7.7.2", @@ -19402,17 +13707,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "devOptional": true, - "license": "BSD-3-Clause", - "peer": true, - "dependencies": { - "randombytes": "^2.1.0" - } - }, "node_modules/serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", @@ -19507,6 +13801,12 @@ "node": ">= 0.8" } }, + "node_modules/set-cookie-parser": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz", + "integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==", + "license": "MIT" + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -19528,49 +13828,6 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, - "node_modules/sharp": { - "version": "0.34.3", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.3.tgz", - "integrity": "sha512-eX2IQ6nFohW4DbvHIOLRB3MHFpYqaqvXd3Tp5e/T/dSH83fxaNJQRvDMhASmkNTsNTVF2/OOopzRCt7xokgPfg==", - "hasInstallScript": true, - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "color": "^4.2.3", - "detect-libc": "^2.0.4", - "semver": "^7.7.2" - }, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-darwin-arm64": "0.34.3", - "@img/sharp-darwin-x64": "0.34.3", - "@img/sharp-libvips-darwin-arm64": "1.2.0", - "@img/sharp-libvips-darwin-x64": "1.2.0", - "@img/sharp-libvips-linux-arm": "1.2.0", - "@img/sharp-libvips-linux-arm64": "1.2.0", - "@img/sharp-libvips-linux-ppc64": "1.2.0", - "@img/sharp-libvips-linux-s390x": "1.2.0", - "@img/sharp-libvips-linux-x64": "1.2.0", - "@img/sharp-libvips-linuxmusl-arm64": "1.2.0", - "@img/sharp-libvips-linuxmusl-x64": "1.2.0", - "@img/sharp-linux-arm": "0.34.3", - "@img/sharp-linux-arm64": "0.34.3", - "@img/sharp-linux-ppc64": "0.34.3", - "@img/sharp-linux-s390x": "0.34.3", - "@img/sharp-linux-x64": "0.34.3", - "@img/sharp-linuxmusl-arm64": "0.34.3", - "@img/sharp-linuxmusl-x64": "0.34.3", - "@img/sharp-wasm32": "0.34.3", - "@img/sharp-win32-arm64": "0.34.3", - "@img/sharp-win32-ia32": "0.34.3", - "@img/sharp-win32-x64": "0.34.3" - } - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -19612,25 +13869,6 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, - "node_modules/simple-functional-loader": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/simple-functional-loader/-/simple-functional-loader-1.2.1.tgz", - "integrity": "sha512-GPDrxrQkE7ijm35QlfPFVp5hBHR6ZcaUq42TEDgf1U5iTL3IDLFvKAbHE/ODqpdfJJ7Xn4cr/slBn12jjNPkaQ==", - "dev": true, - "dependencies": { - "loader-utils": "^2.0.0" - } - }, - "node_modules/simple-swizzle": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", - "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", - "license": "MIT", - "optional": true, - "dependencies": { - "is-arrayish": "^0.3.1" - } - }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -19639,11 +13877,20 @@ "node": ">=8" } }, - "node_modules/source-list-map": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", - "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==", - "dev": true + "node_modules/slow-redact": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/slow-redact/-/slow-redact-0.3.1.tgz", + "integrity": "sha512-NvFvl1GuLZNW4U046Tfi8b26zXo8aBzgCAS2f7yVJR/fArN93mOqSA99cB9uITm92ajSz01bsu1K7SCVVjIMpQ==", + "license": "MIT" + }, + "node_modules/sonic-boom": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.0.tgz", + "integrity": "sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } }, "node_modules/source-map": { "version": "0.7.4", @@ -19657,34 +13904,12 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "devOptional": true, - "license": "MIT", - "peer": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/source-map-support/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "devOptional": true, - "license": "BSD-3-Clause", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/space-separated-tokens": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", @@ -19694,6 +13919,57 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "dev": true, + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.21", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.21.tgz", + "integrity": "sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "license": "BSD-3-Clause" + }, "node_modules/sshpk": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", @@ -19726,11 +14002,43 @@ "node": ">= 0.8" } }, + "node_modules/stdin-discarder": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.2.2.tgz", + "integrity": "sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/stream-shift": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", + "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", + "license": "MIT" + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -19740,11 +14048,31 @@ "node": ">=8" } }, - "node_modules/string-width/node_modules/emoji-regex": { + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "license": "MIT" + }, + "node_modules/string-width/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/string.prototype.matchall": { "version": "4.0.8", @@ -19843,6 +14171,19 @@ "node": ">=8" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -19851,6 +14192,15 @@ "node": ">=4" } }, + "node_modules/strip-bom-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", + "integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -19862,19 +14212,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/style-to-js": { "version": "1.1.16", "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.16.tgz", @@ -19899,56 +14236,6 @@ "inline-style-parser": "0.2.4" } }, - "node_modules/styled-jsx": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz", - "integrity": "sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==", - "license": "MIT", - "dependencies": { - "client-only": "0.0.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "peerDependencies": { - "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "babel-plugin-macros": { - "optional": true - } - } - }, - "node_modules/stylehacks": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-6.0.0.tgz", - "integrity": "sha512-+UT589qhHPwz6mTlCLSt/vMNTJx8dopeJlZAlBMJPWA3ORqu6wmQY7FBXf+qD+FsqoBJODyqNxOUP3jdntFRdw==", - "dev": true, - "dependencies": { - "browserslist": "^4.21.4", - "postcss-selector-parser": "^6.0.4" - }, - "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -19960,39 +14247,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/svgo": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-3.0.2.tgz", - "integrity": "sha512-Z706C1U2pb1+JGP48fbazf3KxHrWOsLme6Rv7imFBn5EnuanDW1GPaA/P1/dvObE670JDePC3mnj0k0B7P0jjQ==", - "dev": true, - "dependencies": { - "@trysound/sax": "0.2.0", - "commander": "^7.2.0", - "css-select": "^5.1.0", - "css-tree": "^2.2.1", - "csso": "^5.0.5", - "picocolors": "^1.0.0" - }, - "bin": { - "svgo": "bin/svgo" - }, - "engines": { - "node": ">=14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/svgo" - } - }, - "node_modules/svgo/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true, - "engines": { - "node": ">= 10" - } - }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -20054,74 +14308,79 @@ "node": ">=18" } }, - "node_modules/terser": { - "version": "5.43.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.43.1.tgz", - "integrity": "sha512-+6erLbBm0+LROX2sPXlUYx/ux5PyE9K/a92Wrt6oA+WDAoFTdpHE5tCYCI5PNzq2y8df4rA+QgHLJuR4jNymsg==", - "devOptional": true, - "license": "BSD-2-Clause", - "peer": true, + "node_modules/tar/node_modules/yallist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", + "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/thread-stream": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz", + "integrity": "sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==", + "license": "MIT", "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.14.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" + "real-require": "^0.2.0" + } + }, + "node_modules/through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "license": "MIT", + "dependencies": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" } }, - "node_modules/terser-webpack-plugin": { - "version": "5.3.14", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.14.tgz", - "integrity": "sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw==", - "devOptional": true, + "node_modules/tinyglobby": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", + "integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==", + "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@jridgewell/trace-mapping": "^0.3.25", - "jest-worker": "^27.4.5", - "schema-utils": "^4.3.0", - "serialize-javascript": "^6.0.2", - "terser": "^5.31.1" + "fdir": "^6.4.4", + "picomatch": "^4.0.2" }, "engines": { - "node": ">= 10.13.0" + "node": ">=12.0.0" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.4.6", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", + "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "dev": true, + "license": "MIT", "peerDependencies": { - "webpack": "^5.1.0" + "picomatch": "^3 || ^4" }, "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "esbuild": { - "optional": true - }, - "uglify-js": { + "picomatch": { "optional": true } } }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, "license": "MIT", - "peer": true - }, - "node_modules/thenby": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/thenby/-/thenby-1.3.4.tgz", - "integrity": "sha512-89Gi5raiWA3QZ4b2ePcEwswC3me9JIg+ToSgtE0JWeCynLnLxNr/f9G+xfo9K+Oj4AFdom8YNJjibIARTJmapQ==", - "dev": true + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, "node_modules/titleize": { "version": "3.0.0", @@ -20154,14 +14413,6 @@ "dev": true, "license": "MIT" }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -20173,6 +14424,15 @@ "node": ">=8.0" } }, + "node_modules/toad-cache": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.7.0.tgz", + "integrity": "sha512-/m8M+2BJUpoJdgAHoG+baCwBT+tf2VraSfkBgl0Y00qIWt41DJ8R5B8nsEw0I58YwF5IZH6z24/2TobDKnqSWw==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -20181,11 +14441,6 @@ "node": ">=0.6" } }, - "node_modules/toml": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", - "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" - }, "node_modules/tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", @@ -20295,37 +14550,18 @@ "node": "*" } }, + "node_modules/turbo-stream": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/turbo-stream/-/turbo-stream-3.1.0.tgz", + "integrity": "sha512-tVI25WEXl4fckNEmrq70xU1XumxUwEx/FZD5AgEcV8ri7Wvrg2o7GEq8U7htrNx3CajciGm+kDyhRf5JB6t7/A==", + "dev": true, + "license": "MIT" + }, "node_modules/tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "license": "MIT", - "peer": true, - "dependencies": { - "prelude-ls": "^1.2.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "license": "(MIT OR CC0-1.0)", - "peer": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -20399,20 +14635,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/typescript": { - "version": "5.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", - "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "license": "Apache-2.0", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/uglify-js": { "version": "3.17.4", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", @@ -20425,6 +14647,18 @@ "node": ">=0.8.0" } }, + "node_modules/uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "license": "MIT", + "dependencies": { + "random-bytes": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -20439,14 +14673,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/undici-types": { - "version": "7.8.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz", - "integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==", - "devOptional": true, - "license": "MIT", - "peer": true - }, "node_modules/unified": { "version": "11.0.5", "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", @@ -20473,18 +14699,24 @@ "license": "MIT" }, "node_modules/unist-util-is": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.2.1.tgz", - "integrity": "sha512-u9njyyfEh43npf1M+yGKDGVPbY/JWEemg5nH05ncKPfi+kBbKBJoTdsogMu33uhytuLlv9y0O7GH7fEdwLdLQw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", + "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", "license": "MIT", "dependencies": { - "@types/unist": "^2.0.0" + "@types/unist": "^3.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, + "node_modules/unist-util-is/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, "node_modules/unist-util-position": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", @@ -20521,21 +14753,6 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "node_modules/unist-util-remove": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/unist-util-remove/-/unist-util-remove-3.1.1.tgz", - "integrity": "sha512-kfCqZK5YVY5yEa89tvpl7KnBBHu2c6CzMkqHUrlOqaRgGOMp0sMvwWOVrbAtj03KhovQB7i96Gda72v/EFE0vw==", - "license": "MIT", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/unist-util-remove-position": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-5.0.0.tgz", @@ -20554,10 +14771,11 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "node_modules/unist-util-remove-position/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "license": "MIT", "dependencies": { "@types/unist": "^3.0.0" }, @@ -20566,10 +14784,17 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/unist-util-remove-position/node_modules/unist-util-visit": { + "node_modules/unist-util-stringify-position/node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/unist-util-visit": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "license": "MIT", "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0", @@ -20580,46 +14805,20 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/unist-util-remove-position/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-stringify-position": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", - "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", - "license": "MIT", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-stringify-position/node_modules/@types/unist": { + "node_modules/unist-util-visit/node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "license": "MIT" }, - "node_modules/unist-util-visit-parents": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.1.3.tgz", - "integrity": "sha512-x6+y8g7wWMyQhL1iZfhIPhDAs7Xwbn9nRosDXl7qoPTSCy0yNxnKc+hWokFifWQIDGi154rdUqKvbCa4+1kLhg==", + "node_modules/unist-util-visit/node_modules/unist-util-visit-parents": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", + "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", "license": "MIT", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" }, "funding": { "type": "opencollective", @@ -20627,10 +14826,10 @@ } }, "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "license": "MIT", "engines": { "node": ">= 10.0.0" } @@ -20655,7 +14854,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==", - "devOptional": true, + "dev": true, "funding": [ { "type": "opencollective", @@ -20686,7 +14885,6 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" } @@ -20708,8 +14906,7 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/utils-merge": { "version": "1.0.1", @@ -20728,6 +14925,42 @@ "uuid": "bin/uuid" } }, + "node_modules/valibot": { + "version": "0.41.0", + "resolved": "https://registry.npmjs.org/valibot/-/valibot-0.41.0.tgz", + "integrity": "sha512-igDBb8CTYr8YTQlOKgaN9nSS0Be7z+WRuaeYqGf3Cjz3aKmSnqEmYnkfVjzIuumGqfHpa3fLIvMEAfhrpqN8ng==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "typescript": ">=5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "node_modules/validate-npm-package-name": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.1.tgz", + "integrity": "sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -20777,18 +15010,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/vfile-matter/node_modules/yaml": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz", - "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", - "license": "ISC", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/vfile-message": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz", @@ -20815,122 +15036,242 @@ "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "license": "MIT" }, - "node_modules/w3c-xmlserializer": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", - "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "node_modules/vite": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.0.6.tgz", + "integrity": "sha512-MHFiOENNBd+Bd9uvc8GEsIzdkn1JxMmEeYX35tI3fv0sJBUTfW5tQsoaOwuY4KhBI09A3dUJ/DXf2yxPVPUceg==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.6", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.40.0", + "tinyglobby": "^0.2.14" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.4.1", + "es-module-lexer": "^1.7.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vite-node/node_modules/debug": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dev": true, "license": "MIT", "dependencies": { - "xml-name-validator": "^5.0.0" + "ms": "^2.1.3" }, "engines": { - "node": ">=18" + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/watchpack": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.4.tgz", - "integrity": "sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==", - "devOptional": true, + "node_modules/vite-node/node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/vite/node_modules/fdir": { + "version": "6.4.6", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", + "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "dev": true, "license": "MIT", - "peer": true, - "dependencies": { - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.1.2" + "peerDependencies": { + "picomatch": "^3 || ^4" }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], "engines": { - "node": ">=10.13.0" + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/webidl-conversions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", - "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, - "license": "BSD-2-Clause", + "license": "MIT", "engines": { "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/webpack": { - "version": "5.100.2", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.100.2.tgz", - "integrity": "sha512-QaNKAvGCDRh3wW1dsDjeMdDXwZm2vqq3zn6Pvq4rHOEOGSaUMgOOjG2Y9ZbIGzpfkJk9ZYTHpDqgDfeBDcnLaw==", - "devOptional": true, + "node_modules/vite/node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "license": "MIT", - "peer": true, "dependencies": { - "@types/eslint-scope": "^3.7.7", - "@types/estree": "^1.0.8", - "@types/json-schema": "^7.0.15", - "@webassemblyjs/ast": "^1.14.1", - "@webassemblyjs/wasm-edit": "^1.14.1", - "@webassemblyjs/wasm-parser": "^1.14.1", - "acorn": "^8.15.0", - "acorn-import-phases": "^1.0.3", - "browserslist": "^4.24.0", - "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.17.2", - "es-module-lexer": "^1.2.1", - "eslint-scope": "5.1.1", - "events": "^3.2.0", - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.2.11", - "json-parse-even-better-errors": "^2.3.1", - "loader-runner": "^4.2.0", - "mime-types": "^2.1.27", - "neo-async": "^2.6.2", - "schema-utils": "^4.3.2", - "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.3.11", - "watchpack": "^2.4.1", - "webpack-sources": "^3.3.3" - }, - "bin": { - "webpack": "bin/webpack.js" + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" }, "engines": { - "node": ">=10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/vitefu": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.1.tgz", + "integrity": "sha512-B/Fegf3i8zh0yFbpzZ21amWzHmuNlLlmJT6n7bu5e+pCHUKQIfXSYokrqOBGEMMe9UG2sostKQF9mml/vYaWJQ==", + "dev": true, + "license": "MIT", + "workspaces": [ + "tests/deps/*", + "tests/projects/*", + "tests/projects/workspace/packages/*" + ], + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0-beta.0" }, "peerDependenciesMeta": { - "webpack-cli": { + "vite": { "optional": true } } }, - "node_modules/webpack-sources": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz", - "integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==", + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", "dev": true, + "license": "MIT", "dependencies": { - "source-list-map": "^2.0.0", - "source-map": "~0.6.1" - } - }, - "node_modules/webpack-sources/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, + "xml-name-validator": "^5.0.0" + }, "engines": { - "node": ">=0.10.0" + "node": ">=18" } }, - "node_modules/webpack/node_modules/webpack-sources": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.3.3.tgz", - "integrity": "sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg==", - "devOptional": true, - "license": "MIT", - "peer": true, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "license": "BSD-2-Clause", "engines": { - "node": ">=10.13.0" + "node": ">=12" } }, "node_modules/whatwg-encoding": { @@ -21030,14 +15371,69 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/word-wrap": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "node_modules/widest-line": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-5.0.0.tgz", + "integrity": "sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA==", "license": "MIT", - "peer": true, + "dependencies": { + "string-width": "^7.0.0" + }, "engines": { - "node": ">=0.10.0" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/widest-line/node_modules/ansi-regex": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/widest-line/node_modules/emoji-regex": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", + "license": "MIT" + }, + "node_modules/widest-line/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/widest-line/node_modules/strip-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/wordwrap": { @@ -21046,10 +15442,28 @@ "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==" }, "node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -21062,6 +15476,68 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/emoji-regex": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", + "license": "MIT" + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -21089,6 +15565,36 @@ } } }, + "node_modules/wsl-utils": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.1.0.tgz", + "integrity": "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==", + "license": "MIT", + "dependencies": { + "is-wsl": "^3.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/wsl-utils/node_modules/is-wsl": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", + "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/xml-name-validator": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", @@ -21106,73 +15612,40 @@ "dev": true, "license": "MIT" }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", "engines": { - "node": ">=10" + "node": ">=0.4" } }, "node_modules/yallist": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", - "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=18" - } + "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz", + "integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==", + "license": "ISC", + "bin": { + "yaml": "bin.mjs" }, "engines": { - "node": ">=10" + "node": ">= 14.6" } }, - "node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "node_modules/zimmerframe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.2.tgz", + "integrity": "sha512-rAbqEGa8ovJy4pyBxZM70hg4pE6gDgaQ0Sl9M3enG3I0d6H4XSAM3GeNGLKnsBpuijUow064sf7ww1nutC5/3w==", "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } + "license": "MIT" }, "node_modules/zwitch": { "version": "2.0.4", diff --git a/package.json b/package.json index 397f27727..6b19889cd 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,21 @@ "node": ">=20" }, "type": "module", + "scripts": { + "dev": "react-router dev", + "res:watch": "rescript watch", + "res:clean": "rescript clean", + "build": "rescript build && react-router build", + "test": "node scripts/test-examples.mjs && node scripts/test-hrefs.mjs", + "reanalyze": "reanalyze -all-cmt .", + "update-index": "npm run generate-llms && node scripts/extract-indices.mjs && node scripts/extract-tocs.mjs && node scripts/extract-syntax.mjs && node scripts/generate_feed.mjs > public/blog/feed.xml", + "sync-bundles": "node scripts/sync-playground-bundles.mjs", + "generate-llms": "node scripts/generate_llms.mjs", + "generate-resources": "node scripts/generate_resources.mjs", + "format": "prettier . --write --experimental-cli && rescript format", + "ci:format": "prettier . --check --experimental-cli", + "preview": "npm run build && static-server build/client" + }, "dependencies": { "@babel/generator": "^7.24.7", "@babel/parser": "^7.24.7", @@ -15,8 +30,10 @@ "@docsearch/react": "^3.9.0", "@headlessui/react": "^2.2.4", "@mdx-js/loader": "^3.1.0", + "@node-cli/static-server": "^3.1.4", + "@react-router/node": "^7.8.1", "@rescript/react": "^0.14.0-rc.1", - "@rescript/webapi": "^0.1.0-experimental-0b87498", + "@rescript/webapi": "^0.1.0-experimental-ae90e53", "codemirror": "^5.54.0", "docson": "^2.1.0", "escodegen": "^2.1.0", @@ -25,55 +42,41 @@ "glob": "^7.1.4", "highlight.js": "^11.9.0", "highlightjs-rescript": "^0.2.2", + "isbot": "^5", "lz-string": "^1.4.4", - "next": "^15.4.7", - "next-mdx-remote": "^5.0.0", + "mdast-util-from-markdown": "^2.0.2", + "mdast-util-toc": "^7.1.0", "react": "^19.1.0", "react-dom": "^19.1.0", "react-markdown": "^10.1.0", + "react-router": "^7.8.1", + "react-router-dom": "^7.9.3", + "react-router-mdx": "^1.0.8", "rehype-slug": "^6.0.0", "rehype-stringify": "^10.0.1", "remark-comment": "^1.0.0", "remark-frontmatter": "^5.0.0", "remark-gfm": "^4.0.1", - "remark-mdx-frontmatter": "^5.0.0", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.1.1", - "remark-stringify": "^11.0.0", "request": "^2.88.0", "rescript": "^12.0.0-beta.6", "stringify-object": "^3.3.0", "unified": "^11.0.5", "vfile-matter": "^5.0.0" }, - "scripts": { - "dev": "next", - "res:watch": "rescript build -w", - "build": "rescript && npm run update-index && next build", - "test": "node scripts/test-examples.mjs && node scripts/test-hrefs.mjs", - "reanalyze": "reanalyze -all-cmt .", - "update-index": "npm run generate-llms && node scripts/extract-indices.mjs && node scripts/extract-tocs.mjs && node scripts/extract-syntax.mjs && node scripts/generate_feed.mjs > public/blog/feed.xml", - "sync-bundles": "node scripts/sync-playground-bundles.mjs", - "generate-llms": "node scripts/generate_llms.mjs", - "generate-resources": "node scripts/generate_resources.mjs", - "format": "prettier . --write --experimental-cli && rescript format", - "ci:format": "prettier . --check --experimental-cli" - }, "devDependencies": { "@mdx-js/react": "^2.3.0", + "@mdx-js/rollup": "^3.1.0", "@prettier/plugin-oxc": "^0.0.4", - "@tailwindcss/postcss": "^4.1.11", - "autoprefixer": "^10.4.14", - "cssnano": "^6.0.1", + "@react-router/dev": "^7.8.1", + "@tailwindcss/vite": "^4.1.13", + "@vitejs/plugin-react": "^4.7.0", + "@vitejs/plugin-rsc": "^0.4.16", "dotenv": "^16.4.7", - "esbuild-loader": "^4.3.0", "jsdom": "^26.1.0", - "postcss": "^8.4.27", - "postcss-cli": "^8.3.0", - "postcss-nesting": "^12.1.1", + "lightningcss": "^1.30.1", "prettier": "^3.6.2", "reanalyze": "^2.16.0", - "simple-functional-loader": "^1.2.1", - "tailwindcss": "^4" + "tailwindcss": "^4", + "vite": "^7.0.6" } } diff --git a/pages/brand.mdx b/pages/brand.mdx index d36e7845a..add9183f9 100644 --- a/pages/brand.mdx +++ b/pages/brand.mdx @@ -2,11 +2,11 @@ ## Logo - +
-[svg](/static/brand/rescript-brandmark.svg) | [png](/static/brand/rescript-brandmark.png) +[svg](/brand/rescript-brandmark.svg) | [png](/brand/rescript-brandmark.png)
@@ -16,11 +16,11 @@
- +
-[white.svg](/static/brand/rescript-logo-white.svg) | [white.png](/static/brand/rescript-logo-white.png) | [red.svg](/static/brand/rescript-logo.svg) | [red.png](/static/brand/rescript-logo.png) +[white.svg](/brand/rescript-logo-white.svg) | [white.png](/brand/rescript-logo-white.png) | [red.svg](/brand/rescript-logo.svg) | [red.png](/brand/rescript-logo.png)
diff --git a/pages/docs/manual/v10.0.0/api.mdx b/pages/docs/manual/v10.0.0/api.mdx deleted file mode 100644 index ce832115e..000000000 --- a/pages/docs/manual/v10.0.0/api.mdx +++ /dev/null @@ -1,15 +0,0 @@ -# Introduction - -ReScript ships 3 modules in its standard library. - -- [Js](api/js): bindings for all your familiar JavaScript APIs. -- [Belt](api/belt): extra collections and helpers not available in JavaScript. -- [Dom](api/dom): Dom related types and modules. - -Usage heuristics: - -- Default to using the `Js` module. Most of the APIs in it are runtime-free and compile down to clean, readable JavaScript, which is our priority. -- For other APIs that aren't available in regular JavaScript (and thus don't exist in our `Js` bindings), use Belt. For example, prefer `Js.Array2` over `Belt.Array`. -- The `Dom` module contains our standardized types used by various userland DOM bindings. Due to the complexity of DOM, we don't mind that you ignore this module and build your application-specific DOM bindings. - -**Note**: we do not recommend other userland standard library alternatives (unless it's DOM bindings). These cause confusion and split points for the community. diff --git a/pages/docs/manual/v10.0.0/api/belt.mdx b/pages/docs/manual/v10.0.0/api/belt.mdx deleted file mode 100644 index 1c5b8039a..000000000 --- a/pages/docs/manual/v10.0.0/api/belt.mdx +++ /dev/null @@ -1,179 +0,0 @@ -# Belt - -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. - -## Motivation - -Belt provides: - -- The **highest quality** immutable data structures in JavaScript. -- Safety by default: A Belt function will never throw exceptions, unless it is - indicated explicitly in the function name (suffix "Exn"). -- Better performance and smaller code size running on the JS platform. -- Ready for [Tree Shaking](https://webpack.js.org/guides/tree-shaking/). - -## Usage - -To use modules from Belt, either refer to them by their fully qualified name (`Belt.List`, `Belt.Array` etc.) or open the `Belt` module by putting - -```res -open Belt -``` - -at the top of your source files. After opening Belt this way, `Array` will refer to `Belt.Array`, `List` will refer to `Belt.List` etc. in the subsequent code. - -If you want to open Belt globally for all files in your project instead, you can put - -```json - "bsc-flags": ["-open Belt"], -``` - -into your `bsconfig.json`. - -**Note**: this is the **only** `open` we encourage. - -Example usage: - -```res -let someNumbers = [1, 1, 4, 2, 3, 6, 3, 4, 2] - -let greaterThan2UniqueAndSorted = - someNumbers - ->Belt.Array.keep(x => x > 2) - // convert to and from set to make values unique - ->Belt.Set.Int.fromArray - ->Belt.Set.Int.toArray // output is already sorted - -Js.log2("result", greaterThan2UniqueAndSorted) -``` - -## Curried vs. Uncurried Callbacks - -For functions taking a callback parameter, there are usually two versions -available: - -- curried (no suffix) -- uncurried (suffixed with `U`) - -E.g.: - -```res -let forEach: (t<'a>, 'a => unit) => unit - -let forEachU: (t<'a>, (. 'a) => unit) => unit -``` - -The uncurried version will be faster in some cases, but for simplicity we recommend to stick with the curried version unless you need the extra performance. - -The two versions can be invoked as follows: - -``` -["a", "b", "c"]->Belt.Array.forEach(x => Js.log(x)) - -["a", "b", "c"]->Belt.Array.forEachU((. x) => Js.log(x)) -``` - -## Specialized Collections - -For collections types like set or map, Belt provides both a generic module as well as specialized, more efficient implementations for string and int keys. - -For example, Belt has the following set modules: - -- [Belt.Set](belt/set) -- [Belt.Set.Int](belt/set-int) -- [Belt.Set.String](belt/set-string) - -## Implementation Details - -### Array access runtime safety - -One common confusion comes from the way Belt handles array access. It differs from than the default standard library's. - -```res -let letters = ["a", "b", "c"] -let a = letters[0] // a == "a" -let capitalA = Js.String.toUpperCase(a) -let k = letters[10] // Raises an exception! The 10th index doesn't exist. -``` - -Because Belt avoids exceptions and returns `options` instead, this code behaves differently: - -```res -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 k = letters[10] // k == None -``` - -Although we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here: - -- Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`. -- The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`. -- `Belt.Array.get` returns values wrapped in options, so `letters[0] == Some("a")`. - -Fortunately, this is easy to fix: - -```res example -open Belt -let letters = ["a", "b", "c"] -let a = letters[0] - -// Use a switch statement: -let capitalA = - switch a { - | Some(a) => Some(Js.String.toUpperCase(a)) - | None => None - } - -let k = letters[10] // k == None -``` - -With that little bit of tweaking, our code now compiles successfully and is 100% free of runtime errors! - -### A Special Encoding for Collection Safety - -When we create a collection library for a custom data type we need a way to provide a comparator function. Take Set for example, suppose its element type is a pair of ints, it needs a custom compare function that takes two tuples and returns their order. The Set could not just be typed as Set.t (int \* int) , its customized compare function needs to manifest itself in the signature, otherwise, if the user creates another customized compare function, the two collection could mix which would result in runtime error. - -We use a phantom type to solve the problem: - -```res -module Comparable1 = - Belt.Id.MakeComparable( - { - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - } - ) - -let mySet1 = Belt.Set.make(~id=module(Comparable1)) - -module Comparable2 = - Belt.Id.MakeComparable( - { - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - } - ) - -let mySet2 = Belt.Set.make(~id=module(Comparable2)) -``` - -Here, the compiler would infer `mySet1` and `mySet2` having different type, so e.g. a `merge` operation that tries to merge these two sets will correctly fail. - -```res -let mySet1: t<(int, int), Comparable1.identity> -let mySet2: t<(int, int), Comparable2.identity> -``` - -`Comparable1.identity` and `Comparable2.identity` are not the same using our encoding scheme. diff --git a/pages/docs/manual/v10.0.0/api/belt/array.mdx b/pages/docs/manual/v10.0.0/api/belt/array.mdx deleted file mode 100644 index c912ac1b9..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/array.mdx +++ /dev/null @@ -1,940 +0,0 @@ -# Array - - - -Utililites for `Array` functions. - - - -### Note about index syntax - -Code like `arr[0]` does _not_ compile to JavaScript `arr[0]`. ReScript transforms the `[]` index syntax into a function: `Array.get(arr, 0)`. By default, this uses the default standard library's `Array.get` function, which may raise an exception if the index isn't found. If you `open Belt`, it will use the `Belt.Array.get` function which returns options instead of raising exceptions. [See this for more information](../belt.mdx#array-access-runtime-safety). - -## length - -```res sig -let length: array<'a> => int -``` - -return the size of the array - -```res example -// Returns 1 -Belt.Array.length(["test"]) -``` - -## size - -```res sig -let size: array<'a> => int -``` - -See Belt_Array.length - -## get - -```res sig -let get: (array<'a>, int) => option<'a> -``` - -If `i <= 0 <= length(arr)` returns `Some(value)` where `value` is the item at index `i`. -If `i` is out of range returns `None` - -## getExn - -```res sig -let getExn: (array<'a>, int) => 'a -``` - -Raise an exception if `i` is out of range. -Otherwise return the value at index `i` in `arr`. - -## getUnsafe - -```res sig -let getUnsafe: (array<'a>, int) => 'a -``` - -Unsafe - -no bounds checking; this would cause type error if `i` does not stay within range - -## getUndefined - -```res sig -let getUndefined: (array<'a>, int) => Js.undefined<'a> -``` - -It does the samething in the runtime as `Belt_Array.getUnsafe` it is type safe since the return type still track whether it is in range or not - -## set - -```res sig -let set: (array<'a>, int, 'a) => bool -``` - -`set(arr, n, x)` modifies `arr` in place; it replaces the nth element of `arr` with `x`. - -Returns false means not updated due to out of range. - -## setExn - -```res sig -let setExn: (array<'a>, int, 'a) => unit -``` - -`setExn(arr, i, x)` raise an exception if `i` is out of range. - -## setUnsafe - -```res sig -let setUnsafe: (array<'a>, int, 'a) => unit -``` - -## shuffleInPlace - -```res sig -let shuffleInPlace: array<'a> => unit -``` - -`shuffleInPlace(arr)` randomly re-orders the items in `arr` - -## shuffle - -```res sig -let shuffle: array<'a> => array<'a> -``` - -Returns a fresh array with items in original array randomly shuffled. - -## reverseInPlace - -```res sig -let reverseInPlace: array<'a> => unit -``` - -`reverseInPlace(arr)` reverses items in `arr` in place. - -```res example -let arr = [10, 11, 12, 13, 14] - -let () = Belt.Array.reverseInPlace(arr) - -arr == [14, 13, 12, 11, 10] -``` - -## reverse - -```res sig -let reverse: array<'a> => array<'a> -``` - -`reverse(arr)` returns a fresh array with items in arr in reverse order. - -```res example -Belt.Array.reverse([10, 11, 12, 13, 14]) == [14, 13, 12, 11, 10] -``` - -## makeUninitialized - -```res sig -let makeUninitialized: int => array> -``` - -`makeUninitialized(n)` creates an array of length `n` filled with the undefined value. You must specify the type of data that will eventually fill the array. - -```res example -let arr: array> = Belt.Array.makeUninitialized(5) - -Belt.Array.getExn(arr, 0) == Js.undefined -``` - -## makeUninitializedUnsafe - -```res sig -let makeUninitializedUnsafe: int => array<'a> -``` - -Unsafe - -```res example -let arr = Belt.Array.makeUninitializedUnsafe(5) - -Js.log(Belt.Array.getExn(arr, 0)) // undefined - -Belt.Array.setExn(arr, 0, "example") - -Js.log(Belt.Array.getExn(arr, 0) == "example") -``` - -## make - -```res sig -let make: (int, 'a) => array<'a> -``` - -`make(n, e)` return an array of size `n` filled with value `e`. -Returns an empty array when `n` is negative. - -## range - -```res sig -let range: (int, int) => array -``` - -`range(start, finish)` create an inclusive array. - -```res example -Belt.Array.range(0, 3) == [0, 1, 2, 3] - -Belt.Array.range(3, 0) == [] - -Belt.Array.range(3, 3) == [3] -``` - -## rangeBy - -```res sig -let rangeBy: (int, int, ~step: int) => array -``` - -`rangeBy(start, finish, ~step)` - -Returns empty array when step is 0 or negative. It also return an empty array when `start > finish`. - -```res example -Belt.Array.rangeBy(0, 10, ~step=3) == [0, 3, 6, 9] - -Belt.Array.rangeBy(0, 12, ~step=3) == [0, 3, 6, 9, 12] - -Belt.Array.rangeBy(33, 0, ~step=1) == [] - -Belt.Array.rangeBy(33, 0, ~step=-1) == [] - -Belt.Array.rangeBy(3, 12, ~step=-1) == [] - -Belt.Array.rangeBy(3, 3, ~step=0) == [] - -Belt.Array.rangeBy(3, 3, ~step=1) == [3] -``` - -## makeByU - -```res sig -let makeByU: (int, (. int) => 'a) => array<'a> -``` - -## makeBy - -```res sig -let makeBy: (int, int => 'a) => array<'a> -``` - -`makeBy(n, f)` - -Return an empty array when n is negative return an array of size n populated by `f(i)` start from `0` to `n - 1`. - -```res example -Belt.Array.makeBy(5, (i) => i) == [0, 1, 2, 3, 4] - -Belt.Array.makeBy(5, (i) => i * i) == [0, 1, 4, 9, 16] -``` - -## makeByAndShuffleU - -```res sig -let makeByAndShuffleU: (int, (. int) => 'a) => array<'a> -``` - -## makeByAndShuffle - -```res sig -let makeByAndShuffle: (int, int => 'a) => array<'a> -``` - -`makeByAndShuffle(n, f)` - -Equivalent to `shuffle(makeBy(n, f))` - -## zip - -```res sig -let zip: (array<'a>, array<'b>) => array<('a, 'b)> -``` - -`zip(a, b)` - -Create an array of pairs from corresponding elements of a and b. Stop with the shorter array. - -```res example -Belt.Array.zip([1, 2], [3, 4, 5]) == [(1, 3), (2, 4)] -``` - -## zipByU - -```res sig -let zipByU: (array<'a>, array<'b>, (. 'a, 'b) => 'c) => array<'c> -``` - -## zipBy - -```res sig -let zipBy: (array<'a>, array<'b>, ('a, 'b) => 'c) => array<'c> -``` - -`zipBy(xs, ys, f)` - -Create an array by applying `f` to corresponding elements of `xs` and `ys`. Stops with shorter array. - -Equivalent to `map(zip(xs, ys), ((a, b)) => f(a, b))` - -```res example -Belt.Array.zipBy([1, 2, 3], [4, 5], (a, b) => 2 * a + b) == [6, 9] -``` - -## unzip - -```res sig -let unzip: array<('a, 'b)> => (array<'a>, array<'b>) -``` - -`unzip(a)` takes an array of pairs and creates a pair of arrays. The first array contains all the first items of the pairs; the second array contains all the second items. - -```res example -Belt.Array.unzip([(1, 2), (3, 4)]) == ([1, 3], [2, 4]) - -Belt.Array.unzip([(1, 2), (3, 4), (5, 6), (7, 8)]) == ([1, 3, 5, 7], [2, 4, 6, 8]) -``` - -## concat - -```res sig -let concat: (array<'a>, array<'a>) => array<'a> -``` - -`concat(xs, ys)` - -Returns a fresh array containing the concatenation of the arrays `v1` and `v2`;so even if `v1` or `v2` is empty; it can not be shared - -```res example -Belt.Array.concat([1, 2, 3], [4, 5]) == [1, 2, 3, 4, 5] - -Belt.Array.concat([], ["a", "b", "c"]) == ["a", "b", "c"] -``` - -## concatMany - -```res sig -let concatMany: array> => array<'a> -``` - -`concatMany(xss)` - -Returns a fresh array as the concatenation of `xss` (an array of arrays) - -```res example -Belt.Array.concatMany([[1, 2, 3], [4, 5, 6], [7, 8]]) == [1, 2, 3, 4, 5, 6, 7, 8] -``` - -## slice - -```res sig -let slice: (array<'a>, ~offset: int, ~len: int) => array<'a> -``` - -`slice(xs, offset, len)` creates a new array with the len elements of `xs` -starting at `offset` for `offset` can be negative;and is evaluated as -`length(xs) - offset(slice, xs) - 1(1)` means get the last element as a -singleton array `slice(xs, ~-len, len)` will return a copy of the array if the -array does not have enough data; `slice` extracts through the end of sequence. - -if `len` is negative; returns the empty array. - -```res example -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=2, ~len=3) == [12, 13, 14] - -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=-4, ~len=3) == [13, 14, 15] - -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=4, ~len=9) == [14, 15, 16] -``` - -## sliceToEnd - -```res sig -let sliceToEnd: (array<'a>, int) => array<'a> -``` - -`sliceToEnd(xs, offset)` creates a new array with the elements of `xs` starting at `offset` - -`offset` can be negative; and is evaluated as `length(xs) - offset(sliceToEnd, xs) - 1` means get the last element as a singleton array - -`sliceToEnd(xs, 0)` will return a copy of the array - -```res example -Belt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], 2) == [12, 13, 14, 15, 16] - -Belt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], -4) == [13, 14, 15, 16] -``` - -## copy - -```res sig -let copy: array<'a> => array<'a> -``` - -`copy(a)` - -Returns a copy of a; that is; a fresh array containing the same elements as a. - -## fill - -```res sig -let fill: (array<'a>, ~offset: int, ~len: int, 'a) => unit -``` - -`fill(arr, ~offset, ~len, x)` - -Modifies `arr` in place, storing `x` in elements number `offset` to `offset + len - 1`. -`offset` can be negative; and is evaluated as `length(arr - offset)` - -`fill(arr, ~offset=-1, ~len=1)` means fill the last element, if the array does not have enough data; `fill` will ignore it - -```res example -let arr = Belt.Array.makeBy(5, (i) => i) - -Belt.Array.fill(arr, ~offset=2, ~len=2, 9) - -arr == [0, 1, 9, 9, 4] - -Belt.Array.fill(arr, ~offset=7, ~len=2, 8) - -arr == [0, 1, 9, 9, 4] -``` - -## blit - -```res sig -let blit: - ( - ~src: array<'a>, - ~srcOffset: int, - ~dst: array<'a>, - ~dstOffset: int, - ~len: int - ) => - unit -``` - -`blit(~src=v1, ~srcOffset=o1, ~dst=v2, ~dstOffset=o2, ~len)` - -copies `len` elements from array `v1`;starting at element number `o1`;to array `v2`, starting at element number `o2`. - -It works correctly even if `v1` and `v2` are the same array;and the source and destination chunks overlap. - -`offset` can be negative; `-1` means `len - 1`; if `len + offset` is still negative;it will be set as 0 - -For each of the examples;presume that `v1 == [10, 11, 12, 13, 14, 15, 16, 17]` and `v2 == [20, 21, 22, 23, 24, 25, 26, 27]`. The result shown is the content of the destination array. - -```res example -let v1 = [10, 11, 12, 13, 14, 15, 16, 17] -let v2 = [20, 21, 22, 23, 24, 25, 26, 27] - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v2, ~dstOffset=2, ~len=3) -v2 == [20, 21, 14, 15, 16, 25, 26, 27] - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v1, ~dstOffset=2, ~len=3) -v1 == [10, 11, 14, 15, 16, 15, 16, 17] -``` - -## blitUnsafe - -```res sig -let blitUnsafe: (~src: array<'a>, ~srcOffset: int, ~dst: array<'a>, ~dstOffset: int, ~len: int) => unit -``` - -Unsafe blit without bounds checking. - -## forEachU - -```res sig -let forEachU: (array<'a>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (array<'a>, 'a => unit) => unit -``` - -`forEach(xs, f)` - -Call `f` on each element of `xs` from the beginning to end. `f` returns `unit`;so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects. - -```res example -Belt.Array.forEach(["a", "b", "c"], x => Js.log("Item: " ++ x)) - -/* - prints: - Item: a - Item: b - Item: c -*/ -let total = ref(0) - -Belt.Array.forEach([1, 2, 3, 4], x => total := total.contents + x) - -total.contents == 1 + 2 + 3 + 4 -``` - -## mapU - -```res sig -let mapU: (array<'a>, (. 'a) => 'b) => array<'b> -``` - -## map - -```res sig -let map: (array<'a>, 'a => 'b) => array<'b> -``` - -`map(xs, f)` - -Returns a new array by calling `f` for each element of `xs` from the beginning to end. - -```res example -Belt.Array.map([1, 2], (x) => x + 2) == [3, 4] -``` - -## getByU - -```res sig -let getByU: (array<'a>, (. 'a) => bool) => option<'a> -``` - -## getBy - -```res sig -let getBy: (array<'a>, 'a => bool) => option<'a> -``` - -`getBy(xs, p)` - -Returns `Some(value)` for the first value in `xs` that satisifies the predicate function `p`; returns `None` if no element satisifies the function. - -```res example -Belt.Array.getBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(4) -Belt.Array.getBy([15, 13, 11], (x) => mod(x, 2) == 0) == None -``` - -## getIndexByU - -```res sig -let getIndexByU: (array<'a>, (. 'a) => bool) => option -``` - -## getIndexBy - -```res sig -let getIndexBy: (array<'a>, 'a => bool) => option -``` - -`getIndexBy(xs, p)` - -returns `Some(index)` for the first value in `xs` that satisifies the predicate function `p`; -returns `None` if no element satisifies the function. - -```res example -Belt.Array.getIndexBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(1) -Belt.Array.getIndexBy([15, 13, 11], (x) => mod(x, 2) == 0) == None -``` - -## keepU - -```res sig -let keepU: (array<'a>, (. 'a) => bool) => array<'a> -``` - -## keep - -```res sig -let keep: (array<'a>, 'a => bool) => array<'a> -``` - -`keep(xs, p)` - -Returns a new array that keep all elements satisfy `p`. - -```res example -Belt.Array.keep([1, 2, 3], (x) => mod(x, 2) == 0) == [2] -``` - -## keepWithIndexU - -```res sig -let keepWithIndexU: (array<'a>, (. 'a, int) => bool) => array<'a> -``` - -## keepWithIndex - -```res sig -let keepWithIndex: (array<'a>, ('a, int) => bool) => array<'a> -``` - -`keepWithIndex(xs, p)` - -Returns a new array that keep all elements satisfy `p`. - -```res example -Belt.Array.keepWithIndex([1, 2, 3], (_x, i) => i == 1) == [2] -``` - -## keepMapU - -```res sig -let keepMapU: (array<'a>, (. 'a) => option<'b>) => array<'b> -``` - -## keepMap - -```res sig -let keepMap: (array<'a>, 'a => option<'b>) => array<'b> -``` - -`keepMap(xs, p)` - -Returns a new array that keep all elements that return a non-None applied `p`. - -```res example -Belt.Array.keepMap([1, 2, 3], x => - if mod(x, 2) == 0 { - Some(x) - } else { - None - } -) -== [2] -``` - -## forEachWithIndexU - -```res sig -let forEachWithIndexU: (array<'a>, (. int, 'a) => unit) => unit -``` - -## forEachWithIndex - -```res sig -let forEachWithIndex: (array<'a>, (int, 'a) => unit) => unit -``` - -`forEachWithIndex(xs, f)` - -The same as `Belt_Array.forEach`; -except that `f` is supplied two arguments: the index starting from 0 and the element from `xs`. - -```res example -Belt.Array.forEachWithIndex(["a", "b", "c"], (i, x) => Js.log("Item " ++ Belt.Int.toString(i) ++ " is " ++ x)) - -/* - prints: - Item 0 is a - Item 1 is b - Item 2 is cc -*/ -let total = ref(0) - -Belt.Array.forEachWithIndex([10, 11, 12, 13], (i, x) => total := total.contents + x + i) - -total.contents == 0 + 10 + 1 + 11 + 2 + 12 + 3 + 13 -``` - -## mapWithIndexU - -```res sig -let mapWithIndexU: (array<'a>, (. int, 'a) => 'b) => array<'b> -``` - -## mapWithIndex - -```res sig -let mapWithIndex: (array<'a>, (int, 'a) => 'b) => array<'b> -``` - -`mapWithIndex(xs, f)` - -`mapWithIndex(xs, f)` applies `f` to each element of `xs`. Function `f` takes two arguments: the index starting from 0 and the element from `xs`. - -```res example -Belt.Array.mapWithIndex([1, 2, 3], (i, x) => i + x) == [0 + 1, 1 + 2, 2 + 3] -``` - -## partitionU - -```res sig -let partitionU: (array<'a>, (. 'a) => bool) => (array<'a>, array<'a>) -``` - -## partition - -```res sig -let partition: (array<'a>, 'a => bool) => (array<'a>, array<'a>) -``` - -`partition(xs, p)` split array into tuple of two arrays based on predicate `p`; first of tuple where predicate cause true, second where predicate cause false. - -```res example -Belt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) == 0) == ([2, 4], [1, 3, 5]) - -Belt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) != 0) == ([1, 3, 5], [2, 4]) -``` - -## reduceU - -```res sig -let reduceU: (array<'b>, 'a, (. 'a, 'b) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (array<'b>, 'a, ('a, 'b) => 'a) => 'a -``` - -`reduce(arr, init, f)` - -Applies `f` to each element of `arr`. - -Function `f` has two parameters: an "accumulator" which starts with a value of `init` and the next value from the array. - -It returns the final value of the accumulator. - -```res example -Belt.Array.reduce([2, 3, 4], 1, (acc, value) => acc + value) == 10 - -Belt.Array.reduce(["a", "b", "c", "d"], "", (a, b) => a ++ b) == "abcd" -``` - -## reduceReverseU - -```res sig -let reduceReverseU: (array<'b>, 'a, (. 'a, 'b) => 'a) => 'a -``` - -## reduceReverse - -```res sig -let reduceReverse: (array<'b>, 'a, ('a, 'b) => 'a) => 'a -``` - -`reduceReverse(xs, init, f)` - -Works like `Belt_Array.reduce`; except that function `f` is applied to each item of `xs` from the last back to the first. - -```res example -Belt.Array.reduceReverse(["a", "b", "c", "d"], "", (a, b) => a ++ b) == "dcba" -``` - -## reduceReverse2U - -```res sig -let reduceReverse2U: (array<'a>, array<'b>, 'c, (. 'c, 'a, 'b) => 'c) => 'c -``` - -## reduceReverse2 - -```res sig -let reduceReverse2: (array<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c -``` - -`reduceReverse2(xs, ys, init, f)` - -Reduces two arrays xs and ys;taking items starting at `min(length(xs), length(ys))` down to and including zero. - -```res example -Belt.Array.reduceReverse2([1, 2, 3], [1, 2], 0, (acc, x, y) => acc + x + y) == 6 -``` - -## reduceWithIndexU - -```res sig -let reduceWithIndexU: (array<'a>, 'b, (. 'b, 'a, int) => 'b) => 'b -``` - -## reduceWithIndex - -```res sig -let reduceWithIndex: (array<'a>, 'b, ('b, 'a, int) => 'b) => 'b -``` - -`reduceWithIndex(arr, init, f)` - -Applies `f` to each element of `arr` from beginning to end. Function `f` has three parameters: an "accumulator", which starts with a value of `init` and the item from the array and the index of each element. `reduceWithIndex` returns the final value of the accumulator. - -```res example -Belt.Array.reduceWithIndex([1, 2, 3, 4], 0, (acc, value, i) => acc + value + i) == 16 -``` - -## someU - -```res sig -let someU: (array<'a>, (. 'a) => bool) => bool -``` - -## some - -```res sig -let some: (array<'a>, 'a => bool) => bool -``` - -`some(xs, p)` - -Returns true if at least one of the elements in `xs` satifies `p`; where `p` is a predicate: a function taking an element and returning a `bool`. - -```res example -Belt.Array.some([2, 3, 4], (x) => mod(x, 2) == 1) == true - -Belt.Array.some([(-1), (-3), (-5)], (x) => x > 0) == false -``` - -## everyU - -```res sig -let everyU: (array<'a>, (. 'a) => bool) => bool -``` - -## every - -```res sig -let every: (array<'a>, 'a => bool) => bool -``` - -`every(xs, p)` - -Returns `true` if all elements satisfy `p`; where `p` is a predicate: a function taking an element and returning a `bool`. - -```res example -Belt.Array.every([1, 3, 5], (x) => mod(x, 2) == 1) == true - -Belt.Array.every([1, (-3), 5], (x) => x > 0) == false -``` - -## every2U - -```res sig -let every2U: (array<'a>, array<'b>, (. 'a, 'b) => bool) => bool -``` - -## every2 - -```res sig -let every2: (array<'a>, array<'b>, ('a, 'b) => bool) => bool -``` - -`every2(xs, ys, p)` - -returns true if `p(xi, yi)` is true for all pairs of elements up to the shorter length (i.e. `min(length(xs), length(ys))`) - -```res example -Belt.Array.every2([1, 2, 3], [0, 1], (a, b) => a > b) == true - -Belt.Array.every2([], [1], (x, y) => x > y) == true - -Belt.Array.every2([2, 3], [1], (x, y) => x > y) == true - -Belt.Array.every2([0, 1], [5, 0], (x, y) => x > y) == false -``` - -## some2U - -```res sig -let some2U: (array<'a>, array<'b>, (. 'a, 'b) => bool) => bool -``` - -## some2 - -```res sig -let some2: (array<'a>, array<'b>, ('a, 'b) => bool) => bool -``` - -`some2(xs, ys, p)` - -returns true if `p(xi, yi)` is true for any pair of elements up to the shorter length (i.e. `min(length(xs), length(ys))`) - -```res example -Belt.Array.some2([0, 2], [1, 0, 3], (a, b) => a > b) == true - -Belt.Array.some2([], [1], (x, y) => x > y) == false - -Belt.Array.some2([2, 3], [1, 4], (x, y) => x > y) == true -``` - -## cmpU - -```res sig -let cmpU: (array<'a>, array<'a>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (array<'a>, array<'a>, ('a, 'a) => int) => int -``` - -`cmp(xs, ys, f)` - -Compared by length if `length(xs) != length(ys)`; returning -1 if `length(xs) < length(ys)` or 1 if `length(xs) > length(ys)` -Otherwise compare one by one `f(x, y)`. `f` returns -a negative number if `x` is “less than” `y` -zero if `x` is “equal to” `y` -a positive number if `x` is “greater than” `y` -The comparison returns the first non-zero result of `f`;or zero if `f` returns zero for all `x` and `y`. - -```res example -Belt.Array.cmp([1, 3, 5], [1, 4, 2], (a, b) => compare(a, b)) == -1 - -Belt.Array.cmp([1, 3, 5], [1, 2, 3], (a, b) => compare(a, b)) == 1 - -Belt.Array.cmp([1, 3, 5], [1, 3, 5], (a, b) => compare(a, b)) == 0 -``` - -## eqU - -```res sig -let eqU: (array<'a>, array<'a>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (array<'a>, array<'a>, ('a, 'a) => bool) => bool -``` - -`eq(xs, ys)` - -return false if length is not the same -otherwise compare items one by one using `f(xi, yi)`; and return true if all results are truefalse otherwise - -```res example -Belt.Array.eq([1, 2, 3], [(-1), (-2), (-3)], (a, b) => abs(a) == abs(b)) == true -``` - -## truncateToLengthUnsafe - -```res sig -let truncateToLengthUnsafe: (array<'a>, int) => unit -``` - -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`. - -If `n` is less than zero; raises a `RangeError`. - -```res example -let arr = ["ant", "bee", "cat", "dog", "elk"] - -Belt.Array.truncateToLengthUnsafe(arr, 3) - -arr == ["ant", "bee", "cat"] -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/debug.mdx b/pages/docs/manual/v10.0.0/api/belt/debug.mdx deleted file mode 100644 index 9fe40751f..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/debug.mdx +++ /dev/null @@ -1,7 +0,0 @@ -# Debug - -## setupChromeDebugger - -```res sig -let setupChromeDebugger: unit => unit -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/float.mdx b/pages/docs/manual/v10.0.0/api/belt/float.mdx deleted file mode 100644 index 9e316e24a..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/float.mdx +++ /dev/null @@ -1,107 +0,0 @@ -# Float - -This module includes convenience methods for handling `float` types. - -## toInt - -```res sig -let toInt: float => int -``` - -Converts a given `float` to an `int`. - -```res example -Js.log(Belt.Float.toInt(1.0) === 1) /* true */ -``` - -## fromInt - -```res sig -let fromInt: int => float -``` - -Converts a given `int` to a `float`. - -```res example -Js.log(Belt.Float.fromInt(1) === 1.0) /* true */ -``` - -## fromString - -```res sig -let fromString: string => option -``` - -Converts a given `string` to a `float`. Returns `Some(float)` when the input is a number, `None` otherwise. - -```res example -Js.log(Belt.Float.fromString("1.0") === Some(1.0)) /* true */ -``` - -## toString - -```res sig -let toString: float => string -``` - -Converts a given `float` to a `string`. Uses the JavaScript `String` constructor under the hood. - -```res example -Js.log(Belt.Float.toString(1.0) === "1.0") /* true */ -``` - -## + - -```re sig -let (+): (float, float) => float -``` - -Addition of two `float` values. -Can be opened in a module to avoid dot-notation (`+.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(2.0 + 2.0 === 4.0) /* true */ -``` - -## - - -```re sig -let (-): (float, float) => float -``` - -Subtraction of two `float` values. -Can be opened in a module to avoid dot-notation (`-.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(2.0 - 1.0 === 1.0) /* true */ -``` - -## \* - -```re sig -let (*): (float, float) => float -``` - -Multiplication of two `float` values. -Can be opened in a module to avoid dot-notation (`*.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(2.0 * 2.0 === 4.0) /* true */ -``` - -## / - -```re sig -let (/): (float, float) => float -``` - -Division of two `float` values. -Can be opened in a module to avoid dot-notation (`/.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(4.0 / 2.0 === 2.0) /* true */ -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/hash-map-int.mdx b/pages/docs/manual/v10.0.0/api/belt/hash-map-int.mdx deleted file mode 100644 index 0adeb762a..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/hash-map-int.mdx +++ /dev/null @@ -1,325 +0,0 @@ -# HashMapInt - - - -Specialized when key type is `int`, more efficient than the generic type - - - -## key - -```res prelude -type key = int -``` - -Type of the `Belt.HashMap.Int` key. - -## t - -```res prelude -type t<'b> -``` - -Type of the `Belt.HashMap.Int` - -## make - -```res sig -let make: (~hintSize: int) => t<'b> -``` - -`make(~hintSize=10)` creates a new hash map by taking the `hintSize`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) - -Belt.HashMap.Int.set(hMap, 1, "a") -``` - -## clear - -```res sig -let clear: t<'b> => unit -``` - -Clears a hash table. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(1, "1")]) -Belt.HashMap.Int.clear(hMap) -Belt.HashMap.Int.isEmpty(hMap) == true -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(1, "1")]) -Belt.HashMap.Int.isEmpty(hMap) == false -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(2, "2")]) - -Belt.HashMap.Int.set(hMap, 1, "1") - -Belt.HashMap.Int.valuesToArray(hMap) == ["1", "2"] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -Creates copy of a hash map. - -```res example -let hMap1 = Belt.HashMap.Int.fromArray([(1, "1"), (2, "2")]) -let hMap2 = Belt.HashMap.Int.copy(hMap1) - -Belt.HashMap.Int.set(hMap2, 2, "3") - -Belt.HashMap.Int.get(hMap1, 2) != Belt.HashMap.Int.get(hMap2, 2) -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -## has - -```res sig -let has: (t<'b>, key) => bool -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") - -Belt.HashMap.Int.get(hMap, 1) == Some("value1") -Belt.HashMap.Int.get(hMap, 2) == None -``` - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -If bound exists, removes it from the hash map. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.remove(hMap, 1) -Belt.HashMap.Int.has(hMap, 1) == false -``` - -## forEachU - -```res sig -let forEachU: (t<'b>, (. key, 'b) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'b>, (key, 'b) => unit) => unit -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.forEach(hMap, (key, value) => Js.log2(key, value)) -// prints ("1", "value1") -``` - -## reduceU - -```res sig -let reduceU: (t<'b>, 'c, (. 'c, key, 'b) => 'c) => 'c -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```res sig -let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.reduce(hMap, "", (acc, key, value) => acc ++ (", " ++ value)) == "value1, value2" -``` - -## keepMapInPlaceU - -```res sig -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```res sig -let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit -``` - -Filters out values for which function `f` returned `None`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.keepMapInPlace(hMap, (key, value) => mod(key, 1) == 0 ? None : Some(value)) -``` - -## size - -```res sig -let size: t<'a> => int -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.size(hMap) == 2 -``` - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -Returns array of key value pairs. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.toArray(hMap) == [(1, "value1"), (2, "value2")] -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -Returns array of keys. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.keysToArray(hMap) == [1, 2] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -Returns array of values. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.valuesToArray(hMap) == ["value1", "value2"] -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(1, "value1"), (1, "value2")]) -Belt.HashMap.Int.toArray(hMap) == [(1, "value1"), (2, "value2")] -``` - -## mergeMany - -```res sig -let mergeMany: (t<'a>, array<(key, 'a)>) => unit -``` - -Merges many key value pairs into hash map. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.mergeMany(hMap, [(1, "value1"), (2, "value2")]) -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a> => array -``` - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "1") - -Belt.HashMap.Int.getBucketHistogram(hMap) -``` - -## logStats - -```res sig -let logStats: t<'a> => unit -``` - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "1") - -Belt.HashMap.Int.logStats(hMap) -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/hash-map-string.mdx b/pages/docs/manual/v10.0.0/api/belt/hash-map-string.mdx deleted file mode 100644 index 401e2dd70..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/hash-map-string.mdx +++ /dev/null @@ -1,337 +0,0 @@ -# HashMapString - - - -Specialized when key type is `string`, more efficient than the generic type - - - -## key - -```res prelude -type key = string -``` - -Type of the `Belt.HashMap.String` key. - -## t - -```res prelude -type t<'b> -``` - -Type of the `Belt.HashMap.String`. - -## make - -```res sig -let make: (~hintSize: int) => t<'b> -``` - -`make(~hintSize=10)` creates a new hash map by taking the `hintSize`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) - -Belt.HashMap.String.set(hMap, "key1", "a") -``` - -## clear - -```res sig -let clear: t<'b> => unit -``` - -Clears a hash table. - -```res example -let hMap = Belt.HashMap.String.fromArray([("1", "1")]) -Belt.HashMap.String.clear(hMap) -Belt.HashMap.String.isEmpty(hMap) == true -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```res example -let hMap = Belt.HashMap.String.fromArray([("1", "1")]) -Belt.HashMap.String.isEmpty(hMap) == false -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```res example -let hMap = Belt.HashMap.String.fromArray([("2", "2")]) - -Belt.HashMap.String.set(hMap, "1", "1") - -Belt.HashMap.String.valuesToArray(hMap) == ["1", "2"] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -Creates copy of a hash map. - -```res example -let hMap1 = Belt.HashMap.String.fromArray([("1", "1"), ("2", "2")]) -let hMap2 = Belt.HashMap.String.copy(hMap1) - -Belt.HashMap.String.set(hMap2, "2", "3") - -Belt.HashMap.String.get(hMap1, "2") != Belt.HashMap.String.get(hMap2, "2") -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") - -Belt.HashMap.String.get(hMap, "1") == Some("value1") -Belt.HashMap.String.get(hMap, "2") == None -``` - -## has - -```res sig -let has: (t<'b>, key) => bool -``` - -Checks if `x` is bound in `tbl`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") - -Belt.HashMap.String.has(hMap, "1") == true -Belt.HashMap.String.has(hMap, "2") == false -``` - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -If bound exists, removes it from the hash map. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.remove(hMap, "1") -Belt.HashMap.String.has(hMap, "1") == false -``` - -## forEachU - -```res sig -let forEachU: (t<'b>, (. key, 'b) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'b>, (key, 'b) => unit) => unit -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.forEach(hMap, (key, value) => Js.log2(key, value)) -// prints ("1", "value1") -``` - -## reduceU - -```res sig -let reduceU: (t<'b>, 'c, (. 'c, key, 'b) => 'c) => 'c -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```res sig -let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.reduce(hMap, "", (acc, key, value) => - acc ++ (", " ++ value) -) == "value1, value2" -``` - -## keepMapInPlaceU - -```res sig -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```res sig -let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit -``` - -Filters out values for which function `f` returned `None`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.keepMapInPlace(hMap, (key, value) => key == "1" ? None : Some(value)) -``` - -## size - -```res sig -let size: t<'a> => int -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.size(hMap) == 2 -``` - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -Returns array of key value pairs. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.toArray(hMap) == [("1", "value1"), ("2", "value2")] -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -Returns array of keys. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.keysToArray(hMap) == ["1", "2"] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -Returns array of values. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.valuesToArray(hMap) == ["value1", "value2"] -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```res example -let hMap = Belt.HashMap.String.fromArray([("1", "value1"), ("2", "value2")]) -Belt.HashMap.String.toArray(hMap) == [("1", "value1"), ("2", "value2")] -``` - -## mergeMany - -```res sig -let mergeMany: (t<'a>, array<(key, 'a)>) => unit -``` - -Merges many key value pairs into hash map. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.mergeMany(hMap, [("1", "value1"), ("2", "value2")]) -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a> => array -``` - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "1") - -Belt.HashMap.String.getBucketHistogram(hMap) -``` - -## logStats - -```res sig -let logStats: t<'a> => unit -``` - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "1") - -Belt.HashMap.String.logStats(hMap) -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/hash-map.mdx b/pages/docs/manual/v10.0.0/api/belt/hash-map.mdx deleted file mode 100644 index 36a8de539..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/hash-map.mdx +++ /dev/null @@ -1,444 +0,0 @@ -# HashMap - - - -The top level provides generic mutable hash map operations. - - - -## t - -```res prelude -type t<'key, 'value, 'id> -``` - -The type of hash tables from type `'key` to type `'value`. - -## id - -```res prelude -type id<'a, 'id> = Belt.Id.hashable<'a, 'id> -``` - -The identity needed for making an empty hash map. - -## make - -```res sig -let make: (~hintSize: int, ~id: id<'key, 'id>) => t<'key, 'value, 'id> -``` - -`make(~hintSize=10, ~id)` creates a new map by taking in the comparator and `hintSize`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) - -Belt.HashMap.set(hMap, 0, "a") -``` - -## clear - -```res sig -let clear: t<'key, 'value, 'id> => unit -``` - -Clears a hash table. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.fromArray([(1, "1")], ~id=module(IntHash)) -Belt.HashMap.clear(hMap) -Belt.HashMap.isEmpty(hMap) == true -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b, 'c> => bool -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -Belt.HashMap.isEmpty(Belt.HashMap.fromArray([(1, "1")], ~id=module(IntHash))) == false -``` - -## set - -```res sig -let set: (t<'key, 'value, 'id>, 'key, 'value) => unit -``` - -`set(hMap, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntHash)) - -Belt.HashMap.set(s0, 2, "3") - -Belt.HashMap.valuesToArray(s0) == ["1", "3", "3"] -``` - -## copy - -```res sig -let copy: t<'key, 'value, 'id> => t<'key, 'value, 'id> -``` - -Creates copy of a hash map. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntHash)) -let s1 = Belt.HashMap.copy(s0) - -Belt.HashMap.set(s0, 2, "3") - -Belt.HashMap.get(s0, 2) != Belt.HashMap.get(s1, 2) -``` - -## get - -```res sig -let get: (t<'key, 'value, 'id>, 'key) => option<'value> -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") - -Belt.HashMap.get(s0, 1) == Some("value1") -Belt.HashMap.get(s0, 2) == None -``` - -## has - -```res sig -let has: (t<'key, 'value, 'id>, 'key) => bool -``` - -Checks if `x` is bound in `tbl`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") - -Belt.HashMap.has(s0, 1) == true -Belt.HashMap.has(s0, 2) == false -``` - -## remove - -```res sig -let remove: (t<'key, 'value, 'id>, 'key) => unit -``` - -If bound exists, removes it from the hash map. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.remove(s0, 1) -Belt.HashMap.has(s0, 1) == false -``` - -## forEachU - -```res sig -let forEachU: (t<'key, 'value, 'id>, (. 'key, 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -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)) -// prints (1, "value1") -``` - -## reduceU - -```res sig -let reduceU: (t<'key, 'value, 'id>, 'c, (. 'c, 'key, 'value) => 'c) => 'c -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```res sig -let reduce: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.reduce(s0, "", (acc, key, value) => acc ++ (", " ++ value)) == "value1, value2" -``` - -## keepMapInPlaceU - -```res sig -let keepMapInPlaceU: (t<'key, 'value, 'id>, (. 'key, 'value) => option<'value>) => unit -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```res sig -let keepMapInPlace: (t<'key, 'value, 'id>, ('key, 'value) => option<'value>) => unit -``` - -Filters out values for which function `f` returned `None`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.keepMapInPlace(s0, (key, value) => key == 1 ? None : Some(value)) -``` - -## size - -```res sig -let size: t<'a, 'b, 'c> => int -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.size(s0) == 2 -``` - -## toArray - -```res sig -let toArray: t<'key, 'value, 'id> => array<('key, 'value)> -``` - -Returns array of key value pairs. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.toArray(s0) == [(1, "value1"), (2, "value2")] -``` - -## keysToArray - -```res sig -let keysToArray: t<'key, 'a, 'b> => array<'key> -``` - -Returns array of keys. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.keysToArray(s0) == [1, 2] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a, 'value, 'b> => array<'value> -``` - -Returns array of values. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.valuesToArray(s0) == ["value1", "value2"] -``` - -## fromArray - -```res sig -let fromArray: (array<('key, 'value)>, ~id: id<'key, 'id>) => t<'key, 'value, 'id> -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(1, "value1"), (2, "value2")], ~id=module(IntHash)) -Belt.HashMap.toArray(s0) == [(1, "value1"), (2, "value2")] -``` - -## mergeMany - -```res sig -let mergeMany: (t<'key, 'value, 'id>, array<('key, 'value)>) => unit -``` - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.mergeMany(hMap, [(1, "1"), (2, "2")]) -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a, 'b, 'c> => array -``` - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(hMap, 1, "1") - -Belt.HashMap.getBucketHistogram(hMap) -``` - -## logStats - -```res sig -let logStats: t<'a, 'b, 'c> => unit -``` - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(hMap, 1, "1") - -Belt.HashMap.logStats(hMap) -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/hash-set-int.mdx b/pages/docs/manual/v10.0.0/api/belt/hash-set-int.mdx deleted file mode 100644 index d73d3f856..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/hash-set-int.mdx +++ /dev/null @@ -1,123 +0,0 @@ -# HashSetInt - - - -This module is `Belt.HashSet` specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with `Belt.HashSet` except its key type is fixed, and identity is not needed(using the built-in one). - - - -## key - -```res prelude -type key = int -``` - -## t - -```res prelude -type t -``` - -## make - -```res sig -let make: (~hintSize: int) => t -``` - -## clear - -```res sig -let clear: t => unit -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -## add - -```res sig -let add: (t, key) => unit -``` - -## copy - -```res sig -let copy: t => t -``` - -## has - -```res sig -let has: (t, key) => bool -``` - -## remove - -```res sig -let remove: (t, key) => unit -``` - -## forEachU - -```res sig -let forEachU: (t, (. key) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t, key => unit) => unit -``` - -## reduceU - -```res sig -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c -``` - -## reduce - -```res sig -let reduce: (t, 'c, ('c, key) => 'c) => 'c -``` - -## size - -```res sig -let size: t => int -``` - -## logStats - -```res sig -let logStats: t => unit -``` - -## toArray - -```res sig -let toArray: t => array -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t => array -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/hash-set-string.mdx b/pages/docs/manual/v10.0.0/api/belt/hash-set-string.mdx deleted file mode 100644 index 277d95228..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/hash-set-string.mdx +++ /dev/null @@ -1,123 +0,0 @@ -# HashSetString - - - -This module is `Belt.HashSet` specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with `Belt.HashSet` except its key type is fixed, and identity is not needed(using the built-in one). - - - -## key - -```res prelude -type key = string -``` - -## t - -```res prelude -type t -``` - -## make - -```res sig -let make: (~hintSize: int) => t -``` - -## clear - -```res sig -let clear: t => unit -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -## add - -```res sig -let add: (t, key) => unit -``` - -## copy - -```res sig -let copy: t => t -``` - -## has - -```res sig -let has: (t, key) => bool -``` - -## remove - -```res sig -let remove: (t, key) => unit -``` - -## forEachU - -```res sig -let forEachU: (t, (. key) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t, key => unit) => unit -``` - -## reduceU - -```res sig -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c -``` - -## reduce - -```res sig -let reduce: (t, 'c, ('c, key) => 'c) => 'c -``` - -## size - -```res sig -let size: t => int -``` - -## logStats - -```res sig -let logStats: t => unit -``` - -## toArray - -```res sig -let toArray: t => array -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t => array -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/hash-set.mdx b/pages/docs/manual/v10.0.0/api/belt/hash-set.mdx deleted file mode 100644 index d10a07ef2..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/hash-set.mdx +++ /dev/null @@ -1,160 +0,0 @@ -# HashSet - - - -A mutable Hash set which allows customized `hash` behavior. -All data are parameterized by not its only type but also a unique identity in the time of initialization, so that two HashSets of ints initialized with different hash functions will have different type. - - - -```res prelude -module I0 = unpack( - Belt.Id.hashableU( - ~hash=(. a: int) => land(a, 65535), - ~eq=(. a, b) => a == b, - ) -) - -let s0 = Belt.HashSet.make(~id=module(I0), ~hintSize=40) - -module I1 = unpack( - Belt.Id.hashableU( - ~hash=(. a: int) => land(a, 255), - ~eq=(. a, b) => a == b, - ) -) - -let s1 = Belt.HashSet.make(~id=module(I1), ~hintSize=40) - -Belt.HashSet.add(s1, 0) -Belt.HashSet.add(s1, 1) -``` - -The invariant must be held: for two elements who are equal, their hashed value should be the same. - -Here the compiler would infer `s0` and `s1` having different type so that it would not mix. - -```res sig -let s0: Belt.HashSet.t -let s1: Belt.HashSet.t -``` - -We can add elements to the collection (see last two lines in the example above). Since this is an mutable data structure, `s1` will contain two pairs. - -## t - -```res prelude -type t<'a, 'id> -``` - -## id - -```res prelude -type id<'a, 'id> = Belt.Id.hashable<'a, 'id> -``` - -## make - -```res sig -let make: (~hintSize: int, ~id: id<'a, 'id>) => t<'a, 'id> -``` - -## clear - -```res sig -let clear: t<'a, 'id> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -## add - -```res sig -let add: (t<'a, 'id>, 'a) => unit -``` - -## copy - -```res sig -let copy: t<'a, 'id> => t<'a, 'id> -``` - -## has - -```res sig -let has: (t<'a, 'id>, 'a) => bool -``` - -## remove - -```res sig -let remove: (t<'a, 'id>, 'a) => unit -``` - -## forEachU - -```res sig -let forEachU: (t<'a, 'id>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a, 'id>, 'a => unit) => unit -``` - -Order unspecified. - -## reduceU - -```res sig -let reduceU: (t<'a, 'id>, 'c, (. 'c, 'a) => 'c) => 'c -``` - -## reduce - -```res sig -let reduce: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c -``` - -Order unspecified. - -## size - -```res sig -let size: t<'a, 'id> => int -``` - -## logStats - -```res sig -let logStats: t<'a, 'b> => unit -``` - -## toArray - -```res sig -let toArray: t<'a, 'id> => array<'a> -``` - -## fromArray - -```res sig -let fromArray: (array<'a>, ~id: id<'a, 'id>) => t<'a, 'id> -``` - -## mergeMany - -```res sig -let mergeMany: (t<'a, 'id>, array<'a>) => unit -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a, 'b> => array -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/id.mdx b/pages/docs/manual/v10.0.0/api/belt/id.mdx deleted file mode 100644 index b8646dffe..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/id.mdx +++ /dev/null @@ -1,157 +0,0 @@ -# Id - - - -Provide utilities to create identified comparators or hashes for data -structures used below. - -It creates a unique identifier per module of functions so that different data -structures with slightly different comparison functions won't mix. - - - -## hash - -```res sig -type hash<'a, 'id> -``` - -Its runtime represenation is a hash function, but signed with a type parameter, so that different hash functions type mismatch. - -## eq - -```res sig -type eq<'a, 'id> -``` - -Its runtime represenation is an eq function, but signed with a type parameter, so that different hash functions type mismatch. - -## cmp - -```res sig -type cmp<'a, 'id> -``` - -Its runtime representation is a cmp function, but signed with a type parameter, so that different hash functions type mismatch. - -## Comparable - -```res prelude -module type Comparable = { - type identity - - type t - - let cmp: Belt.Id.cmp -} -``` - -## comparable - -```res sig -type comparable<'key,'id> = - module(Belt.Id.Comparable with type identity = 'id and type t = 'key) -``` - -is a module of functions, here it only includes cmp. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed by the type system). - -It can be created using function `Belt_Id.comparableU` or `Belt_Id.comparable`. - -The idea of a unique identity when created is that it makes sure two sets would type mismatch if they use different comparison function - -## MakeComparableU - -```res sig -module MakeComparableU: (M: { - type t - let cmp: (. t, t) => int -}) => Comparable with type t = M.t -``` - -## MakeComparable - -```res sig -module MakeComparable: (M: { - type t - let cmp: (t, t) => int -}) => Comparable with type t = M.t -``` - -## comparableU - -```res sig -let comparableU: (~cmp: (. 'a, 'a) => int) => - module(Belt.Id.Comparable with type t = 'a) -``` - -## comparable - -```res sig -type comparable<'key, 'id> = - module(Belt.Id.Comparable with type identity = 'id and type t = 'key) -``` - -## Hashable - -```res prelude -module type Hashable = { - type identity - - type t - - let hash: Belt.Id.hash - - let eq: Belt.Id.eq -} -``` - -## hashable - -```res sig -type hashable<'key, 'id> = - module(Belt.Id.Hashable with type identity = 'id and type t = 'key) -``` - -is a module of functions, here it only includes hash, eq. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed by the type system). - -It can be created using function `Belt_Id.hashableU` or `Belt_Id.hashable`. - -The idea of a unique identity when created is that it makes sure two hash sets would type mismatch if they use different comparison function. - -## MakeHashableU - -```res sig -module MakeHashableU: (M: { - type t - let hash: (. t) => int - let eq: (. t, t) => bool -}) => Hashable with type t = M.t -``` - -## MakeHashable - -```res sig -module MakeHashable: (M: { - type t - let hash: t => int - let eq: (t, t) => bool -}) => Hashable with type t = M.t -``` - -## hashableU - -```res sig -let hashableU: (~hash: (. 'a) => int, ~eq: (. 'a, 'a) => bool) => - module(Belt.Id.Hashable with type t = 'a) -``` - -## hashable - -```res sig -let hashable: (~hash: 'a => int, ~eq: ('a, 'a) => bool) => - module(Belt.Id.Hashable with type t = 'a) -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/int.mdx b/pages/docs/manual/v10.0.0/api/belt/int.mdx deleted file mode 100644 index 3e3a31c36..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/int.mdx +++ /dev/null @@ -1,103 +0,0 @@ -# Int - -This module includes convenience methods for handling `int` types. - -## toFloat - -```res sig -let toFloat: int => float -``` - -Converts a given `int` to a `float`. - -```res example -Js.log(Belt.Int.toFloat(1) === 1.0) /* true */ -``` - -## fromFloat - -```res sig -let fromFloat: float => int -``` - -Converts a given `float` to an `int`. - -```res example -Js.log(Belt.Int.fromFloat(1.0) === 1) /* true */ -``` - -## fromString - -```res sig -let fromString: string => option -``` - -Converts a given `string` to an `int`. Returns `Some(int)` when the input is a number, `None` otherwise. - -```res example -Js.log(Belt.Int.fromString("1") === Some(1)) /* true */ -``` - -## toString - -```res sig -let toString: int => string -``` - -Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood. - -```res example -Js.log(Belt.Int.toString(1) === "1") /* true */ -``` - -## + - -```re sig -let (+): (int, int) => int -``` - -Addition of two `int` values. Same as the addition from `Pervasives`. - -```res example -open Belt.Int -Js.log(2 + 2 === 4) /* true */ -``` - -## - - -```re sig -let (-): (int, int) => int -``` - -Subtraction of two `int` values. Same as the subtraction from `Pervasives`. - -```res example -open Belt.Int -Js.log(2 - 1 === 1) /* true */ -``` - -## \* - -```re sig -let (*): (int, int) => int -``` - -Multiplication of two `int` values. Same as the multiplication from `Pervasives`. - -```res example -open Belt.Int -Js.log(2 * 2 === 4) /* true */ -``` - -## / - -```re sig -let (/): (int, int) => int -``` - -Division of two `int` values. Same as the division from `Pervasives`. - -```res example -open Belt.Int -Js.log(4 / 2 === 2); /* true */ -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/list.mdx b/pages/docs/manual/v10.0.0/api/belt/list.mdx deleted file mode 100644 index fc1795883..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/list.mdx +++ /dev/null @@ -1,1124 +0,0 @@ -# List - - - -Collection functions for manipulating the `list` data structures, a singly-linked list. - -**Prefer Array** if you need any of the following: - -- Random access of element -- Better interop with JavaScript -- Better memory usage & performance. - - - -## t\<'a> - -```res prelude -type t<'a> = list<'a> -``` - -## length - -```res sig -let length: t<'a> => int -``` - -Returns the length of a list. - -```res example -Belt.List.length(list{1, 2, 3}) // 3 -``` - -## size - -```res sig -let size: t<'a> => int -``` - -**See:** list\{length}(#length) - -## head - -```res sig -let head: t<'a> => option<'a> -``` - -Returns `Some(value)` where `value` is the first element in the list, or `None` if `someList` is an empty list. - -```res example -Belt.List.head(list{}) // None -Belt.List.head(list{1, 2, 3}) // Some(1) -``` - -## headExn - -```res sig -let headExn: t<'a> => 'a -``` - -Same as [head](#head), but raises an exception if `someList` is empty. Use with care. - -```res example -Belt.List.headExn(list{1, 2, 3}) // 1 - -Belt.List.headExn(list{}) // Raises an Error -``` - -## tail - -```res sig -let tail: t<'a> => option> -``` - -Returns `None` if `someList` is empty, otherwise it returns `Some(tail)` where `tail` is everything except the first element of `someList`. - -```res example -Belt.List.tail(list{1, 2, 3}) // Some(list{2, 3}) - -Belt.List.tail(list{}) // None -``` - -## tailExn - -```res sig -let tailExn: t<'a> => t<'a> -``` - -Same as [tail](#tail), but raises an exception if `someList` is empty. Use with care. - -```res example -Belt.List.tailExn(list{1, 2, 3}) // list{2, 3} - -Belt.List.tailExn(list{}) // Raises an Error -``` - -## add - -```res sig -let add: (t<'a>, 'a) => t<'a> -``` - -Adds `value` to the beginning of `someList`. - -```res example -Belt.List.add(list{2, 3}, 1) // list{1, 2, 3} - -Belt.List.add(list{"World", "!"}, "Hello") // list{"Hello", "World", "!"} -``` - -## get - -```res sig -let get: (t<'a>, int) => option<'a> -``` - -Return the nth element in `someList`, or `None` if `index` is larger than the length. - -```res example -let abc = list{"A", "B", "C"} - -abc->Belt.List.get(1) // Some("B") - -abc->Belt.List.get(4) // None -``` - -## getExn - -```res sig -let getExn: (t<'a>, int) => 'a -``` - -Same as [get](#get), but raises an exception if `index` is larger than the length. Use with care. - -```res example -let abc = list{"A", "B", "C"} - -abc->Belt.List.getExn(1) // "B" - -abc->Belt.List.getExn(4) // Raises an Error -``` - -## make - -``` -let make: (int, 'a) => t<'a> -``` - -Returns a list of length `numItems` with each element filled with value `v`. Returns an empty list if `numItems` is negative. - -```res example -Belt.List.make(3, 1) // list{1, 1, 1} -``` - -## makeBy - -```res sig -let makeBy: (int, int => 'a) => t<'a> -``` - -Return a list of length `numItems` with element `i` initialized with `f(i)`. -Returns an empty list if `numItems` is negative. - -```res example -Belt.List.makeBy(5, i => i) // list{0, 1, 2, 3, 4} - -Belt.List.makeBy(5, i => i * i) // list{0, 1, 4, 9, 16} -``` - -## makeByU - -```res sig -let makeByU: (int, (. int) => 'a) => t<'a> -``` - -Uncurried version of [makeBy](#makeBy) - -## shuffle - -```res sig -let shuffle: t<'a> => t<'a> -``` - -Returns a new list in random order. - -```res example -Belt.List.shuffle(list{1, 2, 3}) // list{2, 1, 3} -``` - -## drop - -```res sig -let drop: (t<'a>, int) => option> -``` - -Return a new list, dropping the first `n` elements. Returns `None` if `someList` has fewer than `n` elements. - -```res example -list{1, 2, 3}->Belt.List.drop(2) // Some(list{3}) - -list{1, 2, 3}->Belt.List.drop(3) // Some(list{}) - -list{1, 2, 3}->Belt.List.drop(4) // None -``` - -## take - -```res sig -let take: (t<'a>, int) => option> -``` - -Returns a list with the first `n` elements from `someList`, or `None` if `someList` has fewer than `n` elements. - -```res example -list{1, 2, 3}->Belt.List.take(1) // Some(list{1}) - -list{1, 2, 3}->Belt.List.take(2) // Some(list{1, 2}) - -list{1, 2, 3}->Belt.List.take(4) // None -``` - -## splitAt - -```res sig -let splitAt: (t<'a>, int) => option<(list<'a>, list<'a>)> -``` - -Split the list `someList` at `index`. Returns `None` when the length of `someList` is less than `index`. - -```res example -list{"Hello", "World"}->Belt.List.splitAt(1) // Some((list{"Hello"}, list{"World"})) - -list{0, 1, 2, 3, 4}->Belt.List.splitAt(2) // Some((list{0, 1}, list{2, 3, 4})) -``` - -## concat - -```res sig -let concat: (t<'a>, t<'a>) => t<'a> -``` - -Returns the list obtained by adding `secondList` after `firstList`. - -```res example -Belt.List.concat(list{1, 2, 3}, list{4, 5}) // list{1, 2, 3, 4, 5} -``` - -## concatMany - -```res sig -let concatMany: array> => t<'a> -``` - -Returns the list obtained by concatenating all the lists in array `a`, in order. - -```res example -Belt.List.concatMany([list{1, 2, 3}, list{}, list{3}]) // list{1, 2, 3, 3} -``` - -## reverseConcat - -```res sig -let reverseConcat: (t<'a>, t<'a>) => t<'a> -``` - -Equivalent to writing: `concat(reverse(firstList, secondList)` - -```res example -Belt.List.reverseConcat(list{1, 2}, list{3, 4}) // list{2, 1, 3, 4} -``` - -## flatten - -```res sig -let flatten: t> => t<'a> -``` - -Return the list obtained by concatenating all the lists in list `ls`, in order. - -```res example -Belt.List.flatten(list{list{1, 2, 3}, list{}, list{3}}) // list{1, 2, 3, 3} -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -Returns a new list with `f` applied to each element of `someList`. - -```res example -list{1, 2}->Belt.List.map(x => x + 1) // list{3, 4} -``` - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -Uncurried version of [map](#map). - -## zip - -```res sig -let zip: (t<'a>, t<'b>) => t<('a, 'b)> -``` - -Returns a list of pairs from the two lists with the length of the shorter list. - -```res example -Belt.List.zip(list{1, 2}, list{3, 4, 5}) // list{(1, 3), (2, 4)} -``` - -## zipBy - -```res sig -let zipBy: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> -``` - -**See:** [zip](#zip) - -```res example -Belt.List.zipBy(list{1, 2, 3}, list{4, 5}, (a, b) => 2 * a + b) // list{6, 9} -``` - -## zipByU - -```res sig -let zipByU: (t<'a>, t<'b>, (. 'a, 'b) => 'c) => t<'c> -``` - -Uncurried version of [zipBy](#zipBy). - -## mapWithIndex - -```res sig -let mapWithIndex: (t<'a>, (int, 'a) => 'b) => t<'b> -``` - -Applies `f` to each element of `someList`. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`, in that order. - -```res example -list{1, 2, 3}->Belt.List.mapWithIndex((index, x) => index + x) // list{1, 3, 5} -``` - -## mapWithIndexU - -```res sig -let mapWithIndexU: (t<'a>, (. int, 'a) => 'b) => t<'b> -``` - -Uncurried version of [mapWithIndex](#mapWithIndex). - -## fromArray - -```res sig -let fromArray: array<'a> => t<'a> -``` - -Converts the given array to a list. - -```res example -Belt.List.fromArray([1, 2, 3]) // list{1, 2, 3} -``` - -## toArray - -```res sig -let toArray: t<'a> => array<'a> -``` - -Converts the given list to an array. - -```res example -Belt.List.toArray(list{1, 2, 3}) // [1, 2, 3] -``` - -## reverse - -```res sig -let reverse: t<'a> => t<'a> -``` - -Returns a new list whose elements are those of `someList` in reversed order. - -```res example -Belt.List.reverse(list{1, 2, 3}) /* list{3, 2, 1} */ -``` - -## mapReverse - -```res sig -let mapReverse: (t<'a>, 'a => 'b) => t<'b> -``` - -Equivalent to: - -```res -map(someList, f)->reverse -``` - -```res example -list{3, 4, 5}->Belt.List.mapReverse(x => x * x) /* list{25, 16, 9} */ -``` - -## mapReverseU - -```res sig -let mapReverseU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -Uncurried version of [mapReverse](#mapReverse). - -## forEach - -```res sig -let forEach: (t<'a>, 'a => 'b) => unit -``` - -Call `f` on each element of `someList` from the beginning to end. -`f` returns `unit`, so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects. - -```res example -Belt.List.forEach(list{"a", "b", "c"}, x => Js.log("Item: " ++ x)) -/* - prints: - Item: a - Item: b - Item: c -*/ -``` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. 'a) => 'b) => unit -``` - -Uncurried version of [forEach](#forEach). - -## forEachWithIndex - -```res sig -let forEachWithIndex: (t<'a>, (int, 'a) => 'b) => unit -``` - -Call `f` on each element of `someList` from beginning to end. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`. `f` returns `unit`. - -```res example -Belt.List.forEachWithIndex(list{"a", "b", "c"}, (index, x) => { - Js.log("Item " ++ Belt.Int.toString(index) ++ " is " ++ x) -}) -/* - prints: - Item 0 is a - Item 1 is b - Item 2 is cc -*/ -``` - -## forEachWithIndexU - -```res sig -let forEachWithIndexU: (t<'a>, (. int, 'a) => 'b) => unit -``` - -Uncurried version of [forEachWithIndex](#forEachWithIndex). - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -Applies `f` to each element of `someList` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue`. reduce returns the final value of the accumulator. - -```res example -list{1, 2, 3, 4}->Belt.List.reduce(0, (a, b) => a + b) /* 10 */ - -/* same as */ - -list{1, 2, 3, 4}->Belt.List.reduce(0, (acc, item) => acc + item) /* 10 */ -``` - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b -``` - -Uncurried version of [reduce](#reduce). - -## reduceWithIndex - -```res sig -let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b -``` - -Applies `f` to each element of `someList` from beginning to end. Function `f` has three parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue` and the index of each element. `reduceWithIndex` returns the final value of the accumulator. - -```res example -list{1, 2, 3, 4}->Belt.List.reduceWithIndex(0, (acc, item, index) => acc + item + index) /* 16 */ -``` - -## reduceWithIndexU - -```res sig -let reduceWithIndexU: (t<'a>, 'b, (. 'b, 'a, int) => 'b) => 'b -``` - -Uncurried version of [reduceWithIndex](#reduceWithIndex). - -## reduceReverse - -```res sig -let reduceReverse: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -Works like [reduce](#reduce), except that function `f` is applied to each item of `someList` from the last back to the first. - -```res example -list{1, 2, 3, 4}->Belt.List.reduceReverse(0, (a, b) => a + b) /* 10 */ - -list{1, 2, 3, 4}->Belt.List.reduceReverse(10, (a, b) => a - b) /* 0 */ - -list{1, 2, 3, 4}->Belt.List.reduceReverse(list{}, Belt.List.add) // list{1, 2, 3, 4} -``` - -## reduceReverseU - -```res sig -let reduceReverseU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -Uncurried version of [reduceReverse](#reduceReverse). - -## mapReverse2 - -```res sig -let mapReverse2: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> -``` - -Equivalent to: `zipBy(xs, ys, f)->reverse` - -```res example - -Belt.List.mapReverse2(list{1, 2, 3}, list{1, 2}, (a, b) => a + b) // list{4, 2} -``` - -## mapReverse2U - -```res sig -let mapReverse2U: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> -``` - -Uncurried version of [mapReverse2](#mapReverse2). - -## forEach2 - -```res sig -let forEach2: (t<'a>, t<'b>, ('a, 'b) => 'c) => unit -``` - -Stops at the length of the shorter list. - -```res example -Belt.List.forEach2(list{"Z", "Y"}, list{"A", "B", "C"}, (x, y) => Js.log2(x, y)) - -/* - prints: - "Z" "A" - "Y" "B" -*/ -``` - -## forEach2U - -```res sig -let forEach2U: (t<'a>, t<'b>, (.'a, 'b) => 'c) => unit -``` - -Uncurried version of [forEach2](#forEach2). - -## reduce2 - -```res sig -let reduce2: (t<'b>, t<'c>, 'a, ('a, 'b, 'c) => 'a) => 'a -``` - -Applies `f` to each element of `firstList` and `secondList` from beginning to end. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of `initialValue`, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator. - -```res example -Belt.List.reduce2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* 0 + (1 * 1 + 4) + (2 * 2 + 5) */ -``` - -## reduce2U - -```res sig -let reduce2U: (t<'b>, t<'c>, 'a, (.'a, 'b, 'c) => 'a) => 'a -``` - -Uncurried version of [reduce2](#reduce2). - -## reduceReverse2 - -```res sig -let reduceReverse2: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c -``` - -Applies `f` to each element of `firstList` and `secondList` from end to beginning. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of init, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator. - -```res example -Belt.List.reduceReverse2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* + (1 * 1 + 4) + (2 * 2 + 5) */ -``` - -## reduceReverse2U - -```res sig -let reduceReverse2U: (t<'a>, t<'b>, 'c, (.'c, 'a, 'b) => 'c) => 'c -``` - -Uncurried version of [reduceReverse2](#reduceReverse2). - -## every - -```res sig -let every: (t<'a>, 'a => bool) => bool -``` - -Returns `true` if all elements satisfy `pred`, where `pred` is a predicate: a function taking an element and returning a bool. - -```res example -let isBelow10 = value => value < 10 - -list{1, 9, 8, 2}->Belt.List.every(isBelow10) /* true */ - -list{1, 99, 8, 2}->Belt.List.every(isBelow10) /* false */ -``` - -## everyU - -```res sig -let everyU: (t<'a>, (.'a) => bool) => bool -``` - -Uncurried version of [every](#every). - -## some - -```res sig -let some: (t<'a>, 'a => bool) => bool -``` - -Returns `true` if at least _one_ of the elements in `someList` satisfies `pred`, where `pred` is a predicate: a function taking an element and returning a bool. - -```res example -let isAbove100 = value => value > 100 - -list{101, 1, 2, 3}->Belt.List.some(isAbove100) /* true */ - -list{1, 2, 3, 4}->Belt.List.some(isAbove100) /* false */ -``` - -## someU - -```res sig -let someU: (t<'a>, (. 'a) => bool) => bool -``` - -Uncurried version of [some](#some). - -## every2 - -```res sig -let every2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool -``` - -Returns `true` if predicate `pred(a, b)` is `true` for all pairs of elements up to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -```res example -Belt.List.every2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{2, 3}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* false */ -``` - -## every2U - -```res sig -let every2U: (t<'a>, t<'b>, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [every2](#every2). - -## some2 - -```res sig -let some2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool -``` - -Returns `true` if predicate `pred(a, b)` is true for any pair of elements up to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -```res example -Belt.List.some2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */ - -Belt.List.some2(list{}, list{1}, (a, b) => a > b) /* false */ - -Belt.List.some2(list{2, 3}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.some2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* true */ -``` - -## some2U - -```res sig -let some2U: (t<'a>, t<'b>, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [some2](#some2). - -## cmpByLength - -```res sig -let cmpByLength: (t<'a>, t<'a>) => int -``` - -```res -cmpByLength(firstList, secondList) -``` - -Compare two lists solely by length. Returns `-1` if `length(firstList)` is less than `length(secondList)`, `0` if `length(firstList)` equals `length(secondList)`, and `1` if `length(firstList)` is greater than `length(secondList)`. - -```res example -Belt.List.cmpByLength(list{1, 2}, list{3, 4, 5, 6}) /* -1 */ - -Belt.List.cmpByLength(list{1, 2, 3}, list{4, 5, 6}) /* = 0 */ - -Belt.List.cmpByLength(list{1, 2, 3, 4}, list{5, 6}) /* = 1 */ -``` - -## cmp - -```res sig -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -``` - -Compare elements one by one `compareFn(a, b)`. `compareFn` returns a negative number if `a` is "less than" `b`, zero if `a` is "equal to" `b`, a positive number if `a` is "greater than" `b`. - -The comparison returns the first non-zero result of `compareFn`, or zero if `compareFn` returns zero for all `a` and `b`. - -If all items have compared equal, but `firstList` is exhausted first, return `-1`. (`firstList` is shorter). -If all items have compared equal, but `secondList` is exhausted first, return `1` (`firstList` is longer). - -```res example -Belt.List.cmp(list{3}, list{3, 7}, (a, b) => compare(a, b)) /* (-1) */ - -Belt.List.cmp(list{5, 3}, list{5}, (a, b) => compare(a, b)) /* 1 */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 4, 2}, (a, b) => compare(a, b)) /* (-1) */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 2, 3}, (a, b) => compare(a, b)) /* 1 */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 3, 5}, (a, b) => compare(a, b)) /* 0 */ -``` - -**Please note:** The total ordering of List is different from Array, -for Array, we compare the length first and, only if the lengths are equal, elements one by one. -For lists, we just compare elements one by one. - -## cmpU - -```res sig -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int -``` - -Uncurried version of [cmp](#cmp). - -## eq - -```res sig -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -``` - -Check equality of `firstList` and `secondList` using `eqElem` for equality on elements, where `eqElem` is a function that returns `true` if items `x` and `y` meet some criterion for equality, `false` otherwise. eq `false` if length of `firstList` and `secondList` are not the same. - -```res example -Belt.List.eq(list{1, 2, 3}, list{1, 2}, (a, b) => a == b) /* false */ - -Belt.List.eq(list{1, 2}, list{1, 2}, (a, b) => a == b) /* true */ - -Belt.List.eq(list{1, 2, 3}, list{(-1), (-2), (-3)}, (a, b) => abs(a) == abs(b)) /* true */ -``` - -## eqU - -```res sig -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool -``` - -Uncurried version of [eq](#eq). - -## has - -```res sig -let has: (t<'a>, 'b, ('a, 'b) => bool) => bool -``` - -Returns `true` if the list contains at least one element for which `eqFunction(x)` returns true. - -```res example -list{1, 2, 3}->Belt.List.has(2, (a, b) => a == b) /* true */ - -list{1, 2, 3}->Belt.List.has(4, (a, b) => a == b) /* false */ - -list{(-1), (-2), (-3)}->Belt.List.has(2, (a, b) => abs(a) == abs(b)) /* true */ -``` - -## hasU - -```res sig -let hasU: (t<'a>, 'b, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [has](#has). - -## getBy - -```res sig -let getBy: (t<'a>, 'a => bool) => option<'a> -``` - -Returns `Some(value)` for the first value in `someList` that satisfies the predicate function `pred`. Returns `None` if no element satisfies the function. - -```res example -Belt.List.getBy(list{1, 4, 3, 2}, x => x > 3) /* Some(4) */ - -Belt.List.getBy(list{1, 4, 3, 2}, x => x > 4) /* None */ -``` - -## getByU - -```res sig -let getByU: (t<'a>, (. 'a) => bool) => option<'a> -``` - -Uncurried version of [getBy](#getBy). - -## keep - -```res sig -let keep: (t<'a>, 'a => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.keep(list{1, 2, 3, 4}, isEven) /* list{2, 4} */ - -Belt.List.keep(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */ -``` - -## keepU - -```res sig -let keepU: (t<'a>, (. 'a) => bool) => t<'a> -``` - -Uncurried version of [keep](#keep). - -## filter - -```res sig -let filter: (t<'a>, 'a => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.filter(list{1, 2, 3, 4}, isEven) /* list{2, 4} */ - -Belt.List.filter(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */ -``` - -## keepWithIndex - -```res sig -let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.keepWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */ -``` - -## keepWithIndexU - -```res sig -let keepWithIndexU: (t<'a>, (. 'a, int) => bool) => t<'a> -``` - -Uncurried version of [keepWithIndex](#keepWithIndex). - -## filterWithIndex - -```res sig -let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.filterWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */ -``` - -## keepMap - -```res sig -let keepMap: (t<'a>, 'a => option<'b>) => t<'b> -``` - -Applies `f` to each element of `someList`. If `f(x)` returns `Some(value)`, then `value` is _kept_ in the resulting list. -If `f(x)` returns `None`, the element is _not_ retained in the result. - -```res example -let isEven = x => mod(x, 2) == 0 - -list{1, 2, 3, 4} -->Belt.List.keepMap(x => - if (isEven(x)) { - Some(x) - } else { - None - } - ) /* list{2, 4} */ - -list{Some(1), Some(2), None}->Belt.List.keepMap(x => x) /* list{1, 2} */ -``` - -## keepMapU - -```res sig -let keepMapU: (t<'a>, (. 'a) => option<'b>) => t<'b> -``` - -Uncurried version of [keepMap](#keepMap). - -## partition - -```res sig -let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>) -``` - -Creates a pair of lists; the first list consists of all elements of `someList` that satisfy the predicate function `pred`; the second list consists of all elements of `someList` that _do not_ satisfy `pred. - -In other words: - -```res -(elementsThatSatisfies, elementsThatDoesNotSatisfy) -``` - -```res example -Belt.List.partition(list{1, 2, 3, 4}, x => x > 2) /* (list{3, 4}, list{1, 2}) */ -``` - -## partitionU - -```res sig -let partitionU: (t<'a>, (. 'a) => bool) => (t<'a>, t<'a>) -``` - -Uncurried version of [partition](#partition). - -## unzip - -```res sig -let unzip: t<('a, 'b)> => (t<'a>, t<'b>) -``` - -Takes a list of pairs and creates a pair of lists. The first list contains all the first items of the pairs; the second list contains all the second items. - -```res example -Belt.List.unzip(list{(1, 2), (3, 4)}) /* (list{1, 3}, list{2, 4}) */ - -Belt.List.unzip(list{("H", "W"), ("e", "o"), ("l", "r"), ("l", "l"), ("o", "d"), (" ", "!")}) -/* (list{"H", "e", "l", "l", "o", " "}, list{"W", "o", "r", "l", "d", "!"}) */ -``` - -## getAssoc - -```res sig -let getAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c> -``` - -Return the second element of a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`, or `None` if not found. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.getAssoc(3, (a, b) => a == b) /* Some("c") */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.getAssoc(15, (k, item) => k /* 15 */ == item /* 9, 5, 22 */) -/* Some("afternoon") */ -``` - -## getAssocU - -```res sig -let getAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => option<'c> -``` - -Uncurried version of [getAssoc](#getAssoc). - -## hasAssoc - -```res sig -let hasAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => bool -``` - -Returns `true` if there is a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.hasAssoc(1, (a, b) => a == b) /* true */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */) /* false */ -``` - -## hasAssocU - -```res sig -let hasAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [hasAssoc](#hasAssoc). - -## removeAssoc - -```res sig -let removeAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => t<('a, 'c)> -``` - -Return a list after removing the first pair whose first value is `k` per the equality predicate `eqFunction`; if not found, return a new list identical to `someList`. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.removeAssoc(1, (a, b) => a == b) /* list{(2, "b"), (3, "c")} */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.removeAssoc(9, (k, item) => k /* 9 */ == item /* 9, 5, 22 */) -/* list{(15, "afternoon"), (22, "night")} */ -``` - -## removeAssocU - -```res sig -let removeAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => t<('a, 'c)> -``` - -Uncurried version of [removeAssoc](#removeAssoc). - -## setAssoc - -```res sig -let setAssoc: (t<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => t<('a, 'c)> -``` - -If `k` exists in `someList` by satisfying the `eqFunction` predicate, return a new list with the key and value replaced by the new `k` and `v`; otherwise, return a new list with the pair `k`, `v` added to the head of `someList`. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.setAssoc(2, "x", (a, b) => a == b) /* list{(1, "a"), (2, "x"), (3, "c")} */ - -list{(1, "a"), (3, "c")}->Belt.List.setAssoc(2, "b", (a, b) => a == b) /* list{(2, "b"), (1, "a"), (3, "c")} */ - -list{(9, "morning"), (3, "morning?!"), (22, "night")} -->Belt.List.setAssoc(15, "afternoon", (a, b) => mod(a, 12) == mod(b, 12)) -/* list{(9, "morning"), (15, "afternoon"), (22, "night")} */ -``` - -**Please note** - -In the last example, since: `15 mod 12` equals `3 mod 12` - -Both the key _and_ the value are replaced in the list. - -## setAssocU - -```res sig -let setAssocU: (t<('a, 'c)>, 'a, 'c, (. 'a, 'a) => bool) => t<('a, 'c)> -``` - -Uncurried version of [setAssoc](#setAssoc). - -## sort - -```res sig -let sort: (t<'a>, ('a, 'a) => int) => t<'a> -``` - -Returns a sorted list. - -```res example -Belt.List.sort(list{5, 4, 9, 3, 7}, (a, b) => a - b) // list{3, 4, 5, 7, 9} -``` - -## sortU - -```res sig -let sortU: (t<'a>, (. 'a, 'a) => int) => t<'a> -``` - -Uncurried version of [sort](#sort). diff --git a/pages/docs/manual/v10.0.0/api/belt/map-dict.mdx b/pages/docs/manual/v10.0.0/api/belt/map-dict.mdx deleted file mode 100644 index 4a9828f50..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/map-dict.mdx +++ /dev/null @@ -1,397 +0,0 @@ -# MapDict - - - -This module separates identity from data, it is a bit more verbose but slightly more efficient due to the fact that there is no need to pack identity and data back after each operation - -**_Advanced usage only_** - - - -## t - -```res prelude -type t<'key, 'value, 'id> -``` - -## cmp - -```res prelude -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> -``` - -## empty - -```res sig -let empty: t<'k, 'v, 'id> -``` - -## isEmpty - -```res sig -let isEmpty: t<'k, 'v, 'id> => bool -``` - -## has - -```res sig -let has: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int -``` - -## eqU - -```res sig -let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, cmp)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `cmp` is the equality predicate used to compare the data associated with the keys. - -## findFirstByU - -```res sig -let findFirstByU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => option<('k, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Map.Dict.fromArray([(4, "4"), (1, "1"), (2, "2"), (3, "3")], ~cmp=IntCmp.cmp) - -Belt.Map.Dict.findFirstBy(s0, (k, _) => k == 4) == Some((4, "4")) -``` - -## forEachU - -```res sig -let forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b -``` - -`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'k, 'a, 'id> => int -``` - -## toList - -```res sig -let toList: t<'k, 'a, 'id> => list<('k, 'a)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'k, 'a, 'id> => array<('k, 'a)> -``` - -## fromArray - -```res sig -let fromArray: (array<('k, 'a)>, ~cmp: cmp<'k, 'id>) => t<'k, 'a, 'id> -``` - -## keysToArray - -```res sig -let keysToArray: t<'k, 'a, 'id> => array<'k> -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'k, 'a, 'id> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'k, 'a, 'b> => option<'k> -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## maxKey - -```res sig -let maxKey: t<'k, 'a, 'b> => option<'k> -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## minimum - -```res sig -let minimum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## get - -```res sig -let get: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a, ~cmp: cmp<'k, 'id>) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b, 'c> => unit -``` - -## remove - -```res sig -let remove: (t<'a, 'b, 'id>, 'a, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```res sig -let removeMany: (t<'a, 'b, 'id>, array<'a>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -## set - -```res sig -let set: (t<'a, 'b, 'id>, 'a, 'b, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: ( - t<'a, 'b, 'id>, - 'a, - (. option<'b>) => option<'b>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'b, 'id> -``` - -## update - -```res sig -let update: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -## mergeU - -```res sig -let mergeU: ( - t<'a, 'b, 'id>, - t<'a, 'c, 'id>, - (. 'a, option<'b>, option<'c>) => option<'d>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'd, 'id> -``` - -## merge - -```res sig -let merge: ( - t<'a, 'b, 'id>, - t<'a, 'c, 'id>, - ('a, option<'b>, option<'c>) => option<'d>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'd, 'id> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```res sig -let mergeMany: (t<'a, 'b, 'id>, array<('a, 'b)>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -## keepU - -```res sig -let keepU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => t<'k, 'a, 'id> -``` - -## keep - -```res sig -let keep: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id> -``` - -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. - -## partitionU - -```res sig -let partitionU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) -``` - -## partition - -```res sig -let partition: (t<'k, 'a, 'id>, ('k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```res sig -let split: ( - t<'a, 'b, 'id>, - 'a, - ~cmp: cmp<'a, 'id>, -) => ((t<'a, 'b, 'id>, t<'a, 'b, 'id>), option<'b>) -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of `m` whose key is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id> -``` - -## map - -```res sig -let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/map-int.mdx b/pages/docs/manual/v10.0.0/api/belt/map-int.mdx deleted file mode 100644 index 0c63212e7..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/map-int.mdx +++ /dev/null @@ -1,373 +0,0 @@ -# MapInt - - - -Specialized when key type is `int`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison - - - -## key - -```res prelude -type key = int -``` - -## t - -```res prelude -type t<'value> -``` - -The type of maps from type `key` to type `'value`. - -## empty - -```res sig -let empty: t<'v> -``` - -## isEmpty - -```res sig -let isEmpty: t<'v> => bool -``` - -## has - -```res sig -let has: (t<'v>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'v>, t<'v>, (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int -``` - -## eqU - -```res sig -let eqU: (t<'v>, t<'v>, (. 'v, 'v) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool -``` - -`eq(m1,m2)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. - -## findFirstByU - -```res sig -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -let s0 = Belt.Map.Int.fromArray([(4, "4"), (1, "1"), (2, "2"), (3, "3")]) - -Belt.Map.Int.findFirstBy(s0, (k, v) => k == 4) == Some((4, "4")) -``` - -## forEachU - -```res sig -let forEachU: (t<'v>, (. key, 'v) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'v>, (key, 'v) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'v>, 'v2, (. 'v2, key, 'v) => 'v2) => 'v2 -``` - -## reduce - -```res sig -let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 -``` - -`reduce(m, a, f)` computes `f(kN, dN, ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## every - -```res sig -let every: (t<'v>, (key, 'v) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## some - -```res sig -let some: (t<'v>, (key, 'v) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'v> => int -``` - -## toList - -```res sig -let toList: t<'v> => list<(key, 'v)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'v> => array<(key, 'v)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'v)> => t<'v> -``` - -## keysToArray - -```res sig -let keysToArray: t<'v> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'v> => array<'v> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'v> => option<(key, 'v)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## maximum - -```res sig -let maximum: t<'v> => option<(key, 'v)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## get - -```res sig -let get: (t<'v>, key) => option<'v> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'v>, key) => Js.undefined<'v> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'v>, key, 'v) => 'v -``` - -## getExn - -```res sig -let getExn: (t<'v>, key) => 'v -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -**raise** when invariant is not held - -## remove - -```res sig -let remove: (t<'v>, key) => t<'v> -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```res sig -let removeMany: (t<'v>, array) => t<'v> -``` - -## set - -```res sig -let set: (t<'v>, key, 'v) => t<'v> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'v>, key, (. option<'v>) => option<'v>) => t<'v> -``` - -## update - -```res sig -let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> -``` - -## mergeU - -```res sig -let mergeU: (t<'v>, t<'v2>, (. key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -## merge - -```res sig -let merge: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```res sig -let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v> -``` - -## keepU - -```res sig -let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> -``` - -## keep - -```res sig -let keep: (t<'v>, (key, 'v) => bool) => t<'v> -``` - -## partitionU - -```res sig -let partitionU: (t<'v>, (. key, 'v) => bool) => (t<'v>, t<'v>) -``` - -## partition - -```res sig -let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```res sig -let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>) -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of `m` whose key is strictly greater than `x`; `data` is `None` if m contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'v>, (. 'v) => 'v2) => t<'v2> -``` - -## map - -```res sig -let map: (t<'v>, 'v => 'v2) => t<'v2> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'v>, (. key, 'v) => 'v2) => t<'v2> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/map-string.mdx b/pages/docs/manual/v10.0.0/api/belt/map-string.mdx deleted file mode 100644 index c74b488a3..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/map-string.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# Map.String - - - -Specialized when key type is `string`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison - - - -## key - -```res prelude -type key = string -``` - -## t - -```res prelude -type t<'value> -``` - -The type of maps from type `key` to type `'value`. - -## empty - -```res sig -let empty: t<'v> -``` - -## isEmpty - -```res sig -let isEmpty: t<'v> => bool -``` - -## has - -```res sig -let has: (t<'v>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'v>, t<'v>, (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int -``` - -## eqU - -```res sig -let eqU: (t<'v>, t<'v>, (. 'v, 'v) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool -``` - -`eq(m1, m2)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. - -## findFirstByU - -```res sig -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -let s0 = Belt.Map.String.fromArray([("4", 4), ("1", 1), ("2", 2), ("3", 3)]) - -Belt.Map.String.findFirstBy(s0, (k, _) => k == "4") == Some(("4", 4)) -``` - -## forEachU - -```res sig -let forEachU: (t<'v>, (. key, 'v) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'v>, (key, 'v) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'v>, 'v2, (. 'v2, key, 'v) => 'v2) => 'v2 -``` - -## reduce - -```res sig -let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 -``` - -`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...), where k1 ... kN)` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## every - -```res sig -let every: (t<'v>, (key, 'v) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## some - -```res sig -let some: (t<'v>, (key, 'v) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'v> => int -``` - -## toList - -```res sig -let toList: t<'v> => list<(key, 'v)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'v> => array<(key, 'v)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'v)> => t<'v> -``` - -## keysToArray - -```res sig -let keysToArray: t<'v> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'v> => array<'v> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'v> => option<(key, 'v)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## maximum - -```res sig -let maximum: t<'v> => option<(key, 'v)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## get - -```res sig -let get: (t<'v>, key) => option<'v> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'v>, key) => Js.undefined<'v> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'v>, key, 'v) => 'v -``` - -## getExn - -```res sig -let getExn: (t<'v>, key) => 'v -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -**raise** when invariant is not held - -## remove - -```res sig -let remove: (t<'v>, key) => t<'v> -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```res sig -let removeMany: (t<'v>, array) => t<'v> -``` - -## set - -```res sig -let set: (t<'v>, key, 'v) => t<'v> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'v>, key, (. option<'v>) => option<'v>) => t<'v> -``` - -## update - -```res sig -let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> -``` - -## mergeU - -```res sig -let mergeU: (t<'v>, t<'v2>, (. key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -## merge - -```res sig -let merge: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```res sig -let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v> -``` - -## keepU - -```res sig -let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> -``` - -## keep - -```res sig -let keep: (t<'v>, (key, 'v) => bool) => t<'v> -``` - -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. - -## partitionU - -```res sig -let partitionU: (t<'v>, (. key, 'v) => bool) => (t<'v>, t<'v>) -``` - -## partition - -```res sig -let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of s that do not satisfy `p`. - -## split - -```res sig -let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>) -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of m whose key is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'v>, (. 'v) => 'v2) => t<'v2> -``` - -## map - -```res sig -let map: (t<'v>, 'v => 'v2) => t<'v2> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'v>, (. key, 'v) => 'v2) => t<'v2> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/map.mdx b/pages/docs/manual/v10.0.0/api/belt/map.mdx deleted file mode 100644 index ba31ca263..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/map.mdx +++ /dev/null @@ -1,649 +0,0 @@ -# Map - -The top level provides generic immutable map operations. - -It also has three specialized inner modules `Belt.Map.Int`, `Belt.Map.String` and `Belt.Map.Dict`. - -## t - -```res prelude -type t<'key, 'value, 'identity> -``` - -`'key` is the field type - -`'value` is the element type - -`'identity` the identity of the collection - -## id - -```res prelude -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -``` - -The identity needed for making an empty map. - -## make - -```res sig -let make: (~id: id<'k, 'id>) => t<'k, 'v, 'id> -``` - -`make(~id)` creates a new map by taking in the comparator. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let m = Belt.Map.make(~id=module(IntCmp)) - -Belt.Map.set(m, 0, "a") -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b, 'c> => bool -``` - -`isEmpty(m)` checks whether a map m is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.isEmpty(Belt.Map.fromArray([(1, "1")], ~id=module(IntCmp))) == false -``` - -## has - -```res sig -let has: (t<'k, 'v, 'id>, 'k) => bool -``` - -`has(m, k)` checks whether `m` has the key `k`. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.has(Belt.Map.fromArray([(1, "1")], ~id=module(IntCmp)), 1) == true -``` - -## cmpU - -```res sig -let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int -``` - -`cmp(m0, m1, vcmp);` - -Total ordering of map given total ordering of value function. - -It will compare size first and each element following the order one by one. - -## eq - -```res sig -let eqU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, (. 'v, 'v) => bool) => bool -``` - -`eq(m1, m2, veq)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `veq` is the equality predicate used to compare the data associated with the keys. - -## eq - -```res sig -let eq: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool -``` - -## findFirstByU - -```res sig -let findFirstByU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => option<('k, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "")]) - -Belt.Map.findFirstBy(s0, (k, v) => k == 4) /* (4, "4") */ -``` - -## forEachU - -```res sig -let forEachU: (t<'k, 'v, 'id>, (. 'k, 'v) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "")]) - -let acc = ref(list{}) - -Belt.Map.forEach(s0, (k, v) => acc := list{(k, v), ...acc.contents}) - -acc.contents == list{(4, "4"), (3, "3"), (2, "2"), (1, "1")} -``` - -## reduceU - -```res sig -let reduceU: (t<'k, 'v, 'id>, 'acc, (. 'acc, 'k, 'v) => 'acc) => 'acc -``` - -## reduce - -```res sig -let reduce: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc -``` - -`reduce(m, a, f)` computes `(f(kN, dN) ... (f(k1, d1, a))...)`, where `k1 ... kN` are the keys of all bindings in m (in increasing order), and `d1 ... dN` are the associated data. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "3")]) - -Belt.Map.reduce(s0, list{}, (acc, k, v) => list{ - (k, v), - ...acc, -}) /* [(4, "4"), (3, "3"), (2, "2"), (1, "1"), 0] */ -``` - -## everyU - -```res sig -let everyU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => bool -``` - -## every - -```res sig -let every: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => bool -``` - -## some - -```res sig -let some: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'k, 'v, 'id> => int -``` - -`size(s)` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.size(Belt.Map.fromArray([(2, "2"), (2, "1"), (3, "3")], ~id=module(IntCmp))) == 2 -``` - -## toArray - -```res sig -let toArray: t<'k, 'v, 'id> => array<('k, 'v)> -``` - -`toArray(s)` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.toArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - (1, "1"), - (2, "2"), - (3, "3"), - ] -``` - -## toList - -```res sig -let toList: t<'k, 'v, 'id> => list<('k, 'v)> -``` - -In increasing order. - -See `Belt.Map.toArray` - -## fromArray - -```res sig -let fromArray: (array<('k, 'v)>, ~id: id<'k, 'id>) => t<'k, 'v, 'id> -``` - -`fromArray(kvs, ~id);` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.toArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - (1, "1"), - (2, "2"), - (3, "3"), - ] -``` - -## keysToArray - -```res sig -let keysToArray: t<'k, 'v, 'id> => array<'k> -``` - -`keysToArray(s);` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.keysToArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - 1, - 2, - 3, - ] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'k, 'v, 'id> => array<'v> -``` - -`valuesToArray(s);` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.valuesToArray( - Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), -) == ["1", "2", "3"] -``` - -## minKey - -```res sig -let minKey: t<'k, 'a, 'b> => option<'k> -``` - -`minKey(s)` returns the minimum key, None if not exist. - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -See `Belt.Map.minKey` - -## maxKey - -```res sig -let maxKey: t<'k, 'a, 'b> => option<'k> -``` - -`maxKey(s)` returns the maximum key, None if not exist. - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -See `Belt.Map.maxKey` - -## minimum - -```res sig -let minimum: t<'k, 'v, 'a> => option<('k, 'v)> -``` - -`minimum(s)` returns the minimum key value pair, None if not exist - -## minUndefined - -```res sig -let minUndefined: t<'k, 'v, 'a> => Js.undefined<('k, 'v)> -``` - -See `Belt.Map.minimum` - -## maximum - -```res sig -let maximum: t<'k, 'v, 'a> => option<('k, 'v)> -``` - -`maximum(s)` returns the maximum key value pair, None if not exist. - -## maxUndefined - -```res sig -let maxUndefined: t<'k, 'v, 'a> => Js.undefined<('k, 'v)> -``` - -See `Belt.Map.maximum` - -## get - -```res sig -let get: (t<'k, 'v, 'id>, 'k) => option<'v> -``` - -`get(s, k)` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.get(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), 2) == - Some("2") - -Belt.Map.get(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), 2) == None -``` - -## getUndefined - -```res sig -let getUndefined: (t<'k, 'v, 'id>, 'k) => Js.undefined<'v> -``` - -See `Belt.Map.get` - -Returns `undefined` when not found - -## getWithDefault - -```res sig -let getWithDefault: (t<'k, 'v, 'id>, 'k, 'v) => 'v -``` - -`getWithDefault(s, k, default)` - -See `Belt.Map.get` - -Returns default when `k` is not found. - -## getExn - -```res sig -let getExn: (t<'k, 'v, 'id>, 'k) => 'v -``` - -`getExn(s, k)` - -See `Belt.Map.getExn` - -raise when `k` not exist - -## remove - -```res sig -let remove: (t<'k, 'v, 'id>, 'k) => t<'k, 'v, 'id> -``` - -`remove(m, x)` when `x` is not in `m`, `m` is returned reference unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)) - -let s1 = Belt.Map.remove(s0, 1) - -let s2 = Belt.Map.remove(s1, 1) - -s1 === s2 - -Belt.Map.keysToArray(s1) == [2, 3] -``` - -## removeMany - -```res sig -let removeMany: (t<'k, 'v, 'id>, array<'k>) => t<'k, 'v, 'id> -``` - -`removeMany(s, xs)` - -Removing each of `xs` to `s`, note unlike `Belt.Map.remove`, the reference of return value might be changed even if none in `xs` exists `s`. - -## set - -```res sig -let set: (t<'k, 'v, 'id>, 'k, 'v) => t<'k, 'v, 'id> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, with a new binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)) - -let s1 = Belt.Map.set(s0, 2, "3") - -Belt.Map.valuesToArray(s1) == ["1", "3", "3"] -``` - -## updateU - -```res sig -let updateU: (t<'k, 'v, 'id>, 'k, (. option<'v>) => option<'v>) => t<'k, 'v, 'id> -``` - -## update - -```res sig -let update: (t<'k, 'v, 'id>, 'k, option<'v> => option<'v>) => t<'k, 'v, 'id> -``` - -`update(m, x, f)` returns a map containing the same bindings as `m`, except for the binding of `x`. Depending on the value of `y` where `y` is `f(get(m, x))`, the binding of `x` is added, removed or updated. If `y` is `None`, the binding is removed if it exists; otherwise, if `y` is `Some(z)` then `x` is associated to `z` in the resulting map. - -## mergeMany - -```res sig -let mergeMany: (t<'k, 'v, 'id>, array<('k, 'v)>) => t<'k, 'v, 'id> -``` - -`mergeMany(s, xs)` - -Adding each of `xs` to `s`, note unlike `add`, the reference of return value might be changed even if all values in `xs` exist `s`. - -## mergeU - -```res sig -let mergeU: ( - t<'k, 'v, 'id>, - t<'k, 'v2, 'id>, - (. 'k, option<'v>, option<'v2>) => option<'v3>, -) => t<'k, 'v3, 'id> -``` - -## merge - -```res sig -let merge: ( - t<'k, 'v, 'id>, - t<'k, 'v2, 'id>, - ('k, option<'v>, option<'v2>) => option<'v3>, -) => t<'k, 'v3, 'id> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## keepU - -```res sig -let keepU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => t<'k, 'v, 'id> -``` - -## keep - -```res sig -let keep: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id> -``` - -`keep(m, p)` returns the map with all the bindings in m that satisfy predicate `p`. - -## partitionU - -```res sig -let partitionU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) -``` - -## partition - -```res sig -let partition: (t<'k, 'v, 'id>, ('k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```res sig -let split: (t<'k, 'v, 'id>, 'k) => ((t<'k, 'v, 'id>, t<'k, 'v, 'id>), option<'v>) -``` - -`split(x, m)` returns a tuple `(l, r)`, data, where `l` is the map with all the bindings of `m` whose 'k is strictly less than `x`; `r` is the map with all the bindings of m whose 'k is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'k, 'v, 'id>, (. 'v) => 'v2) => t<'k, 'v2, 'id> -``` - -## map - -```res sig -let map: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id> -``` - -`map(m, f) returns a map with same domain as`m`, where the associated value`a`of all bindings of`m`has been replaced by the result of the application of`f`to`a`. The bindings are passed to`f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'k, 'v, 'id>, (. 'k, 'v) => 'v2) => t<'k, 'v2, 'id> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'k, 'v, 'id>, ('k, 'v) => 'v2) => t<'k, 'v2, 'id> -``` - -`mapWithKey(m, f)` - -The same as `Belt.Map.map` except that `f` is supplied with one more argument: the key. - -## getData - -```res sig -let getData: t<'k, 'v, 'id> => Belt_MapDict.t<'k, 'v, 'id> -``` - -`getData(s0)` - -Advanced usage only - -Returns the raw data (detached from comparator), but its type is still manifested, so that user can pass identity directly without boxing. - -## getId - -```res sig -let getId: t<'k, 'v, 'id> => id<'k, 'id> -``` - -Advanced usage only - -Returns the identity of s0. - -## packIdData - -```res sig -let packIdData: (~id: id<'k, 'id>, ~data: Belt_MapDict.t<'k, 'v, 'id>) => t<'k, 'v, 'id> -``` - -`packIdData(~id, ~data)` - -Advanced usage only - -Returns the packed collection. diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-map-int.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-map-int.mdx deleted file mode 100644 index 73fbcaaab..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-map-int.mdx +++ /dev/null @@ -1,299 +0,0 @@ -# MutableMapInt - -## key - -```res prelude -type key = int -``` - -## t - -```res prelude -type t<'a> -``` - -## make - -```res sig -let make: unit => t<'a> -``` - -## clear - -```res sig -let clear: t<'a> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## has - -```res sig -let has: (t<'a>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```res sig -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, cmp)` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. key, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, (key, 'a) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The application order of `f` is in increasing order. - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, key, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'a>, (key, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## someU - -```res sig -let someU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'a>, (key, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## size - -```res sig -let size: t<'a> => int -``` - -## toList - -```res sig -let toList: t<'a> => list<(key, 'a)> -``` - -In increasing order - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'a> => option<(key, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'a> => option<(key, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'a>, key) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'a>, key, 'a) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'a>, key) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -Raise when invariant is not held. - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```res sig -let removeMany: (t<'a>, array) => unit -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'a>, key, (. option<'a>) => option<'a>) => unit -``` - -## update - -```res sig -let update: (t<'a>, key, option<'a> => option<'a>) => unit -``` - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'a>, (. key, 'a) => 'b) => t<'b> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-map-string.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-map-string.mdx deleted file mode 100644 index cfc1d228d..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-map-string.mdx +++ /dev/null @@ -1,299 +0,0 @@ -# MutableMapString - -## key - -```res prelude -type key = string -``` - -## t - -```res prelude -type t<'a> -``` - -## make - -```res sig -let make: unit => t<'a> -``` - -## clear - -```res sig -let clear: t<'a> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## has - -```res sig -let has: (t<'a>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```res sig -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, cmp)` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. key, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, (key, 'a) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The application order of `f` is in increasing order. - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, key, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'a>, (key, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## someU - -```res sig -let someU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'a>, (key, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## size - -```res sig -let size: t<'a> => int -``` - -## toList - -```res sig -let toList: t<'a> => list<(key, 'a)> -``` - -In increasing order - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'a> => option<(key, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'a> => option<(key, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'a>, key) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'a>, key, 'a) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'a>, key) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -Raise when invariant is not held. - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```res sig -let removeMany: (t<'a>, array) => unit -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'a>, key, (. option<'a>) => option<'a>) => unit -``` - -## update - -```res sig -let update: (t<'a>, key, option<'a> => option<'a>) => unit -``` - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'a>, (. key, 'a) => 'b) => t<'b> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-map.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-map.mdx deleted file mode 100644 index 21ed52d60..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-map.mdx +++ /dev/null @@ -1,313 +0,0 @@ -# MutableMap - - - -A mutable sorted map module which allows customize compare behavior. - - - -Same as `Belt.Map`, but mutable. - -## t - -```res prelude -type t<'k, 'v, 'id> -``` - -## id - -```res prelude -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -``` - -## make - -```res sig -let make: (~id: id<'k, 'id>) => t<'k, 'a, 'id> -``` - -## clear - -```res sig -let clear: t<'a, 'b, 'c> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b, 'c> => bool -``` - -## has - -```res sig -let has: (t<'k, 'a, 'b>, 'k) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```res sig -let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, eqf)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `eqf` is the equality predicate used to compare the data associated with the keys. - -## forEachU - -```res sig -let forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit -``` - -`forEach(m, f)` applies f to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. - -## someU - -```res sig -let someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. - -## size - -```res sig -let size: t<'k, 'a, 'id> => int -``` - -## toList - -```res sig -let toList: t<'k, 'a, 'id> => list<('k, 'a)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'k, 'a, 'id> => array<('k, 'a)> -``` - -## fromArray - -```res sig -let fromArray: (array<('k, 'a)>, ~id: id<'k, 'id>) => t<'k, 'a, 'id> -``` - -## keysToArray - -```res sig -let keysToArray: t<'k, 'a, 'b> => array<'k> -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'b, 'a, 'c> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'k, 'a, 'b> => option<'k> -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## maxKey - -```res sig -let maxKey: t<'k, 'a, 'b> => option<'k> -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## minimum - -```res sig -let minimum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## get - -```res sig -let get: (t<'k, 'a, 'id>, 'k) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'k, 'a, 'id>, 'k) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b, 'c> => unit -``` - -Raise when invariant is not held. - -## remove - -```res sig -let remove: (t<'k, 'a, 'id>, 'k) => unit -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```res sig -let removeMany: (t<'k, 'a, 'id>, array<'k>) => unit -``` - -## set - -```res sig -let set: (t<'k, 'a, 'id>, 'k, 'a) => unit -``` - -`set(m, x, y)` do the in-place modification - -## updateU - -```res sig -let updateU: (t<'k, 'a, 'id>, 'k, (. option<'a>) => option<'a>) => unit -``` - -## update - -```res sig -let update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit -``` - -## mergeMany - -```res sig -let mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unit -``` - -## mapU - -```res sig -let mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id> -``` - -## map - -```res sig -let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-queue.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-queue.mdx deleted file mode 100644 index 9efd21a4b..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-queue.mdx +++ /dev/null @@ -1,175 +0,0 @@ -# MutableQueue - - - -An FIFO(first in first out) queue data structure. - - - -## t - -```res prelude -type t<'a> -``` - -The type of queues containing elements of `type('a)`. - -## make - -```res sig -let make: unit => t<'a> -``` - -Returns a new queue, initially empty. - -## clear - -```res sig -let clear: t<'a> => unit -``` - -Discard all elements from the queue. - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -Returns `true` if the given queue is empty, `false` otherwise. - -## fromArray - -```res sig -let fromArray: array<'a> => t<'a> -``` - -`fromArray` a is equivalent to `Array.forEach(a, add(q, a));` - -## add - -```res sig -let add: (t<'a>, 'a) => unit -``` - -`add(q, x)` adds the element `x` at the end of the queue `q`. - -## peek - -```res sig -let peek: t<'a> => option<'a> -``` - -`peekOpt(q)` returns the first element in queue `q`, without removing it from the queue. - -## peekUndefined - -```res sig -let peekUndefined: t<'a> => Js.undefined<'a> -``` - -`peekUndefined(q)` returns `undefined` if not found. - -## peekExn - -```res sig -let peekExn: t<'a> => 'a -``` - -raise an exception if `q` is empty - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -`pop(q)` removes and returns the first element in queue `q`. - -## popUndefined - -```res sig -let popUndefined: t<'a> => Js.undefined<'a> -``` - -`popUndefined(q)` removes and returns the first element in queue `q`. it will return `undefined` if it is already empty. - -## popExn - -```res sig -let popExn: t<'a> => 'a -``` - -`popExn(q)` raise an exception if q is empty. - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -`copy(q)` returns a fresh queue. - -## size - -```res sig -let size: t<'a> => int -``` - -Returns the number of elements in a queue. - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, 'a => unit) => unit -``` - -`forEach(q, f) applies`f`in turn to all elements of`q`, from the least recently entered to the most recently entered. The queue itself is unchanged. - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -`reduce(q, accu, f)` is equivalent to `List.reduce(l, accu, f)`, where `l` is the list of `q`'s elements. The queue remains unchanged. - -## transfer - -```res sig -let transfer: (t<'a>, t<'a>) => unit -``` - -`transfer(q1, q2)` adds all of `q1`'s elements at the end of the queue `q2`, then clears `q1`. It is equivalent to the sequence `forEach((x) => add(x, q2), q1);`; clear `q1`, but runs in constant time. - -## toArray - -```res sig -let toArray: t<'a> => array<'a> -``` - -First added will be in the beginning of the array. diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-set-int.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-set-int.mdx deleted file mode 100644 index f4fd5a6ce..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-set-int.mdx +++ /dev/null @@ -1,559 +0,0 @@ -# MutableSetInt - - - -This module is [Belt.MutableSet](mutable-set) specialized with key type to be a `int` type. -It is more efficient in general, the API is the same with [Belt.MutableSet](mutable-set) except its key type is fixed, and identity is not needed (using the built-in one). - - - -## value - -```res prelude -type value = int -``` - -The type of the set elements - -## t - -```res prelude -type t -``` - -Type of the sets. - -## make - -```res sig -let make: unit => t -``` - -Returns empty set. - -```res example -let set = Belt.MutableSet.Int.make() -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 3, 2, 4]) - -s0->Belt.MutableSet.Int.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```res sig -let copy: t => t -``` - -Returns copy of a set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 3, 2, 4]) - -let copied = s0->Belt.MutableSet.Int.copy -copied->Belt.MutableSet.Int.toArray /* [1, 2, 3, 4] */ -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.MutableSet.Int.fromArray([]) -let notEmpty = Belt.MutableSet.Int.fromArray([1]) - -Belt.MutableSet.Int.isEmpty(empty) /* true */ -Belt.MutableSet.Int.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.MutableSet.Int.fromArray([1, 4, 2, 5]) - -set->Belt.MutableSet.Int.has(3) /* false */ -set->Belt.MutableSet.Int.has(1) /* true */ -``` - -## add - -```res sig -let add: (t, value) => unit -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.Int.make() -s0->Belt.MutableSet.Int.add(1) -s0->Belt.MutableSet.Int.add(2) -s0->Belt.MutableSet.Int.add(2) - -s0->Belt.MutableSet.Int.toArray /* [1, 2] */ -``` - -## addCheck - -``` -let addCheck: (t, value) => bool; -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.MutableSet.Int.make() - -set->Belt.MutableSet.Int.mergeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.Int.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t, value) => unit -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([2, 3, 1, 4, 5]) -s0->Belt.MutableSet.Int.remove(1) -s0->Belt.MutableSet.Int.remove(3) -s0->Belt.MutableSet.Int.remove(3) - -s0->Belt.MutableSet.Int.toArray /* [2,4,5] */ -``` - -## removeCheck - -```res sig -let removeCheck: (t, value) => bool -``` - -## removeMany - -```res sig -let removeMany: (t, array) => unit -``` - -Removes each element of array from set. - -```res example -let set = Belt.MutableSet.Int.fromArray([1, 2, 3, 4]) - -set->Belt.MutableSet.Int.removeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.Int.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -let union = Belt.MutableSet.Int.union(s0, s1) -union->Belt.MutableSet.Int.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -let intersect = Belt.MutableSet.Int.intersect(s0, s1) -intersect->Belt.MutableSet.Int.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -Belt.MutableSet.Int.toArray(Belt.MutableSet.Int.diff(s0, s1)) /* [6] */ -Belt.MutableSet.Int.toArray(Belt.MutableSet.Int.diff(s1, s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -let s2 = Belt.MutableSet.Int.intersect(s0, s1) -Belt.MutableSet.Int.subset(s2, s0) /* true */ -Belt.MutableSet.Int.subset(s2, s1) /* true */ -Belt.MutableSet.Int.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3]) -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 5]) - -Belt.MutableSet.Int.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let acc = ref(list{}) -s0->Belt.MutableSet.Int.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -``` -let reduce: (t, 'a, ('a, value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -s0->Belt.MutableSet.Int.reduce(list{}, (acc, element) => - acc->Belt.List.add(element) -) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.Int.fromArray([2, 4, 6, 8]) -s0->Belt.MutableSet.Int.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 4, 6, 8]) -s0->Belt.MutableSet.Int.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) -let s1 = s0->Belt.MutableSet.Int.keep(isEven) - -s1->Belt.MutableSet.Int.toArray /* [2, 4] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) -let (s1, s2) = s0->Belt.MutableSet.Int.partition(isOdd) - -s1->Belt.MutableSet.Int.toArray /* [1,3,5] */ -s2->Belt.MutableSet.Int.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4]) - -s0->Belt.MutableSet.Int.size /* 4 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.minimum /* None */ -s1->Belt.MutableSet.Int.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.minUndefined /* undefined */ -s1->Belt.MutableSet.Int.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.maximum /* None */ -s1->Belt.MutableSet.Int.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.maxUndefined /* undefined */ -s1->Belt.MutableSet.Int.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) - -s0->Belt.MutableSet.Int.get(3) /* Some(3) */ -s0->Belt.MutableSet.Int.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) - -let ((smaller, larger), present) = s0->Belt.MutableSet.Int.split(3) - -present /* true */ -smaller->Belt.MutableSet.Int.toArray /* [1,2] */ -larger->Belt.MutableSet.Int.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-set-string.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-set-string.mdx deleted file mode 100644 index 2acd4467e..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-set-string.mdx +++ /dev/null @@ -1,561 +0,0 @@ -# MutableSetString - - - -This module is [Belt.MutableSet](mutable-set) specialized with key type to be a `string` type. -It is more efficient in general, the API is the same with [Belt.MutableSet](mutable-set) except its key type is fixed, and identity is not needed (using the built-in one) - - - -## value - -```res prelude -type value = string -``` - -The type of the set elements. - -## t - -```res prelude -type t -``` - -The type of sets. - -## make - -```res sig -let make: unit => t -``` - -Returns empty set. - -```res example -let set = Belt.MutableSet.String.make() -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange", "banana"]) - -s0->Belt.MutableSet.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```res sig -let copy: t => t -``` - -Returns copy of a set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["orange", "apple"]) - -let copied = s0->Belt.MutableSet.String.copy -copied->Belt.MutableSet.String.toArray /* ["apple", "orange"] */ -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.MutableSet.String.fromArray([]) -let notEmpty = Belt.MutableSet.String.fromArray(["apple"]) - -Belt.MutableSet.String.isEmpty(empty) /* true */ -Belt.MutableSet.String.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.MutableSet.String.fromArray(["apple", "orange", "banana"]) - -set->Belt.MutableSet.String.has("strawberry") /* false */ -set->Belt.MutableSet.String.has("apple") /* true */ -``` - -## add - -```res sig -let add: (t, value) => unit -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.String.make() -s0->Belt.MutableSet.String.add("apple") -s0->Belt.MutableSet.String.add("banana") -s0->Belt.MutableSet.String.add("banana") - -s0->Belt.MutableSet.String.toArray /* ["apple", "banana"] */ -``` - -## addCheck - -```res sig -let addCheck: (t, value) => bool -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -Adds each element of array to set. - -```res example -let set = Belt.MutableSet.String.make() - -set->Belt.MutableSet.String.mergeMany(["apple", "banana", "orange", "strawberry"]) -set->Belt.MutableSet.String.toArray /* ["apple", "banana", "orange", "strawberry"] */ -``` - -## remove - -```res sig -let remove: (t, value) => unit -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["orange", "banana", "apple"]) -s0->Belt.MutableSet.String.remove("apple") -s0->Belt.MutableSet.String.remove("banana") -s0->Belt.MutableSet.String.remove("banana") - -s0->Belt.MutableSet.String.toArray /* ["orange"] */ -``` - -## removeCheck - -```res sig -let removeCheck: (t, value) => bool -``` - -## removeMany - -```res sig -let removeMany: (t, array) => unit -``` - -Removes each element of array from set. - -```res example -let set = Belt.MutableSet.String.fromArray(["apple", "banana", "orange"]) - -set->Belt.MutableSet.String.removeMany(["strawberry", "apple", "banana", "orange"]) -set->Belt.MutableSet.String.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let union = Belt.MutableSet.String.union(s0, s1) -union->Belt.MutableSet.String.toArray /* ["apple", "banana", "carrot", "orange", "strawberry"] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let intersect = Belt.MutableSet.String.intersect(s0, s1) -intersect->Belt.MutableSet.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "strawberry"]) -Belt.MutableSet.String.toArray(Belt.MutableSet.String.diff(s0, s1)) /* ["carrot"] */ -Belt.MutableSet.String.toArray(Belt.MutableSet.String.diff(s1, s0)) /* ["strawberry"] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["5", "2", "3", "5", "6"]) -let s1 = Belt.MutableSet.String.fromArray(["5", "2", "3", "1", "5", "4"]) -let s2 = Belt.MutableSet.String.intersect(s0, s1) -Belt.MutableSet.String.subset(s2, s0) /* true */ -Belt.MutableSet.String.subset(s2, s1) /* true */ -Belt.MutableSet.String.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange"]) -let s1 = Belt.MutableSet.String.fromArray(["orange", "apple"]) - -Belt.MutableSet.String.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["banana", "orange", "apple"]) -let acc = ref(list{}) -s0->Belt.MutableSet.String.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* ["orange", "banana", "apple"] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange"]) -s0->Belt.MutableSet.String.reduce(0, (acc, element) => acc + String.length(element)) /* 11 */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let hasAtLeastFiveChars = x => String.length(x) >= 5 - -let s0 = Belt.MutableSet.String.fromArray(["apple", "carrot"]) -s0->Belt.MutableSet.String.every(hasAtLeastFiveChars) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.MutableSet.String.fromArray(["strawberry", "apple"]) -s0->Belt.MutableSet.String.some(hasFiveChars) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange", "banana"]) -let s1 = s0->Belt.MutableSet.String.keep(hasFiveChars) - -s1->Belt.MutableSet.String.toArray /* ["apple"] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.MutableSet.String.fromArray(["apple", "carrot"]) -let (s1, s2) = s0->Belt.MutableSet.String.partition(hasFiveChars) - -s1->Belt.MutableSet.String.toArray /* ["apple"] */ -s2->Belt.MutableSet.String.toArray /* ["carrot"] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple"]) - -s0->Belt.MutableSet.String.size /* 1 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "watermelon"]) - -s0->Belt.MutableSet.String.toList /* ["apple", "watermelon"] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "watermelon"]) - -s0->Belt.MutableSet.String.toArray /* ["apple", "watermelon"] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.minimum /* None */ -s1->Belt.MutableSet.String.minimum /* Some("apple") */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.minUndefined /* undefined */ -s1->Belt.MutableSet.String.minUndefined /* "apple" */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.maximum /* None */ -s1->Belt.MutableSet.String.maximum /* Some("orange") */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.maxUndefined /* undefined */ -s1->Belt.MutableSet.String.maxUndefined /* orange */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "carrot"]) - -s0->Belt.MutableSet.String.get("carrot") /* Some("carrot") */ -s0->Belt.MutableSet.String.get("watermelon") /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange"]) - -let ((smaller, larger), present) = s0->Belt.MutableSet.String.split("banana") - -present /* true */ -smaller->Belt.MutableSet.String.toArray /* ["apple"] */ -larger->Belt.MutableSet.String.toArray /* ["orange"] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-set.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-set.mdx deleted file mode 100644 index 371f04de0..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-set.mdx +++ /dev/null @@ -1,711 +0,0 @@ -# MutableSet - - - -A **mutable** sorted set module which allows customize compare behavior. -The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map. - -It also has three specialized inner modules [Belt.MutableSet.Int](mutable-set-int) and [Belt.MutableSet.String](mutable-set-string) - This module separates data from function which is more verbose but slightly more efficient - - - -```res example -module PairComparator = Belt.Id.MakeComparable({ - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } -}) - -let mySet = Belt.MutableSet.make(~id=module(PairComparator)) -mySet->Belt.MutableSet.add((1, 2)) -``` - -## t - -```res prelude -type t<'value, 'id> -``` - -`'value` is the element type - -`'id` the identity of the collection - -## id - -```res prelude -type id<'value, 'id> = Belt_Id.comparable<'value, 'id> -``` - -The identity needed for making a set from scratch - -## make - -```res sig -let make: (~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates a new set by taking in the comparator - -## fromArray - -```res sig -let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates new set from array of elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```res sig -let copy: t<'value, 'id> => t<'value, 'id> -``` - -Returns copy of a set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -let copied = s0->Belt.MutableSet.copy -copied->Belt.MutableSet.toArray /* [1, 2, 3, 4] */ -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -Checks if set is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let empty = Belt.MutableSet.fromArray([], ~id=module(IntCmp)) -let notEmpty = Belt.MutableSet.fromArray([1], ~id=module(IntCmp)) - -Belt.MutableSet.isEmpty(empty) /* true */ -Belt.MutableSet.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t<'value, 'a>, 'value) => bool -``` - -Checks if element exists in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.fromArray([1, 4, 2, 5], ~id=module(IntCmp)) - -set->Belt.MutableSet.has(3) /* false */ -set->Belt.MutableSet.has(1) /* true */ -``` - -## add - -```res sig -let add: (t<'value, 'id>, 'value) => unit -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -s0->Belt.MutableSet.add(1) -s0->Belt.MutableSet.add(2) -s0->Belt.MutableSet.add(2) - -s0->Belt.MutableSet.toArray /* [1, 2] */ -``` - -## addCheck - -```res sig -let addCheck: (t<'value, 'id>, 'value) => bool -``` - -## mergeMany - -```res sig -let mergeMany: (t<'value, 'id>, array<'value>) => unit -``` - -Adds each element of array to set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.make(~id=module(IntCmp)) - -set->Belt.MutableSet.mergeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t<'value, 'id>, 'value) => unit -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([2, 3, 1, 4, 5], ~id=module(IntCmp)) -s0->Belt.MutableSet.remove(1) -s0->Belt.MutableSet.remove(3) -s0->Belt.MutableSet.remove(3) - -s0->Belt.MutableSet.toArray /* [2,4,5] */ -``` - -## removeCheck - -```res sig -let removeCheck: (t<'value, 'id>, 'value) => bool -``` - -## removeMany - -```res sig -let removeMany: (t<'value, 'id>, array<'value>) => unit -``` - -Removes each element of array from set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp)) - -set->Belt.MutableSet.removeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.toArray /* [] */ -``` - -## union - -```res sig -let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns union of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let union = Belt.MutableSet.union(s0, s1) -union->Belt.MutableSet.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns intersection of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let intersect = Belt.MutableSet.intersect(s0, s1) -intersect->Belt.MutableSet.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns elements from first set, not existing in second set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -Belt.MutableSet.toArray(Belt.MutableSet.diff(s0, s1)) /* [6] */ -Belt.MutableSet.toArray(Belt.MutableSet.diff(s1, s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if second set is subset of first set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let s2 = Belt.MutableSet.intersect(s0, s1) -Belt.MutableSet.subset(s2, s0) /* true */ -Belt.MutableSet.subset(s2, s1) /* true */ -Belt.MutableSet.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t<'value, 'id>, t<'value, 'id>) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if two sets are equal. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 5], ~id=module(IntCmp)) - -Belt.MutableSet.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'value, 'id>, 'value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let acc = ref(list{}) -s0->Belt.MutableSet.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -s0->Belt.MutableSet.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## every - -```res sig -let every: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.fromArray([2, 4, 6, 8], ~id=module(IntCmp)) -s0->Belt.MutableSet.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## some - -```res sig -let some: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 4, 6, 8], ~id=module(IntCmp)) -s0->Belt.MutableSet.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> -``` - -## keep - -```res sig -let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) -let s1 = s0->Belt.MutableSet.keep(isEven) - -s1->Belt.MutableSet.toArray /* [2, 4] */ -``` - -## partitionU - -```res sig -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -## partition - -```res sig -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) -let (s1, s2) = s0->Belt.MutableSet.partition(isOdd) - -s1->Belt.MutableSet.toArray /* [1,3,5] */ -s2->Belt.MutableSet.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t<'value, 'id> => int -``` - -Returns size of the set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp)) - -s0->Belt.MutableSet.size /* 4 */ -``` - -## toList - -```res sig -let toList: t<'value, 'id> => list<'value> -``` - -Returns list of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t<'value, 'id> => array<'value> -``` - -Returns array of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t<'value, 'id> => option<'value> -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.minimum /* None */ -s1->Belt.MutableSet.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.minUndefined /* undefined */ -s1->Belt.MutableSet.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t<'value, 'id> => option<'value> -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.maximum /* None */ -s1->Belt.MutableSet.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.maxUndefined /* undefined */ -s1->Belt.MutableSet.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t<'value, 'id>, 'value) => option<'value> -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.get(3) /* Some(3) */ -s0->Belt.MutableSet.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t<'value, 'id>, 'value) => 'value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) - -let ((smaller, larger), present) = s0->Belt.MutableSet.split(3) - -present /* true */ -smaller->Belt.MutableSet.toArray /* [1,2] */ -larger->Belt.MutableSet.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b> => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v10.0.0/api/belt/mutable-stack.mdx b/pages/docs/manual/v10.0.0/api/belt/mutable-stack.mdx deleted file mode 100644 index d8c51f494..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/mutable-stack.mdx +++ /dev/null @@ -1,105 +0,0 @@ -# MutableStack - - - -First in last out stack. This module implements stacks, with in-place modification. - - - -## t - -```res prelude -type t<'a> -``` - -## make - -```res sig -let make: unit => t<'a> -``` - -Returns a new stack, initially empty. - -## clear - -```res sig -let clear: t<'a> => unit -``` - -Discard all elements from the stack. - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -`copy(x)` O(1) operation, return a new stack. - -## push - -```res sig -let push: (t<'a>, 'a) => unit -``` - -## popUndefined - -```res sig -let popUndefined: t<'a> => Js.undefined<'a> -``` - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -## topUndefined - -```res sig -let topUndefined: t<'a> => Js.undefined<'a> -``` - -## top - -```res sig -let top: t<'a> => option<'a> -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## size - -```res sig -let size: t<'a> => int -``` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, 'a => unit) => unit -``` - -## dynamicPopIterU - -```res sig -let dynamicPopIterU: (t<'a>, (. 'a) => unit) => unit -``` - -## dynamicPopIter - -```res sig -let dynamicPopIter: (t<'a>, 'a => unit) => unit -``` - -`dynamicPopIter(s, f)` apply `f` to each element of `s`. The item is poped before applying `f`, `s` will be empty after this opeartion. This function is useful for worklist algorithm. diff --git a/pages/docs/manual/v10.0.0/api/belt/option.mdx b/pages/docs/manual/v10.0.0/api/belt/option.mdx deleted file mode 100644 index 7cd48cca4..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/option.mdx +++ /dev/null @@ -1,256 +0,0 @@ -# Option - - - -In Belt we represent the existence and nonexistence of a value by wrapping it -with the `option` type. In order to make it a bit more convenient to work with -option-types, Belt provides utility-functions for it. - -The `option` type is a part of the Reason / OCaml standard library which is defined like this: - - - -```res sig -type option<'a> = None | Some('a) -``` - -```res example -let someString: option = Some("hello") -``` - -## getExn - -```res sig -let getExn: option<'a> => 'a -``` - -Raises an Error in case `None` is provided. Use with care. - -```res example -Belt.Option.getExn(Some(3)) /* 3 */ - -Belt.Option.getExn(None) /* Raises an Error */ -``` - -## mapWithDefault - -```res sig -let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b -``` - -If `optionValue` is of `Some(value)`, -this function returns that value applied with `f`, in other words `f(value)`. - -If `optionValue` is `None`, the default is returned. - -```res example -let someValue = Some(3) -someValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 8 */ - -let noneValue = None -noneValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 0 */ -``` - -## mapWithDefaultU - -```res sig -let mapWithDefaultU: (option<'a>, 'b, (. 'a) => 'b) => 'b -``` - -Uncurried version of [mapWithDefault](#mapWithDefault). - -## map - -```res sig -let map: (option<'a>, 'a => 'b) => option<'b> -``` - -If `optionValue` is `Some(value)` this returns `f(value)`, otherwise it returns `None`. - -```res example -Belt.Option.map(Some(3), x => x * x) /* Some(9) */ - -Belt.Option.map(None, x => x * x) /* None */ -``` - -## mapU - -```res sig -let mapU: (option<'a>, (. 'a) => 'b) => option<'b> -``` - -Uncurried version of [map](#map). - -## flatMap - -```res sig -let flatMap: (option<'a>, 'a => option<'b>) => option<'b> -``` - -If `optionValue` is `Some(value)`, returns `f(value)`, otherwise returns -`None`.
-The function `f` must have a return type of `option<'b>`. - -```res example -let addIfAboveOne = value => - if (value > 1) { - Some(value + 1) - } else { - None - } - -Belt.Option.flatMap(Some(2), addIfAboveOne) /* Some(3) */ - -Belt.Option.flatMap(Some(-4), addIfAboveOne) /* None */ - -Belt.Option.flatMap(None, addIfAboveOne) /* None */ -``` - -## flatMapU - -```res sig -let flatMapU: (option<'a>, (. 'a) => option<'b>) => option<'b> -``` - -Uncurried version of flatMap. - -## getWithDefault - -```res sig -let getWithDefault: (option<'a>, 'a) => 'a -``` - -If `optionalValue` is `Some(value)`, returns `value`, otherwise default. - -```res example -Belt.Option.getWithDefault(None, "Banana") /* Banana */ - -Belt.Option.getWithDefault(Some("Apple"), "Banana") /* Apple */ -``` - -```res example -let greet = (firstName: option) => - "Greetings " ++ firstName->Belt.Option.getWithDefault("Anonymous") - -Some("Jane")->greet /* "Greetings Jane" */ - -None->greet /* "Greetings Anonymous" */ -``` - -```res example -Belt.Option.getWithDefault(Some(1812), 1066) /* 1812 */ - -Belt.Option.getWithDefault(None, 1066) /* 1066 */ -``` - -## isSome - -```res sig -let isSome: option<'a> => bool -``` - -Returns `true` if the argument is `Some(value)`, `false` otherwise. - -```res example -Belt.Option.isSome(None) /* false */ - -Belt.Option.isSome(Some(1)) /* true */ -``` - -## isNone - -```res sig -let isNone: option<'a> => bool -``` - -Returns `true` if the argument is `None`, `false` otherwise. - -```res example -Belt.Option.isNone(None) /* true */ - -Belt.Option.isNone(Some(1)) /* false */ -``` - -## eq - -```res sig -let eq: (option<'a>, option<'b>, ('a, 'b) => bool) => bool -``` - -Evaluates two optional values for equality with respect to a predicate -function. If both `optValue1` and `optValue2` are `None`, returns `true`. -If one of the arguments is `Some(value)` and the other is `None`, returns -`false`. - -If arguments are `Some(value1)` and `Some(value2)`, returns the result of -`predicate(value1, value2)`; the predicate function must return a bool. - -```res example -let clockEqual = (a, b) => mod(a, 12) == mod(b, 12) - -open Belt.Option - -eq(Some(3), Some(15), clockEqual) /* true */ - -eq(Some(3), None, clockEqual) /* false */ - -eq(None, Some(3), clockEqual) /* false */ - -eq(None, None, clockEqual) /* true */ -``` - -## eqU - -```res sig -let eqU: (option<'a>, option<'b>, (.'a, 'b) => bool) => bool -``` - -Uncurried version of [eq](#eq). - -## cmp - -```res sig -let cmp: (option<'a>, option<'b>, ('a, 'b) => int) => int -``` - -`cmp(optValue1, optValue2, comparisonFunction)` compares two optional values -with respect to given `comparisonFunction`. - -If both `optValue1` and `optValue2` are `None`, it returns `0`. - -If the first argument is `Some(value1)` and the second is `None`, returns `1` -(something is greater than nothing). - -If the first argument is `None` and the second is `Some(value2)`, returns `-1` -(nothing is less than something). - -If the arguments are `Some(value1)` and `Some(value2)`, returns the result of -`comparisonFunction(value1, value2)`; comparisonFunction takes two arguments -and returns `-1` if the first argument is less than the second, `0` if the -arguments are equal, and `1` if the first argument is greater than the second. - -```res example -let clockCompare = (a, b) => compare(mod(a, 12), mod(b, 12)) - -open Belt.Option - -cmp(Some(3), Some(15), clockCompare) /* 0 */ - -cmp(Some(3), Some(14), clockCompare) /* 1 */ - -cmp(Some(2), Some(15), clockCompare) /* (-1) */ - -cmp(None, Some(15), clockCompare) /* (-1) */ - -cmp(Some(14), None, clockCompare) /* 1 */ - -cmp(None, None, clockCompare) /* 0 */ -``` - -## cmpU - -```res sig -let cmpU: (option<'a>, option<'b>, ((.'a, 'b) => int)) => int -``` - -Uncurried version of [cmp](#cmp). diff --git a/pages/docs/manual/v10.0.0/api/belt/range.mdx b/pages/docs/manual/v10.0.0/api/belt/range.mdx deleted file mode 100644 index 87f52c71e..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/range.mdx +++ /dev/null @@ -1,130 +0,0 @@ -# Range - - - -A small utility module to provide inclusive range operations for `[start, -finish]`. Internally it is relying on loops instead of creating new arrays, -which makes it pretty performant and memory friendly. - - - -## forEachU - -```res sig -let forEachU: (int, int, (. int) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (int, int, int => unit) => unit -``` - -`forEach(start, finish, action)` - -equivalent to `Belt.Array.(forEach(range(start, finish), action))` - -```res example -Belt.Range.forEach(0, 4, (i) => Js.log(i)) - -/* - * prints: - * 0 - * 1 - * 2 - * 3 - * 4 - */ -``` - -## everyU - -```res sig -let everyU: (int, int, (. int) => bool) => bool -``` - -## every - -```res sig -let every: (int, int, int => bool) => bool -``` - -`every(start, finish, p)` - -equivalent to `Belt.Array.(every(range(start, finish), p))` - -```res example -Belt.Range.every(0, 4, (i) => i < 5) /* true */ - -Belt.Range.every(0, 4, (i) => i < 4) /* false */ -``` - -## everyByU - -```res sig -let everyByU: (int, int, ~step: int, (. int) => bool) => bool -``` - -## everyBy - -```res sig -let everyBy: (int, int, ~step: int, int => bool) => bool -``` - -`everyBy(start, finish, ~step, p)` - -See `Belt_Array.rangeBy` - -equivalent to `Belt.Array.(every(rangeBy(start, finish, ~step), p))` - -```res example -Belt.Range.everyBy(0, 4, ~step=1, (i) => mod(i, 2) === 0) /* false */ - -Belt.Range.everyBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */ -``` - -## someU - -```res sig -let someU: (int, int, (. int) => bool) => bool -``` - -## some - -```res sig -let some: (int, int, int => bool) => bool -``` - -`some(start, finish, p)` - -equivalent to `Belt.Array.(some(range(start, finish), p))` - -```res example -Belt.Range.some(0, 4, (i) => i > 5) /* false */ - -Belt.Range.some(0, 4, (i) => i > 2) /* true */ -``` - -## someByU - -```res sig -let someByU: (int, int, ~step: int, (. int) => bool) => bool -``` - -## someBy - -```res sig -let someBy: (int, int, ~step: int, int => bool) => bool -``` - -`someBy(start, finish, ~step, p)` - -See `Belt_Array.rangeBy` - -equivalent to `Belt.Array.(some(rangeBy(start, finish, ~step), p))` - -```res example -Belt.Range.someBy(1, 5, ~step=2, (i) => mod(i, 2) === 0) /* false */ - -Belt.Range.someBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */ -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/result.mdx b/pages/docs/manual/v10.0.0/api/belt/result.mdx deleted file mode 100644 index a6106ed33..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/result.mdx +++ /dev/null @@ -1,242 +0,0 @@ -# Result - - - -Result types are really useful to describe the result of a certain operation -without relying on exceptions or `option` types. - -This module gives you useful utilities to create and combine `Result` data. - - - -## t - -```res prelude -type t<'a, 'b> = - | Ok('a) - | Error('b) -``` - -The type `Result.t` describes a variant of two states: -`Ok(someResult)` represents a successful operation, whereby -``Error(someError)` signals an erronous operation. - -In this concrete example, we are defining our own `Result` type to reflect an HTTP like -query operation: - -```res example -type responseError = NotAvailable | NotFound -type queryResult = t - -let failQueryUser = (username: string): queryResult => { - Error(NotAvailable) -} -``` - -## getExn - -```res sig -let getExn: t<'a, 'b> => 'a -``` - -`getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception - -```res example -Belt.Result.getExn(Belt.Result.Ok(42)) == 42 - -Belt.Result.getExn(Belt.Result.Error("Invalid data")) /* raises exception */ -``` - -## mapWithDefaultU - -```res sig -let mapWithDefaultU: (t<'a, 'c>, 'b, (. 'a) => 'b) => 'b -``` - -## mapWithDefault - -```res sig -let mapWithDefault: (t<'a, 'c>, 'b, 'a => 'b) => 'b -``` - -`mapWithDefault(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, -otherwise `default`. - -```res example -let ok = Belt.Result.Ok(42) -Belt.Result.mapWithDefault(ok, 0, (x) => x / 2) == 21 - -let error = Belt.Result.Error("Invalid data") -Belt.Result.mapWithDefault(error, 0, (x) => x / 2) == 0 -``` - -## mapU - -```res sig -let mapU: (t<'a, 'c>, (. 'a) => 'b) => t<'b, 'c> -``` - -## map - -```res sig -let map: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> -``` - -`map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res -unchanged. Function `f` takes a value of the same type as `n` and returns an -ordinary value. - -```res example -let f = (x) => sqrt(Belt.Int.toFloat(x)) - -Belt.Result.map(Ok(64), f) == Ok(8.0) - -Belt.Result.map(Error("Invalid data"), f) == Error("Invalid data") -``` - -## flatMapU - -```res sig -let flatMapU: (t<'a, 'c>, (. 'a) => t<'b, 'c>) => t<'b, 'c> -``` - -## flatMap - -```res sig -let flatMap: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c> -``` - -`flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res -unchanged. Function `f` takes a value of the same type as `n` and returns a -`Belt.Result`. - -```res example -let recip = (x) => - if (x !== 0.0) { - Belt.Result.Ok(1.0 /. x) - } else { - Belt.Result.Error("Divide by zero") - } - -Belt.Result.flatMap(Ok(2.0), recip) == Ok(0.5) - -Belt.Result.flatMap(Ok(0.0), recip) == Error("Divide by zero") - -Belt.Result.flatMap(Error("Already bad"), recip) == Error("Already bad") -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'a, 'b>, 'a) => 'a -``` - -`getWithDefault(res, defaultValue)`: If `res` is `Ok(n)`, returns `n`, -otherwise `default` - -```res example -Belt.Result.getWithDefault(Ok(42), 0) == 42 - -Belt.Result.getWithDefault(Error("Invalid Data"), 0) == 0 -``` - -## isOk - -```res sig -let isOk: t<'a, 'b> => bool -``` - -`isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is -the `Error(e)` variant. - -## isError - -```res sig -let isError: t<'a, 'b> => bool -``` - -`isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if -it is the `Ok(n)` variant. - -## eqU - -```res sig -let eqU: (t<'a, 'c>, t<'b, 'd>, (. 'a, 'b) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool -``` - -`eq(res1, res2, f)`: Determine if two `Belt.Result` variables are equal with -respect to an equality function. If `res1` and `res2` are of the form `Ok(n)` -and `Ok(m)`, return the result of `f(n, m)`. If one of `res1` and `res2` are of -the form `Error(e)`, return false If both `res1` and `res2` are of the form -`Error(e)`, return true - -```res example -let good1 = Belt.Result.Ok(42) - -let good2 = Belt.Result.Ok(32) - -let bad1 = Belt.Result.Error("invalid") - -let bad2 = Belt.Result.Error("really invalid") - -let mod10equal = (a, b) => mod(a, 10) === mod(b, 10) - -Belt.Result.eq(good1, good2, mod10equal) == true - -Belt.Result.eq(good1, bad1, mod10equal) == false - -Belt.Result.eq(bad2, good2, mod10equal) == false - -Belt.Result.eq(bad1, bad2, mod10equal) == true -``` - -## cmpU - -```res sig -let cmpU: (t<'a, 'c>, t<'b, 'd>, (. 'a, 'b) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => int) => int -``` - -`cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a -comparison function. The comparison function returns -1 if the first variable -is "less than" the second, 0 if the two variables are equal, and 1 if the first -is "greater than" the second. - -If `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of -`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`, -return -1 (nothing is less than something) If `res1` is of the form `Ok(n)` and -`res2` of the form `Error(e)`, return 1 (something is greater than nothing) If -both `res1` and `res2` are of the form `Error(e)`, return 0 (equal) - -```res example -let good1 = Belt.Result.Ok(59) - -let good2 = Belt.Result.Ok(37) - -let bad1 = Belt.Result.Error("invalid") - -let bad2 = Belt.Result.Error("really invalid") - -let mod10cmp = (a, b) => Pervasives.compare(mod(a, 10), mod(b, 10)) - -Belt.Result.cmp(Ok(39), Ok(57), mod10cmp) == 1 - -Belt.Result.cmp(Ok(57), Ok(39), mod10cmp) == (-1) - -Belt.Result.cmp(Ok(39), Error("y"), mod10cmp) == 1 - -Belt.Result.cmp(Error("x"), Ok(57), mod10cmp) == (-1) - -Belt.Result.cmp(Error("x"), Error("y"), mod10cmp) == 0 -``` diff --git a/pages/docs/manual/v10.0.0/api/belt/set-dict.mdx b/pages/docs/manual/v10.0.0/api/belt/set-dict.mdx deleted file mode 100644 index 5e687d3d2..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/set-dict.mdx +++ /dev/null @@ -1,679 +0,0 @@ -# SetDict - - - -This module separates identity from data. It is a bit more verbose but slightly more efficient due to the fact that there is no need to pack identity and data back after each operation. - - - -## t - -```res prelude -type t<'value, 'identity> -``` - -`'value` is the element type - -`'identity` the identity of the collection - -## cmp - -```res prelude -type cmp<'value, 'id> = Belt.Id.cmp<'value, 'id> -``` - -Type of compare function. - -## empty - -```res sig -let empty: t<'value, 'id> -``` - -```res example -let s0 = Belt.Set.Dict.empty -``` - -## fromArray - -```res sig -let fromArray: (array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Creates new set from array of elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 3, 2, 4], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array<'value> => t<'value, 'id> -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -Checks if set is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let empty = Belt.Set.Dict.fromArray([], ~cmp=IntCmp.cmp) -let notEmpty = Belt.Set.Dict.fromArray([1], ~cmp=IntCmp.cmp) - -Belt.Set.Dict.isEmpty(empty) /* true */ -Belt.Set.Dict.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => bool -``` - -Checks if an element exists in the set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.fromArray([1, 4, 2, 5], ~cmp=IntCmp.cmp) - -set->Belt.Set.Dict.has(3, ~cmp=IntCmp.cmp) /* false */ -set->Belt.Set.Dict.has(1, ~cmp=IntCmp.cmp) /* true */ -``` - -## add - -```res sig -let add: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = s0->Belt.Set.Dict.add(1, ~cmp=IntCmp.cmp) -let s2 = s1->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp) -let s3 = s2->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.toArray /* [] */ -s1->Belt.Set.Dict.toArray /* [1] */ -s2->Belt.Set.Dict.toArray /* [1, 2] */ -s3->Belt.Set.Dict.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t<'value, 'id>, array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.empty - -let newSet = set->Belt.Set.Dict.mergeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp) -newSet->Belt.Set.Dict.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([2, 3, 1, 4, 5], ~cmp=IntCmp.cmp) -let s1 = s0->Belt.Set.Dict.remove(1, ~cmp=IntCmp.cmp) -let s2 = s1->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp) -let s3 = s2->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp) - -s1->Belt.Set.Dict.toArray /* [2,3,4,5] */ -s2->Belt.Set.Dict.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t<'value, 'id>, array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp) - -let newSet = set->Belt.Set.Dict.removeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp) -newSet->Belt.Set.Dict.toArray /* [] */ -``` - -## union - -```res sig -let union: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Returns union of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let union = Belt.Set.Dict.union(s0, s1, ~cmp=IntCmp.cmp) -union->Belt.Set.Dict.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Returns intersection of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let intersect = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp) -intersect->Belt.Set.Dict.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Returns elements from first set, not existing in second set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) - -let diff1 = Belt.Set.Dict.diff(s0, s1, ~cmp=IntCmp.cmp) -let diff2 = Belt.Set.Dict.diff(s1, s0, ~cmp=IntCmp.cmp) - -diff1->Belt.Set.Dict.toArray /* [6] */ -diff2->Belt.Set.Dict.toArray /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => bool -``` - -Checks if second set is subset of first set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let s2 = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp) -Belt.Set.Dict.subset(s2, s0, ~cmp=IntCmp.cmp) /* true */ -Belt.Set.Dict.subset(s2, s1, ~cmp=IntCmp.cmp) /* true */ -Belt.Set.Dict.subset(s1, s0, ~cmp=IntCmp.cmp) /* false */ -``` - -## cmp - -```res sig -let cmp: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => bool -``` - -Checks if two sets are equal. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([3, 2, 5], ~cmp=IntCmp.cmp) - -Belt.Set.Dict.eq(s0, s1, ~cmp=IntCmp.cmp) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'value, 'id>, 'value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let acc = ref(list{}) -s0->Belt.Set.Dict.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## every - -```res sig -let every: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Dict.fromArray([2, 4, 6, 8], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## some - -```res sig -let some: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 4, 6, 8], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> -``` - -## keep - -```res sig -let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) -let s1 = s0->Belt.Set.Dict.keep(isEven) - -s1->Belt.Set.Dict.toArray /* [2,4] */ -``` - -## partitionU - -```res sig -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -## partition - -```res sig -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) -let (s1, s2) = s0->Belt.Set.Dict.partition(isOdd) - -s1->Belt.Set.Dict.toArray /* [1,3,5] */ -s2->Belt.Set.Dict.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t<'value, 'id> => int -``` - -Returns size of the set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.size /* 4 */ -``` - -## toList - -```res sig -let toList: t<'value, 'id> => list<'value> -``` - -Returns list of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t<'value, 'id> => array<'value> -``` - -Returns array of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t<'value, 'id> => option<'value> -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.minimum /* None */ -s1->Belt.Set.Dict.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.minUndefined /* undefined */ -s1->Belt.Set.Dict.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t<'value, 'id> => option<'value> -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.maximum /* None */ -s1->Belt.Set.Dict.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.maxUndefined /* undefined */ -s1->Belt.Set.Dict.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => option<'value> -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.get(3, ~cmp=IntCmp.cmp) /* Some(3) */ -s0->Belt.Set.Dict.get(20, ~cmp=IntCmp.cmp) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => Js.undefined<'value> -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => 'value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: ( - t<'value, 'id>, - 'value, - ~cmp: cmp<'value, 'id>, -) => ((t<'value, 'id>, t<'value, 'id>), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) - -let ((smaller, larger), present) = s0->Belt.Set.Dict.split(3, ~cmp=IntCmp.cmp) - -present /* true */ -smaller->Belt.Set.Dict.toArray /* [1,2] */ -larger->Belt.Set.Dict.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b> => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v10.0.0/api/belt/set-int.mdx b/pages/docs/manual/v10.0.0/api/belt/set-int.mdx deleted file mode 100644 index f64c7731a..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/set-int.mdx +++ /dev/null @@ -1,536 +0,0 @@ -# SetInt - - - -Specialized when value type is `int`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison. - - - -## value - -```res prelude -type value = int -``` - -The type of the set elements. - -## t - -```res prelude -type t -``` - -Type of the sets. - -## empty - -```res sig -let empty: t -``` - -Empty set - -```res example -let s0 = Belt.Set.Int.empty -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 3, 2, 4]) - -s0->Belt.Set.Int.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.Set.Int.fromArray([]) -let notEmpty = Belt.Set.Int.fromArray([1]) - -Belt.Set.Int.isEmpty(empty) /* true */ -Belt.Set.Int.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.Set.Int.fromArray([1, 4, 2, 5]) - -set->Belt.Set.Int.has(3) /* false */ -set->Belt.Set.Int.has(1) /* true */ -``` - -## add - -```res sig -let add: (t, value) => t -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = s0->Belt.Set.Int.add(1) -let s2 = s1->Belt.Set.Int.add(2) -let s3 = s2->Belt.Set.Int.add(2) -s0->Belt.Set.Int.toArray /* [] */ -s1->Belt.Set.Int.toArray /* [1] */ -s2->Belt.Set.Int.toArray /* [1, 2] */ -s3->Belt.Set.Int.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => t -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.Set.Int.empty - -let newSet = set->Belt.Set.Int.mergeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.Int.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t, value) => t -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.Int.fromArray([2, 3, 1, 4, 5]) -let s1 = s0->Belt.Set.Int.remove(1) -let s2 = s1->Belt.Set.Int.remove(3) -let s3 = s2->Belt.Set.Int.remove(3) - -s1->Belt.Set.Int.toArray /* [2,3,4,5] */ -s2->Belt.Set.Int.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t, array) => t -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -let set = Belt.Set.Int.fromArray([1, 2, 3, 4]) - -let newSet = set->Belt.Set.Int.removeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.Int.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -let union = Belt.Set.Int.union(s0, s1) -union->Belt.Set.Int.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -let intersect = Belt.Set.Int.intersect(s0, s1) -intersect->Belt.Set.Int.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -Belt.Set.Int.toArray(Belt.Set.Int.diff(s0, s1)) /* [6] */ -Belt.Set.Int.toArray(Belt.Set.Int.diff(s1, s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -let s2 = Belt.Set.Int.intersect(s0, s1) -Belt.Set.Int.subset(s2, s0) /* true */ -Belt.Set.Int.subset(s2, s1) /* true */ -Belt.Set.Int.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3]) -let s1 = Belt.Set.Int.fromArray([3, 2, 5]) - -Belt.Set.Int.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let acc = ref(list{}) -s0->Belt.Set.Int.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -s0->Belt.Set.Int.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Int.fromArray([2, 4, 6, 8]) -s0->Belt.Set.Int.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Int.fromArray([1, 2, 4, 6, 8]) -s0->Belt.Set.Int.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) -let s1 = s0->Belt.Set.Int.keep(isEven) - -s1->Belt.Set.Int.toArray /* [2,4] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) -let (s1, s2) = s0->Belt.Set.Int.partition(isOdd) - -s1->Belt.Set.Int.toArray /* [1,3,5] */ -s2->Belt.Set.Int.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4]) - -s0->Belt.Set.Int.size /* 4 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.minimum /* None */ -s1->Belt.Set.Int.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.minUndefined /* undefined */ -s1->Belt.Set.Int.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.maximum /* None */ -s1->Belt.Set.Int.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.maxUndefined /* undefined */ -s1->Belt.Set.Int.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) - -s0->Belt.Set.Int.get(3) /* Some(3) */ -s0->Belt.Set.Int.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a tuple `((l, r), present)`, where `l` is the set of elements of set that are strictly less than value, `r` is the set of elements of set that are strictly greater than value, `present` is `false` if set contains no element equal to value, or `true` if set contains an element equal to value. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) - -let ((smaller, larger), present) = s0->Belt.Set.Int.split(3) - -present /* true */ -smaller->Belt.Set.Int.toArray /* [1,2] */ -larger->Belt.Set.Int.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v10.0.0/api/belt/set-string.mdx b/pages/docs/manual/v10.0.0/api/belt/set-string.mdx deleted file mode 100644 index ee429dc5d..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/set-string.mdx +++ /dev/null @@ -1,537 +0,0 @@ -# SetString - - - -Specialized when value type is `string`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison. - - - -## value - -```res prelude -type value = string -``` - -The type of the set elements. - -## t - -```res prelude -type t -``` - -The type of sets. - -## empty - -```res sig -let empty: t -``` - -Empty set - -```res example -let s0 = Belt.Set.String.empty -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "orange", "banana"]) - -s0->Belt.Set.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.Set.String.fromArray([]) -let notEmpty = Belt.Set.String.fromArray(["apple"]) - -Belt.Set.String.isEmpty(empty) /* true */ -Belt.Set.String.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.Set.String.fromArray(["apple", "orange", "banana"]) - -set->Belt.Set.String.has("strawberry") /* false */ -set->Belt.Set.String.has("apple") /* true */ -``` - -## add - -```res sig -let add: (t, value) => t -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.String.empty -let s1 = s0->Belt.Set.String.add("apple") -let s2 = s1->Belt.Set.String.add("banana") -let s3 = s2->Belt.Set.String.add("banana") -s0->Belt.Set.String.toArray /* [] */ -s1->Belt.Set.String.toArray /* ["apple"] */ -s2->Belt.Set.String.toArray /* ["apple", "banana"] */ -s3->Belt.Set.String.toArray /* ["apple", "banana"] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => t -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.Set.String.empty - -let newSet = set->Belt.Set.String.mergeMany(["apple", "banana", "orange", "strawberry"]) - -newSet->Belt.Set.String.toArray /* ["apple", "banana", "orange", "strawberry"] */ -``` - -## remove - -```res sig -let remove: (t, value) => t -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.String.fromArray(["orange", "banana", "apple"]) -let s1 = s0->Belt.Set.String.remove("apple") -let s2 = s1->Belt.Set.String.remove("banana") -let s3 = s2->Belt.Set.String.remove("banana") - -s1->Belt.Set.String.toArray /* ["orange", "banana"] */ -s2->Belt.Set.String.toArray /* ["orange"] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t, array) => t -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -let set = Belt.Set.String.fromArray(["apple", "banana", "orange"]) - -let newSet = set->Belt.Set.String.removeMany(["strawberry", "apple", "banana", "orange"]) -newSet->Belt.Set.String.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.Set.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let union = Belt.Set.String.union(s0, s1) -union->Belt.Set.String.toArray /* ["apple", "banana", "carrot", "orange", "strawberry"] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.Set.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let intersect = Belt.Set.String.intersect(s0, s1) -intersect->Belt.Set.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.Set.String.fromArray(["apple", "banana", "orange", "strawberry"]) -Belt.Set.String.toArray(Belt.Set.String.diff(s0, s1)) /* ["carrot"] */ -Belt.Set.String.toArray(Belt.Set.String.diff(s1, s0)) /* ["strawberry"] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.Set.String.fromArray(["5", "2", "3", "5", "6"]) -let s1 = Belt.Set.String.fromArray(["5", "2", "3", "1", "5", "4"]) -let s2 = Belt.Set.String.intersect(s0, s1) -Belt.Set.String.subset(s2, s0) /* true */ -Belt.Set.String.subset(s2, s1) /* true */ -Belt.Set.String.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "orange"]) -let s1 = Belt.Set.String.fromArray(["orange", "apple"]) - -Belt.Set.String.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.Set.String.fromArray(["banana", "orange", "apple"]) -let acc = ref(list{}) -s0->Belt.Set.String.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* ["orange", "banana", "apple"] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "orange"]) -s0->Belt.Set.String.reduce(0, (acc, element) => acc + String.length(element)) /* 11 */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let hasAtLeastFiveChars = x => String.length(x) >= 5 - -let s0 = Belt.Set.String.fromArray(["apple", "carrot"]) -s0->Belt.Set.String.every(hasAtLeastFiveChars) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.Set.String.fromArray(["strawberry", "apple"]) -s0->Belt.Set.String.some(hasFiveChars) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.Set.String.fromArray(["apple", "orange", "banana"]) -let s1 = s0->Belt.Set.String.keep(hasFiveChars) - -s1->Belt.Set.String.toArray /* ["apple"] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.Set.String.fromArray(["apple", "carrot"]) -let (s1, s2) = s0->Belt.Set.String.partition(hasFiveChars) - -s1->Belt.Set.String.toArray /* ["apple"] */ -s2->Belt.Set.String.toArray /* ["carrot"] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.Set.String.fromArray(["apple"]) - -s0->Belt.Set.String.size /* 1 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "watermelon"]) - -s0->Belt.Set.String.toList /* ["apple", "watermelon"] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "watermelon"]) - -s0->Belt.Set.String.toArray /* ["apple", "watermelon"] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.minimum /* None */ -s1->Belt.Set.String.minimum /* Some("apple") */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.minUndefined /* undefined */ -s1->Belt.Set.String.minUndefined /* "apple" */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.maximum /* None */ -s1->Belt.Set.String.maximum /* Some("orange") */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.maxUndefined /* undefined */ -s1->Belt.Set.String.maxUndefined /* orange */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "carrot"]) - -s0->Belt.Set.String.get("carrot") /* Some("carrot") */ -s0->Belt.Set.String.get("watermelon") /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -See [get](#get) - returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -See [get](#get) - raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a triple `((l, r), present)`, where `l` is the set of elements of set that are strictly less than value, `r` is the set of elements of set that are strictly greater than value, `present` is `false` if set contains no element equal to value, or `true` if set contains an element equal to value. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange"]) - -let ((smaller, larger), present) = s0->Belt.Set.String.split("banana") - -present /* true */ -smaller->Belt.Set.String.toArray /* ["apple"] */ -larger->Belt.Set.String.toArray /* ["orange"] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v10.0.0/api/belt/set.mdx b/pages/docs/manual/v10.0.0/api/belt/set.mdx deleted file mode 100644 index 173cdd865..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/set.mdx +++ /dev/null @@ -1,590 +0,0 @@ -# Set - - - -A **immutable** sorted set module which allows customize compare behavior. -The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map. - -It also has three specialized inner modules [Belt.Set.Int](set-int), [Belt.Set.String](set-string) and [Belt.Set.Dict](set-dict) - This module separates data from function which is more verbose but slightly more efficient - - - -```res example -module PairComparator = - Belt.Id.MakeComparable({ - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch (Pervasives.compare(a0, b0)) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - }) - -let mySet = Belt.Set.make(~id=module(PairComparator)) -let mySet2 = Belt.Set.add(mySet, (1, 2)) -``` - -**Note:** This module's examples will assume a predeclared module for integers -called `IntCmp`. It is declared like this: - -```res prelude -module IntCmp = - Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare - }) -``` - -## t - -```res prelude -type t<'value, 'identity> -``` - -`'value` is the element type - -`'identity` the identity of the collection - -## id - -```res prelude -type id<'value, 'id> = Belt_Id.comparable<'value, 'id> -``` - -The identity needed for making a set from scratch - -## make - -```res sig -let make: (~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates a new set by taking in the comparator - -```res example -let set = Belt.Set.make(~id=module(IntCmp)) -``` - -## fromArray - -```res sig -let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.Set.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -s0->Belt.Set.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.Set.fromArray([], ~id=module(IntCmp)) -let notEmpty = Belt.Set.fromArray([1],~id=module(IntCmp)) - -Belt.Set.isEmpty(empty) /* true */ -Belt.Set.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t<'value, 'id>, 'value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.Set.fromArray([1, 4, 2, 5], ~id=module(IntCmp)) - -set->Belt.Set.has(3) /* false */ -set->Belt.Set.has(1) /* true */ -``` - -## add - -```res sig -let add: (t<'value, 'id>, 'value) => t<'value, 'id> -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = s0->Belt.Set.add(1) -let s2 = s1->Belt.Set.add(2) -let s3 = s2->Belt.Set.add(2) -s0->Belt.Set.toArray /* [] */ -s1->Belt.Set.toArray /* [1] */ -s2->Belt.Set.toArray /* [1, 2] */ -s3->Belt.Set.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id> -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.Set.make(~id=module(IntCmp)) - -let newSet = set->Belt.Set.mergeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t<'value, 'id>, 'value) => t<'value, 'id> -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.fromArray([2,3,1,4,5], ~id=module(IntCmp)) -let s1 = s0->Belt.Set.remove(1) -let s2 = s1->Belt.Set.remove(3) -let s3 = s2->Belt.Set.remove(3) - -s1->Belt.Set.toArray /* [2,3,4,5] */ -s2->Belt.Set.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id> -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -let set = Belt.Set.fromArray([1, 2, 3, 4],~id=module(IntCmp)) - -let newSet = set->Belt.Set.removeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.toArray /* [] */ -``` - -## union - -```res sig -let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns union of two sets. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let union = Belt.Set.union(s0, s1) -union->Belt.Set.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let intersect = Belt.Set.intersect(s0, s1) -intersect->Belt.Set.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -Belt.Set.toArray(Belt.Set.diff(s0, s1)) /* [6] */ -Belt.Set.toArray(Belt.Set.diff(s1,s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let s2 = Belt.Set.intersect(s0, s1) -Belt.Set.subset(s2, s0) /* true */ -Belt.Set.subset(s2, s1) /* true */ -Belt.Set.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t<'value, 'id>, t<'value, 'id>) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.Set.fromArray([5,2,3], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,5], ~id=module(IntCmp)) - -Belt.Set.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'value, 'id>, 'value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let acc = ref(list{}) -s0->Belt.Set.forEach(x => { - acc := Belt.List.add(acc.contents, x) -}) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -s0->Belt.Set.reduce(list{}, (acc, element) => - acc->Belt.List.add(element) -) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## every - -```res sig -let every: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.fromArray([2,4,6,8], ~id=module(IntCmp)) -s0->Belt.Set.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## some - -```res sig -let some: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.fromArray([1,2,4,6,8], ~id=module(IntCmp)) -s0->Belt.Set.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> -``` - -## keep - -```res sig -let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) -let s1 = s0->Belt.Set.keep(isEven) - -s1->Belt.Set.toArray /* [2,4] */ -``` - -## partitionU - -```res sig -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -## partition - -```res sig -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) -let (s1, s2) = s0->Belt.Set.partition(isOdd) - -s1->Belt.Set.toArray /* [1,3,5] */ -s2->Belt.Set.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t<'value, 'id> => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.Set.fromArray([1,2,3,4], ~id=module(IntCmp)) - -s0->Belt.Set.size /* 4 */ -``` - -## toArray - -```res sig -let toArray: t<'value, 'id> => array<'value> -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.toArray /* [1,2,3,5] */ -``` - -## toList - -```res sig -let toList: t<'value, 'id> => list<'value> -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.toList /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t<'value, 'id> => option<'value> -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.minimum /* None */ -s1->Belt.Set.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.minUndefined /* undefined */ -s1->Belt.Set.minUndefined /* 1 */ -``` - -## maximum - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.maximum /* None */ -s1->Belt.Set.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.maxUndefined /* undefined */ -s1->Belt.Set.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t<'value, 'id>, 'value) => option<'value> -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) - -s0->Belt.Set.get(3) /* Some(3) */ -s0->Belt.Set.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t<'value, 'id>, 'value) => 'value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) - -let ((smaller, larger), present) = s0->Belt.Set.split(3) - -present /* true */ -smaller->Belt.Set.toArray /* [1,2] */ -larger->Belt.Set.toArray /* [4,5] */ - -``` - -## getData - -```res sig -let getData: t<'value, 'id> => Belt_SetDict.t<'value, 'id> -``` - -**Advanced usage only** - -Returns the raw data (detached from comparator), but its type is still manifested, so that user can pass identity directly without boxing. - -## getId - -```res sig -let getId: t<'value, 'id> => id<'value, 'id> -``` - -**Advanced usage only** - -Returns the identity of set. - -## packIdData - -```res sig -let packIdData: (~id: id<'value, 'id>, ~data: Belt_SetDict.t<'value, 'id>) => t<'value, 'id> -``` - -**Advanced usage only** - -Returns the packed collection. diff --git a/pages/docs/manual/v10.0.0/api/belt/sort-array-int.mdx b/pages/docs/manual/v10.0.0/api/belt/sort-array-int.mdx deleted file mode 100644 index 15fc2dc4c..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/sort-array-int.mdx +++ /dev/null @@ -1,59 +0,0 @@ -# SortArrayInt - - - -This is a specialized module for `Belt.SortArray`, the docs in that module also applies here, except the comparator is fixed and inlined. - - - -## element - -```res prelude -type element = int -``` - -## strictlySortedLength - -```res sig -let strictlySortedLength: array => int -``` - -The same as `Belt.SortArray.strictlySortedLength` except the comparator is fixed. - -Returns `+n` means increasing order `-n` means negative order. - -## isSorted - -```res sig -let isSorted: array => bool -``` - -`sorted(xs)` return true if `xs` is in non strict increasing order. - -## stableSortInPlace - -```res sig -let stableSortInPlace: array => unit -``` - -The same as `Belt.SortArray.stableSortInPlaceBy` except the comparator is fixed. - -## stableSort - -```res sig -let stableSort: array => array -``` - -The same as `Belt.SortArray.stableSortBy` except the comparator is fixed. - -## binarySearch - -```res sig -let binarySearch: (array, element) => int -``` - -If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value. - -If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot(-1) = 0` if `key` is larger than all elements return `- (len + 1)` since `lnot(-(len+1)) = len`. diff --git a/pages/docs/manual/v10.0.0/api/belt/sort-array-string.mdx b/pages/docs/manual/v10.0.0/api/belt/sort-array-string.mdx deleted file mode 100644 index 3016c1903..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/sort-array-string.mdx +++ /dev/null @@ -1,59 +0,0 @@ -# SortArrayString - - - -This is a specialized module for `Belt.SortArray`, the docs in that module also applies here, except the comparator is fixed and inlined. - - - -## element - -```res prelude -type element = string -``` - -## strictlySortedLength - -```res sig -let strictlySortedLength: array => int -``` - -The same as `Belt.SortArray.strictlySortedLength` except the comparator is fixed. - -Returns `+n` means increasing order `-n` means negative order. - -## isSorted - -```res sig -let isSorted: array => bool -``` - -`sorted(xs)` return true if `xs` is in non strict increasing order. - -## stableSortInPlace - -```res sig -let stableSortInPlace: array => unit -``` - -The same as `Belt.SortArray.stableSortInPlaceBy` except the comparator is fixed. - -## stableSort - -```res sig -let stableSort: array => array -``` - -The same as `Belt.SortArray.stableSortBy` except the comparator is fixed. - -## binarySearch - -```res sig -let binarySearch: (array, element) => int -``` - -If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value. - -If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot(-1) = 0` if `key` is larger than all elements return `- (len + 1)` since `lnot(-(len+1)) = len`. diff --git a/pages/docs/manual/v10.0.0/api/belt/sort-array.mdx b/pages/docs/manual/v10.0.0/api/belt/sort-array.mdx deleted file mode 100644 index 8d6e3d1ee..000000000 --- a/pages/docs/manual/v10.0.0/api/belt/sort-array.mdx +++ /dev/null @@ -1,111 +0,0 @@ -# SortArray - -## SortArrayInt - -```res example -module Int = Belt.SortArray.Int -``` - -Specialized when key type is `int`, more efficient than the generic type - -## SortArrayString - -```res example -module String = Belt.SortArray.String -``` - -Specialized when key type is `string`, more efficient than the generic type - -## strictlySortedLengthU - -```res sig -let strictlySortedLengthU: (array<'a>, (. 'a, 'a) => bool) => int -``` - -## strictlySortedLength - -```res sig -let strictlySortedLength: (array<'a>, ('a, 'a) => bool) => int -``` - -`strictlySortedLenght(xs, cmp);` return `+n` means increasing order `-n` means negative order - -```res example -Belt.SortArray.strictlySortedLength([1, 2, 3, 4, 3], (x, y) => x < y) == 4 - -Belt.SortArray.strictlySortedLength([], (x, y) => x < y) == 0 - -Belt.SortArray.strictlySortedLength([1], (x, y) => x < y) == 1 - -Belt.SortArray.strictlySortedLength([4, 3, 2, 1], (x, y) => x < y) == -4 -``` - -## isSortedU - -```res sig -let isSortedU: (array<'a>, (. 'a, 'a) => int) => bool -``` - -## isSorted - -```res sig -let isSorted: (array<'a>, ('a, 'a) => int) => bool -``` - -`isSorted(arr, cmp)`: Returns true if array is increasingly sorted (equal is okay) - -## stableSortInPlaceByU - -```res sig -let stableSortInPlaceByU: (array<'a>, (. 'a, 'a) => int) => unit -``` - -## stableSortInPlaceBy - -```res sig -let stableSortInPlaceBy: (array<'a>, ('a, 'a) => int) => unit -``` - -## stableSortByU - -```res sig -let stableSortByU: (array<'a>, (. 'a, 'a) => int) => array<'a> -``` - -## stableSortBy - -```res sig -let stableSortBy: (array<'a>, ('a, 'a) => int) => array<'a> -``` - -`stableSortBy(xs, cmp)`: Returns a fresh array Sort `xs` in place using -comparator `cmp`, the stable means if the elements are equal, their order will -be preserved - -## binarySearchByU - -```res sig -let binarySearchByU: (array<'a>, 'a, (. 'a, 'a) => int) => int -``` - -## binarySearchBy - -```res sig -let binarySearchBy: (array<'a>, 'a, ('a, 'a) => int) => int -``` - -If value is not found and value is less than one or more elements in array, the -negative number returned is the bitwise complement of the index of the first -element that is larger than value. - -If value is not found and value is greater -than all elements in array, the negative number returned is the bitwise -complement of (the index of the last element plus 1)for example, if `key` is -smaller than all elements return `-1` since `lnot(-1) == 0` if `key` is larger -than all elements return `lnot(-1) == 0` since `lnot(- (len + 1)) == len` - -```res example -Belt.SortArray.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 33, Pervasives.compare) == 4 - -lnot(Belt.SortArray.binarySearchBy([1, 3, 5, 7], 4, Pervasives.compare)) == 2 -``` diff --git a/pages/docs/manual/v10.0.0/api/dom.mdx b/pages/docs/manual/v10.0.0/api/dom.mdx deleted file mode 100644 index b74050f73..000000000 --- a/pages/docs/manual/v10.0.0/api/dom.mdx +++ /dev/null @@ -1,855 +0,0 @@ -# Dom - - - -The Dom module offers a canonical set of dom related types that third party libraries can depend on. It only provides types, no functions to manipulate the values of certain types whatsoever. - - - -## animation - -```res sig -type animation -``` - -## cssStyleDeclaration - -```res sig -type cssStyleDeclaration -``` - -## cssStyleSheet - -```res sig -type cssStyleSheet -``` - -## node - -```res sig -type node -``` - -## characterData - -```res sig -type characterData -``` - -## cdataSection - -```res sig -type cdataSection -``` - -## comment - -```res sig -type comment -``` - -## document - -```res sig -type document -``` - -## documentType - -```res sig -type documentType -``` - -## domImplementation - -```res sig -type domImplementation -``` - -## element - -```res sig -type element -``` - -## htmlCollection - -```res sig -type htmlCollection -``` - -## htmlFormControlsCollection - -```res sig -type htmlFormControlsCollection -``` - -## htmlOptionsCollection - -```res sig -type htmlOptionsCollection -``` - -## intersectionObserver - -```res sig -type intersectionObserver -``` - -## intersectionObserverEntry - -```res sig -type intersectionObserverEntry -``` - -## mutationObserver - -```res sig -type mutationObserver -``` - -## mutationRecord - -```res sig -type mutationRecord -``` - -## performanceObserver - -```res sig -type performanceObserver -``` - -## performanceObserverEntryList - -```res sig -type performanceObserverEntryList -``` - -## reportingObserver - -```res sig -type reportingObserver -``` - -## reportingObserverOptions - -```res sig -type reportingObserverOptions -``` - -## resizeObserver - -```res sig -type resizeObserver -``` - -## resizeObserverEntry - -```res sig -type resizeObserverEntry -``` - -## namedNodeMap - -```res sig -type namedNodeMap -``` - -## nodeList - -```res sig -type nodeList -``` - -## radioNodeList - -```res sig -type radioNodeList -``` - -## processingInstruction - -```res sig -type processingInstruction -``` - -## shadowRoot - -```res sig -type shadowRoot -``` - -## text - -```res sig -type text -``` - -## domRect - -```res sig -type domRect -``` - -## dataTransfer - -```res sig -type dataTransfer -``` - -## domStringMap - -```res sig -type domStringMap -``` - -## history - -```res sig -type history -``` - -## htmlDocument - -```res sig -type htmlDocument -``` - -## htmlElement - -```res sig -type htmlElement -``` - -## htmlAnchorElement - -```res sig -type htmlAnchorElement -``` - -## htmlAreaElement - -```res sig -type htmlAreaElement -``` - -## htmlAudioElement - -```res sig -type htmlAudioElement -``` - -## htmlBaseElement - -```res sig -type htmlBaseElement -``` - -## htmlBodyElement - -```res sig -type htmlBodyElement -``` - -## htmlBrElement - -```res sig -type htmlBrElement -``` - -## htmlButtonElement - -```res sig -type htmlButtonElement -``` - -## htmlCanvasElement - -```res sig -type htmlCanvasElement -``` - -## htmlDataElement - -```res sig -type htmlDataElement -``` - -## htmlDataListElement - -```res sig -type htmlDataListElement -``` - -## htmlDialogElement - -```res sig -type htmlDialogElement -``` - -## htmlDivElement - -```res sig -type htmlDivElement -``` - -## htmlDlistElement - -```res sig -type htmlDlistElement -``` - -## htmlEmbedElement - -```res sig -type htmlEmbedElement -``` - -## htmlFieldSetElement - -```res sig -type htmlFieldSetElement -``` - -## htmlFormElement - -```res sig -type htmlFormElement -``` - -## htmlHeadElement - -```res sig -type htmlHeadElement -``` - -## htmlHeadingElement - -```res sig -type htmlHeadingElement -``` - -## htmlHrElement - -```res sig -type htmlHrElement -``` - -## htmlHtmlElement - -```res sig -type htmlHtmElement -``` - -## htmlIframeElement - -```res sig -type htmlIframeElement -``` - -## htmlImageElement - -```res sig -type htmlImageElement -``` - -## htmlInputElement - -```res sig -type htmlInputElement -``` - -## htmlLabelElement - -```res sig -type htmlLabelElement -``` - -## htmlLegendElement - -```res sig -type htmlLegendElement -``` - -## htmlLiElement - -```res sig -type htmlLiElement -``` - -## htmlLinkElement - -```res sig -type htmlLinkElement -``` - -## htmlMapElement - -```res sig -type htmlMapElement -``` - -## htmlMediaElement - -```res sig -type htmlMediaElement -``` - -## htmlMenuElement - -```res sig -type htmlMenuElement -``` - -## htmlMetaElement - -```res sig -type htmlMetaElement -``` - -## htmlMeterElement - -```res sig -type htmlMeterElement -``` - -## htmlModElement - -```res sig -type htmlModElement -``` - -## htmlOListElement - -```res sig -type htmlOListElement -``` - -## htmlObjectElement - -```res sig -type htmlObjectElement -``` - -## htmlOptGroupElement - -```res sig -type htmlOptGroupElement -``` - -## htmlOptionElement - -```res sig -type htmlOptionElement -``` - -## htmlOutputElement - -```res sig -type htmlOutputElement -``` - -## htmlParagraphElement - -```res sig -type htmlParagraphElement -``` - -## htmlParamElement - -```res sig -type htmlParamElement -``` - -## htmlPreElement - -```res sig -type htmlPreElement -``` - -## htmlProgressElement - -```res sig -type htmlProgressElement -``` - -## htmlQuoteElement - -```res sig -type htmlQuoteElement -``` - -## htmlScriptElement - -```res sig -type htmlScriptElement -``` - -## htmlSelectElement - -```res sig -type htmlSelectElement -``` - -## htmlSlotElement - -```res sig -type htmlSlotElement -``` - -## htmlSourceElement - -```res sig -type htmlSourceElement -``` - -## htmlSpanElement - -```res sig -type htmlSpanElement -``` - -## htmlStyleElement - -```res sig -type htmlStyleElement -``` - -## htmlTableCaptionElement - -```res sig -type htmlTableCaptionElement -``` - -## htmlTableCellElement - -```res sig -type htmlTableCellElement -``` - -## htmlTableColElement - -```res sig -type htmlTableColElement -``` - -## htmlTableDataCellElement - -```res sig -type htmlTableDataCellElement -``` - -## htmlTableElement - -```res sig -type htmlTableElement -``` - -## htmlTableHeaderCellElement - -```res sig -type htmlTableHeaderCellElement -``` - -## htmlTableRowElement - -```res sig -type htmlTableRowElement -``` - -## htmlTableSectionElement - -```res sig -type htmlTableSectionElement -``` - -## htmlTextAreaElement - -```res sig -type htmlTextAreaElement -``` - -## htmlTimeElement - -```res sig -type htmlTimeElement -``` - -## htmlTitleElement - -```res sig -type htmlTitleElement -``` - -## htmlTrackElement - -```res sig -type htmlTrackElement -``` - -## htmlUlistElement - -```res sig -type htmlUlistElement -``` - -## htmlUnknownElement - -```res sig -type htmlUnknownElement -``` - -## htmlVideoElement - -```res sig -type htmlVideoElement -``` - -## location - -```res sig -type location -``` - -## window - -```res sig -type window -``` - -## xmlDocument - -```res sig -type xmlDocument -``` - -## event - -```res sig -type event -``` - -## uiEvent - -```res sig -type uiEvent -``` - -## animationEvent - -```res sig -type animationEvent -``` - -## beforeUnloadEvent - -```res sig -type beforeUnloadEvent -``` - -## clipboardEvent - -```res sig -type clipboardEvent -``` - -## closeEvent - -```res sig -type closeEvent -``` - -## compositionEvent - -```res sig -type compositionEvent -``` - -## customEvent - -```res sig -type customEvent -``` - -## dragEvent - -```res sig -type dragEvent -``` - -## errorEvent - -```res sig -type errorEvent -``` - -## focusEvent - -```res sig -type focusEvent -``` - -## idbVersionChangeEvent - -```res sig -type idbVersionChangeEvent -``` - -## inputEvent - -```res sig -type inputEvent -``` - -## keyboardEvent - -```res sig -type keyboardEvent -``` - -## mouseEvent - -```res sig -type mouseEvent -``` - -## pageTransitionEvent - -```res sig -type pageTransitionEvent -``` - -## pointerEvent - -```res sig -type pointerEvent -``` - -## popStateEvent - -```res sig -type popStateEvent -``` - -## progressEvent - -```res sig -type progressEvent -``` - -## relatedEvent - -```res sig -type relatedEvent -``` - -## storageEvent - -```res sig -type storageEvent -``` - -## svgZoomEvent - -```res sig -type svgZoomEvent -``` - -## timeEvent - -```res sig -type timeEvent -``` - -## touchEvent - -```res sig -type touchEvent -``` - -## trackEvent - -```res sig -type trackEvent -``` - -## transitionEvent - -```res sig -type transitionEvent -``` - -## webGlContextEvent - -```res sig -type webGlContextEvent -``` - -## wheelEvent - -```res sig -type wheelEvent -``` - -## range - -```res sig -type range -``` - -## selection - -```res sig -type selection -``` - -## domTokenList - -```res sig -type domTokenList -``` - -## domSettableTokenList - -```res sig -type domSettableTokenList -``` - -## nodeFilter - -```res sig -type nodeFilter = { - acceptNode: (Dom.element) => int -} -``` - -## nodeIterator - -```res sig -type nodeIterator -``` - -## treeWalker - -```res sig -type treeWalker -``` - -## svgRect - -```res sig -type svgRect -``` - -## svgPoint - -```res sig -type svgPoint -``` - -## eventPointerId - -```res sig -type eventPointerId -``` diff --git a/pages/docs/manual/v10.0.0/api/dom/storage.mdx b/pages/docs/manual/v10.0.0/api/dom/storage.mdx deleted file mode 100644 index 281240683..000000000 --- a/pages/docs/manual/v10.0.0/api/dom/storage.mdx +++ /dev/null @@ -1,55 +0,0 @@ -# Storage - -## t - -```res prelude sig -type t -``` - -## getItem - -```res sig -external getItem: (string, t) => option = "getItem" -``` - -## setItem - -```res sig -external setItem: (string, string, t) => unit = "setItem" -``` - -## removeItem - -```res sig -external removeItem: (string, t) => unit = "removeItem" -``` - -## clear - -```res sig -external clear: t => unit = "clear" -``` - -## key - -```res sig -external key: (int, t) => option = "key" -``` - -## length - -```res sig -external length: t => int = "length" -``` - -## localStorage - -```res sig -@val external localStorage: t = "localStorage" -``` - -## sessionStorage - -```res sig -@val external sessionStorage: t = "sessionStorage" -``` diff --git a/pages/docs/manual/v10.0.0/api/dom/storage2.mdx b/pages/docs/manual/v10.0.0/api/dom/storage2.mdx deleted file mode 100644 index 5292b85a3..000000000 --- a/pages/docs/manual/v10.0.0/api/dom/storage2.mdx +++ /dev/null @@ -1,61 +0,0 @@ -# Storage2 - - - -The same as [Dom.Storage](./storage2), but with `t` on first argument position for proper `->` usage. - - - -## t - -```res prelude sig -type t -``` - -## getItem - -```res sig -external getItem: (t, string) => option = "getItem" -``` - -## setItem - -```res sig -external setItem: (t, string, string) => unit = "setItem" -``` - -## removeItem - -```res sig -external removeItem: (t, string) => unit = "removeItem" -``` - -## clear - -```res sig -external clear: t => unit = "clear" -``` - -## key - -```res sig -external key: (t, int) => option = "key" -``` - -## length - -```res sig -external length: t => int = "length" -``` - -## localStorage - -```res sig -@val external localStorage: t = "localStorage" -``` - -## sessionStorage - -```res sig -@val external sessionStorage: t = "sessionStorage" -``` diff --git a/pages/docs/manual/v10.0.0/api/js.mdx b/pages/docs/manual/v10.0.0/api/js.mdx deleted file mode 100644 index c8f023802..000000000 --- a/pages/docs/manual/v10.0.0/api/js.mdx +++ /dev/null @@ -1,179 +0,0 @@ -# Js - -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/array-2) 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._ - -In the meantime, there are several options for dealing with the data-last APIs: - -```res example -/* Js.String (data-last API used with pipe last operator) */ -Js.log("2019-11-10" |> Js.String.split("-")) -Js.log("ReScript" |> Js.String.startsWith("Re")) - -/* Js.String (data-last API used with pipe first operator) */ -Js.log("2019-11-10"->Js.String.split("-", _)) -Js.log("ReScript"->Js.String.startsWith("Re", _)) - -/* Js.String (data-last API used without any piping) */ -Js.log(Js.String.split("-", "2019-11-10")) -Js.log(Js.String.startsWith("Re", "ReScript")) -``` - -## Js.Xxx2 Modules - -Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latters are old modules. - -## Object - -```res sig -type t<+'a> -``` - -Js object type. - -```res example -let x: {"x": int, "y": int} = {"x": 1, "y": 2} -``` - -## Nullable and Undefined - -```res prelude -type null<+'a> -``` - -nullable, value of this type can be either null or 'a this type is the same as type t in Js.Null - -```res prelude -type undefined<+'a> -``` - -value of this type can be either undefined or 'a this type is the same as type t in Js.Undefined - -```res prelude -type nullable<+'a> -``` - -value of this type can be undefined, null or 'a this type is the same as type t n Js.Null_undefined - -```res prelude -type null_undefined<'a> = Js.nullable<'a> -``` - -```res sig -let toOption: Js.nullable<'a> => option<'a> -``` - -```res sig -let undefinedToOption: Js.undefined<'a> => option<'a> -``` - -```res sig -let nullToOption: Js.null<'a> => option<'a> -``` - -```res sig -let test: Js.nullable<'a> => bool -``` - -```res sig -let isNullable: Js.nullable<'a> => bool -``` - -```res sig -let testAny: 'a => bool -``` - -The same as `Js.test` except that it is more permissive on the types of input. - -```res sig -type promise<+'a, +'e> -``` - -Deprecated. please use `Js.Promise`. -The promise type, defined here for interoperation across packages. - -```res sig -let null: Js.null<'a> -``` - -The same as empty in `Js.Null`. Will be compiled as `null`. - -```res sig -let undefined: Js.undefined<'a> -``` - -The same as empty `Js.Undefined`. Will be compiled as `undefined`. - -## TypeOf - -```res sig -let typeof: 'a => string -``` - -`typeof x` will be compiled as `typeof x` in JS. Please consider functions in `Js.Types` for a type safe way of reflection. - -## Logging - -```res sig -let log: 'a => unit -let log2: ('a, 'b) => unit -let log3: ('a, 'b, 'c) => unit -let log4: ('a, 'b, 'c, 'd) => unit -``` - -A convenience function to log everything. - -```res sig -let logMany: array<'a> => unit -``` - -A convenience function to log more than 4 arguments - -## Comparison - -```res sig -let eqNull: ('a, null<'a>) => bool -let eqUndefined: ('a, undefined<'a>) => bool -let eqNullable: ('a, nullable<'a>) => bool -``` - -```res sig -let unsafe_lt: ('a, 'a) => bool -``` - -`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. - -```res sig -let unsafe_le: ('a, 'a) => bool -``` - -`unsafe_le a b` will be compiled as `a <= b`. See also `Js.unsafe_lt`. - -```res sig -let unsafe_gt: ('a, 'a) => bool -``` - -`unsafe_gt a b` will be compiled as `a > b`. See also `Js.unsafe_lt`. - -```res sig -let unsafe_ge: ('a, 'a) => bool -``` - -`unsafe_ge a b` will be compiled as `a >= b`. See also `Js.unsafe_lt`. diff --git a/pages/docs/manual/v10.0.0/api/js/array-2.mdx b/pages/docs/manual/v10.0.0/api/js/array-2.mdx deleted file mode 100644 index ad627fab9..000000000 --- a/pages/docs/manual/v10.0.0/api/js/array-2.mdx +++ /dev/null @@ -1,900 +0,0 @@ -# Array2 - - - -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: - -```res example -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: - -```res example -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) -} -``` - - - -## t - -```res prelude -type t<'a> = array<'a> -``` - -The type used to describe a JavaScript array. - -## array_like - -```res prelude -type array_like<'a> -``` - -A type used to describe JavaScript objects that are like an array or are iterable. - -## from - -```res sig -let from: array_like<'a> => array<'a> -``` - -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. - -```res example -let strArr = Js.String.castToArrayLike("abcd") -Js.Array2.from(strArr) == ["a", "b", "c", "d"] -``` - -## fromMap - -```res sig -let fromMap: (array_like<'a>, 'a => 'b) => array<'b> -``` - -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. - -```res example -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] -``` - -## isArray - -```res sig -let isArray: 'a => bool -``` - -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. - -```res example -Js.Array2.isArray([5, 2, 3, 1, 4]) == true -Js.Array2.isArray(list{5, 2, 3, 1, 4}) == true -Js.Array2.isArray("abcd") == false -``` - -## length - -```res sig -let length: array<'a> => int -``` - -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. - -## copyWithin - -```res sig -let copyWithin: (t<'a>, ~to_: int) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array2.copyWithin(arr, ~to_=2) == [100, 101, 100, 101, 102] -arr == [100, 101, 100, 101, 102] -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (t<'a>, ~to_: int, ~from: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (t<'a>, ~to_: int, ~start: int, ~end_: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillInPlace - -```res sig -let fillInPlace: (t<'a>, 'a) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array2.fillInPlace(arr, 99) == [99, 99, 99, 99, 99] -arr == [99, 99, 99, 99, 99] -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (t<'a>, 'a, ~from: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (t<'a>, 'a, ~start: int, ~end_: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## push - -```res sig -let push: (t<'a>, 'a) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array2.push(arr, "dog") == 4 -arr == ["ant", "bee", "cat", "dog"] -``` - -## pushMany - -```res sig -let pushMany: (t<'a>, array<'a>) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array2.pushMany(arr, ["dog", "elk"]) == 5 -arr == ["ant", "bee", "cat", "dog", "elk"] -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t<'a> => t<'a> -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array2.reverseInPlace(arr) == ["cat", "bee", "ant"] -arr == ["cat", "bee", "ant"] -``` - -## shift - -```res sig -let shift: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## sortInPlace - -```res sig -let sortInPlace: t<'a> => t<'a> -``` - -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. - -```res example -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] -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: (t<'a>, ('a, 'a) => int) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## spliceInPlace - -```res sig -let spliceInPlace: (t<'a>, ~pos: int, ~remove: int, ~add: array<'a>) => t<'a> -``` - -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. - -```res example -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"] -``` - -## removeFromInPlace - -```res sig -let removeFromInPlace: (t<'a>, ~pos: int) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array2.removeFromInPlace(arr, ~pos=4) == ["e", "f"] -arr == ["a", "b", "c", "d"] -``` - -## removeCountInPlace - -```res sig -let removeCountInPlace: (t<'a>, ~pos: int, ~count: int) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array2.removeCountInPlace(arr, ~pos=2, ~count=3) == ["c", "d", "e"] -arr == ["a", "b", "f"] -``` - -## unshift - -```res sig -let unshift: (t<'a>, 'a) => int -``` - -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. - -```res example -let arr = ["b", "c", "d"] -Js.Array2.unshift(arr, "a") == 4 -arr == ["a", "b", "c", "d"] -``` - -## unshiftMany - -```res sig -let unshiftMany: (t<'a>, array<'a>) => int -``` - -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. - -```res example -let arr = ["d", "e"] -Js.Array2.unshiftMany(arr, ["a", "b", "c"]) == 5 -arr == ["a", "b", "c", "d", "e"] -``` - -## append - -```res sig -let append: (t<'a>, 'a) => t<'a> -``` - -Deprecated. `append()` is not type-safe. Use `concat()` instead. - -## concat - -```res sig -let concat: (t<'a>, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array2.concat(["a", "b"], ["c", "d", "e"]) == ["a", "b", "c", "d", "e"] -``` - -## concatMany - -```res sig -let concatMany: (t<'a>, array>) => t<'a> -``` - -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. - -```res example -Js.Array2.concatMany(["a", "b", "c"], [["d", "e"], ["f", "g", "h"]]) == [ - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - ] -``` - -## includes - -```res sig -let includes: (t<'a>, 'a) => bool -``` - -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. - -```res example -Js.Array2.includes(["a", "b", "c"], "b") == true -Js.Array2.includes(["a", "b", "c"], "x") == false -``` - -## indexOf - -```res sig -let indexOf: (t<'a>, 'a) => int -``` - -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. - -```res example -Js.Array2.indexOf([100, 101, 102, 103], 102) == 2 -Js.Array2.indexOf([100, 101, 102, 103], 999) == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (t<'a>, 'a, ~from: int) => int -``` - -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. - -```res example -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 -``` - -## joinWith - -```res sig -let joinWith: (t<'a>, string) => string -``` - -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. - -```res example -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" -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (t<'a>, 'a) => int -``` - -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. - -```res example -Js.Array2.lastIndexOf(["a", "b", "a", "c"], "a") == 2 -Js.Array2.lastIndexOf(["a", "b", "a", "c"], "x") == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (t<'a>, 'a, ~from: int) => int -``` - -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. - -```res example -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 -``` - -## slice - -```res sig -let slice: (t<'a>, ~start: int, ~end_: int) => t<'a> -``` - -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. - -```res example -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) == [] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -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. - -## sliceFrom - -```res sig -let sliceFrom: (t<'a>, int) => t<'a> -``` - -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. - -```res example -Js.Array2.sliceFrom([100, 101, 102, 103, 104], 2) == [102, 103, 104] -``` - -## toString - -```res sig -let toString: t<'a> => string -``` - -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. - -```res example -Js.Array2.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8" -Js.Array2.toString(["a", "b", "c"]) == "a,b,c" -``` - -## toLocaleString - -```res sig -let toLocaleString: t<'a> => string -``` - -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. - -```res example -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 -``` - -## every - -```res sig -let every: (t<'a>, 'a => bool) => bool -``` - -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. - -```res example -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 -``` - -## everyi - -```res sig -let everyi: (t<'a>, ('a, int) => bool) => bool -``` - -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. - -```res example -// 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 -``` - -## filter - -```res sig -let filter: (t<'a>, 'a => bool) => t<'a> -``` - -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. - -```res example -let nonEmpty = s => s != "" -Js.Array2.filter(["abc", "", "", "def", "ghi"], nonEmpty) == ["abc", "def", "ghi"] -``` - -## filteri - -```res sig -let filteri: (t<'a>, ('a, int) => bool) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## find - -```res sig -let find: (t<'a>, 'a => bool) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findi - -```res sig -let findi: (t<'a>, ('a, int) => bool) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findIndex - -```res sig -let findIndex: (t<'a>, 'a => bool) => int -``` - -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. - -```res example -Js.Array2.findIndex([33, 22, -55, 77, -44], x => x < 0) == 2 -Js.Array2.findIndex([33, 22, 55, 77, 44], x => x < 0) == -1 -``` - -## findIndexi - -```res sig -let findIndexi: (t<'a>, ('a, int) => bool) => int -``` - -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. - -```res example -// 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 -``` - -## forEach - -```res sig -let forEach: (t<'a>, 'a => unit) => unit -``` - -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. - -```res example -// display all elements in an array -Js.Array2.forEach(["a", "b", "c"], x => Js.log(x)) == () -``` - -## forEachi - -```res sig -let forEachi: (t<'a>, ('a, int) => unit) => unit -``` - -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. - -```res example -// display all elements in an array as a numbered list -Js.Array2.forEachi(["a", "b", "c"], (item, index) => Js.log2(index + 1, item)) == () -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -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. - -```res example -Js.Array2.map([12, 4, 8], x => x * x) == [144, 16, 64] -Js.Array2.map(["animal", "vegetable", "mineral"], Js.String.length) == [6, 9, 7] -``` - -## mapi - -```res sig -let mapi: (t<'a>, ('a, int) => 'b) => t<'b> -``` - -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. - -```res example -// multiply each item in array by its position -let product = (item, index) => item * index -Js.Array2.mapi([10, 11, 12], product) == [0, 11, 24] -``` - -## reduce - -```res sig -let reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b -``` - -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. - -```res example -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) -``` - -## reducei - -```res sig -let reducei: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b -``` - -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. - -```res example -// 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 -``` - -## reduceRight - -```res sig -let reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b -``` - -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. - -```res example -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) -``` - -## reduceRighti - -```res sig -let reduceRighti: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b -``` - -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. - -```res example -// 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 -``` - -## some - -```res sig -let some: (t<'a>, 'a => bool) => bool -``` - -Returns `true` if the predicate function given as the second argument to `some()` returns `true` for any element in the array; `false` otherwise. - -```res example -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 -``` - -## somei - -```res sig -let somei: (t<'a>, ('a, int) => bool) => bool -``` - -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 - -```res example -// 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 -``` - -## unsafe_get - -```res sig -let unsafe_get: (array<'a>, int) => 'a -``` - -Returns the value at the given position in the array if the position is in bounds; returns the JavaScript value `undefined` otherwise. - -```res example -let arr = [100, 101, 102, 103] -Js.Array2.unsafe_get(arr, 3) == 103 -Js.Array2.unsafe_get(arr, 4) // returns undefined -``` - -## unsafe_set - -```res sig -let unsafe_set: (array<'a>, int, 'a) => unit -``` - -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._ - -```res example -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. -``` diff --git a/pages/docs/manual/v10.0.0/api/js/array.mdx b/pages/docs/manual/v10.0.0/api/js/array.mdx deleted file mode 100644 index 4c55ae32d..000000000 --- a/pages/docs/manual/v10.0.0/api/js/array.mdx +++ /dev/null @@ -1,934 +0,0 @@ -# Array - - - -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. - -Here is an example to find the sum of squares of all even numbers in an array. -Without pipe last, we must call the functions in reverse order: - -```res example -let isEven = x => mod(x, 2) == 0 -let square = x => x * x -let result = { - open Js.Array - reduce(\"+", 0, map(square, filter(isEven, [5, 2, 3, 4, 1]))) -} -``` - -With pipe last, we call the functions in the “natural” order: - -```res example -let isEven = x => mod(x, 2) == 0 -let square = x => x * x -let result = { - open Js.Array - [5, 2, 3, 4, 1] |> filter(isEven) |> map(square) |> reduce(\"+", 0) -} -``` - - - -## t - -```res prelude -type t<'a> = array<'a> -``` - -The type used to describe a JavaScript array. - -## array_like - -```res prelude -type array_like<'a> = Js_array2.array_like<'a> -``` - -A type used to describe JavaScript objects that are like an array or are iterable. - -## from - -```res sig -let from: array_like<'a> => array<'a> -``` - -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. - -```res example -let strArr = Js.String.castToArrayLike("abcd") -Js.Array.from(strArr) == ["a", "b", "c", "d"] -``` - -## fromMap - -```res sig -let fromMap: (array_like<'a>, 'a => 'b) => array<'b> -``` - -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. - -```res example -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] -``` - -## isArray - -```res sig -let isArray: 'a => bool -``` - -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. - -```res example -Js.Array.isArray([5, 2, 3, 1, 4]) == true -Js.Array.isArray(list{5, 2, 3, 1, 4}) == true -Js.Array.isArray("abcd") == false -``` - -## length - -```res sig -let length: array<'a> => int -``` - -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. - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array.copyWithin(~to_=2, arr) == [100, 101, 100, 101, 102] -arr == [100, 101, 100, 101, 102] -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillInPlace - -```res sig -let fillInPlace: ('a, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array.fillInPlace(99, arr) == [99, 99, 99, 99, 99] -arr == [99, 99, 99, 99, 99] -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: ('a, ~from: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: ('a, ~start: int, ~end_: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## push - -```res sig -let push: ('a, t<'a>) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array.push("dog", arr) == 4 -arr == ["ant", "bee", "cat", "dog"] -``` - -## pushMany - -```res sig -let pushMany: (array<'a>, t<'a>) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array.pushMany(["dog", "elk"], arr) == 5 -arr == ["ant", "bee", "cat", "dog", "elk"] -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t<'a> => t<'a> -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array.reverseInPlace(arr) == ["cat", "bee", "ant"] -arr == ["cat", "bee", "ant"] -``` - -## shift - -```res sig -let shift: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## sortInPlace - -```res sig -let sortInPlace: t<'a> => t<'a> -``` - -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. - -```res example -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] -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: (('a, 'a) => int, t<'a>) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## spliceInPlace - -```res sig -let spliceInPlace: (~pos: int, ~remove: int, ~add: array<'a>, t<'a>) => t<'a> -``` - -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. - -```res example -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"] -``` - -## removeFromInPlace - -```res sig -let removeFromInPlace: (~pos: int, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array.removeFromInPlace(~pos=4, arr) == ["e", "f"] -arr == ["a", "b", "c", "d"] -``` - -## removeCountInPlace - -```res sig -let removeCountInPlace: (~pos: int, ~count: int, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array.removeCountInPlace(~pos=2, ~count=3, arr) == ["c", "d", "e"] -arr == ["a", "b", "f"] -``` - -## unshift - -```res sig -let unshift: ('a, t<'a>) => int -``` - -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. - -```res example -let arr = ["b", "c", "d"] -Js.Array.unshift("a", arr) == 4 -arr == ["a", "b", "c", "d"] -``` - -## unshiftMany - -```res sig -let unshiftMany: (array<'a>, t<'a>) => int -``` - -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. - -```res example -let arr = ["d", "e"] -Js.Array.unshiftMany(["a", "b", "c"], arr) == 5 -arr == ["a", "b", "c", "d", "e"] -``` - -## append - -```res sig -let append: ('a, t<'a>) => t<'a> -``` - -Deprecated. `append()` is not type-safe. Use `concat()` instead. - -## concat - -```res sig -let concat: (t<'a>, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array.concat(["c", "d", "e"], ["a", "b"]) == ["a", "b", "c", "d", "e"] -``` - -## concatMany - -```res sig -let concatMany: (array>, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array.concatMany([["d", "e"], ["f", "g", "h"]], ["a", "b", "c"]) == [ - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - ] -``` - -## includes - -```res sig -let includes: ('a, t<'a>) => bool -``` - -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. - -```res example -Js.Array.includes("b", ["a", "b", "c"]) == true -Js.Array.includes("x", ["a", "b", "c"]) == false -``` - -## indexOf - -```res sig -let indexOf: ('a, t<'a>) => int -``` - -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. - -```res example -Js.Array.indexOf(102, [100, 101, 102, 103]) == 2 -Js.Array.indexOf(999, [100, 101, 102, 103]) == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: ('a, ~from: int, t<'a>) => int -``` - -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. - -```res example -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 -``` - -## join - -```res sig -let join: t<'a> => string -``` - -Deprecated. Use `joinWith` instead. - -## joinWith - -```res sig -let joinWith: (string, t<'a>) => string -``` - -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. - -```res example -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" -``` - -## lastIndexOf - -```res sig -let lastIndexOf: ('a, t<'a>) => int -``` - -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. - -```res example -Js.Array.lastIndexOf("a", ["a", "b", "a", "c"]) == 2 -Js.Array.lastIndexOf("x", ["a", "b", "a", "c"]) == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: ('a, ~from: int, t<'a>) => int -``` - -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. - -```res example -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 -``` - -## lastIndexOf_start - -```res sig -let lastIndexOf_start: ('a, t<'a>) => int -``` - -Deprecated. Please use `lastIndexOf`. - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t<'a>) => t<'a> -``` - -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. - -```res example -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) == [] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -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. - -## slice_copy - -```res sig -let slice_copy: (unit, t<'a>) => t<'a> -``` - -Deprecated. Please use `copy`. - -## sliceFrom - -```res sig -let sliceFrom: (int, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array.sliceFrom(2, [100, 101, 102, 103, 104]) == [102, 103, 104] -``` - -## slice_start - -```res sig -let slice_start: (int, t<'a>) => t<'a> -``` - -Deprecated. Please `sliceFrom`. - -## toString - -```res sig -let toString: t<'a> => string -``` - -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. - -```res example -Js.Array.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8" -Js.Array.toString(["a", "b", "c"]) == "a,b,c" -``` - -## toLocaleString - -```res sig -let toLocaleString: t<'a> => string -``` - -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. - -```res example -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 -``` - -## every - -```res sig -let every: ('a => bool, t<'a>) => bool -``` - -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. - -```res example -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 -``` - -## everyi - -```res sig -let everyi: (('a, int) => bool, t<'a>) => bool -``` - -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. - -```res example -// 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 -``` - -## filter - -```res sig -let filter: ('a => bool, t<'a>) => t<'a> -``` - -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. - -```res example -let nonEmpty = s => s != "" -Js.Array.filter(nonEmpty, ["abc", "", "", "def", "ghi"]) == ["abc", "def", "ghi"] -``` - -## filteri - -```res sig -let filteri: (('a, int) => bool, t<'a>) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## find - -```res sig -let find: ('a => bool, t<'a>) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findi - -```res sig -let findi: (('a, int) => bool, t<'a>) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findIndex - -```res sig -let findIndex: ('a => bool, t<'a>) => int -``` - -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. - -```res example -Js.Array.findIndex(x => x < 0, [33, 22, -55, 77, -44]) == 2 -Js.Array.findIndex(x => x < 0, [33, 22, 55, 77, 44]) == -1 -``` - -## findIndexi - -```res sig -let findIndexi: (('a, int) => bool, t<'a>) => int -``` - -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. - -```res example -// 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 -``` - -## forEach - -```res sig -let forEach: ('a => unit, t<'a>) => unit -``` - -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. - -```res example -// display all elements in an array -Js.Array.forEach(x => Js.log(x), ["a", "b", "c"]) == () -``` - -## forEachi - -```res sig -let forEachi: (('a, int) => unit, t<'a>) => unit -``` - -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. - -```res example -// display all elements in an array as a numbered list -Js.Array.forEachi((item, index) => Js.log2(index + 1, item), ["a", "b", "c"]) == () -``` - -## map - -```res sig -let map: ('a => 'b, t<'a>) => t<'b> -``` - -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. - -```res example -Js.Array.map(x => x * x, [12, 4, 8]) == [144, 16, 64] -Js.Array.map(Js.String.length, ["animal", "vegetable", "mineral"]) == [6, 9, 7] -``` - -## mapi - -```res sig -let mapi: (('a, int) => 'b, t<'a>) => t<'b> -``` - -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. - -```res example -// multiply each item in array by its position -let product = (item, index) => item * index -Js.Array.mapi(product, [10, 11, 12]) == [0, 11, 24] -``` - -## reduce - -```res sig -let reduce: (('b, 'a) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -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) -``` - -## reducei - -```res sig -let reducei: (('b, 'a, int) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -// 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 -``` - -## reduceRight - -```res sig -let reduceRight: (('b, 'a) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -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) -``` - -## reduceRighti - -```res sig -let reduceRighti: (('b, 'a, int) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -// 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 -``` - -## some - -```res sig -let some: ('a => bool, t<'a>) => bool -``` - -Returns `true` if the predicate function given as the first argument to `some()` returns `true` for any element in the array; `false` otherwise. - -```res example -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 -``` - -## somei - -```res sig -let somei: (('a, int) => bool, t<'a>) => bool -``` - -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 - -```res example -// 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 -``` - -## unsafe_get - -```res sig -let unsafe_get: (array<'a>, int) => 'a -``` - -Returns the value at the given position in the array if the position is in bounds; returns -the JavaScript value `undefined` otherwise. - -```res example -let arr = [100, 101, 102, 103] -Js.Array.unsafe_get(arr, 3) == 103 -Js.Array.unsafe_get(arr, 4) // returns undefined -``` - -## unsafe_set - -```res sig -let unsafe_set: (array<'a>, int, 'a) => unit -``` - -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._ - -```res example -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. -``` diff --git a/pages/docs/manual/v10.0.0/api/js/console.mdx b/pages/docs/manual/v10.0.0/api/js/console.mdx deleted file mode 100644 index c7d83a8ed..000000000 --- a/pages/docs/manual/v10.0.0/api/js/console.mdx +++ /dev/null @@ -1,113 +0,0 @@ -# Console - - - -Provide console (logging) utilities. - - - -## log - -```res sig -let log: 'a => unit -``` - -```res sig -let log2: ('a, 'b) => unit -``` - -```res sig -let log3: ('a, 'b, 'c) => unit -``` - -```res sig -let log4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let logMany: array<'a> => unit -``` - -## info - -```res sig -let info: 'a => unit -``` - -```res sig -let info2: ('a, 'b) => unit -``` - -```res sig -let info3: ('a, 'b, 'c) => unit -``` - -```res sig -let info4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let infoMany: array<'a> => unit -``` - -## warn - -```res sig -let warn: 'a => unit -``` - -```res sig -let warn2: ('a, 'b) => unit -``` - -```res sig -let warn3: ('a, 'b, 'c) => unit -``` - -```res sig -let warn4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let warnMany: array<'a> => unit -``` - -## error - -```res sig -let error: 'a => unit -``` - -```res sig -let error2: ('a, 'b) => unit -``` - -```res sig -let error3: ('a, 'b, 'c) => unit -``` - -```res sig -let error4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let errorMany: array<'a> => unit -``` - -## trace - -```res sig -let trace: unit => unit -``` - -## timeStart - -```res sig -let timeStart: string => unit -``` - -## timeEnd - -```res sig -let timeEnd: string => unit -``` diff --git a/pages/docs/manual/v10.0.0/api/js/date.mdx b/pages/docs/manual/v10.0.0/api/js/date.mdx deleted file mode 100644 index a381d68e5..000000000 --- a/pages/docs/manual/v10.0.0/api/js/date.mdx +++ /dev/null @@ -1,1134 +0,0 @@ -# Date - - - -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. - - - -In these examples, we will be using this date: - -```res prelude -let exampleDate = Js.Date.fromFloat(123456654321.0) -``` - -which is Thu, 29 Nov 1973 21:30:54 GMT. There is no particular significance to this date. -The code used to access this date is running in the Europe/Austria time zone with the `en_US.utf8` locale. - -In all of these functions, month values are in the range 0-11, where January is month zero. - -## t - -```res prelude -type t -``` - -## valueOf - -```res sig -let valueOf: t => float -``` - -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.) - -```res example -Js.Date.valueOf(exampleDate) == 123456654321.0 -``` - -## make - -```res sig -let make: unit => t -``` - -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. - -```res example -let now = Js.Date.make() -``` - -## fromFloat - -```res sig -let fromFloat: float => t -``` - -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. - -```res example -Js.Date.fromFloat(123456654321.0) == exampleDate -``` - -## fromString - -```res sig -let fromString: string => t -``` - -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. - -```res example -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 -``` - -## makeWithYM - -```res sig -let makeWithYM: (~year: float, ~month: float, unit) => t -``` - -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. - -```res example -let november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ()) -``` - -## makeWithYMD - -```res sig -let makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t -``` - -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. - -## makeWithYMDH - -```res sig -let makeWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => t -``` - -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. - -## makeWithYMDHM - -```res sig -let makeWithYMDHM: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - unit, -) => t -``` - -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. - -## makeWithYMDHMS - -```res sig -let makeWithYMDHMS: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - ~seconds: float, - unit, -) => t -``` - -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. - -```res example -Js.Date.makeWithYMDHMS( - ~year=1973.0, - ~month=11.0, - ~date=29.0, - ~hours=21.0, - ~minutes=30.0, - ~seconds=54.321, - (), -) == exampleDate -``` - -## utcWithYM - -```res sig -let utcWithYM: (~year: float, ~month: float, unit) => float -``` - -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. - -```res example -let november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ()) -``` - -## utcWithYMD - -```res sig -let 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 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. - -## utcWithYMDH - -```res sig -let 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 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. - -## utcWithYMDHM - -```res sig -let 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 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. - -## utcWithYMDHMS - -```res sig -let utcWithYMDHMS: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - ~seconds: 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. - -## now - -```res sig -let now: unit => float -``` - -Returns the current time as number of milliseconds since Unix epoch. - -## parse - -```res sig -let parse: string => t -``` - -Deprecated. Use [`fromString()`](#fromstring). - -## parseAsFloat - -```res sig -let parseAsFloat: string => float -``` - -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. - -## getDate - -```res sig -let getDate: t => 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. - -```res example -Js.Date.getDate(exampleDate) == 29.0 -``` - -## getDay - -```res sig -let getDay: t => float -``` - -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. - -```res example -Js.Date.getDay(exampleDate) == 4.0 -``` - -## getFullYear - -```res sig -let getFullYear: t => float -``` - -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. - -```res example -Js.Date.getFullYear(exampleDate) == 1973.0 -``` - -## getHours - -```res sig -let getHours: t => float -``` - -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. - -```res example -Js.Date.getHours(exampleDate) == 22.0 // Vienna is in GMT+01:00 -``` - -## getMilliseconds - -```res sig -let getMilliseconds: t => float -``` - -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. - -```res example -Js.Date.getMilliseconds(exampleDate) == 321.0 -``` - -## getMinutes - -```res sig -let getMinutes: t => float -``` - -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. - -```res example -Js.Date.getMinutes(exampleDate) == 30.0 -``` - -## getMonth - -```res sig -let getMonth: t => float -``` - -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. - -```res example -Js.Date.getMonth(exampleDate) == 10.0 -``` - -## getSeconds - -```res sig -let getSeconds: t => float -``` - -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. - -```res example -Js.Date.getSeconds(exampleDate) == 54.0 -``` - -## getTime - -```res sig -let getTime: t => float -``` - -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. - -```res example -Js.Date.getTime(exampleDate) == 123456654321.0 -``` - -## getTimezoneOffset - -```res sig -let getTimezoneOffset: t => float -``` - -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. - -```res example -Js.Date.getTimezoneOffset(exampleDate) == -60.0 -``` - -## getUTCDate - -```res sig -let getUTCDate: t => float -``` - -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. - -```res example -Js.Date.getUTCDate(exampleDate) == 29.0 -``` - -## getUTCDay - -```res sig -let getUTCDay: t => float -``` - -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. - -```res example -Js.Date.getUTCDay(exampleDate) == 4.0 -``` - -## getUTCFullYear - -```res sig -let getUTCFullYear: t => float -``` - -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. - -```res example -Js.Date.getUTCFullYear(exampleDate) == 1973.0 -``` - -## getUTCHours - -```res sig -let getUTCHours: t => float -``` - -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. - -```res example -Js.Date.getUTCHours(exampleDate) == 21.0 -``` - -## getUTCMilliseconds - -```res sig -let getUTCMilliseconds: t => float -``` - -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. - -```res example -Js.Date.getUTCMilliseconds(exampleDate) == 321.0 -``` - -## getUTCMinutes - -```res sig -let getUTCMinutes: t => float -``` - -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. - -```res example -Js.Date.getUTCMinutes(exampleDate) == 30.0 -``` - -## getUTCMonth - -```res sig -let getUTCMonth: t => float -``` - -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. - -```res example -Js.Date.getUTCMonth(exampleDate) == 10.0 -``` - -## getUTCSeconds - -```res sig -let getUTCSeconds: t => float -``` - -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. - -```res example -Js.Date.getUTCSeconds(exampleDate) == 54.0 -``` - -## getYear - -```res sig -let getYear: t => float -``` - -Deprecated. Use `getFullYear()` instead. - -## setDate - -```res sig -let setDate: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setFullYear - -```res sig -let setFullYear: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setFullYearM - -```res sig -let setFullYearM: (t, ~year: float, ~month: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setFullYearMD - -```res sig -let setFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setHours - -```res sig -let setHours: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setHoursM - -```res sig -let setHoursM: (t, ~hours: float, ~minutes: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setHoursMS - -```res sig -let setHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setHoursMSMs - -```res sig -let setHoursMSMs: ( - t, - ~hours: float, - ~minutes: float, - ~seconds: float, - ~milliseconds: float, - unit, -) => float -``` - -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. - -```res example -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) -``` - -## setMilliseconds - -```res sig -let setMilliseconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setMinutes - -```res sig -let setMinutes: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setMinutesS - -```res sig -let setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setMinutesSMs - -```res sig -let setMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setMonth - -```res sig -let setMonth: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setMonthD - -```res sig -let setMonthD: (t, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setSeconds - -```res sig -let setSeconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setSecondsMs - -```res sig -let setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setTime - -```res sig -let setTime: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCDate - -```res sig -let setUTCDate: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCFullYear - -```res sig -let setUTCFullYear: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCFullYearM - -```res sig -let setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCFullYearMD - -```res sig -let setUTCFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCHours - -```res sig -let setUTCHours: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCHoursM - -```res sig -let setUTCHoursM: (t, ~hours: float, ~minutes: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCHoursMS - -```res sig -let setUTCHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCHoursMSMs - -```res sig -let setUTCHoursMSMs: ( - t, - ~hours: float, - ~minutes: float, - ~seconds: float, - ~milliseconds: float, - unit, -) => float -``` - -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. - -```res example -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) -``` - -## setUTCMilliseconds - -```res sig -let setUTCMilliseconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCMinutes - -```res sig -let setUTCMinutes: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCMinutesS - -```res sig -let setUTCMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCMinutesSMs - -```res sig -let setUTCMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCMonth - -```res sig -let setUTCMonth: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCMonthD - -```res sig -let setUTCMonthD: (t, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCSeconds - -```res sig -let setUTCSeconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCSecondsMs - -```res sig -let setUTCSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCTime - -```res sig -let setUTCTime: (t, float) => float -``` - -Same as [`setTime()`](#settime). - -## setYear - -```res sig -let setYear: (t, float) => float -``` - -Deprecated. Use [`setFullYear()`](#setfullyear) instead. - -## toDateString - -```res sig -let toDateString: t => string -``` - -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. - -```res example -Js.Date.toDateString(exampleDate) == "Thu Nov 29 1973" -``` - -## toGMTString - -```res sig -let toGMTString: t => string -``` - -Deprecated. Use [`toUTCString()`](#toutcstring) instead. - -## toISOString - -```res sig -let toISOString: t => string -``` - -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. - -```res example -Js.Date.toISOString(exampleDate) == "1973-11-29T21:30:54.321Z" -``` - -## toJSON - -```res sig -let toJSON: t => string -``` - -Deprecated. This method is unsafe. It will be changed to return `option` in a future release. Please use `toJSONUnsafe()` instead. - -## toJSONUnsafe - -```res sig -let toJSONUnsafe: t => string -``` - -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. - -```res example -Js.Date.toJSONUnsafe(exampleDate) == "1973-11-29T21:30:54.321Z" -``` - -## toLocaleDateString - -```res sig -let toLocaleDateString: t => string -``` - -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. - -```res example -Js.Date.toLocaleDateString(exampleDate) == "11/29/1973" // for en_US.utf8 -Js.Date.toLocaleDateString(exampleDate) == "29.11.73" // for de_DE.utf8 -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -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. - -```res example -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 -``` - -## toLocaleTimeString - -```res sig -let toLocaleTimeString: t => string -``` - -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. - -```res example -Js.Date.toLocaleString(exampleDate) == "10:30:54 PM" // for en_US.utf8 -Js.Date.toLocaleString(exampleDate) == "22:30:54" // for de_DE.utf8 -``` - -## toString - -```res sig -let toString: t => string -``` - -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. - -```res example -Js.Date.toString( - exampleDate, -) == "Thu Nov 29 1973 22:30:54 GMT+0100 (Central European Standard Time)" -``` - -## toTimeString - -```res sig -let toTimeString: t => string -``` - -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. - -```res example -Js.Date.toTimeString(exampleDate) == "22:30:54 GMT+0100 (Central European Standard Time)" -``` - -## toUTCString - -```res sig -let toUTCString: t => string -``` - -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. - -```res example -Js.Date.toUTCString(exampleDate) == "Thu, 29 Nov 1973 21:30:54 GMT" -``` diff --git a/pages/docs/manual/v10.0.0/api/js/dict.mdx b/pages/docs/manual/v10.0.0/api/js/dict.mdx deleted file mode 100644 index 0758932ae..000000000 --- a/pages/docs/manual/v10.0.0/api/js/dict.mdx +++ /dev/null @@ -1,165 +0,0 @@ -# Dict - - - -Provide utilities for JS dictionary object. - -**Note:** This module's examples will assume this predeclared dictionary: - -```res prelude -let ages = Js.Dict.fromList(list{("Maria", 30), ("Vinh", 22), ("Fred", 49)}) -``` - - - -## t - -```res prelude -type t<'a> -``` - -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. - -## key - -```res prelude -type key = string -``` - -The type for dictionary keys. This means that dictionaries _must_ use `string`s as their keys. - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -`Js.Dict.get(key)` returns `None` if the key is not found in the dictionary, `Some(value)` otherwise. - -```res example -Js.Dict.get(ages, "Vinh") == Some(22) -Js.Dict.get(ages, "Paul") == None -``` - -## unsafeGet - -```res sig -let unsafeGet: (t<'a>, key) => '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). - -```res example -Js.Dict.unsafeGet(ages, "Fred") == 49 -Js.Dict.unsafeGet(ages, "Paul") // returns undefined -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`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._ - -```res example -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)})) -``` - -## keys - -```res sig -let keys: t<'a> => array -``` - -Returns all the keys in the dictionary `dict`. - -```res example -Js.Dict.keys(ages) == ["Maria", "Vinh", "Fred"] -``` - -## empty - -```res sig -let empty: unit => t<'a> -``` - -Returns an empty dictionary. - -## unsafeDeleteKey - -```res sig -let unsafeDeleteKey: (. t, string) => unit -``` - -Experimental internal function - -## entries - -```res sig -let entries: t<'a> => array<(key, 'a)> -``` - -Returns an array of key/value pairs in the given dictionary (ES2017). - -```res example -Js.Dict.entries(ages) == [("Maria", 30), ("Vinh", 22), ("Fred", 49)] -``` - -## values - -```res sig -let values: t<'a> => array<'a> -``` - -Returns the values in the given dictionary (ES2017). - -```res example -Js.Dict.values(ages) == [30, 22, 49] -``` - -## fromList - -```res sig -let fromList: list<(key, 'a)> => t<'a> -``` - -Creates a new dictionary containing each (key, value) pair in its list argument. - -```res example -let capitals = Js.Dict.fromList(list{("Japan", "Tokyo"), ("France", "Paris"), ("Egypt", "Cairo")}) -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -Creates a new dictionary containing each (key, value) pair in its array argument. - -```res example -let capitals2 = Js.Dict.fromArray([("Germany", "Berlin"), ("Burkina Faso", "Ouagadougou")]) -``` - -## map - -```res sig -let map: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -`map(f, dict)` maps `dict` to a new dictionary with the same keys, using the function `f` to map each value. - -```res example -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)}) -``` diff --git a/pages/docs/manual/v10.0.0/api/js/exn.mdx b/pages/docs/manual/v10.0.0/api/js/exn.mdx deleted file mode 100644 index 730a4b2ed..000000000 --- a/pages/docs/manual/v10.0.0/api/js/exn.mdx +++ /dev/null @@ -1,103 +0,0 @@ -# Exn - - - -Provide utilities for dealing with JS exceptions. - - - -## t - -```res prelude -type t -``` - -## exn - -```res sig -type exn += - private - | Error(t) -``` - -## asJsExn - -```res sig -let asJsExn: exn => option -``` - -## stack - -```res sig -let stack: t => option -``` - -## message - -```res sig -let message: t => option -``` - -## name - -```res sig -let name: t => option -``` - -## fileName - -```res sig -let fileName: t => option -``` - -## isCamlExceptionOrOpenVariant - -```res sig -let isCamlExceptionOrOpenVariant: 'a => bool -``` - -Internal use only. - -## raiseError - -```res sig -let raiseError: string => 'a -``` - -Raise Js exception Error object with stacktrace. - -## raiseEvalError - -```res sig -let raiseEvalError: string => 'a -``` - -## raiseRangeError - -```res sig -let raiseRangeError: string => 'a -``` - -## raiseReferenceError - -```res sig -let raiseReferenceError: string => 'a -``` - -## raiseSyntaxError - -```res sig -let raiseSyntaxError: string => 'a -``` - -## raiseTypeError - -```res sig -let raiseTypeError: string => 'a -``` - -## raiseUriError - -```res sig -let raiseUriError: string => 'a -``` diff --git a/pages/docs/manual/v10.0.0/api/js/float.mdx b/pages/docs/manual/v10.0.0/api/js/float.mdx deleted file mode 100644 index 13f375ad5..000000000 --- a/pages/docs/manual/v10.0.0/api/js/float.mdx +++ /dev/null @@ -1,283 +0,0 @@ -# Float - - - -Provide utilities for JS float. - - - -## \_NaN - -```res sig -let _NaN: float -``` - -The special value "Not a Number". - -## isNaN - -```res sig -let isNaN: float => bool -``` - -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`. - -Returns true if the given value is `_NaN`, false otherwise. - -## isFinite - -```res sig -let isFinite: float => bool -``` - -Tests if the given value is finite. -Returns true if the given value is a finite number, false otherwise. - -```res example -/* returns [false] */ -Js.Float.isFinite(infinity) -``` - -```res example -/* returns [false] */ -Js.Float.isFinite(neg_infinity) -``` - -```res example -/* returns [false] */ -Js.Float.isFinite(Js.Float._NaN) -``` - -```res example -/* returns [true] */ -Js.Float.isFinite(1234.) -``` - -## toExponential - -```res sig -let toExponential: float => string -``` - -Formats a float using exponential (scientific) notation. -Returns a string representing the given value in exponential notation. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.71234e+1" */ -Js.Float.toExponential(77.1234)->Js.log -``` - -```res example -/* prints "7.7e+1" */ -Js.Float.toExponential(77.)->Js.log -``` - -## toExponentialWithPrecision - -```res sig -let toExponentialWithPrecision: (float, ~digits: int) => string -``` - -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). - -Returns a `string` representing the given value in exponential notation. - -The output will be rounded or padded with zeroes if necessary. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.71e+1" */ -Js.Float.toExponentialWithPrecision(77.1234, ~digits=2)->Js.log -``` - -## toFixed - -```res sig -let toFixed: float => string -``` - -Formats a `float` using fixed point notation. -Returns a `string` representing the given value in fixed-point notation (usually). -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "12346" (note the rounding) */ -Js.Float.toFixed(12345.6789)->Js.log -``` - -```res example -/* print "1.2e+21" */ -Js.Float.toFixed(1.2e21)->Js.log -``` - -## toFixedWithPrecision - -```res sig -let toFixedWithPrecision: (float, ~digits: int) => string -``` - -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. - -Returns a `string` representing the given value in fixed-point notation (usually). - -The output will be rounded or padded with zeroes if necessary. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "12345.7" (note the rounding) */ -Js.Float.toFixedWithPrecision(12345.6789, ~digits=1)->Js.log -``` - -```res example -/* prints "0.00" (note the added zeroes) */ -Js.Float.toFixedWithPrecision(0., ~digits=2)->Js.log -``` - -## toPrecision - -```res sig -let toPrecision: float => string -``` - -Formats a `float` 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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "12345.6789" */ -Js.Float.toPrecision(12345.6789)->Js.log -``` - -```res example -/* print "1.2e+21" */ -Js.Float.toPrecision(1.2e21)->Js.log -``` - -## toPrecisionWithPrecision - -```res sig -let toPrecisionWithPrecision: (float, ~digits: int) => string -``` - -Formats a `float` using some fairly arbitrary rules. -`digits` specifies how many digits should appear in total. The value must be 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 for digits before the decimal point. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "1e+4" */ -Js.Float.toPrecisionWithPrecision(12345.6789, ~digits=1)->Js.log -``` - -```res example -/* prints "0.0" */ -Js.Float.toPrecisionWithPrecision(0., ~digits=2)->Js.log -``` - -## toString - -```res sig -let toString: float => string -``` - -Formats a `float` as a `string`. -Returns a `string` representing the given value in fixed-point (usually). - -```res example -/* prints "12345.6789" */ -Js.Float.toString(12345.6789)->Js.log -``` - -## toStringWithRadix - -```res sig -let toStringWithRadix: (float, ~radix: int) => string -``` - -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). - -Returns a `string` representing the given value in fixed-point (usually). -Raises `RangeError` if `radix` is not in the range \[2, 36\] (inclusive). - -```res example -/* prints "110" */ -Js.Float.toStringWithRadix(6., ~radix=2)->Js.log -``` - -```res example -/* prints "11.001000111101011100001010001111010111000010100011111" */ -Js.Float.toStringWithRadix(3.14, ~radix=2)->Js.log -``` - -```res example -/* prints "deadbeef" */ -Js.Float.toStringWithRadix(3735928559., ~radix=16)->Js.log - -``` - -```res example -/* prints "3f.gez4w97ry0a18ymf6qadcxr" */ -Js.Float.toStringWithRadix(123.456, ~radix=36)->Js.log -``` - -## fromString - -```res sig -let fromString: string => float -``` - -Parses the given `string` into a `float` using JavaScript semantics. -Returns the number as a `float` if successfully parsed, `_NaN` otherwise. - -```res example -/* returns 123 */ -Js.Float.fromString("123") -``` - -```res example -/* returns 12.3 */ -Js.Float.fromString("12.3") -``` - -```res example -/* returns 0 */ -Js.Float.fromString("") -``` - -```res example -/* returns 17 */ -Js.Float.fromString("0x11") -``` - -```res example -/* returns 3 */ -Js.Float.fromString("0b11") -``` - -```res example -/* returns 9 */ -Js.Float.fromString("0o11") -``` - -```res example -/* returns [_NaN] */ -Js.Float.fromString("hello") -``` - -```res example -/* returns [_NaN] */ -Js.Float.fromString("100a") -``` diff --git a/pages/docs/manual/v10.0.0/api/js/global.mdx b/pages/docs/manual/v10.0.0/api/js/global.mdx deleted file mode 100644 index 7bba67610..000000000 --- a/pages/docs/manual/v10.0.0/api/js/global.mdx +++ /dev/null @@ -1,179 +0,0 @@ -# Global - - - -Provide bindings to JS global functions in global namespace. - - - -```res prelude -type intervalId -``` - -Identify an interval started by `Js.Global.setInterval`. - -```res prelude -type timeoutId -``` - -Identify timeout started by `Js.Global.setTimeout`. - -## clearInterval - -```res sig -let clearInterval: intervalId => unit -``` - -Clear an interval started by `Js.Global.setInterval` - -```res example -/* 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)) -``` - -## clearTimeout - -```res sig -let clearTimeout: timeoutId => unit -``` - -Clear a timeout started by `Js.Global.setTimeout`. - -```res example -/* 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)) -} -``` - -## setInterval - -```res sig -let setInterval: (unit => unit, int) => intervalId -``` - -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. - -```res example -/* 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) -``` - -## setIntervalFloat - -```res sig -let setIntervalFloat: (unit => unit, float) => intervalId -``` - -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. - -```res example -/* 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) -``` - -## setTimeout - -```res sig -let setTimeout: (unit => unit, int) => timeoutId -``` - -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. - -```res example -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!" - -Js.Global.setTimeout(() => Js.log(message), 1000) -``` - -## setTimeoutFloat - -```res sig -let setTimeoutFloat: (unit => unit, float) => timeoutId -``` - -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. - -```res example -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!" - -Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0) -``` - -## encodeURI - -```res sig -let encodeURI: string => string -``` - -URL-encodes a string. - -## decodeURI - -```res sig -let decodeURI: string => string -``` - -Decodes a URL-enmcoded string produced by encodeURI. - -## encodeURIComponent - -```res sig -let encodeURIComponent: string => string -``` - -URL-encodes a string, including characters with special meaning in a URI. - -## decodeURIComponent - -```res sig -let decodeURIComponent: string => string -``` - -Decodes a URL-enmcoded string produced by encodeURIComponent diff --git a/pages/docs/manual/v10.0.0/api/js/int.mdx b/pages/docs/manual/v10.0.0/api/js/int.mdx deleted file mode 100644 index 1fc48b47a..000000000 --- a/pages/docs/manual/v10.0.0/api/js/int.mdx +++ /dev/null @@ -1,146 +0,0 @@ -# Int - - - -Provide utilities for handling `int`. - - - -## toExponential - -```res sig -let toExponential: int => string -``` - -Formats an `int` using exponential (scientific) notation. -Returns a `string` representing the given value in exponential notation. -Raises `RangeError` if digits is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.7e+1" */ -Js.log(Js.Int.toExponential(77)) -``` - -## toExponentialWithPrecision - -```res sig -let toExponentialWithPrecision: (int, ~digits: int) => string -``` - -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. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.70e+1" */ -Js.log(Js.Int.toExponentialWithPrecision(77, ~digits=2)) - -/* prints "5.68e+3" */ -Js.log(Js.Int.toExponentialWithPrecision(5678, ~digits=2)) -``` - -## toPrecision - -```res sig -let toPrecision: int => string -``` - -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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "123456789" */ -Js.log(Js.Int.toPrecision(123456789)) -``` - -## toPrecisionWithPrecision - -```res sig -let toPrecisionWithPrecision: (int, ~digits: int) => string -``` - -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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "1.2e+8" */ -Js.log(Js.Int.toPrecisionWithPrecision(123456789, ~digits=2)) - -/* prints "0.0" */ -Js.log(Js.Int.toPrecisionWithPrecision(0, ~digits=2)) -``` - -## toString - -```res sig -let toString: int => string -``` - -Formats an `int` as a `string`. -Returns a `string` representing the given value in fixed-point (usually). - -```res example -/* prints "123456789" */ -Js.log(Js.Int.toString(123456789)) -``` - -## toStringWithRadix - -```res sig -let toStringWithRadix: (int, ~radix: int) => string -``` - -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). -Raises `RangeError` if `radix` is not in the range \[2, 36\] (inclusive). - -```res example -/* 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)) -``` - -## toFloat - -```res sig -let toFloat: int => float -``` - -## equal - -```res sig -let equal: (int, int) => bool -``` - -## max - -```res sig -let max: int -``` - -## min - -```res sig -let min: int -``` diff --git a/pages/docs/manual/v10.0.0/api/js/json.mdx b/pages/docs/manual/v10.0.0/api/js/json.mdx deleted file mode 100644 index 99c970894..000000000 --- a/pages/docs/manual/v10.0.0/api/js/json.mdx +++ /dev/null @@ -1,292 +0,0 @@ -# Json - - - -Provide utilities for JSON. - - - -## t - -```res prelude -type t -``` - -The JSON data structure. - -## kind - -```res prelude -type rec kind<'a> = - | String: kind - | Number: kind - | Object: kind> - | Array: kind> - | Boolean: kind - | Null: kind -``` - -Underlying type of a JSON value. - -## tagged_t - -```res prelude -type tagged_t = - | JSONFalse - | JSONTrue - | JSONNull - | JSONString(string) - | JSONNumber(float) - | JSONObject(Js_dict.t) - | JSONArray(array) -``` - -## classify - -```res sig -let classify: t => tagged_t -``` - -## test - -```res sig -let test: ('a, kind<'b>) => bool -``` - -`test(v, kind)` returns `true` if `v` is of `kind`. - -## decodeString - -```res sig -let decodeString: t => option -``` - -`decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise. - -## decodeNumber - -```res sig -let decodeNumber: t => option -``` - -`decodeNumber(json)` returns `Some(n)` if `json` is a `number`, `None` otherwise. - -## decodeObject - -```res sig -let decodeObject: t => option> -``` - -`decodeObject(json)` returns `Some(o)` if `json` is an `object`, `None` otherwise. - -## decodeArray - -```res sig -let decodeArray: t => option> -``` - -`decodeArray(json)` returns `Some(a)` if `json` is an `array`, `None` otherwise. - -## decodeBoolean - -```res sig -let decodeBoolean: t => option -``` - -`decodeBoolean(json)` returns `Some(b)` if `json` is a `boolean`, `None` otherwise. - -## decodeNull - -```res sig -let decodeNull: t => option> -``` - -`decodeNull(json)` returns `Some(null)` if `json` is a `null`, `None` otherwise. - -## null - -```res sig -let null: t -``` - -`null` is the singleton null JSON value. - -## string - -```res sig -let string: string => t -``` - -`string(s)` makes a JSON string of the `string` `s`. - -## number - -```res sig -let number: float => t -``` - -`number(n)` makes a JSON number of the `float` `n`. - -## boolean - -```res sig -let boolean: bool => t -``` - -`boolean(b)` makes a JSON boolean of the `bool` `b`. - -## object\_ - -```res sig -let object_: Js_dict.t => t -``` - -`object_(dict)` makes a JSON object of the `Js.Dict.t` `dict`. - -## array - -```res sig -let array: array => t -``` - -`array_(a)` makes a JSON array of the `Js.Json.t` array `a`. - -## stringArray - -```res sig -let stringArray: array => t -``` - -`stringArray(a)` makes a JSON array of the `string` array `a`. - -## numberArray - -```res sig -let numberArray: array => t -``` - -`numberArray(a)` makes a JSON array of the `float` array `a`. - -## booleanArray - -```res sig -let booleanArray: array => t -``` - -`booleanArray(a)` makes a JSON array of the `bool` array `a`. - -## objectArray - -```res sig -let objectArray: array> => t -``` - -`objectArray(a) makes a JSON array of the `JsDict.t`array`a`. - -## parseExn - -```res sig -let parseExn: string => t -``` - -`parseExn(s)` parses the `string` `s` into a JSON data structure. -Returns a JSON data structure. -Raises `SyntaxError` if the given string is not a valid JSON. Note: `SyntaxError` is a JavaScript exception. - -```res example -/* 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") -} -``` - -```res example -/* 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 Js.Dict.t */ - 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 ] } `)) -``` - -## stringify - -```res sig -let stringify: t => string -``` - -`stringify(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure. - -```res example -/* 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(["bucklescript", "ocaml", "js"])) - - Js.log(Js.Json.stringify(Js.Json.object_(dict))) -} -``` - -## stringifyWithSpace - -```res sig -let stringifyWithSpace: (t, int) => string -``` - -`stringify(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure with spacing. - -```res example -/* 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(["bucklescript", "ocaml", "js"])) - - Js.log(Js.Json.stringifyWithSpace(Js.Json.object_(dict), 2)) -} -``` - -## stringifyAny - -```res sig -let stringifyAny: 'a => option -``` - -`stringifyAny(value)` formats any value into a JSON string. - -```res example -/* prints `["hello", "world"]` */ -Js.log(Js.Json.stringifyAny(["hello", "world"])) -``` diff --git a/pages/docs/manual/v10.0.0/api/js/list.mdx b/pages/docs/manual/v10.0.0/api/js/list.mdx deleted file mode 100644 index 72b908489..000000000 --- a/pages/docs/manual/v10.0.0/api/js/list.mdx +++ /dev/null @@ -1,143 +0,0 @@ -# List - - - -Provide utilities for list. - - - -## t - -```res prelude -type t<'a> = list<'a> -``` - -## length - -```res sig -let length: t<'a> => int -``` - -## cons - -```res sig -let cons: ('a, t<'a>) => t<'a> -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## hd - -```res sig -let hd: t<'a> => option<'a> -``` - -## tl - -```res sig -let tl: t<'a> => option> -``` - -## nth - -```res sig -let nth: (t<'a>, int) => option<'a> -``` - -## revAppend - -```res sig -let revAppend: (t<'a>, t<'a>) => t<'a> -``` - -## rev - -```res sig -let rev: t<'a> => t<'a> -``` - -## mapRev - -```res sig -let mapRev: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -## map - -```res sig -let map: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -## iter - -```res sig -let iter: ((. 'a) => unit, t<'a>) => unit -``` - -## iteri - -```res sig -let iteri: ((. int, 'a) => unit, t<'a>) => unit -``` - -## foldLeft - -```res sig -let foldLeft: ((. 'a, 'b) => 'a, 'a, list<'b>) => 'a -``` - -Application order is left to right, tail-recurisve. - -## foldRight - -```res sig -let foldRight: ((. 'a, 'b) => 'b, list<'a>, 'b) => 'b -``` - -Application order is right to left, tail-recursive. - -## flatten - -```res sig -let flatten: t> => t<'a> -``` - -## filter - -```res sig -let filter: ((. 'a) => bool, t<'a>) => t<'a> -``` - -## filterMap - -```res sig -let filterMap: ((. 'a) => option<'b>, t<'a>) => t<'b> -``` - -## countBy - -```res sig -let countBy: ((. 'a) => bool, list<'a>) => int -``` - -## init - -```res sig -let init: (int, (. int) => 'a) => t<'a> -``` - -## toVector - -```res sig -let toVector: t<'a> => Js_vector.t<'a> -``` - -## equal - -```res sig -let equal: ((. 'a, 'a) => bool, list<'a>, list<'a>) => bool -``` diff --git a/pages/docs/manual/v10.0.0/api/js/math.mdx b/pages/docs/manual/v10.0.0/api/js/math.mdx deleted file mode 100644 index 69cd10d4d..000000000 --- a/pages/docs/manual/v10.0.0/api/js/math.mdx +++ /dev/null @@ -1,626 +0,0 @@ -# Math - - - -Provide utilities for JS Math. Note: The constants `_E`, `_LN10`, `_LN2`, `_LOG10E`, `_LOG2E`, `_PI`, `_SQRT1_2`, and `_SQRT2` begin with an underscore because ReasonML variable names cannot begin with a capital letter. (Module names begin with upper case.) - - - -## \_E - -```res sig -let _E: float -``` - -Euler's number; ≈ 2.718281828459045. See [`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) on MDN. - -## \_LN2 - -```res sig -let _LN2: float -``` - -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. - -## \_LN10 - -```res sig -let _LN10: float -``` - -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. - -## \_LOG2E - -```res sig -let _LOG2E: float -``` - -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. - -## \_LOG10E - -```res sig -let _LOG10E: float -``` - -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. - -## \_PI - -```res sig -let _PI: float -``` - -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. - -## \_SQRT1_2 - -```res sig -let _SQRT1_2: float -``` - -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. - -## \_SQRT2 - -```res sig -let _SQRT2: float -``` - -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. - -## abs_int - -```res sig -let abs_int: int => int -``` - -Absolute value for integer argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. - -## abs_float - -```res sig -let abs_float: float => float -``` - -Absolute value for float argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. - -## acos - -```res sig -let acos: float => float -``` - -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. - -## acosh - -```res sig -let acosh: float => float -``` - -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. - -## asin - -```res sig -let asin: float => float -``` - -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. - -## asinh - -```res sig -let asinh: float => float -``` - -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. - -## atan - -```res sig -let atan: float => float -``` - -Arctangent (in radians) of argument. See [`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) on MDN. - -## atanh - -```res sig -let atanh: float => float -``` - -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. - -## atan2 - -```res sig -let atan2: (~y: float, ~x: float, unit) => float -``` - -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. - -```res example -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 -``` - -## cbrt - -```res sig -let cbrt: float => float -``` - -Cube root. See [`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) on MDN - -## unsafe_ceil_int - -```res sig -let unsafe_ceil_int: float => int -``` - -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. - -```res example -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 -``` - -## unsafe_ceil - -```res sig -let unsafe_ceil: float => int -``` - -Deprecated; please use [`unsafe_ceil_int`](#unsafe_ceil_int) instead. - -## ceil_int - -```res sig -let ceil_int: float => 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. - -```res example -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 -``` - -## ceil - -```res sig -let ceil: float => int -``` - -Deprecated; please use [`ceil_int`](#ceil_int) instead. - -## ceil_float - -```res sig -let ceil_float: float => float -``` - -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. - -```res example -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 -``` - -## clz32 - -```res sig -let clz32: int => int -``` - -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. - -```res example -Js.Math.clz32(0) == 32 -Js.Math.clz32(-1) == 0 -Js.Math.clz32(255) == 24 -``` - -## cos - -```res sig -let cos: float => float -``` - -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. - -## cosh - -```res sig -let cosh: float => float -``` - -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. - -## exp - -```res sig -let exp: float => float -``` - -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. - -## expm1 - -```res sig -let expm1: float => float -``` - -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. - -## unsafe_floor_int - -```res sig -let unsafe_floor_int: float => int -``` - -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. - -```res example -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 -``` - -## unsafe_floor - -```res sig -let unsafe_floor: float => int -``` - -Deprecated; please use [`unsafe_floor_int`](#unsafe_floor_int) instead. - -## floor_int - -```res sig -let floor_int: float => 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. - -```res example -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 -``` - -## floor - -```res sig -let floor: float => int -``` - -Deprecated; please use [`floor_int`](#floor_int) instead. - -## floor_float - -```res sig -let floor_float: float => float -``` - -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. - -```res example -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 -``` - -## fround - -```res sig -let fround: float => float -``` - -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. - -```res example -Js.Math.fround(5.5) == 5.5 -Js.Math.fround(5.05) == 5.050000190734863 -``` - -## hypot - -```res sig -let hypot: (float, float) => float -``` - -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. - -## hypotMany - -```res sig -let hypotMany: array => float -``` - -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. - -```res example -Js.Math.hypotMany([3.0, 4.0, 12.0]) == 13.0 -``` - -## imul - -```res sig -let imul: (int, int) => int -``` - -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. - -## log - -```res sig -let log: float => float -``` - -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. - -```res example -Js.Math.log(Js.Math._E) == 1.0 -Js.Math.log(100.0) == 4.605170185988092 -``` - -## log1p - -```res sig -let log1p: float => float -``` - -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. - -```res example -Js.Math.log1p(Js.Math._E -. 1.0) == 1.0 -Js.Math.log1p(99.0) == 4.605170185988092 -``` - -## log10 - -```res sig -let log10: float => float -``` - -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. - -```res example -Js.Math.log10(1000.0) == 3.0 -Js.Math.log10(0.01) == -2.0 -Js.Math.log10(Js.Math.sqrt(10.0)) == 0.5 -``` - -## log2 - -```res sig -let log2: float => float -``` - -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. - -```res example -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 -``` - -## max_int - -```res sig -let max_int: (int, int) => int -``` - -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. - -## maxMany_int - -```res sig -let maxMany_int: array => int -``` - -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. - -## max_float - -```res sig -let max_float: (float, float) => float -``` - -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. - -## maxMany_float - -```res sig -let maxMany_float: array => float -``` - -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. - -## min_int - -```res sig -let min_int: (int, int) => int -``` - -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. - -## minMany_int - -```res sig -let minMany_int: array => int -``` - -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. - -## min_float - -```res sig -let min_float: (float, float) => float -``` - -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. - -## minMany_float - -```res sig -let minMany_float: array => float -``` - -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. - -## pow_int - -```res sig -let pow_int: (~base: int, ~exp: int) => int -``` - -Raises 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. - -```res example -Js.Math.pow_int(~base=3, ~exp=4) == 81 -``` - -## pow_float - -```res sig -let pow_float: (~base: float, ~exp: float) => float -``` - -Raises 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. - -```res example -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 -``` - -## random - -```res sig -let random: unit => float -``` - -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. - -## random_int - -```res sig -let random_int: (int, int) => int -``` - -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. - -## unsafe_round - -```res sig -let unsafe_round: float => int -``` - -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. - -```res example -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 -``` - -## round - -```res sig -let round: float => float -``` - -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. - -## sign_int - -```res sig -let sign_int: int => int -``` - -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. - -## sign_float - -```res sig -let sign_float: float => float -``` - -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. - -## sin - -```res sig -let sin: float => float -``` - -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. - -## sinh - -```res sig -let sinh: float => float -``` - -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. - -## sqrt - -```res sig -let sqrt: float => float -``` - -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. - -## tan - -```res sig -let tan: float => float -``` - -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. - -## tanh - -```res sig -let tanh: float => float -``` - -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. - -## unsafe_trunc - -```res sig -let unsafe_trunc: float => int -``` - -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. - -## trunc - -```res sig -let trunc: float => float -``` - -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. diff --git a/pages/docs/manual/v10.0.0/api/js/null-undefined.mdx b/pages/docs/manual/v10.0.0/api/js/null-undefined.mdx deleted file mode 100644 index 754524e19..000000000 --- a/pages/docs/manual/v10.0.0/api/js/null-undefined.mdx +++ /dev/null @@ -1,114 +0,0 @@ -# Null_undefined - - - -Provide utilities around `Js.null_undefined`. - - - -## t - -```res prelude -type t<'a> = Js.null_undefined<'a> -``` - -Local alias for `Js.null_undefined<'a>`. - -## return - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.null_undefined<'a>` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -## isNullable - -```res sig -let isNullable: t<'a> => bool -``` - -Returns `true` if the given value is null or undefined, `false` otherwise. - -## null - -```res sig -let null: t<'a> -``` - -The null value of type `Js.null_undefined<'a>`. - -## undefined - -```res sig -let undefined: t<'a> -``` - -The undefined value of type `Js.null_undefined<'a>`. - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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>`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.null_undefined) => - Js.Null_undefined.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.null_undefined) => - Js.Null_undefined.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option<'a>` to `Js.null_undefined<'a>`. -`Some(a)` => `a` -`None` => `undefined` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.null_undefined<'a>` to `option<'a>`. -`a` => `Some(a)` -`undefined` => `None` -`null` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v10.0.0/api/js/null.mdx b/pages/docs/manual/v10.0.0/api/js/null.mdx deleted file mode 100644 index 2ef17290c..000000000 --- a/pages/docs/manual/v10.0.0/api/js/null.mdx +++ /dev/null @@ -1,107 +0,0 @@ -# Null - - - -Provide utilities around `null<'a>`. - - - -```res prelude -type t<'a> = Js.null<'a> -``` - -Local alias for `Js.null<'a>`. - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.null<'a>` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -Returns `true` if the given value is empty (`null`), `false` otherwise. - -## empty - -```res sig -let empty: t<'a> -``` - -The empty value, `null`. - -## getUnsafe - -```res sig -let getUnsafe: t<'a> => 'a -``` - -## getExn - -```res sig -let getExn: t<'a> => 'a -``` - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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>`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.null) => - Js.Null.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.null) => - Js.Null.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option<'a>` to `Js.null<'a>`. -`Some(a)` => `a` -`None` => `empty` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.null<'a>` to `option<'a>`. -`a` => `Some(a)` -`empty` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v10.0.0/api/js/nullable.mdx b/pages/docs/manual/v10.0.0/api/js/nullable.mdx deleted file mode 100644 index 736dad78d..000000000 --- a/pages/docs/manual/v10.0.0/api/js/nullable.mdx +++ /dev/null @@ -1,114 +0,0 @@ -# Nullable - - - -Provide utilities around `Js.null_undefined`. - - - -## t - -```res prelude -type t<'a> = Js.null_undefined<'a> -``` - -Local alias for `Js.null_undefined<'a>`. - -## return - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.null_undefined<'a>` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -## isNullable - -```res sig -let isNullable: t<'a> => bool -``` - -Returns `true` if the given value is null or undefined, `false` otherwise. - -## null - -```res sig -let null: t<'a> -``` - -The null value of type `Js.null_undefined<'a>`. - -## undefined - -```res sig -let undefined: t<'a> -``` - -The undefined value of type `Js.null_undefined<'a>`. - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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>`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.null_undefined) => - Js.Nullable.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.null_undefined) => - Js.Nullable.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option<'a>` to `Js.null_undefined<'a>`. -`Some(a)` => `a` -`None` => `undefined` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.null_undefined<'a>` to `option<'a>`. -`a` => `Some(a)` -`undefined` => `None` -`null` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v10.0.0/api/js/obj.mdx b/pages/docs/manual/v10.0.0/api/js/obj.mdx deleted file mode 100644 index f8b082345..000000000 --- a/pages/docs/manual/v10.0.0/api/js/obj.mdx +++ /dev/null @@ -1,57 +0,0 @@ -# Obj - - - -Provide utilities for Js.t. - - - -## empty - -```res sig -let empty: unit => {..} -``` - -`empty()` returns the empty object `{}`. - -## assign - -```res sig -let assign: ({..}, {..}) => {..} -``` - -`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`. - -```res example -/* 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) -``` - -## keys - -```res sig -let keys: {..} => array -``` - -`keys(obj)` returns an `array` of the keys of `obj`'s own enumerable properties. diff --git a/pages/docs/manual/v10.0.0/api/js/option.mdx b/pages/docs/manual/v10.0.0/api/js/option.mdx deleted file mode 100644 index 61e3700c8..000000000 --- a/pages/docs/manual/v10.0.0/api/js/option.mdx +++ /dev/null @@ -1,171 +0,0 @@ -# Option - - - -Provide utilities for handling `option`. - - - -## t - -```res sig -type t<'a> = option<'a> -``` - -## some - -```res sig -let some: 'a => option<'a> -``` - -Wraps the given value in `Some()` - -```res example -Js.Option.some(1066) == Some(1066) -``` - -## isSome - -```res sig -let isSome: option<'a> => bool -``` - -Returns `true` if the argument is `Some(value)`; `false` if the argument is `None`. - -## isSomeValue - -```res sig -let isSomeValue: ((. 'a, 'a) => bool, 'a, option<'a>) => bool -``` - -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)`. - -```res example -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 -``` - -## isNone - -```res sig -let isNone: option<'a> => bool -``` - -Returns `true` if the argument is `None`; `false` otherwise. - -## getExn - -```res sig -let getExn: option<'a> => 'a -``` - -If the argument to `getExn()` is of the form `Some(value)`, returns `value`. If given `None`, it throws a `getExn` exception. - -## equal - -```res sig -let equal: ((. 'a, 'b) => bool, option<'a>, option<'b>) => bool -``` - -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` - -```res example -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 -``` - -## andThen - -```res sig -let andThen: ((. 'a) => option<'b>, option<'a>) => option<'b> -``` - -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)`. - -```res example -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 -``` - -## map - -```res sig -let map: ((. 'a) => 'b, option<'a>) => option<'b> -``` - -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. - -```res example -let square = (. x) => x * x -Js.Option.map(square, Some(3)) == Some(9) -Js.Option.map(square, None) == None -``` - -## getWithDefault - -```res sig -let getWithDefault: ('a, option<'a>) => 'a -``` - -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. - -```res example -Js.Option.getWithDefault(1066, Some(15)) == 15 -Js.Option.getWithDefault(1066, None) == 1066 -``` - -## default - -```res sig -let default: ('a, option<'a>) => 'a -``` - -**See:** [getWithDefault](#getWithDefault) - -## filter - -```res sig -let filter: ((. 'a) => bool, option<'a>) => option<'a> -``` - -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`. - -```res example -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 -``` - -## firstSome - -```res sig -let firstSome: (option<'a>, option<'a>) => option<'a> -``` - -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. - -```res example -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 -``` diff --git a/pages/docs/manual/v10.0.0/api/js/promise.mdx b/pages/docs/manual/v10.0.0/api/js/promise.mdx deleted file mode 100644 index df1331769..000000000 --- a/pages/docs/manual/v10.0.0/api/js/promise.mdx +++ /dev/null @@ -1,91 +0,0 @@ -# Promise - - - -Provide bindings to JS promise. - - - -## t - -```res prelude -type t<+'a> -``` - -## error - -```res prelude -type error -``` - -## make - -```res sig -let make: ((~resolve: (. 'a) => unit, ~reject: (. exn) => unit) => unit) => t<'a> -``` - -## resolve - -```res sig -let resolve: 'a => t<'a> -``` - -## reject - -```res sig -let reject: exn => t<'a> -``` - -## all - -```res sig -let all: array> => t> -``` - -## all2 - -```res sig -let all2: ((t<'a0>, t<'a1>)) => t<('a0, 'a1)> -``` - -## all3 - -```res sig -let all3: ((t<'a0>, t<'a1>, t<'a2>)) => t<('a0, 'a1, 'a2)> -``` - -## all4 - -```res sig -let all4: ((t<'a0>, t<'a1>, t<'a2>, t<'a3>)) => t<('a0, 'a1, 'a2, 'a3)> -``` - -## all5 - -```res sig -let all5: ((t<'a0>, t<'a1>, t<'a2>, t<'a3>, t<'a4>)) => t<('a0, 'a1, 'a2, 'a3, 'a4)> -``` - -## all6 - -```res sig -let all6: ((t<'a0>, t<'a1>, t<'a2>, t<'a3>, t<'a4>, t<'a5>)) => t<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)> -``` - -## race - -```res sig -let race: array> => t<'a> -``` - -## then\_ - -```res sig -let then_: ('a => t<'b>, t<'a>) => t<'b> -``` - -## catch - -```res sig -let catch: (error => t<'a>, t<'a>) => t<'a> -``` diff --git a/pages/docs/manual/v10.0.0/api/js/re.mdx b/pages/docs/manual/v10.0.0/api/js/re.mdx deleted file mode 100644 index 665eb7a2d..000000000 --- a/pages/docs/manual/v10.0.0/api/js/re.mdx +++ /dev/null @@ -1,238 +0,0 @@ -# Re - - - -Provide bindings to JS regular expressions (RegExp). - - - -## t - -```res prelude -type t -``` - -The RegExp object. - -## result - -```res prelude -type result -``` - -The result of a executing a RegExp on a string. - -## captures - -```res sig -let captures: result => array> -``` - -An `array` of the match and captures, the first is the full match and the remaining are the substring captures. - -## matches - -```res sig -let matches: result => array -``` - -Deprecated. Use captures instead. -An `array` of the matches, the first is the full match and the remaining are the substring matches. - -## index - -```res sig -let index: result => int -``` - -0-based index of the match in the input string. - -## input - -```res sig -let input: result => string -``` - -The original input string. - -## fromString - -```res sig -let fromString: string => t -``` - -Constructs a RegExp object (Js.Re.t) from a `string`. -Regex literals `%re("/.../")` 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. - -```res example -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") -``` - -## fromStringWithFlags - -```res sig -let fromStringWithFlags: (string, ~flags: string) => t -``` - -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) - -## flags - -```res sig -let flags: t => string -``` - -Returns the enabled flags as a string. - -## global - -```res sig -let global: t => bool -``` - -Returns a `bool` indicating whether the global flag is set. - -## ignoreCase - -```res sig -let ignoreCase: t => bool -``` - -Returns a `bool` indicating whether the ignoreCase flag is set. - -## lastIndex - -```res sig -let lastIndex: t => int -``` - -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. - -```res example -let re = %re("/ab*/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 - } -} -``` - -## setLastIndex - -```res sig -let setLastIndex: (t, int) => unit -``` - -Sets the index at which the next match will start its search from. - -## multiline - -```res sig -let multiline: t => bool -``` - -Returns a `bool` indicating whether the multiline flag is set. - -## source - -```res sig -let source: t => string -``` - -Returns the pattern as a `string`. - -## sticky - -```res sig -let sticky: t => bool -``` - -Returns a `bool` indicating whether the sticky flag is set. - -## unicode - -```res sig -let unicode: t => bool -``` - -Returns a `bool` indicating whether the unicode flag is set. - -## exec\_ - -```res sig -let exec_: (t, string) => option -``` - -Executes a search on a given string using the given RegExp object. -Returns `Some(Js.Re.result)` if a match is found, `None` otherwise. - -```res example -/* Match "quick brown" followed by "jumps", ignoring characters in between - * Remember "brown" and "jumps" - * Ignore case - */ - -let re = %re("/quick\s(brown).+?(jumps)/ig") -let result = Js.Re.exec_(re, "The Quick Brown Fox Jumps Over The Lazy Dog") -``` - -## exec - -```res sig -let exec: (string, t) => option -``` - -Deprecated. please use `Js.Re.exec_` instead. - -## test\_ - -```res sig -let test_: (t, string) => bool -``` - -Tests whether the given RegExp object will match a given `string`. -Returns true if a match is found, false otherwise. - -```res example -/* 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" */ -``` - -## test - -```res sig -let test: (string, t) => bool -``` - -Deprecated. please use `Js.Re.test_` instead. diff --git a/pages/docs/manual/v10.0.0/api/js/result.mdx b/pages/docs/manual/v10.0.0/api/js/result.mdx deleted file mode 100644 index b9a747f95..000000000 --- a/pages/docs/manual/v10.0.0/api/js/result.mdx +++ /dev/null @@ -1,15 +0,0 @@ -# Result - - - -Define the interface for result. - - - -## t - -```res sig -type t<'good, 'bad> = - | Ok('good) - | Error('bad) -``` diff --git a/pages/docs/manual/v10.0.0/api/js/string-2.mdx b/pages/docs/manual/v10.0.0/api/js/string-2.mdx deleted file mode 100644 index 1b93d443d..000000000 --- a/pages/docs/manual/v10.0.0/api/js/string-2.mdx +++ /dev/null @@ -1,804 +0,0 @@ -# String2 - - - -Provide bindings to JS string. Optimized for pipe-first. - - - -## t - -```res prelude -type t = string -``` - -## make - -```res sig -let make: 'a => t -``` - -`make(value)` converts the given value to a `string`. - -```res example -Js.String2.make(3.5) == "3.5" -Js.String2.make([1, 2, 3]) == "1,2,3" -``` - -## fromCharCode - -```res sig -let fromCharCode: int => t -``` - -`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. - -```res example -Js.String2.fromCharCode(65) == "A" -Js.String2.fromCharCode(0x3c8) == `ψ` -Js.String2.fromCharCode(0xd55c) == `한` -Js.String2.fromCharCode(-64568) == `ψ` -``` - -## fromCharCodeMany - -```res sig -let fromCharCodeMany: array => t -``` - -`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. - -## fromCodePoint - -```res sig -let fromCodePoint: int => t -``` - -`fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. -If the number is not a valid code point, it raises `RangeError`. -Thus, `fromCodePoint(0x1F63A)` will produce a correct value, unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN. - -```res example -Js.String2.fromCodePoint(65) == "A" -Js.String2.fromCodePoint(0x3c8) == `ψ` -Js.String2.fromCodePoint(0xd55c) == `한` -Js.String2.fromCodePoint(0x1f63a) == `😺` -``` - -## fromCodePointMany - -```res sig -let fromCodePointMany: array => t -``` - -`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. - -```res example -Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` -``` - -## length - -```res sig -let length: t => int -``` - -`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. - -```res example -Js.String2.length("abcd") == 4 -``` - -## get - -```res sig -let get: (t, int) => t -``` - -`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`. - -```res example -Js.String2.get("Reason", 0) == "R" -Js.String2.get("Reason", 4) == "o" -Js.String2.get(`Rẽasöń`, 5) == `ń` -``` - -## charAt - -```res sig -let charAt: (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. - -```res example -Js.String2.charAt("Reason", 0) == "R" -Js.String2.charAt("Reason", 12) == "" -Js.String2.charAt(`Rẽasöń`, 5) == `ń` -``` - -## charCodeAt - -```res sig -let charCodeAt: (t, int) => float -``` - -`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. - -```res example -Js.String2.charCodeAt(`😺`, 0) == 0xd83d->Belt.Int.toFloat -Js.String2.codePointAt(`😺`, 0) == Some(0x1f63a) -``` - -## codePointAt - -```res sig -let codePointAt: (t, int) => option -``` - -`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. - -```res example -Js.String2.codePointAt(`¿😺?`, 1) == Some(0x1f63a) -Js.String2.codePointAt("abc", 5) == None -``` - -## concat - -```res sig -let concat: (t, t) => t -``` - -`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. - -```res example -Js.String2.concat("cow", "bell") == "cowbell" -``` - -## concatMany - -```res sig -let concatMany: (t, array) => t -``` - -`concat(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. - -```res example -Js.String2.concatMany("1st", ["2nd", "3rd", "4th"]) == "1st2nd3rd4th" -``` - -## endsWith - -```res sig -let endsWith: (t, t) => bool -``` - -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. - -```res example -Js.String2.endsWith("BuckleScript", "Script") == true -Js.String2.endsWith("BuckleShoes", "Script") == false -``` - -## endsWithFrom - -```res sig -let endsWithFrom: (t, t, int) => bool -``` - -`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. - -```res example -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 -``` - -## includes - -```res sig -let includes: (t, t) => bool -``` - -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. - -```res example -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 -``` - -## includesFrom - -```res sig -let includesFrom: (t, t, int) => bool -``` - -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. - -```res example -Js.String2.includesFrom("programmer", "gram", 1) == true -Js.String2.includesFrom("programmer", "gram", 4) == false -Js.String2.includesFrom(`대한민국`, `한`, 1) == true -``` - -## indexOf - -```res sig -let indexOf: (t, t) => int -``` - -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. - -```res example -Js.String2.indexOf("bookseller", "ok") == 2 -Js.String2.indexOf("bookseller", "sell") == 4 -Js.String2.indexOf("beekeeper", "ee") == 1 -Js.String2.indexOf("bookseller", "xyz") == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (t, t, int) => int -``` - -`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. - -```res example -Js.String2.indexOfFrom("bookseller", "ok", 1) == 2 -Js.String2.indexOfFrom("bookseller", "sell", 2) == 4 -Js.String2.indexOfFrom("bookseller", "sell", 5) == -1 -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (t, t) => int -``` - -`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. - -```res example -Js.String2.lastIndexOf("bookseller", "ok") == 2 -Js.String2.lastIndexOf("beekeeper", "ee") == 4 -Js.String2.lastIndexOf("abcdefg", "xyz") == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (t, t, int) => int -``` - -`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. - -```res example -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 -``` - -## localeCompare - -```res sig -let localeCompare: (t, t) => float -``` - -`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. - -```res example -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 -``` - -## match - -```res sig -let match_: (t, Js_re.t) => option>> -``` - -`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. Javscript String.prototype.match can return `undefined` for optional capture groups that are not found, thus the element of the returned array is typed `option`. See [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) on MDN. - -```res example -Js.String2.match_("The better bats", %re("/b[aeiou]t/")) == Some([Some("bet")]) -Js.String2.match_("The better bats", %re("/b[aeiou]t/g")) == Some([Some("bet"), Some("bat")]) -Js.String2.match_("Today is 2018-04-05.", %re("/(\d+)-(\d+)-(\d+)/")) == - Some([Some("2018-04-05"), Some("2018"), Some("04"), Some("05")]) -Js.String2.match_("The large container.", %re("/b[aeiou]g/")) == None -``` - -## normalize - -```res sig -let normalize: t => t -``` - -`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. - -## normalizeByForm - -```res sig -let normalizeByForm: (t, t) => t -``` - -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.. - -## repeat - -```res sig -let repeat: (t, int) => t -``` - -`repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`. Raises `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. - -```res example -Js.String2.repeat("ha", 3) == "hahaha" -Js.String2.repeat("empty", 0) == "" -``` - -## replace - -```res sig -let replace: (t, t, t) => t -``` - -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. - -```res example -Js.String2.replace("old string", "old", "new") == "new string" -Js.String2.replace("the cat and the dog", "the", "this") == "this cat and the dog" -``` - -## replaceByRe - -```res sig -let replaceByRe: (t, Js_re.t, t) => t -``` - -`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. - -```res example -Js.String2.replaceByRe("vowels be gone", %re("/[aeiou]/g"), "x") == "vxwxls bx gxnx" -Js.String2.replaceByRe("Juan Fulano", %re("/(\w+) (\w+)/"), "$2, $1") == "Fulano, Juan" -``` - -## unsafeReplaceBy0 - -```res sig -let unsafeReplaceBy0: (t, Js_re.t, (t, int, t) => t) => t -``` - -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. - -```res example -let str = "beautiful vowels" -let re = %re("/[aeiou]/g") -let matchFn = (matchPart, _offset, _wholeString) => Js.String2.toUpperCase(matchPart) - -Js.String2.unsafeReplaceBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" -``` - -## unsafeReplaceBy1 - -```res sig -let unsafeReplaceBy1: (t, Js_re.t, (t, t, int, t) => t) => t -``` - -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. - -```res example -let str = "Jony is 40" -let re = %re("/(Jony is )\d+/g") -let matchFn = (_match, part1, _offset, _wholeString) => { - part1 ++ "41" -} - -Js.String2.unsafeReplaceBy1(str, re, matchFn) == "Jony is 41" -``` - -## unsafeReplaceBy2 - -```res sig -let unsafeReplaceBy2: (t, Js_re.t, (t, t, t, int, t) => t) => t -``` - -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. - -```res example -let str = "7 times 6" -let re = %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" -``` - -## unsafeReplaceBy3 - -```res sig -let unsafeReplaceBy3: (t, Js_re.t, (t, t, t, t, int, t) => t) => t -``` - -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. - -## search - -```res sig -let search: (t, Js_re.t) => int -``` - -`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. - -```res example -Js.String2.search("testing 1 2 3", %re("/\d+/")) == 8 -Js.String2.search("no numbers", %re("/\d+/")) == -1 -``` - -## slice - -```res sig -let slice: (t, ~from: int, ~to_: int) => t -``` - -`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. - -```res example -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) == "" -``` - -## sliceToEnd - -```res sig -let sliceToEnd: (t, ~from: int) => t -``` - -`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. - -```res example -Js.String2.sliceToEnd("abcdefg", ~from=4) == "efg" -Js.String2.sliceToEnd("abcdefg", ~from=-2) == "fg" -Js.String2.sliceToEnd("abcdefg", ~from=7) == "" -``` - -## split - -```res sig -let split: (t, t) => array -``` - -`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. - -```res example -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"] -``` - -## splitAtMost - -```res sig -let splitAtMost: (t, t, ~limit: int) => array -``` - -`splitAtMost(str, delimiter, ~limit:n)` 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. - -```res example -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=3) == ["ant", "bee", "cat"] -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=0) == [] -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=9) == [ - "ant", - "bee", - "cat", - "dog", - "elk", - ] -``` - -## splitByRe - -```res sig -let splitByRe: (t, Js_re.t) => array> -``` - -`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. - -```res example -Js.String2.splitByRe("art; bed , cog ;dad", %re("/\s*[,;]\s*/")) == [ - Some("art"), - Some("bed"), - Some("cog"), - Some("dad"), - ] -``` - -## splitByReAtMost - -```res sig -let splitByReAtMost: (t, Js_re.t, ~limit: int) => array> -``` - -`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. - -```res example -Js.String2.splitByReAtMost("one: two: three: four", %re("/\s*:\s*/"), ~limit=3) == [ - Some("one"), - Some("two"), - Some("three"), - ] - -Js.String2.splitByReAtMost("one: two: three: four", %re("/\s*:\s*/"), ~limit=0) == [] - -Js.String2.splitByReAtMost("one: two: three: four", %re("/\s*:\s*/"), ~limit=8) == [ - Some("one"), - Some("two"), - Some("three"), - Some("four"), - ] -``` - -## startsWith - -```res sig -let startsWith: (t, t) => bool -``` - -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. - -```res example -Js.String2.startsWith("BuckleScript", "Buckle") == true -Js.String2.startsWith("BuckleScript", "") == true -Js.String2.startsWith("JavaScript", "Buckle") == false -``` - -## startsWithFrom - -```res sig -let startsWithFrom: (t, t, int) => bool -``` - -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. - -```res example -Js.String2.startsWithFrom("BuckleScript", "kle", 3) == true -Js.String2.startsWithFrom("BuckleScript", "", 3) == true -Js.String2.startsWithFrom("JavaScript", "Buckle", 2) == false -``` - -## substr - -```res sig -let substr: (t, ~from: int) => t -``` - -`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. - -```res example -Js.String2.substr("abcdefghij", ~from=3) == "defghij" -Js.String2.substr("abcdefghij", ~from=-3) == "hij" -Js.String2.substr("abcdefghij", ~from=12) == "" -``` - -## substrAtMost - -```res sig -let substrAtMost: (t, ~from: int, ~length: int) => t -``` - -`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. - -```res example -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) == "" -``` - -## substring - -```res sig -let substring: (t, ~from: int, ~to_: int) => t -``` - -`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. - -```res example -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" -``` - -## substringToEnd - -```res sig -let substringToEnd: (t, ~from: int) => t -``` - -`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. - -```res example -Js.String2.substringToEnd("playground", ~from=4) == "ground" -Js.String2.substringToEnd("playground", ~from=-3) == "playground" -Js.String2.substringToEnd("playground", ~from=12) == "" -``` - -## toLowerCase - -```res sig -let toLowerCase: t => t -``` - -`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. - -```res example -Js.String2.toLowerCase("ABC") == "abc" -Js.String2.toLowerCase(`ΣΠ`) == `σπ` -Js.String2.toLowerCase(`ΠΣ`) == `πς` -``` - -## toLocaleLowerCase - -```res sig -let toLocaleLowerCase: t => t -``` - -`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. - -## toUpperCase - -```res sig -let toUpperCase: t => t -``` - -`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. - -```res example -Js.String2.toUpperCase("abc") == "ABC" -Js.String2.toUpperCase(`Straße`) == `STRASSE` -Js.String2.toUpperCase(`πς`) == `ΠΣ` -``` - -## toLocaleUpperCase - -```res sig -let toLocaleUpperCase: t => t -``` - -`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. - -## trim - -```res sig -let trim: t => t -``` - -`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. - -```res example -Js.String2.trim(" abc def ") == "abc def" -Js.String2.trim("\n\r\t abc def \n\n\t\r ") == "abc def" -``` - -## anchor - -```res sig -let anchor: (t, t) => t -``` - -`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. - -```res example -Js.String2.anchor("Page One", "page1") == "Page One" -``` - -## link - -```res sig -let link: (t, t) => t -``` - -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. - -```res example -Js.String2.link("Go to page two", "page2.html") == "Go to page two" -``` - -## castToArrayLike - -```res sig -let castToArrayLike: t => Js_array2.array_like -``` - -Casts its argument to an `array_like` entity that can be processed by functions such as `Js.Array2.fromMap()` - -```res example -let s = "abcde" -let arr = Js.Array2.fromMap(Js.String2.castToArrayLike(s), x => x) -arr == ["a", "b", "c", "d", "e"] -``` diff --git a/pages/docs/manual/v10.0.0/api/js/string.mdx b/pages/docs/manual/v10.0.0/api/js/string.mdx deleted file mode 100644 index bbfdbaaca..000000000 --- a/pages/docs/manual/v10.0.0/api/js/string.mdx +++ /dev/null @@ -1,814 +0,0 @@ -# String - - - -Provide bindings to JS string. Optimized for pipe-last. - - - -## t - -```res prelude -type t = string -``` - -## make - -```res sig -let make: 'a => t -``` - -`make(value)` converts the given value to a `string`. - -```res example -Js.String2.make(3.5) == "3.5" -Js.String2.make([1, 2, 3]) == "1,2,3" -``` - -## fromCharCode - -```res sig -let fromCharCode: int => t -``` - -`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. - -```res example -Js.String2.fromCharCode(65) == "A" -Js.String2.fromCharCode(0x3c8) == `ψ` -Js.String2.fromCharCode(0xd55c) == `한` -Js.String2.fromCharCode(-64568) == `ψ` -``` - -## fromCharCodeMany - -```res sig -let fromCharCodeMany: array => t -``` - -`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. - -## fromCodePoint - -```res sig -let fromCodePoint: int => t -``` - -`fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. -If the number is not a valid code point, it raises `RangeError`. -Thus, `fromCodePoint(0x1F63A)` will produce a correct value, unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN. - -```res example -Js.String2.fromCodePoint(65) == "A" -Js.String2.fromCodePoint(0x3c8) == `ψ` -Js.String2.fromCodePoint(0xd55c) == `한` -Js.String2.fromCodePoint(0x1f63a) == `😺` -``` - -## fromCodePointMany - -```res sig -let fromCodePointMany: array => t -``` - -`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. - -```res example -Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` -``` - -## length - -```res sig -let length: t => int -``` - -`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. - -```res example -Js.String2.length("abcd") == 4 -``` - -## get - -```res sig -let get: (t, int) => t -``` - -`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`. - -```res example -Js.String2.get("Reason", 0) == "R" -Js.String2.get("Reason", 4) == "o" -Js.String2.get(`Rẽasöń`, 5) == `ń` -``` - -## charAt - -```res sig -let charAt: (int, t) => 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. - -```res example -Js.String.charAt(0, "Reason") == "R" -Js.String.charAt(12, "Reason") == "" -Js.String.charAt(5, `Rẽasöń`) == `ń` -``` - -## charCodeAt - -```res sig -let charCodeAt: (int, t) => float -``` - -`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. - -```res example -Js.String.charCodeAt(0, `😺`) == 0xd83d->Belt.Int.toFloat -Js.String.codePointAt(0, `😺`) == Some(0x1f63a) -``` - -## codePointAt - -```res sig -let codePointAt: (int, t) => option -``` - -`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. - -```res example -Js.String.codePointAt(1, `¿😺?`) == Some(0x1f63a) -Js.String.codePointAt(5, "abc") == None -``` - -## concat - -```res sig -let concat: (t, t) => t -``` - -`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. - -```res example -Js.String.concat("bell", "cow") == "cowbell" -``` - -## concatMany - -```res sig -let concatMany: (array, t) => t -``` - -`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. - -```res example -Js.String.concatMany(["2nd", "3rd", "4th"], "1st") == "1st2nd3rd4th" -``` - -## endsWith - -```res sig -let endsWith: (t, t) => bool -``` - -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. - -```res example -Js.String.endsWith("Script", "BuckleScript") == true -Js.String.endsWith("Script", "BuckleShoes") == false -``` - -## endsWithFrom - -```res sig -let endsWithFrom: (t, int, t) => bool -``` - -`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. - -```res example -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 -``` - -## includes - -```res sig -let includes: (t, t) => bool -``` - -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. - -```res example -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 -``` - -## includesFrom - -```res sig -let includesFrom: (t, int, t) => bool -``` - -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. - -```res example -Js.String.includesFrom("gram", 1, "programmer") == true -Js.String.includesFrom("gram", 4, "programmer") == false -Js.String.includesFrom(`한`, 1, `대한민국`) == true -``` - -## indexOf - -```res sig -let indexOf: (t, t) => int -``` - -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. - -```res example -Js.String.indexOf("ok", "bookseller") == 2 -Js.String.indexOf("sell", "bookseller") == 4 -Js.String.indexOf("ee", "beekeeper") == 1 -Js.String.indexOf("xyz", "bookseller") == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (t, t, int) => int -``` - -`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. - -```res example -Js.String.indexOfFrom("ok", 1, "bookseller") == 2 -Js.String.indexOfFrom("sell", 2, "bookseller") == 4 -Js.String.indexOfFrom("sell", 5, "bookseller") == -1 -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (t, t) => int -``` - -`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. - -```res example -Js.String.lastIndexOf("ok", "bookseller") == 2 -Js.String.lastIndexOf("ee", "beekeeper") == 4 -Js.String.lastIndexOf("xyz", "abcdefg") == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (t, int, t) => int -``` - -`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. - -```res example -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 -``` - -## localeCompare - -```res sig -let localeCompare: (t, t) => float -``` - -`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. - -```res example -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 -``` - -## match - -```res sig -let match_: (Js_re.t, t) => option>> -``` - -`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. Javscript String.prototype.match can return `undefined` for optional capture groups that are not found, thus the element of the returned array is typed `option`. See [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) on MDN. - -```res example -Js.String.match_(%re("/b[aeiou]t/"), "The better bats") == Some([Some("bet")]) -Js.String.match_(%re("/b[aeiou]t/g"), "The better bats") == Some([Some("bet"), Some("bat")]) -Js.String.match_(%re("/(\d+)-(\d+)-(\d+)/"), "Today is 2018-04-05.") == - Some([Some("2018-04-05"), Some("2018"), Some("04"), Some("05")]) -Js.String.match_(%re("/b[aeiou]g/"), "The large container.") == None -``` - -## normalize - -```res sig -let normalize: t => t -``` - -`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. - -## normalizeByForm - -```res sig -let normalizeByForm: (t, t) => t -``` - -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. - -## repeat - -```res sig -let repeat: (t, int) => t -``` - -`repeat(n, str)` returns a `string` that consists of `n` repetitions of `str`. Raises `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. - -```res example -Js.String.repeat(3, "ha") == "hahaha" -Js.String.repeat(0, "empty") == "" -``` - -## replace - -```res sig -let replace: (t, t, t) => t -``` - -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. - -```res example -Js.String.replace("old", "new", "old string") == "new string" -Js.String.replace("the", "this", "the cat and the dog") == "this cat and the dog" -``` - -## replaceByRe - -```res sig -let replaceByRe: (Js_re.t, t, t) => t -``` - -`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. - -```res example -Js.String.replaceByRe(%re("/[aeiou]/g"), "x", "vowels be gone") == "vxwxls bx gxnx" -Js.String.replaceByRe(%re("/(\w+) (\w+)/"), "$2, $1", "Juan Fulano") == "Fulano, Juan" -``` - -## unsafeReplaceBy0 - -```res sig -let unsafeReplaceBy0: (Js_re.t, (t, int, t) => t, t) => t -``` - -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. - -```res example -let str = "beautiful vowels" -let re = %re("/[aeiou]/g") -let matchFn = (matchPart, _offset, _wholeString) => Js.String.toUpperCase(matchPart) - -Js.String.unsafeReplaceBy0(re, matchFn, str) == "bEAUtIfUl vOwEls" -``` - -## unsafeReplaceBy1 - -```res sig -let unsafeReplaceBy1: (Js_re.t, (t, t, int, t) => t, t) => t -``` - -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. - -```res example -let str = "Jony is 40" -let re = %re("/(Jony is )\d+/g") -let matchFn = (_match, part1, _offset, _wholeString) => { - part1 ++ "41" -} - -Js.String.unsafeReplaceBy1(re, matchFn, str) == "Jony is 41" -``` - -## unsafeReplaceBy2 - -```res sig -let unsafeReplaceBy2: (Js_re.t, (t, t, t, int, t) => t, t) => t -``` - -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. - -```res example -let str = "7 times 6" -let re = %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" -``` - -## unsafeReplaceBy3 - -```res sig -let unsafeReplaceBy3: (Js_re.t, (t, t, t, t, int, t) => t, t) => t -``` - -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. - -## search - -```res sig -let search: (Js_re.t, t) => int -``` - -`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. - -```res example -Js.String.search(%re("/\d+/"), "testing 1 2 3") == 8 -Js.String.search(%re("/\d+/"), "no numbers") == -1 -``` - -## slice - -```res sig -let slice: (~from: int, ~to_: int, t) => t -``` - -`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. - -```res example -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") == "" -``` - -## sliceToEnd - -```res sig -let sliceToEnd: (~from: int, t) => t -``` - -`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. - -```res example -Js.String.sliceToEnd(~from=4, "abcdefg") == "efg" -Js.String.sliceToEnd(~from=-2, "abcdefg") == "fg" -Js.String.sliceToEnd(~from=7, "abcdefg") == "" -``` - -## split - -```res sig -let split: (t, t) => array -``` - -`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. - -```res example -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"] -``` - -## splitAtMost - -```res sig -let splitAtMost: (t, ~limit: int, t) => array -``` - -`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. - -```res example -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"] -``` - -## splitLimited - -```res sig -let splitLimited: (t, int, t) => array -``` - -Deprecated - Please use splitAtMost. - -## splitByRe - -```res sig -let splitByRe: (Js_re.t, t) => array> -``` - -`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. - -```res example -Js.String.splitByRe(%re("/\s*[,;]\s*/"), "art; bed , cog ;dad") == [ - Some("art"), - Some("bed"), - Some("cog"), - Some("dad"), - ] -``` - -## splitByReAtMost - -```res sig -let splitByReAtMost: (Js_re.t, ~limit: int, t) => array> -``` - -`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. - -```res example -Js.String.splitByReAtMost(%re("/\s*:\s*/"), ~limit=3, "one: two: three: four") == [ - Some("one"), - Some("two"), - Some("three"), - ] - -Js.String.splitByReAtMost(%re("/\s*:\s*/"), ~limit=0, "one: two: three: four") == [] - -Js.String.splitByReAtMost(%re("/\s*:\s*/"), ~limit=8, "one: two: three: four") == [ - Some("one"), - Some("two"), - Some("three"), - Some("four"), - ] -``` - -## splitRegexpLimited - -```res sig -let splitRegexpLimited: (Js_re.t, int, t) => array -``` - -Deprecated - Please use splitByReAtMost. - -## startsWith - -```res sig -let startsWith: (t, t) => bool -``` - -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. - -```res example -Js.String.startsWith("Buckle", "BuckleScript") == true -Js.String.startsWith("", "BuckleScript") == true -Js.String.startsWith("Buckle", "JavaScript") == false -``` - -## startsWithFrom - -```res sig -let startsWithFrom: (t, int, t) => bool -``` - -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. - -```res example -Js.String.startsWithFrom("kle", 3, "BuckleScript") == true -Js.String.startsWithFrom("", 3, "BuckleScript") == true -Js.String.startsWithFrom("Buckle", 2, "JavaScript") == false -``` - -## substr - -```res sig -let substr: (~from: int, t) => t -``` - -`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. - -```res example -Js.String.substr(~from=3, "abcdefghij") == "defghij" -Js.String.substr(~from=-3, "abcdefghij") == "hij" -Js.String.substr(~from=12, "abcdefghij") == "" -``` - -## substrAtMost - -```res sig -let substrAtMost: (~from: int, ~length: int, t) => t -``` - -`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. - -```res example -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") == "" -``` - -## substring - -```res sig -let substring: (~from: int, ~to_: int, t) => t -``` - -`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. - -```res example -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" -``` - -## substringToEnd - -```res sig -let substringToEnd: (~from: int, t) => t -``` - -`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. - -```res example -Js.String.substringToEnd(~from=4, "playground") == "ground" -Js.String.substringToEnd(~from=-3, "playground") == "playground" -Js.String.substringToEnd(~from=12, "playground") == "" -``` - -## toLowerCase - -```res sig -let toLowerCase: t => t -``` - -`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. - -```res example -Js.String.toLowerCase("ABC") == "abc" -Js.String.toLowerCase(`ΣΠ`) == `σπ` -Js.String.toLowerCase(`ΠΣ`) == `πς` -``` - -## toLocaleLowerCase - -```res sig -let toLocaleLowerCase: t => t -``` - -`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. - -## toUpperCase - -```res sig -let toUpperCase: t => t -``` - -`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. - -```res example -Js.String.toUpperCase("abc") == "ABC" -Js.String.toUpperCase(`Straße`) == `STRASSE` -Js.String.toUpperCase(`πς`) == `ΠΣ` -``` - -## toLocaleUpperCase - -```res sig -let toLocaleUpperCase: t => t -``` - -`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. - -## trim - -```res sig -let trim: t => t -``` - -`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. - -```res example -Js.String.trim(" abc def ") == "abc def" -Js.String.trim("\n\r\t abc def \n\n\t\r ") == "abc def" -``` - -## anchor - -```res sig -let anchor: (t, t) => t -``` - -`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. - -```res example -Js.String.anchor("page1", "Page One") == "Page One" -``` - -## link - -```res sig -let link: (t, t) => t -``` - -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. - -```res example -Js.String.link("page2.html", "Go to page two") == "Go to page two" -``` - -## castToArrayLike - -```res sig -let castToArrayLike: t => Js_array2.array_like -``` - -Casts its argument to an `array_like` entity that can be processed by functions such as `Js.Array2.fromMap()` - -```res example -let s = "abcde" -let arr = Js.Array2.fromMap(Js.String.castToArrayLike(s), x => x) -arr == ["a", "b", "c", "d", "e"] -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2.mdx deleted file mode 100644 index ab447dbdc..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2.mdx +++ /dev/null @@ -1,41 +0,0 @@ -# TypedArray2 - - - -Provide bindings to JS typed array. - - - -## array_buffer - -```res sig -type array_buffer -``` - -## array_like - -```res sig -type array_like<'a> -``` - -## module ArrayBuffer - -## module Int8Array - -## module Uint8Array - -## module Uint8ClampedArray - -## module Int16Array - -## module Uint16Array - -## module Int32Array - -## module Uint32Array - -## module Float32Array - -## module Float64Array - -## module DataView diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_array-buffer.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_array-buffer.mdx deleted file mode 100644 index a0af5cafa..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_array-buffer.mdx +++ /dev/null @@ -1,39 +0,0 @@ -# TypedArray2.ArrayBuffer - - - -Provide bindings to JS typed array ArrayBuffer. - - - -## t - -```res prelude -type t = Js_typed_array2.array_buffer -``` - -## make - -```res sig -let make: int => t -``` - -Takes length. initializes elements to 0. - -## byteLength - -```res sig -let byteLength: t => int -``` - -## slice - -```res sig -let slice: (t, ~start: int, ~end_: int) => Js_typed_array2.array_buffer -``` - -## sliceFrom - -```res sig -let sliceFrom: (t, int) => Js_typed_array2.array_buffer -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_data-view.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_data-view.mdx deleted file mode 100644 index 0b65c8da7..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_data-view.mdx +++ /dev/null @@ -1,223 +0,0 @@ -# TypedArray2.DataView - - - -Provide bindings to JS typed array DataView. - - - -## t - -```res prelude -type t -``` - -## make - -```res sig -let make: Js_typed_array2.array_buffer => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## getInt8 - -```res sig -let getInt8: (t, int) => int -``` - -## getUint8 - -```res sig -let getUint8: (t, int) => int -``` - -## getInt16 - -```res sig -let getInt16: (t, int) => int -``` - -## getInt16LittleEndian - -```res sig -let getInt16LittleEndian: (t, int) => int -``` - -## getUint16 - -```res sig -let getUint16: (t, int) => int -``` - -## getUint16LittleEndian - -```res sig -let getUint16LittleEndian: (t, int) => int -``` - -## getInt32 - -```res sig -let getInt32: (t, int) => int -``` - -## getInt32LittleEndian - -```res sig -let getInt32LittleEndian: (t, int) => int -``` - -## getUint32 - -```res sig -let getUint32: (t, int) => int -``` - -## getUint32LittleEndian - -```res sig -let getUint32LittleEndian: (t, int) => int -``` - -## getFloat32 - -```res sig -let getFloat32: (t, int) => float -``` - -## getFloat32LittleEndian - -```res sig -let getFloat32LittleEndian: (t, int) => float -``` - -## getFloat64 - -```res sig -let getFloat64: (t, int) => float -``` - -## getFloat64LittleEndian - -```res sig -let getFloat64LittleEndian: (t, int) => float -``` - -## setInt8 - -```res sig -let setInt8: (t, int, int) => unit -``` - -## setUint8 - -```res sig -let setUint8: (t, int, int) => unit -``` - -## setInt16 - -```res sig -let setInt16: (t, int, int) => unit -``` - -## setInt16LittleEndian - -```res sig -let setInt16LittleEndian: (t, int, int) => unit -``` - -## setUint16 - -```res sig -let setUint16: (t, int, int) => unit -``` - -## setUint16LittleEndian - -```res sig -let setUint16LittleEndian: (t, int, int) => unit -``` - -## setInt32 - -```res sig -let setInt32: (t, int, int) => unit -``` - -## setInt32LittleEndian - -```res sig -let setInt32LittleEndian: (t, int, int) => unit -``` - -## setUint32 - -```res sig -let setUint32: (t, int, int) => unit -``` - -## setUint32LittleEndian - -```res sig -let setUint32LittleEndian: (t, int, int) => unit -``` - -## setFloat32 - -```res sig -let setFloat32: (t, int, float) => unit -``` - -## setFloat32LittleEndian - -```res sig -let setFloat32LittleEndian: (t, int, float) => unit -``` - -## setFloat64 - -```res sig -let setFloat64: (t, int, float) => unit -``` - -## setFloat64LittleEndian - -```res sig -let setFloat64LittleEndian: (t, int, float) => unit -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_float-32-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_float-32-array.mdx deleted file mode 100644 index e8ded9652..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_float-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Float32Array - - - -Provide bindings to JS typed array Float32Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_float-64-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_float-64-array.mdx deleted file mode 100644 index 9e56a8585..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_float-64-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Float64Array - - - -Provide bindings to JS typed array Float64Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-16-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-16-array.mdx deleted file mode 100644 index 754bbaa80..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Int16Array - - - -Provide bindings to JS typed array Int16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-32-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-32-array.mdx deleted file mode 100644 index efeb8dddd..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray2.Int32Array - - - -Provide bindings to JS typed array Int32Array. - - - -## t - -```res prelude -type elt = int32 -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array2.array_buffer => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-8-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-8-array.mdx deleted file mode 100644 index c75df550c..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_int-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Int8Array - - - -Provide bindings to JS typed array Int8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-16-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-16-array.mdx deleted file mode 100644 index 38a507f30..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint16Array - - - -Provide bindings to JS typed array Uint16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-32-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-32-array.mdx deleted file mode 100644 index d65d4174d..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.UInt32Array - - - -Provide bindings to JS typed array Uint32Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-array.mdx deleted file mode 100644 index 4bb64163b..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint8Array - - - -Provide bindings to JS typed array Uint8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx deleted file mode 100644 index effd38955..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint8ClampedArray - - - -Provide bindings to JS typed array Uint8ClampedArray. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array.mdx deleted file mode 100644 index cbafefce5..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array.mdx +++ /dev/null @@ -1,51 +0,0 @@ -# TypedArray - - - -Provide bindings to JS typed array. - - - -## array_buffer - -```res sig -type array_buffer -``` - -## array_like - -```res sig -type array_like<'a> -``` - -## module type Type - -```res sig -module type Type = { - type t -} -``` - -## module ArrayBuffer - -## module type S - -## module Int8Array - -## module Uint8Array - -## module Uint8ClampedArray - -## module Int16Array - -## module Uint16Array - -## module Int32Array - -## module Uint32Array - -## module Float32Array - -## module Float64Array - -## module DataView diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_array-buffer.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_array-buffer.mdx deleted file mode 100644 index f5dbd3860..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_array-buffer.mdx +++ /dev/null @@ -1,39 +0,0 @@ -# TypedArray.ArrayBuffer - - - -Provide bindings to JS typed array ArrayBuffer. - - - -## t - -```res prelude -type t = Js_typed_array.array_buffer -``` - -## make - -```res sig -let make: int => t -``` - -Takes length. initializes elements to 0. - -## byteLength - -```res sig -let byteLength: t => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => Js_typed_array.array_buffer -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => Js_typed_array.array_buffer -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_data-view.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_data-view.mdx deleted file mode 100644 index 6a02034ff..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_data-view.mdx +++ /dev/null @@ -1,223 +0,0 @@ -# TypedArray.DataView - - - -Provide bindings to JS typed array DataView. - - - -## t - -```res prelude -type t = Js_typed_array2.DataView.t -``` - -## make - -```res sig -let make: Js_typed_array.array_buffer => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## getInt8 - -```res sig -let getInt8: (t, int) => int -``` - -## getUint8 - -```res sig -let getUint8: (t, int) => int -``` - -## getInt16 - -```res sig -let getInt16: (t, int) => int -``` - -## getInt16LittleEndian - -```res sig -let getInt16LittleEndian: (t, int) => int -``` - -## getUint16 - -```res sig -let getUint16: (t, int) => int -``` - -## getUint16LittleEndian - -```res sig -let getUint16LittleEndian: (t, int) => int -``` - -## getInt32 - -```res sig -let getInt32: (t, int) => int -``` - -## getInt32LittleEndian - -```res sig -let getInt32LittleEndian: (t, int) => int -``` - -## getUint32 - -```res sig -let getUint32: (t, int) => int -``` - -## getUint32LittleEndian - -```res sig -let getUint32LittleEndian: (t, int) => int -``` - -## getFloat32 - -```res sig -let getFloat32: (t, int) => float -``` - -## getFloat32LittleEndian - -```res sig -let getFloat32LittleEndian: (t, int) => float -``` - -## getFloat64 - -```res sig -let getFloat64: (t, int) => float -``` - -## getFloat64LittleEndian - -```res sig -let getFloat64LittleEndian: (t, int) => float -``` - -## setInt8 - -```res sig -let setInt8: (t, int, int) => unit -``` - -## setUint8 - -```res sig -let setUint8: (t, int, int) => unit -``` - -## setInt16 - -```res sig -let setInt16: (t, int, int) => unit -``` - -## setInt16LittleEndian - -```res sig -let setInt16LittleEndian: (t, int, int) => unit -``` - -## setUint16 - -```res sig -let setUint16: (t, int, int) => unit -``` - -## setUint16LittleEndian - -```res sig -let setUint16LittleEndian: (t, int, int) => unit -``` - -## setInt32 - -```res sig -let setInt32: (t, int, int) => unit -``` - -## setInt32LittleEndian - -```res sig -let setInt32LittleEndian: (t, int, int) => unit -``` - -## setUint32 - -```res sig -let setUint32: (t, int, int) => unit -``` - -## setUint32LittleEndian - -```res sig -let setUint32LittleEndian: (t, int, int) => unit -``` - -## setFloat32 - -```res sig -let setFloat32: (t, int, float) => unit -``` - -## setFloat32LittleEndian - -```res sig -let setFloat32LittleEndian: (t, int, float) => unit -``` - -## setFloat64 - -```res sig -let setFloat64: (t, int, float) => unit -``` - -## setFloat64LittleEndian - -```res sig -let setFloat64LittleEndian: (t, int, float) => unit -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_float-32-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_float-32-array.mdx deleted file mode 100644 index 06b3a5866..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_float-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Float32Array - - - -Provide bindings to JS typed array Float32Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> = Js_typed_array2.Float32Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array.array_buffer => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_float-64-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_float-64-array.mdx deleted file mode 100644 index 3df7aaa1a..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_float-64-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Float64Array - - - -Provide bindings to JS typed array Float64Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> = Js_typed_array2.Float64Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array.array_buffer => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_int-16-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_int-16-array.mdx deleted file mode 100644 index ba9bb68b2..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_int-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Int16Array - - - -Provide bindings to JS typed array Int16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Int16Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_int-32-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_int-32-array.mdx deleted file mode 100644 index 181940b34..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_int-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Int32Array - - - -Provide bindings to JS typed array Int32Array. - - - -## t - -```res prelude -type elt = int32 -type typed_array<'a> = Js_typed_array2.Int32Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array.array_buffer => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_int-8-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_int-8-array.mdx deleted file mode 100644 index fce0667de..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_int-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Int8Array - - - -Provide bindings to JS typed array Int8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Int8Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_type-s.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_type-s.mdx deleted file mode 100644 index d71e5dcd7..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_type-s.mdx +++ /dev/null @@ -1,309 +0,0 @@ -# TypedArray type S - - - -TODO - - - -## t - -```res prelude -type elt -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-16-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_uint-16-array.mdx deleted file mode 100644 index 4628398b5..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint16Array - - - -Provide bindings to JS typed array Uint16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint16Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-32-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_uint-32-array.mdx deleted file mode 100644 index 667ed5134..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.UInt32Array - - - -Provide bindings to JS typed array Uint32Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint32Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-8-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_uint-8-array.mdx deleted file mode 100644 index 1cc7887ab..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint8Array - - - -Provide bindings to JS typed array Uint8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint8Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-8-clamped-array.mdx b/pages/docs/manual/v10.0.0/api/js/typed-array_uint-8-clamped-array.mdx deleted file mode 100644 index e5372dfbe..000000000 --- a/pages/docs/manual/v10.0.0/api/js/typed-array_uint-8-clamped-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint8ClampedArray - - - -Provide bindings to JS typed array Uint8ClampedArray. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint8ClampedArray.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/types.mdx b/pages/docs/manual/v10.0.0/api/js/types.mdx deleted file mode 100644 index bf19e7d0b..000000000 --- a/pages/docs/manual/v10.0.0/api/js/types.mdx +++ /dev/null @@ -1,78 +0,0 @@ -# Types - - - -Provide utilities for manipulating JS types. - - - -## symbol - -```res prelude -type symbol -``` - -## obj_val - -```res prelude -type obj_val -``` - -## undefined_val - -```res prelude -type undefined_val -``` - -## null_val - -```res prelude -type null_val -``` - -## function_val - -```res prelude -type function_val -``` - -## t - -```res prelude -type rec t<'a> = - | Undefined: t - | Null: t - | Boolean: t - | Number: t - | String: t - | Function: t - | Object: t - | Symbol: t -``` - -## test - -```res sig -let test: ('a, t<'b>) => bool -``` - -## tagged_t - -```res prelude -type tagged_t = - | JSFalse - | JSTrue - | JSNull - | JSUndefined - | JSNumber(float) - | JSString(string) - | JSFunction(function_val) - | JSObject(obj_val) - | JSSymbol(symbol) -``` - -## classify - -```res sig -let classify: 'a => tagged_t -``` diff --git a/pages/docs/manual/v10.0.0/api/js/undefined.mdx b/pages/docs/manual/v10.0.0/api/js/undefined.mdx deleted file mode 100644 index 9f318ed12..000000000 --- a/pages/docs/manual/v10.0.0/api/js/undefined.mdx +++ /dev/null @@ -1,119 +0,0 @@ -# Undefined - - - -Provide utilities around `Js.undefined`. - - - -## t - -```res prelude -type t<'a> = Js.undefined<'a> -``` - -Local alias for 'a Js.undefined. - -## return - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.undefined<'a>` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -Returns `true` if the given value is empty (undefined), `false` otherwise. - -## testAny - -```res sig -let testAny: 'a => bool -``` - -Since 1.6.1 Returns `true` if the given value is empty (undefined). - -## empty - -```res sig -let empty: t<'a> -``` - -The empty value, `undefined`. - -## getUnsafe - -```res sig -let getUnsafe: t<'a> => 'a -``` - -## getExn - -```res sig -let getExn: t<'a> => 'a -``` - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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>`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.undefined) => - Js.Undefined.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.undefined) => - Js.Undefined.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option<'a>` to `Js.undefined<'a>`. -`Some(a)` => `a` -`None` => `empty` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.undefined<'a>` to `option<'a>` -`a` => `Some(a)` -`empty` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v10.0.0/api/js/vector.mdx b/pages/docs/manual/v10.0.0/api/js/vector.mdx deleted file mode 100644 index cefea9a87..000000000 --- a/pages/docs/manual/v10.0.0/api/js/vector.mdx +++ /dev/null @@ -1,157 +0,0 @@ -# Vector - - - -Provide vector utilities. - - - -## t - -```res prelude -type t<'a> = array<'a> -``` - -## filterInPlace - -```res sig -let filterInPlace: ((. 'a) => bool, t<'a>) => unit -``` - -p : predicate -a : array - -## empty - -```res sig -let empty: t<'a> => unit -``` - -## pushBack - -```res sig -let pushBack: ('a, t<'a>) => unit -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -Create a shallow copy of a vector. - -## memByRef - -```res sig -let memByRef: ('a, t<'a>) => bool -``` - -Find by JS (===) equality. - -## iter - -```res sig -let iter: ((. 'a) => unit, t<'a>) => unit -``` - -## iteri - -```res sig -let iteri: ((. int, 'a) => unit, t<'a>) => unit -``` - -## toList - -```res sig -let toList: t<'a> => list<'a> -``` - -## map - -```res sig -let map: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -## mapi - -```res sig -let mapi: ((. int, 'a) => 'b, t<'a>) => t<'b> -``` - -## foldLeft - -```res sig -let foldLeft: ((. 'a, 'b) => 'a, 'a, t<'b>) => 'a -``` - -## foldRight - -```res sig -let foldRight: ((. 'b, 'a) => 'a, t<'b>, 'a) => 'a -``` - -## length - -```res sig -let length: t<'a> => int -``` - -Return the length (number of elements) of the given array. - -## get - -```res sig -let get: (t<'a>, int) => 'a -``` - -`Vector.get(a, n)` returns the element number `n` of vector `a`. The first element has number 0. The last element has number `Vector.length(a) - 1`. You can also write `a[n]` instead of `Vector.get(a, n)`. -Raise `Invalid_argument "index out of bounds"` if `n` is outside the range 0 to (`Array.length(a) - 1`). - -## set - -```res sig -let set: (t<'a>, int, 'a) => unit -``` - -`Vector.set(a, n, x)` modifies vector `a` in place, replacing element number `n` with `x`. -Raise `Invalid_argument "index out of bounds"` if `n` is outside the range 0 to `Array.length(a) - 1`. - -## make - -```res sig -let make: (int, 'a) => t<'a> -``` - -`Vector.make(n, x)` returns a fresh vector of length `n`, initialized with `x`. All the elements of this new vector are initially physically equal to `x` (in the sense of the `==` predicate). -Consequently, if `x` is mutable, it is shared among all elements of the array, and modifying `x` through one of the array entries will modify all other entries at the same time. -Raise `Invalid_argument` if `n < 0` or `n > Sys.max_array_length`. If the value of `x` is a floating-point number, then the maximum size is only `Sys.max_array_length / 2`. - -## init - -```res sig -let init: (int, (. int) => 'a) => t<'a> -``` - -Raises `RangeError` when n is negative. -n : size - -## append - -```res sig -let append: ('a, t<'a>) => t<'a> -``` - -`append(x, a)` returns a fresh vector with `x` appended to `a`. - -## unsafe_get - -```res sig -let unsafe_get: (t<'a>, int) => 'a -``` - -## unsafe_set - -```res sig -let unsafe_set: (t<'a>, int, 'a) => unit -``` diff --git a/pages/docs/manual/v10.0.0/array-and-list.mdx b/pages/docs/manual/v10.0.0/array-and-list.mdx deleted file mode 100644 index e1f4adb6a..000000000 --- a/pages/docs/manual/v10.0.0/array-and-list.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -title: "Array & List" -description: "Arrays and List data structures" -canonical: "/docs/manual/latest/array-and-list" ---- - -# Array and List - -## Array - -Arrays are our main ordered data structure. They work the same way as JavaScript arrays: they can be randomly accessed, dynamically resized, updated, etc. - - - -```res example -let myArray = ["hello", "world", "how are you"] -``` - -```js -var myArray = ["hello", "world", "how are you"]; -``` - - - -ReScript arrays' items must have the same type, i.e. homogeneous. - -### Usage - -See the [Js.Array](api/js/array) API. - -Access & update an array item like so: - - - -```res example -let myArray = ["hello", "world", "how are you"] - -let firstItem = myArray[0] // "hello" - -myArray[0] = "hey" // now ["hey", "world", "how are you"] - -let pushedValue = Js.Array2.push(myArray, "bye") -``` - -```js -var myArray = ["hello", "world", "how are you"]; - -var firstItem = myArray[0]; - -myArray[0] = "hey"; - -var pushedValue = myArray.push("bye"); -``` - - - -## List - -ReScript provides a singly linked list too. Lists are: - -- immutable -- fast at prepending items -- fast at getting the head -- slow at everything else - - - -```res example -let myList = list{1, 2, 3} -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; -``` - - - -Like arrays, lists' items need to be of the same type. - -### Usage - -You'd use list for its resizability, its fast prepend (adding at the head), and its fast split, all of which are immutable and relatively efficient. - -Do **not** use list if you need to randomly access an item or insert at non-head position. Your code would end up obtuse and/or slow. - -The standard lib provides a [List module](api/belt/list). - -#### Immutable Prepend - -Use the spread syntax: - - - -```res prelude -let myList = list{1, 2, 3} -let anotherList = list{0, ...myList} -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; - -var anotherList = { - hd: 0, - tl: myList, -}; -``` - - - -`myList` didn't mutate. `anotherList` is now `list{0, 1, 2, 3}`. This is efficient (constant time, not linear). `anotherList`'s last 3 elements are shared with `myList`! - -**Note that `list{a, ...b, ...c}` was a syntax error** before compiler v10.1. In general, the pattern should be used with care as its performance and allocation overhead are linear (`O(n)`). - -#### Access - -`switch` (described in the [pattern matching section](pattern-matching-destructuring.md)) is usually used to access list items: - - - -```res example -let message = - switch myList { - | list{} => "This list is empty" - | list{a, ...rest} => "The head of the list is the string " ++ Js.Int.toString(a) - } -``` - -```js -var message = myList - ? "The head of the list is the string " + (1).toString() - : "This list is empty"; -``` - - diff --git a/pages/docs/manual/v10.0.0/async-await.mdx b/pages/docs/manual/v10.0.0/async-await.mdx deleted file mode 100644 index bc8dcb984..000000000 --- a/pages/docs/manual/v10.0.0/async-await.mdx +++ /dev/null @@ -1,337 +0,0 @@ ---- -title: "Async / Await" -description: "Async / await for asynchronous operations" -canonical: "/docs/manual/latest/async-await" ---- - - - -
- -```res prelude -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" -@val external sendAnalytics: string => promise = "GlobalAPI.sendAnalytics" -``` - -
- - - -# Async / Await - -**Since 10.1** - -ReScript comes with `async` / `await` support to make asynchronous, `Promise` based code easier to read and write. This feature is very similar to its JS equivalent, so if you are already familiar with JS' `async` / `await`, you will feel right at home. - -## How it looks - -Let's start with a quick example to show-case the syntax: - - - -```res -// Some fictive functionality that offers asynchronous network actions -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" -@val external sendAnalytics: string => promise = "GlobalAPI.sendAnalytics" - -// We use the `async` keyword to allow the use of `await` in the function body -let logUserDetails = async (userId: string) => { - // We use `await` to fetch the user email from our fictive user endpoint - let email = await fetchUserMail(userId) - - await sendAnalytics(`User details have been logged for ${userId}`) - - Js.log(`Email address for user ${userId}: ${email}`) -} -``` - -```js -async function logUserDetails(userId) { - var email = await GlobalAPI.fetchUserMail(userId); - await GlobalAPI.sendAnalytics( - "User details have been logged for " + userId + "", - ); - console.log("Email address for user " + userId + ": " + email + ""); -} -``` - - - -As we can see above, an `async` function is defined via the `async` keyword right before the function's parameter list. In the function body, we are now able to use the `await` keyword to explicitly wait for a `Promise` value and assign its content to a let binding `email`. - -You will probably notice that this looks very similar to `async` / `await` in JS, but there are still a few details that are specific to ReScript. The next few sections will go through all the details that are specific to the ReScript type system. - -## Basics - -- You may only use `await` in `async` function bodies -- `await` may only be called on a `promise` value -- `await` calls are expressions, therefore they can be used in pattern matching (`switch`) -- A function returning a `promise<'a>` is equivalent to an `async` function returning a value `'a` (important for writing signature files and bindings) -- `promise` values and types returned from an `async` function don't auto-collapse into a "flat promise" like in JS (more on this later) - -## Types and `async` functions - -### `async` function type signatures - -Function type signatures (i.e defined in signature files) don't require any special keywords for `async` usage. Whenever you want to type an `async` function, use a `promise` return type. - -```resi -// Demo.resi - -let fetchUserMail: string => promise -``` - -The same logic applies to type definitions in `.res` files: - -```res example -// function type -type someAsyncFn = int => promise - -// Function type annotation -let fetchData: string => promise = async (userId) => { - await fetchUserMail(userId) -} -``` - -**BUT:** When typing `async` functions in your implementation files, you need to omit the `promise<'a>` type: - -```res -// This function is compiled into a `string => promise` type. -// The promise<...> part is implicitly added by the compiler. -let fetchData = async (userId: string): string => { - await fetchUserMail("test") -} -``` - -For completeness reasons, let's expand the full signature and inline type definitions in one code snippet: - -```res -// Note how the inline return type uses `string`, while the type definition uses `promise` -let fetchData: string => promise = async (userId: string): string { - await fetchUserMail(userId) -} -``` - -**Note:** In a practical scenario you'd either use a type signature, or inline types, not both at the same time. In case you are interested in the design decisions, check out [this discussion](https://github.com/rescript-lang/rescript/pull/5913#issuecomment-1359003870). - -### `async` uncurried functions - -The `async` keyword does also work for uncurried functions. - -```res -let fetchData = async (. userId: string): string { - await fetchUserMail(userId) -} -``` - -### Promises don't auto-collapse in async functions - -In JS, nested promises (i.e. `promise>`) will automatically collapse into a flat promise (`promise<'a>`). This is not the case in ReScript. Use the `await` function to manually unwrap any nested promises within an `async` function instead. - -```res -let fetchData = async (userId: string): string => { - // We can't just return the result of `fetchUserMail`, otherwise we'd get a - // type error due to our function return type of type `string` - await fetchUserMail(userId) -} -``` - -## Error handling - -You may use `try / catch` or `switch` to handle exceptions during async execution. - -```res -// For simulation purposes -let authenticate = async () => { - raise(Js.Exn.raiseRangeError("Authentication failed.")) -} - -let checkAuth = async () => { - try { - await authenticate() - } catch { - | Js.Exn.Error(e) => - switch Js.Exn.message(e) { - | Some(msg) => Js.log("JS error thrown: " ++ msg) - | None => Js.log("Some other exception has been thrown") - } - } -} -``` - -Note how we are essentially catching JS errors the same way as described in our [Exception](exception#catch-rescript-exceptions-from-js) section. - -You may unify error and value handling in a single switch as well: - -```res -let authenticate = async () => { - raise(Js.Exn.raiseRangeError("Authentication failed.")) -} - -let checkAuth = async () => { - switch await authenticate() { - | _ => Js.log("ok") - | exception Js.Exn.Error(e) => - switch Js.Exn.message(e) { - | Some(msg) => Js.log("JS error thrown: " ++ msg) - | None => Js.log("Some other exception has been thrown") - } - } -} -``` - -**Important:** When using `await` with a `switch`, always make sure to put the actual await call in the `switch` expression, otherwise your `await` error will not be caught. - -## Piping `await` calls - -You may want to pipe the result of an `await` call right into another function. -This can be done by wrapping your `await` calls in a new `{}` closure. - - - -```res example -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" - -let fetchData = async () => { - let mail = {await fetchUserMail("1234")}->Js.String2.toUpperCase - Js.log(`All upper-cased mail: ${mail}`) -} -``` - -```js -async function fetchData(param) { - var mail = (await GlobalAPI.fetchUserMail("1234")).toUpperCase(); - console.log("All upper-cased mail: " + mail + ""); -} -``` - - - -Note how the original closure was removed in the final JS output. No extra allocations! - -## Pattern matching on `await` calls - -`await` calls are just another kind of expression, so you can use `switch` pattern matching for more complex logic. - - - -```res example -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" - -let fetchData = async () => { - switch (await fetchUserMail("user1"), await fetchUserMail("user2")) { - | (user1Mail, user2Mail) => { - Js.log("user 1 mail: " ++ user1Mail) - Js.log("user 2 mail: " ++ user2Mail) - } - - | exception JsError(err) => Js.log2("Some error occurred", err) - } -} -``` - -```js -async function fetchData(param) { - var val; - var val$1; - try { - val = await GlobalAPI.fetchUserMail("user1"); - val$1 = await GlobalAPI.fetchUserMail("user2"); - } catch (raw_err) { - var err = Caml_js_exceptions.internalToOCamlException(raw_err); - if (err.RE_EXN_ID === "JsError") { - console.log("Some error occurred", err._1); - return; - } - throw err; - } - console.log("user 1 mail: " + val); - console.log("user 2 mail: " + val$1); -} -``` - - - -## `await` multiple promises - -We can utilize the `Js.Promise2` module to handle multiple promises. E.g. let's use `Js.Promise2.all` to wait for multiple promises before continuing the program: - -```res -let pauseReturn = (value, timeout) => { - Js.Promise2.make((~resolve, ~reject) => { - Js.Global.setTimeout(() => { - resolve(. value) - }, timeout)->ignore - }) -} - -let logMultipleValues = async () => { - let promise1 = pauseReturn("value1", 2000) - let promise2 = pauseReturn("value2", 1200) - let promise3 = pauseReturn("value3", 500) - - let all = await Js.Promise2.all([promise1, promise2, promise3]) - - switch all { - | [v1, v2, v3] => Js.log(`All values: ${v1}, ${v2}, ${v3}`) - | _ => Js.log("this should never happen") - } -} -``` - -## JS Interop with `async` functions - -`async` / `await` practically works with any function that returns a `promise<'a>` value. Map your `promise` returning function via an `external`, and use it in an `async` function as usual. - -Here's a full example of using the MDN `fetch` API, using `async` / `await` to simulate a login: - -```res -// A generic Response type for typing our fetch requests -module Response = { - type t<'data> - @send external json: t<'data> => promise<'data> = "json" -} - -// A binding to our globally available `fetch` function. `fetch` is a -// standardized function to retrieve data from the network that is available in -// all modern browsers. -@val @scope("globalThis") -external fetch: ( - string, - 'params, -) => promise, "error": Js.Nullable.t}>> = - "fetch" - -// We now use our asynchronous `fetch` function to simulate a login. -// Note how we use `await` with regular functions returning a `promise`. -let login = async (email: string, password: string) => { - let body = { - "email": email, - "password": password, - } - - let params = { - "method": "POST", - "headers": { - "Content-Type": "application/json", - }, - "body": Js.Json.stringifyAny(body), - } - - try { - let response = await fetch("https://reqres.in/api/login", params) - let data = await response->Response.json - - switch Js.Nullable.toOption(data["error"]) { - | Some(msg) => Error(msg) - | None => - switch Js.Nullable.toOption(data["token"]) { - | Some(token) => Ok(token) - | None => Error("Didn't return a token") - } - } - } catch { - | _ => Error("Unexpected network error occurred") - } -} -``` diff --git a/pages/docs/manual/v10.0.0/attribute.mdx b/pages/docs/manual/v10.0.0/attribute.mdx deleted file mode 100644 index 5b366fbd8..000000000 --- a/pages/docs/manual/v10.0.0/attribute.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: "Attribute (Decorator)" -description: "Annotations in ReScript" -canonical: "/docs/manual/latest/attribute" ---- - -# Attribute (Decorator) - -Like many other languages, ReScript allows annotating a piece of code to express extra functionality. Here's an example: - - - -```res -@inline -let mode = "dev" - -let mode2 = mode -``` - -```js -var mode2 = "dev"; -``` - - - -The `@inline` annotation tells `mode`'s value to be inlined into its usage sites (see output). We call such annotation "attribute" (or "decorator" in JavaScript). - -An attribute starts with `@` and goes before the item it annotates. In the above example, it's hooked onto the let binding. - -## Usage - -> **Note:** In previous versions (< 8.3) all our interop related attributes started with a `bs.` prefix (`bs.module`, `bs.val`). Our formatter will automatically drop them in newer ReScript versions. - -You can put an attribute almost anywhere. You can even add extra data to them by using them visually like a function call. Here are a few famous attributes (explained in other sections): - - - -```res -@@warning("-27") - - -@unboxed -type a = Name(string) - -@val external message: string = "message" - -type student = { - age: int, - @as("aria-label") ariaLabel: string, -} - -@deprecated -let customDouble = foo => foo * 2 - -@deprecated("Use SomeOther.customTriple instead") -let customTriple = foo => foo * 3 -``` - -```js - -``` - - - -1. `@@warning("-27")` is a standalone attribute that annotates the entire file. Those attributes start with `@@`. Here, it carries the data `"-27"`. You can find a full list of all available warnings [here](./warning-numbers). -2. `@unboxed` annotates the type definition. -3. `@val` annotates the `external` statement. -4. `@as("aria-label")` annotates the `ariaLabel` record field. -5. `@deprecated` annotates the `customDouble` expression. This shows a warning while compiling telling consumers to not rely on this method long-term. -6. `@deprecated("Use SomeOther.customTriple instead")` annotates the `customTriple` expression with a string to describe the reason for deprecation. - -For a list of all decorators and their usage, please refer to the [Syntax Lookup](/syntax-lookup) page. - -## Extension Point - -There's a second category of attributes, called "extension points" (a remnant term of our early systems): - - - -```res -%raw("var a = 1") -``` - -```js -var a = 1; -``` - - - -Extension points are attributes that don't _annotate_ an item; they _are_ the item. Usually they serve as placeholders for the compiler to implicitly substitute them with another item. - -Extension points start with `%`. A standalone extension point (akin to a standalone regular attribute) starts with `%%`. - -For a list of all extension points and their usage, please refer to the [Syntax Lookup](/syntax-lookup) page. diff --git a/pages/docs/manual/v10.0.0/bind-to-global-js-values.mdx b/pages/docs/manual/v10.0.0/bind-to-global-js-values.mdx deleted file mode 100644 index 373e8cf12..000000000 --- a/pages/docs/manual/v10.0.0/bind-to-global-js-values.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: "Bind to Global JS Values" -description: "JS interop with global JS values in ReScript" -canonical: "/docs/manual/latest/bind-to-global-js-values" ---- - -# Bind to Global JS Values - -**First**, make sure the value you'd like to model doesn't already exist in our [provided API](api/js). - -Some JS values, like `setTimeout`, live in the global scope. You can bind to them like so: - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -@val external clearTimeout: float => unit = "clearTimeout" -``` - -```js -// Empty output -``` - - - -(We already provide `setTimeout`, `clearTimeout` and others in the [Js.Global](api/js/global) module). - -This binds to the JavaScript [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrworkerGlobalScope/setTimeout) methods and the corresponding `clearTimeout`. The `external`'s type annotation specifies that `setTimeout`: - -- Takes a function that accepts `unit` and returns `unit` (which on the JS side turns into a function that accepts nothing and returns nothing aka `undefined`), -- and an integer that specifies the duration before calling said function, -- returns a number that is the timeout's ID. This number might be big, so we're modeling it as a float rather than the 32-bit int. - -### Tips & Tricks - -**The above isn't ideal**. See how `setTimeout` returns a `float` and `clearTimeout` accepts one. There's no guarantee that you're passing the float created by `setTimeout` into `clearTimeout`! For all we know, someone might pass it `Math.random()` into the latter. - -We're in a language with a great type system now! Let's leverage a popular feature to solve this problem: abstract types. - - - -```res example -type timerId -@val external setTimeout: (unit => unit, int) => timerId = "setTimeout" -@val external clearTimeout: timerId => unit = "clearTimeout" - -let id = setTimeout(() => Js.log("hello"), 100) -clearTimeout(id) -``` - -```js -var id = setTimeout(function (param) { - console.log("hello"); -}, 100); - -clearTimeout(id); -``` - - - -Clearly, `timerId` is a type that can only be created by `setTimeout`! Now we've guaranteed that `clearTimeout` _will_ be passed a valid ID. Whether it's a number under the hood is now a mere implementation detail. - -Since `external`s are inlined, we end up with JS output as readable as hand-written JS. - -## Global Modules - -If you want to bind to a value inside a global module, e.g. `Math.random`, attach a `scope` to your `val` external: - - - -```res example -@scope("Math") @val external random: unit => float = "random" -let someNumber = random() -``` - -```js -var someNumber = Math.random(); -``` - - - -you can bind to an arbitrarily deep object by passing a tuple to `scope`: - - - -```res example -@val @scope(("window", "location", "ancestorOrigins")) -external length: int = "length" -``` - -```js -// Empty output -``` - - - -This binds to `window.location.ancestorOrigins.length`. - -## Special Global Values - -Global values like `__filename` and `__DEV__` don't always exist; you can't even model them as an `option`, since the mere act of referring to them in ReScript (then compiled into JS) would trigger the usual `Uncaught ReferenceError: __filename is not defined` error in e.g. the browser environment. - -For these troublesome global values, ReScript provides a special approach: `%external(a_single_identifier)`. - - - -```res example -switch %external(__DEV__) { -| Some(_) => Js.log("dev mode") -| None => Js.log("production mode") -} -``` - -```js -var match = typeof __DEV__ === "undefined" ? undefined : __DEV__; - -if (match !== undefined) { - console.log("dev mode"); -} else { - console.log("production mode"); -} -``` - - - -That first line's `typeof` check won't trigger a JS ReferenceError. - -Another example: - - - -```res example -switch %external(__filename) { -| Some(f) => Js.log(f) -| None => Js.log("non-node environment") -}; -``` - -```js -var match = typeof __filename === "undefined" ? undefined : __filename; - -if (match !== undefined) { - console.log(match); -} else { - console.log("non-node environment"); -} -``` - - - - diff --git a/pages/docs/manual/v10.0.0/bind-to-js-function.mdx b/pages/docs/manual/v10.0.0/bind-to-js-function.mdx deleted file mode 100644 index aacc7b573..000000000 --- a/pages/docs/manual/v10.0.0/bind-to-js-function.mdx +++ /dev/null @@ -1,515 +0,0 @@ ---- -title: "Bind to JS Function" -description: "JS interop with functions in ReScript" -canonical: "/docs/manual/latest/bind-to-js-function" ---- - -# Function - -Binding a JS function is like binding any other value: - - - -```res example -// Import nodejs' path.dirname -@module("path") external dirname: string => string = "dirname" -let root = dirname("/User/github") // returns "User" -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - - - -We also expose a few special features, described below. - -## Labeled Arguments - -ReScript has [labeled arguments](function.md#labeled-arguments) (that can also be optional). These work on an `external` too! You'd use them to _fix_ a JS function's unclear usage. Assuming we're modeling this: - -```js -// MyGame.js - -function draw(x, y, border) { - // suppose `border` is optional and defaults to false -} -draw(10, 20); -draw(20, 20, true); -``` - -It'd be nice if on ReScript's side, we can bind & call `draw` while labeling things a bit: - - - -```res example -@module("MyGame") -external draw: (~x: int, ~y: int, ~border: bool=?, unit) => unit = "draw" - -draw(~x=10, ~y=20, ~border=true, ()) -draw(~x=10, ~y=20, ()) -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, true); -MyGame.draw(10, 20, undefined); -``` - - - -We've compiled to the same function, but now the usage is much clearer on the ReScript side thanks to labels! - -**Note**: in this particular case, you need a unit, `()` after `border`, since `border` is an [optional argument at the last position](function.md#optional-labeled-arguments). Not having a unit to indicate you've finished applying the function would generate a warning. - -Note that you can freely reorder the labels on the ReScript side; they'll always correctly appear in their declaration order in the JavaScript output: - - - -```res example -@module("MyGame") -external draw: (~x: int, ~y: int, ~border: bool=?, unit) => unit = "draw" - -draw(~x=10, ~y=20, ()) -draw(~y=20, ~x=10, ()) -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, undefined); -MyGame.draw(10, 20, undefined); -``` - - - -## Object Method - -Functions attached to JS objects (other than JS modules) require a special way of binding to them, using `send`: - - - -```res example -type document // abstract type for a document object -@send external getElementById: (document, string) => Dom.element = "getElementById" -@val external doc: document = "document" - -let el = getElementById(doc, "myId") -``` - -```js -var el = document.getElementById("myId"); -``` - - - -In a `send`, the object is always the first argument. Actual arguments of the method follow (this is a bit what modern OOP objects are really). - -### Chaining - -Ever used `foo().bar().baz()` chaining ("fluent api") in JS OOP? We can model that in ReScript too, through the [pipe operator](pipe.md). - -## Variadic Function Arguments - -You might have JS functions that take an arbitrary amount of arguments. ReScript supports modeling those, under the condition that the arbitrary arguments part is homogenous (aka of the same type). If so, add `variadic` to your `external`. - - - -```res example -@module("path") @variadic -external join: array => string = "join" - -let v = join(["a", "b"]) -``` - -```js -var Path = require("path"); -var v = Path.join("a", "b"); -``` - - - -`module` will be explained in [Import from/Export to JS](import-from-export-to-js.md). - -## Modeling Polymorphic Function - -Apart from the above special-case, JS function in general are often arbitrary overloaded in terms of argument types and number. How would you bind to those? - -### Trick 1: Multiple `external`s - -If you can exhaustively enumerate the many forms an overloaded JS function can take, simply bind to each differently: - - - -```res example -@module("MyGame") external drawCat: unit => unit = "draw" -@module("MyGame") external drawDog: (~giveName: string) => unit = "draw" -@module("MyGame") external draw: (string, ~useRandomAnimal: bool) => unit = "draw" -``` - -```js -// Empty output -``` - - - -Note how all three externals bind to the same JS function, `draw`. - -### Trick 2: Polymorphic Variant + `unwrap` - -If you have the irresistible urge of saying "if only this JS function argument was a variant instead of informally being either `string` or `int`", then good news: we do provide such `external` features through annotating a parameter as a polymorphic variant! Assuming you have the following JS function you'd like to bind to: - -```js -function padLeft(value, padding) { - if (typeof padding === "number") { - return Array(padding + 1).join(" ") + value; - } - if (typeof padding === "string") { - return padding + value; - } - throw new Error(`Expected string or number, got '${padding}'.`); -} -``` - -Here, `padding` is really conceptually a variant. Let's model it as such. - - - -```res example -@val -external padLeft: ( - string, - @unwrap [ - | #Str(string) - | #Int(int) - ]) - => string = "padLeft" -padLeft("Hello World", #Int(4)) -padLeft("Hello World", #Str("Message from ReScript: ")) -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -Obviously, the JS side couldn't have an argument that's a polymorphic variant! But here, we're just piggy backing on poly variants' type checking and syntax. The secret is the `@unwrap` annotation on the type. It strips the variant constructors and compile to just the payload's value. See the output. - -## Constrain Arguments Better - -Consider the Node `fs.readFileSync`'s second argument. It can take a string, but really only a defined set: `"ascii"`, `"utf8"`, etc. You can still bind it as a string, but we can use poly variants + `string` to ensure that our usage's more correct: - - - -```res example -@module("fs") -external readFileSync: ( - ~name: string, - @string [ - | #utf8 - | @as("ascii") #useAscii - ], -) => string = "readFileSync" - -readFileSync(~name="xx.txt", #useAscii) -``` - -```js -var Fs = require("fs"); -Fs.readFileSync("xx.txt", "ascii"); -``` - - - -- Attaching `@string` to the whole poly variant type makes its constructor compile to a string of the same name. -- Attaching a `@as("bla")` to a constructor lets you customize the final string. - -And now, passing something like `"myOwnUnicode"` or other variant constructor names to `readFileSync` would correctly error. - -Aside from string, you can also compile an argument to an int, using `int` instead of `string` in a similar way: - - - -```res example -@val -external testIntType: ( - @int [ - | #onClosed - | @as(20) #onOpen - | #inBinary - ]) - => int = "testIntType" -testIntType(#inBinary) -``` - -```js -testIntType(21); -``` - - - -`onClosed` compiles to `0`, `onOpen` to `20` and `inBinary` to **`21`**. - -## Unknown for type safety - -It is best practice to inspect data received from untrusted external functions to ensure it contains what you expect. This helps avoid run-time crashes and unexpected behavior. If you're certain about what an external function returns, simply assert the return value as `string` or `array` or whatever you want it to be. Otherwise use `unknown`. The ReScript type system will prevent you from using an `unknown` until you first inspect it and "convert" it using JSON parsing utilities or similar tools. - -Consider the example below of two external functions that access the value of a property on a JavaScript object. `getPropertyUnsafe` returns an `'a`, which means "anything you want it to be." ReScript allows you to use this value as a `string` or `array` or any other type. Quite convenient! But if the property is missing or contains something unexpected, your code might break. You can make the binding more safe by changing `'a` to `string` or `option<'a>`, but this doesn't completely eliminate the problem. - -The `getPropertySafe` function returns an `unknown`, which could be `null` or a `string` or anything else. But ReScript prevents you from using this value inappropriately until it has been safely parsed. - -```res example -@get_index external getPropertyUnsafe: ({..}, string) => 'a = "" -@get_index external getPropertySafe: ({..}, string) => unknown = "" - -let person = {"name": "Bob", "age": 12} - -let greeting1 = "Hello, " ++ getPropertyUnsafe(person, "name") // works (this time!) -// let greeting2 = "Hello, " ++ getPropertySafe(person, "name") // syntax error -``` - -## Special-case: Event Listeners - -One last trick with polymorphic variants: - - - -```res example -type readline - -@send -external on: ( - readline, - @string [ - | #close(unit => unit) - | #line(string => unit) - ] - ) - => readline = "on" - -let register = rl => - rl - ->on(#close(event => ())) - ->on(#line(line => Js.log(line))); -``` - -```js -function register(rl) { - return rl - .on("close", function ($$event) {}) - .on("line", function (line) { - console.log(line); - }); -} -``` - - - - - -## Fixed Arguments - -Sometimes it's convenient to bind to a function using an `external`, while passing predetermined argument values to the JS function: - - - -```res example -@val -external processOnExit: ( - @as("exit") _, - int => unit -) => unit = "process.on" - -processOnExit(exitCode => - Js.log("error code: " ++ Js.Int.toString(exitCode)) -); -``` - -```js -process.on("exit", function (exitCode) { - console.log("error code: " + exitCode.toString()); -}); -``` - - - -The `@as("exit")` and the placeholder `_` argument together indicates that you want the first argument to compile to the string `"exit"`. You can also use any JSON literal with `as`: ``@as(json`true`)``, ``@as(json`{"name": "John"}`)``, etc. - -## Ignore arguments - -You can also explicitly "hide" `external` function parameters in the JS output, which may be useful if you want to add type constraints to other parameters without impacting the JS side: - - - -```res -@val external doSomething: (@ignore 'a, 'a) => unit = "doSomething" - -doSomething("this only shows up in ReScript code", "test") -``` - -```js -doSomething("test"); -``` - - - -**Note:** It's a pretty niche feature, mostly used to map to polymorphic JS APIs. - -## Curry & Uncurry - -Curry is a delicious Indian dish. More importantly, in the context of ReScript (and functional programming in general), currying means that function taking multiple arguments can be applied a few arguments at time, until all the arguments are applied. - -See the `addFive` intermediate function? `add` takes in 3 arguments but received only 1. It's interpreted as "currying" the argument `5` and waiting for the next 2 arguments to be applied later on. Type signatures: - -```res sig -let add: (int, int, int) => int -let addFive: (int, int) => int -let twelve: int -``` - -(In a dynamic language such as JS, currying would be dangerous, since accidentally forgetting to pass an argument doesn't error at compile time). - -### Drawback - -Unfortunately, due to JS not having currying because of the aforementioned reason, it's hard for ReScript multi-argument functions to map cleanly to JS functions 100% of the time: - -1. When all the arguments of a function are supplied (aka no currying), ReScript does its best to to compile e.g. a 3-arguments call into a plain JS call with 3 arguments. - -2. If it's too hard to detect whether a function application is complete\*, ReScript will use a runtime mechanism (the `Curry` module) to curry as many args as we can and check whether the result is fully applied. - -3. Some JS APIs like `throttle`, `debounce` and `promise` might mess with context, aka use the function `bind` mechanism, carry around `this`, etc. Such implementation clashes with the previous currying logic. - -\* If the call site is typed as having 3 arguments, we sometimes don't know whether it's a function that's being curried, or if the original one indeed has only 3 arguments. - -ReScript tries to do #1 as much as it can. Even when it bails and uses #2's currying mechanism, it's usually harmless. - -**However**, if you encounter #3, heuristics are not good enough: you need a guaranteed way of fully applying a function, without intermediate currying steps. We provide such guarantee through the use of the ["uncurrying" syntax](./function#uncurried-function) on a function declaration & call site. - -### Solution: Use Guaranteed Uncurrying - -[Uncurried function](function.md#uncurried-function) annotation also works on `external`: - - - -```res example -type timerId -@val external setTimeout: ((. unit) => unit, int) => timerId = "setTimeout" - -let id = setTimeout((.) => Js.log("hello"), 1000) -``` - -```js -var id = setTimeout(function () { - console.log("hello"); -}, 1000); -``` - - - -#### Extra Solution - -The above solution is safe, guaranteed, and performant, but sometimes visually a little burdensome. We provide an alternative solution if: - -- you're using `external` -- the `external` function takes in an argument that's another function -- you want the user **not** to need to annotate the call sites with the dot - - - -Then try `@uncurry`: - - - -```res example -@send external map: (array<'a>, @uncurry ('a => 'b)) => array<'b> = "map" -map([1, 2, 3], x => x + 1) -``` - -```js -// Empty output -``` - - - -In general, `uncurry` is recommended; the compiler will do lots of optimizations to resolve the currying to uncurrying at compile time. However, there are some cases the compiler can't optimize it. In these cases, it will be converted to a runtime check. - -## Modeling `this`-based Callbacks - -Many JS libraries have callbacks which rely on this (the source), for example: - -```js -x.onload = function (v) { - console.log(this.response + v); -}; -``` - -Here, `this` would point to `x` (actually, it depends on how `onload` is called, but we digress). It's not correct to declare `x.onload` of type `(. unit) -> unit`. Instead, we introduced a special attribute, `this`, which allows us to type `x` as so: - - - -```res example -type x -@val external x: x = "x" -@set external setOnload: (x, @this ((x, int) => unit)) => unit = "onload" -@get external resp: x => int = "response" -setOnload(x, @this ((o, v) => Js.log(resp(o) + v))) -``` - -```js -x.onload = function (v) { - var o = this; - console.log((o.response + v) | 0); -}; -``` - - - -`this` has its first parameter is reserved for `this` and for arity of 0, there is no need for a redundant `unit` type. - -## Function Nullable Return Value Wrapping - -For JS functions that return a value that can also be `undefined` or `null`, we provide `@return(...)`. To automatically convert that value to an `option` type (recall that ReScript `option` type's `None` value only compiles to `undefined` and not `null`). - - - -```res example -type element -type dom - -@send @return(nullable) -external getElementById: (dom, string) => option = "getElementById" - -let test = dom => { - let elem = dom->(getElementById("haha")) - switch (elem) { - | None => 1 - | Some(_ui) => 2 - } -} -``` - -```js -function test(dom) { - var elem = dom.getElementById("haha"); - if (elem == null) { - return 1; - } else { - console.log(elem); - return 2; - } -} -``` - - - -`return(nullable)` attribute will automatically convert `null` and `undefined` to `option` type. - -Currently 4 directives are supported: `null_to_opt`, `undefined_to_opt`, `nullable` and `identity`. - - - -`identity` will make sure that compiler will do nothing about the returned value. It is rarely used, but introduced here for debugging purpose. diff --git a/pages/docs/manual/v10.0.0/bind-to-js-object.mdx b/pages/docs/manual/v10.0.0/bind-to-js-object.mdx deleted file mode 100644 index 9be967bcd..000000000 --- a/pages/docs/manual/v10.0.0/bind-to-js-object.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -title: "Bind to JS Object" -description: "Interop with JS objects in ReScript" -canonical: "/docs/manual/latest/bind-to-js-object" ---- - -# Bind to JS Object - -JavaScript objects are a combination of several use-cases: - -- As a "record" or "struct" in other languages (like ReScript and C). -- As a hash map. -- As a class. -- As a module to import/export. - -ReScript cleanly separates the binding methods for JS object based on these 4 use-cases. This page documents the first three. Binding to JS module objects is described in the [Import from/Export to JS](import-from-export-to-js.md) section. - - - -## Bind to Record-like JS Objects - -### Bind Using ReScript Record - -If your JavaScript object has fixed fields, then it's conceptually like a ReScript record. Since a ReScript record compiles to a clean JavaScript object, you can definitely type a JS object as a ReScript record! - - - -```res example -type person = { - name: string, - friends: array, - age: int, -} - -@module("MySchool") external john: person = "john" - -let johnName = john.name -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -External is documented [here](external.md). `@module` is documented [here](import-from-export-to-js.md). - -If you want or need to use different field names on the ReScript and the JavaScript side, you can use the `@as` decorator: - - - -```res example -type action = { - @as("type") type_: string -} - -let action = {type_: "ADD_USER"} -``` - -```js -var action = { - type: "ADD_USER", -}; -``` - - - -This is useful to map to JavaScript attribute names that cannot be expressed in ReScript (such as keywords). - -It is also possible to map a ReScript record to a JavaScript array by passing indices to the `@as` decorator: - - - -```res -type t = { - @as("0") foo: int, - @as("1") bar: string, -} - -let value = {foo: 7, bar: "baz"} -``` - -```js -var value = [7, "baz"]; -``` - - - -### Bind Using ReScript Object - -Alternatively, you can use [ReScript object](object.md) to model a JS object too: - - - -```res example -type person = { - "name": string, - "friends": array, - "age": int, -} - -@module("MySchool") external john: person = "john" - -let johnName = john["name"] -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -### Bind Using Special Getter and Setter Attributes - -Alternatively, you can use `get` and `set` to bind to individual fields of a JS object: - - - -```res example -type textarea -@set external setName: (textarea, string) => unit = "name" -@get external getName: textarea => string = "name" -``` - -```js - -``` - - - -You can also use `get_index` and `set_index` to access a dynamic property or an index: - - - -```res example -type t -@new external create: int => t = "Int32Array" -@get_index external get: (t, int) => int = "" -@set_index external set: (t, int, int) => unit = "" - -let i32arr = create(3) -i32arr->set(0, 42) -Js.log(i32arr->get(0)) -``` - -```js -var i32arr = new Int32Array(3); -i32arr[0] = 42; -console.log(i32arr[0]); -``` - - - -## Bind to Hash Map-like JS Object - -If your JavaScript object: - -- might or might not add/remove keys -- contains only values that are of the same type - -Then it's not really an object, it's a hash map. Use [Js.Dict](api/js/dict), which contains operations like `get`, `set`, etc. and cleanly compiles to a JavaScript object still. - -## Bind to a JS Object That's a Class - -Use `new` to emulate e.g. `new Date()`: - - - -```res example -type t -@new external createDate: unit => t = "Date" - -let date = createDate() -``` - -```js -var date = new Date(); -``` - - - -You can chain `new` and `module` if the JS module you're importing is itself a class: - - - -```res example -type t -@new @module external book: unit => t = "Book" -let myBook = book() -``` - -```js -var Book = require("Book"); -var myBook = new Book(); -``` - - diff --git a/pages/docs/manual/v10.0.0/browser-support-polyfills.mdx b/pages/docs/manual/v10.0.0/browser-support-polyfills.mdx deleted file mode 100644 index c1de7a491..000000000 --- a/pages/docs/manual/v10.0.0/browser-support-polyfills.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: "Browser Support & Polyfills" -description: "Note on browser support in ReScript" -canonical: "/docs/manual/latest/browser-support-polyfills" ---- - -# Browser Support & Polyfills - -ReScript compiles to JavaScript **ES5**, with the exception of optionally allowing to compile to ES6's module import & export. - -For [old browsers](https://caniuse.com/#search=typed%20array), you also need to polyfill TypedArray. The following standard library functions require it: - -- `Int64.float_of_bits` -- `Int64.bits_of_float` -- `Int32.float_of_bits` -- `Int32.bits_of_float` - -If you don't use these functions, you're fine. Otherwise, it'll be a runtime failure. diff --git a/pages/docs/manual/v10.0.0/build-configuration-schema.mdx b/pages/docs/manual/v10.0.0/build-configuration-schema.mdx deleted file mode 100644 index 0b32cfc3e..000000000 --- a/pages/docs/manual/v10.0.0/build-configuration-schema.mdx +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: "Configuration Schema" -metaTitle: "Build System Configuration Schema" -description: "Schema exploration widget for the ReScript configuration file" -canonical: "/docs/manual/latest/build-configuration-schema" ---- - -import dynamic from "next/dynamic"; - -export const Docson = dynamic( - () => - import("src/components/Docson").then((comp) => { - return comp.make; - }), - { - ssr: false, - loading: () =>
Loading...
, - }, -); - -export default function BuildConfigurationSchemaPage() { - return ; -} diff --git a/pages/docs/manual/v10.0.0/build-configuration.mdx b/pages/docs/manual/v10.0.0/build-configuration.mdx deleted file mode 100644 index cf73a1da4..000000000 --- a/pages/docs/manual/v10.0.0/build-configuration.mdx +++ /dev/null @@ -1,200 +0,0 @@ ---- -title: "Configuration" -metaTitle: "Build System Configuration" -description: "Details about the configuration of the ReScript build system (bsconfig.json)" -canonical: "/docs/manual/latest/build-configuration" ---- - -# Configuration - -`bsconfig.json` is the single, mandatory build meta file needed for `rescript`. - -**The complete configuration schema is [here](./build-configuration-schema)**. We'll _non-exhaustively_ highlight the important parts in prose below. - -## name, namespace - -`name` is the name of the library, used as its "namespace". You can activate namespacing through `"namespace": true` in your `bsconfig.json`. Namespacing is almost **mandatory**; we haven't turned it on by default yet to preserve backward-compatibility. - -**Explanation**: by default, your files, once used as a third-party dependency, are available globally to the consumer. E.g. if you have an `Util.re` and the consumer also has a file of the same name, they will clash. Turning on `namespace` avoids this by wrapping all your own project's files into an extra module layer; instead of a global `Util` module, the consumer will see you as `MyProject.Util`. **The namespacing affects your consumers, not yourself**. - -Aka, in ReScript, "namespace" is just a fancy term for an auto-generated module that wraps all your project's files (efficiently and correctly, of course!) for third-party consumption. - -We don't do folder-level namespacing for your own project; all your own file names must be unique. This is a constraint that enables several features such as fast search and easier project reorganization. - -**Note**: the `bsconfig.json` `name` should be the same as the `package.json` `name`, to avoid confusing corner-cases. However, this means that you can't use a camelCased names such as `MyProject`, since `package.json` and npm forbid you to do so (some file systems are case-insensitive). To have the namespace/module as `MyProject`, write `"name": "my-project"`. ReScript will turn that into the camelCased name correctly. - -**Note on custom namespacing**: if for some reason, you need a namespace that is different from what your `name` will produce, you can directly send a string to the `namespace` option. For example, if your package is a binding named `bs-some-thing`, you can use `"namespace": "some-thing"` to get `SomeThing` namespace instead of `BsSomeThing`. - -## sources - -Your source files need to be specified explicitly (we don't want to accidentally drill down into some unrelated directories). Examples: - -```json -{ - "sources": ["src", "examples"] -} -``` - -```json -{ - "sources": { - "dir": "src", - "subdirs": ["page"] - } -} -``` - -```json -{ - "sources": [ - "examples", - { - "dir": "src", - "subdirs": true // recursively builds every subdirectory - } - ] -} -``` - -You can mark your directories as dev-only (for e.g. tests). These won't be built and exposed to third-parties, or even to other "dev" directories in the same project: - -```json -{ - "sources": { - "dir": "test", - "type": "dev" - } -} -``` - -You can also explicitly allow which modules can be seen from outside. This feature is especially useful for library authors who want to have a single entry point for their users. -Here, the file `src/MyMainModule.res` is exposed to outside consumers, while all other files are private. - -```json -{ - "sources": { - "dir": "src", - "public": ["MyMainModule"] - } -} -``` - -## bs-dependencies, bs-dev-dependencies - -List of ReScript dependencies. Just like `package.json`'s dependencies, they'll be searched in `node_modules`. - -Note that only sources marked with `"type":"dev"` will be able to resolve modules from `bs-dev-dependencies`. - -## pinned-dependencies - -**Since 8.4**: List of pinned dependencies. A pinned dependency will always be rebuilt whenever you build a toplevel package (e.g. your main app) with `rescript`. - -This is useful for working on multiple independent ReScript packages simultaneously. More usage details can be found in our dedicated [pinned dependencies](./build-pinned-dependencies) page. - -## external-stdlib - -**Since 9.0**: This setting allows depending on an externally built stdlib package (instead of a locally built stdlib runtime). Useful for shipping packages that are only consumed in JS or TS without any dependencies to the ReScript development toolchain. - -More details can be found on our [external stdlib](./build-external-stdlib) page. - -## reason, refmt (old) - -`reason` config is enabled by default. To turn on JSX for [ReasonReact](https://reasonml.github.io/reason-react/), specify: - -```json -{ - "reason": { "react-jsx": 3 }, - "refmt": 3 -} -``` - -The `refmt` config **should be explicitly specified** as `3`. - -## js-post-build - -Hook that's invoked every time a file is recompiled. Good for JS build system interop, but please use it **sparingly**. Calling your custom command for every recompiled file slows down your build and worsens the building experience for even third-party users of your lib. - -Example: - -```json -{ - "js-post-build": { - "cmd": "/path/to/node ../../postProcessTheFile.js" - } -} -``` - -Note that the path resolution for the command (`node` in this case) is done so: - -- `/myCommand` is resolved into `/myCommand` -- `package/myCommand` is resolved into `node_modules/package/myCommand` -- `./myCommand` is resolved into `myProjectRoot/myCommand` -- `myCommand` is just called as `myCommand`, aka a globally available executable. But note that ReScript doesn't read into your shell's environment, so if you put e.g. `node`, it won't find it unless you specify an absolute path. Alternatively, add `#!/usr/local/bin/node` to the top of your script to directly call it without prepending `node`. - -The command itself is called from inside `lib/bs`. - -## package-specs - -Output to either CommonJS (the default) or ES6 modules. Example: - -```json -{ - "package-specs": { - "module": "commonjs", - "in-source": true - } -} -``` - -- `"module": "es6-global"` resolves `node_modules` using relative paths. Good for development-time usage of ES6 in conjunction with browsers like Safari and Firefox that support ES6 modules today. **No more dev-time bundling**! -- `"in-source": true` generates output alongside source files. If you omit it, it'll generate the artifacts into `lib/js`. The output directory is not configurable otherwise. - -This configuration only applies to you, when you develop the project. When the project is used as a third-party library, the consumer's own `bsconfig.json` `package-specs` overrides the configuration here, logically. - -## suffix - -Either `".js"`, `".mjs"`, `".cjs"` or `".bs.js"`. Currently prefer `bs.js` for now. - -### Design Decisions - -Generating JS files with the `.bs.js` suffix means that, on the JS side, you can do `const myReScriptFile = require('./theFile.bs')`. The benefits: - -- It's immediately clear that we're dealing with a generated JS file here. -- It avoids clashes with a potential `theFile.js` file in the same folder. -- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**. -- [genType](/docs/manual/latest/typescript-integration) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. - -## warnings - -Selectively turn on/off certain warnings and/or turn them into hard errors. Example: - -```json -{ - "warnings": { - "number": "-44-102", - "error": "+5" - } -} -``` - -Turn off warning `44` and `102` (polymorphic comparison). Turn warning `5` (partial application whose result has function type and is ignored) into a hard error. - -The warning numbers are shown in the build output when they're triggered. See [Warning Numbers](./warning-numbers) for the complete list. - -## bsc-flags - -Extra flags to pass to the compiler. For advanced usages. - -## Environment Variables - -We heavily disrecommend the usage of environment variables, but for certain cases, they're justified. - -### Error Output Coloring: `NINJA_ANSI_FORCED` - -This is mostly for other programmatic usage of `rescript` where outputting colors is not desired. - -When `NINJA_ANSI_FORCED` is set to `1`: `rescript` produces color. -When `NINJA_ANSI_FORCED` is set to `0`: `rescript` doesn't produce color. -When `NINJA_ANSI_FORCED` is not set: `rescript` might or might not produce color, depending on a smart detection of where it's outputted. - -> Note that the underlying compiler will always be passed `-color always`. See more details in [this issue](https://github.com/rescript-lang/rescript/issues/2984#issuecomment-410669163). diff --git a/pages/docs/manual/v10.0.0/build-external-stdlib.mdx b/pages/docs/manual/v10.0.0/build-external-stdlib.mdx deleted file mode 100644 index 7bb943ef6..000000000 --- a/pages/docs/manual/v10.0.0/build-external-stdlib.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: "External Stdlib" -metaTitle: "External Stdlib" -description: "Configuring an external ReScript stdlib package" -canonical: "/docs/manual/latest/build-external-stdlib" ---- - -# External Stdlib - -**Since 9.0** - -Your ReScript project depends on the `rescript` package as a [`devDependency`](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file), which includes our compiler, build system and runtime like `Belt`. However, you had to move it to `dependency` in `package.json` if you publish your code: - -- To Docker or other low-storage deployment devices. -- For pure JS/TS consumers who probably won't install `bs-platform` in their own project. - -In these cases, the size or mere presence of `bs-platform` can be troublesome, since it includes not just our necessary runtime like `Belt`, but also our compiler and build system. - -To solve that, we now publish our runtime as a standalone package at [`@rescript/std`](https://www.npmjs.com/package/@rescript/std), whose versions mirror `bs-platform`'s. Now you can keep `bs-platform` as a `devDependency` and have only `@rescript/std` as your runtime `dependency`. - -**This is an advanced feature**. Please only use it in the aforementioned scenarios. If you already use a JS bundler with dead code elimination, you might not need this feature. - -## Configuration - -Say you want to publish a JS-only ReScript 9.0 library. Install the packages like this: - -```sh -npm install bs-platform@9.0.0 --save-dev -npm install @rescript/std@9.0.0 -``` - -Then add this to `bsconfig.json`: - -```json -{ - // ... - "external-stdlib": "@rescript/std" -} -``` - -Now the compiled JS code will import using the path defined by `external-stdlib`. Check the JS output tab: - - - -```res -Belt.Array.forEach([1, 2, 3], num => Js.log(num)) -``` - -```js -// Note the require path starting with "@rescript/std". -var Belt_Array = require("@rescript/std/lib/js/belt_Array.js"); - -Belt_Array.forEach([1, 2, 3], function (num) { - console.log(num); -}); -``` - - - -**Make sure the version number of `bs-platform` and `@rescript/std` match in your `package.json`** to avoid running into runtime issues due to mismatching stdlib assumptions. diff --git a/pages/docs/manual/v10.0.0/build-overview.mdx b/pages/docs/manual/v10.0.0/build-overview.mdx deleted file mode 100644 index 0788a8ed6..000000000 --- a/pages/docs/manual/v10.0.0/build-overview.mdx +++ /dev/null @@ -1,72 +0,0 @@ ---- -title: "Overview" -metaTitle: "Build System Overview" -description: "Documentation about the ReScript build system and its toolchain" -canonical: "/docs/manual/latest/build-overview" ---- - -# Build System Overview - -ReScript comes with a build system, [`rescript`](https://www.npmjs.com/package/rescript), that's fast, lean and used as the authoritative build system of the community. - -Every ReScript project needs a build description file, `bsconfig.json`. - -## Options - -See `rescript -help`: - -``` -❯ rescript -help -Available flags --v, -version display version number --h, -help display help -Subcommands: - build - clean - format - convert - help -Run rescript subcommand -h for more details, -For example: - rescript build -h - rescript format -h -The default `rescript` is equivalent to `rescript build` subcommand -``` - -## Build Project - -Each build will create build artifacts from your project's source files. - -**To build a project (including its dependencies / pinned-dependencies)**, run: - -```sh -rescript -``` - -Which is an alias for `rescript build`. - -To keep a build watcher, run: - -```sh -rescript build -w -``` - -Any new file change will be picked up and the build will re-run. - -**Note**: third-party libraries (in `node_modules`, or via `pinned-dependencies`) aren't watched, as doing so may exceed the node.js watcher count limit. - -**Note 2**: In case you want to set up a project in a JS-monorepo-esque approach (`npm` and `yarn` workspaces) where changes in your sub packages should be noticed by the build, you will need to define pinned dependencies in your main project's `bsconfig.json`. More details [here](./build-pinned-dependencies). - -## Clean Project - -If you ever get into a stale build for edge-case reasons, use: - -```sh -rescript clean -``` - -This will clean your own project's build artifacts. To also clean the dependencies' artifacts: - -```sh -rescript clean -with-deps -``` diff --git a/pages/docs/manual/v10.0.0/build-performance.mdx b/pages/docs/manual/v10.0.0/build-performance.mdx deleted file mode 100644 index 9775da08a..000000000 --- a/pages/docs/manual/v10.0.0/build-performance.mdx +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: "Performance" -metaTitle: "Build Performance" -description: "ReScript build performance and measuring tools" -canonical: "/docs/manual/latest/build-performance" ---- - -# Build Performance - -ReScript considers performance at install time, build time and run time as a serious feature; it's one of those things you don't notice until you realize it's missing. - -## Profile Your Build - -Sometime your build can be slow due to some confused infra setups. We provide an interactive visualization of your build's performance via `bstracing`: - -```sh -./node_modules/.bin/bstracing -``` - -Run the above command at your ReScript project's root; it'll spit out a JSON file you can drag and drop into `chrome://tracing`. - -import Image from "src/components/Image"; - - - -## Under the Hood - -ReScript itself uses a build system under the hood, called [Ninja](https://ninja-build.org). Ninja is like Make, but cross-platform, minimal, focuses in perf and destined to be more of a low-level building block than a full-blown build system. In this regard, Ninja's a great implementation detail for `rescript`. - -ReScript reads into `bsconfig.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level compiler commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build. - -## The JS Wrapper - -`rescript` itself is a Node.js wrapper which takes care of some miscellaneous tasks, plus the watcher. The lower-level, watcher-less, fast native `rescript` is called `rescript.exe`. It's located at `node_modules/rescript/{your-platform}/rescript.exe`. - -If you don't need the watcher, you can run said `rescript.exe`. This side-steps Node.js' long startup time, which can be in the order of `100ms`. Our editor plugin finds and uses this native `rescript.exe` for better performance. - -## Numbers - -Raw `rescript.exe` build on a small project should be around `70ms`. This doubles when you use the JS `rescript` wrapper which comes with a watcher, which is practically faster since you don't manually run the build at every change (though you should opt for the raw `rescript.exe` for programmatic usage, e.g. inserting rescript into your existing JS build pipeline). - -No-op build (when no file's changed) should be around `15ms`. Incremental rebuild (described soon) of a single file in a project is around `70ms` too. - -Cleaning the artifacts should be instantaneous. - -### Extreme Test - -We've stress-tested `rescript.exe` on a big project of 10,000 files (2 directories, 5000 files each, first 5000 no dependencies, last 5000 10 dependencies on files from the former directory) using https://github.com/rescript-lang/build-benchmark, on a Retina Macbook Pro Early 2015 (3.1 GHz Intel Core i7). - - - -- No-op build of 10k files: `800ms` (the minimum amount of time required to check the mtimes of 10k files). -- Clean build: \<3 minutes. -- Incremental build: depends on the number of the dependents of the file. No dependent means `1s`. - -### Stability - -`rescript` is a file-based build system. We don't do in-memory build, even if that speeds up the build a lot. In-memory builds risk memory leaks, out-of-memory errors, corrupt halfway build and others. Our watcher mode stays open for days or months with no leak. - -The watcher is also just a thin file watcher that calls `rescript.exe`. We don't like babysitting daemon processes. - -## Incrementality & Correctness - -ReScript doesn't take whole seconds to run every time. The bulk of the build performance comes from incremental build, aka re-building a previously built project when a few files changed. - -In short, thanks to our compiler and the build system's architecture, we're able to **only build what's needed**. E.g. if `MyFile.res` isn't changed, then it's not recompiled. You can roughly emulate such incrementalism in languages like JavaScript, but the degree of correctness is unfortunately low. For example, if you rename or move a JS file, then the watcher might get confused and not pick up the "new" file or fail to clean things up correctly, resulting in you needing to clean your build and restart anew, which defeats the purpose. - -Say goodbye to stale build from your JavaScript ecosystem! - -## Speed Up Incremental Build - -ReScript uses the concept of interface files (`.resi`) (or, equivalently, [module signatures](module.md#signatures)). Exposing only what you need naturally speeds up incremental builds. E.g. if you change a `.res` file whose corresponding `.resi` file doesn't expose the changed part, then you've reduced the amount of dependent files you have to rebuild. - -## Programmatic Usage - -Unfortunately, JS build systems are usually the bottleneck for building a JS project nowadays. Having parts of the build blazingly fast doesn't matter much if the rest of the build takes seconds or literally minutes. Here are a few suggestions: - -- Convert more files into ReScript =). Fewer files going through fewer parts of the JS pipeline helps a ton. -- Careful with bringing in more dependencies: libraries, syntax transforms (e.g. the unofficially supported PPX), build step loaders, etc. The bulk of these dragging down the editing & building experience might out-weight the API benefits they provide. - -## Hot Reloading - -Hot reloading refers to maintaining a dev server and listening to file changes in a way that allows the server to pipe some delta changes right into the currently running browser page. This provides a relatively fast iteration workflow while working in specific frameworks. - -However, hot reloading is fragile by nature, and counts on the occasional inconsistencies (bad state, bad eval, etc.) and the heavy devserver setup/config being less of a hassle than the benefits it provides. We err on the side of caution and stability in general, and decided not to provide a built-in hot reloading _yet_. **Note**: you can still use the hot reloading facility provided by your JS build pipeline. diff --git a/pages/docs/manual/v10.0.0/build-pinned-dependencies.mdx b/pages/docs/manual/v10.0.0/build-pinned-dependencies.mdx deleted file mode 100644 index ac1326142..000000000 --- a/pages/docs/manual/v10.0.0/build-pinned-dependencies.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: "Pinned Dependencies" -metaTitle: "Pinned Dependencies" -description: "Handling multiple packages within one ReScript project with pinned dependencies" -canonical: "/docs/manual/latest/build-pinned-dependencies" ---- - -# Pinned Dependencies - -**Since 8.4** - -Usually we'd recommend to use ReScript in a single-codebase style by using one `bsconfig.json` file for your whole codebase. - -There are scenarios where you still want to connect and build multiple independent ReScript packages for one main project though (`npm` workspaces-like "monorepos"). This is where `pinned-dependencies` come into play. - -## Package Types - -Before we go into detail, let's first explain all the different package types recognized by the build system: - -- Toplevel (this is usually the final app you are building, which has dependencies to other packages) -- Pinned dependencies (these are your local packages that should always rebuild when you build your toplevel, those should be listed in `bs-dependencies` and `pinned-dependencies`) -- Normal dependencies (these are packages that are consumed from npm and listed via `bs-dependencies`) - -Whenever a package is being built (`rescript build`), the build system will build the toplevel package with its pinned-dependencies. So any changes made in a pinned dependency will automatically be reflected in the final app. - -## Build System Package Rules - -The build system respects the following rules for each package type: - -**Toplevel** - -- Warnings reported -- Warn-error respected -- Builds dev dependencies -- Builds pinned dependencies -- Runs custom rules -- Package-specs like ES6/CommonJS overrides all its dependencies - -**Pinned dependencies** - -- Warnings reported -- Warn-error respected -- Ignores pinned dependencies -- Builds dev dependencies -- Runs custom rules - -**Normal dependencies** - -- Warnings, warn-error ignored -- Ignores dev directories -- Ignores pinned dependencies -- Ignores custom generator rules - -So with that knowledge in mind, let's dive into some more concrete examples to see our pinned dependencies in action. - -## Examples - -### Yarn workspaces - -Let's assume we have a codebase like this: - -``` -myproject/ - app/ - - src/App.res - - bsconfig.json - common/ - - src/Header.res - - bsconfig.json - myplugin/ - - src/MyPlugin.res - - bsconfig.json - package.json -``` - -Our `package.json` file within our codebase root would look like this: - -```json -{ - "name": "myproject", - "private": true, - "workspaces": { - "packages": ["app", "common", "myplugin"] - } -} -``` - -Our `app` folder would be our toplevel package, consuming our `common` and `myplugin` packages as `pinned-dependencies`. The configuration for `app/bsconfig.json` looks like this: - -```json -{ - "name": "app", - "version": "1.0.0", - "sources": { - "dir": "src", - "subdirs": true - }, - /* ... */ - "bs-dependencies": ["common", "myplugin"], - "pinned-dependencies": ["common", "myplugin"] - /* ... */ -} -``` - -Now, whenever we are running `rescript build` within our `app` package, the compiler would always rebuild any changes within its pinned dependencies as well. - -**Important:** ReScript will not rebuild any `pinned-dependencies` in watch mode! This is due to the complexity of file watching, so you'd need to set up your own file-watcher process that runs `rescript build` on specific file changes. diff --git a/pages/docs/manual/v10.0.0/control-flow.mdx b/pages/docs/manual/v10.0.0/control-flow.mdx deleted file mode 100644 index 0abb918c7..000000000 --- a/pages/docs/manual/v10.0.0/control-flow.mdx +++ /dev/null @@ -1,221 +0,0 @@ ---- -title: "If-Else & Loops" -description: "If, else, ternary, for, and while" -canonical: "/docs/manual/latest/control-flow" ---- - -# If-Else & Loops - -ReScript supports `if`, `else`, ternary expression (`a ? b : c`), `for` and `while`. - -ReScript also supports our famous pattern matching, which will be covered in [its own section](pattern-matching-destructuring.md) - -## If-Else & Ternary - -Unlike its JavaScript counterpart, ReScript's `if` is an expression; they evaluate to their body's content: - - - -```res -let message = if isMorning { - "Good morning!" -} else { - "Hello!" -} -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**Note:** an `if-else` expression without the final `else` branch implicitly gives `()` (aka the `unit` type). So this: - - - -```res -if showMenu { - displayMenu() -} -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -is basically the same as: - - - -```res -if showMenu { - displayMenu() -} else { - () -} -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -Here's another way to look at it. This is clearly wrong: - -```res -let result = if showMenu { - 1 + 2 -} -``` - -It'll give a type error, saying basically that the implicit `else` branch has the type `unit` while the `if` branch has type `int`. Intuitively, this makes sense: what would `result`'s value be, if `showMenu` was `false`? - -We also have ternary sugar, but **we encourage you to prefer if-else when possible**. - - - -```res -let message = isMorning ? "Good morning!" : "Hello!" -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**`if-else` and ternary are much less used** in ReScript than in other languages; [Pattern-matching](pattern-matching-destructuring.md) kills a whole category of code that previously required conditionals. - -## For Loops - -For loops iterate from a starting value up to (and including) the ending value. - - - -```res -for i in startValueInclusive to endValueInclusive { - Js.log(i) -} -``` - -```js -for (var i = startValueInclusive; i <= endValueInclusive; ++i) { - console.log(i); -} -``` - - - - - -```res example -// prints: 1 2 3, one per line -for x in 1 to 3 { - Js.log(x) -} -``` - -```js -for (var x = 1; x <= 3; ++x) { - console.log(x); -} -``` - - - -You can make the `for` loop count in the opposite direction by using `downto`. - - - -```res -for i in startValueInclusive downto endValueInclusive { - Js.log(i) -} -``` - -```js -for (var i = startValueInclusive; i >= endValueInclusive; --i) { - console.log(i); -} -``` - - - - - -```res example -// prints: 3 2 1, one per line -for x in 3 downto 1 { - Js.log(x) -} -``` - -```js -for (var x = 3; x >= 1; --x) { - console.log(x); -} -``` - - - -## While Loops - -While loops execute its body code block while its condition is true. - - - -```res -while testCondition { - // body here -} -``` - -```js -while (testCondition) { - // body here -} -``` - - - -### Tips & Tricks - -There's no loop-breaking `break` keyword (nor early `return` from functions, for that matter) in ReScript. However, we can break out of a while loop easily through using a [mutable binding](mutation.md). - - - -```res example -let break = ref(false) - -while !break.contents { - if Js.Math.random() > 0.3 { - break := true - } else { - Js.log("Still running") - } -} -``` - -```js -var $$break = { - contents: false, -}; - -while (!$$break.contents) { - if (Math.random() > 0.3) { - $$break.contents = true; - } else { - console.log("Still running"); - } -} -``` - - diff --git a/pages/docs/manual/v10.0.0/converting-from-js.mdx b/pages/docs/manual/v10.0.0/converting-from-js.mdx deleted file mode 100644 index 4234c0c83..000000000 --- a/pages/docs/manual/v10.0.0/converting-from-js.mdx +++ /dev/null @@ -1,313 +0,0 @@ ---- -title: "Converting from JS" -description: "How to convert to ReScript with an existing JS codebase" -canonical: "/docs/manual/latest/converting-from-js" ---- - -# Converting from JS - -ReScript offers a unique project conversion methodology which: - -- Ensures minimal disruption to your teammates (very important!). -- Remove the typical friction of verifying conversion's correctness and performance guarantees. -- Doesn't force you to search for pre-made binding libraries made by others. **ReScript doesn't need the equivalent of TypeScript's `DefinitelyTyped`**. - -## Step 1: Install ReScript - -Run `npm install rescript` on your project, then imitate our [New Project](installation#new-project) workflow by adding a `bsconfig.json` at the root. Then start `npx rescript build -w`. - -## Step 2: Copy Paste the Entire JS File - -Let's work on converting a file called `src/main.js`. - -```js -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -``` - -First, copy the entire file content over to a new file called `src/Main.res` by using our [`%%raw` JS embedding trick](embed-raw-javascript): - - - -```res example -%%raw(` -const school = require('school'); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -`) -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} - -/* Not a pure module */ -``` - - - -Add this file to `bsconfig.json`: - -```json - "sources": { - "dir" : "src", - "subdirs" : true - }, -``` - -Open an editor tab for `src/Main.bs.js`. Do a command-line `diff -u src/main.js src/Main.bs.js`. Aside from whitespaces, you should see only minimal, trivial differences. You're already a third of the way done! - -**Always make sure** that at each step, you keep the ReScript output `.bs.js` file open to compare against the existing JavaScript file. Our compilation output is very close to your hand-written JavaScript; you can simply eye the difference to catch conversion bugs! - -## Step 3: Extract Parts into Idiomatic ReScript - -Let's turn the `defaultId` variable into a ReScript let-binding: - - - -```res example -let defaultId = 10 - -%%raw(` -const school = require('school'); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -`) -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -const school = require('school'); - -function queryResult(usePayload, payload) { - if usePayload { - return payload.student - } else { - return school.getStudentById(defaultId) - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -/* Not a pure module */ -``` - - - -Check the output. Diff it. Code still works. Moving on! Extract the function: - - - -```res -%%raw(` -const school = require('school'); -`) - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload.student - } else { - school.getStudentById(defaultId) - } -} -``` - -```js - -``` - - - -Format the code: `./node_modules/.bin/rescript format src/Main.res`. - -We have a type error: "The record field student can't be found". That's fine! **Always ensure your code is syntactically valid first**. Fixing type errors comes later. - -## Step 4: Add `external`s, Fix Types - -The previous type error is caused by `payload`'s record declaration (which supposedly contains the field `student`) not being found. Since we're trying to convert as quickly as possible, let's use our [object](object) feature to avoid needing type declaration ceremonies: - - - -```res -%%raw(` -const school = require('school'); -`) - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload["student"] - } else { - school["getStudentById"](. defaultId) - } -} -``` - -```js - -``` - - - -Now this triggers the next type error, that `school` isn't found. Let's use [`external`](external) to bind to that module: - - - -```res example -@module external school: 'whatever = "school" - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload["student"] - } else { - school["getStudentById"](. defaultId) - } -} -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We hurrily typed `school` as a polymorphic `'whatever` and let its type be inferred by its usage below. The inference is technically correct, but within the context of bringing it a value from JavaScript, slightly dangerous. This is just the interop trick we've shown in the [`external`](external) page. - -Anyway, the file passes the type checker again. Check the `.bs.js` output, diff with the original `.js`; we've now converted a file over to ReScript! - -Now, you can delete the original, hand-written `main.js` file, and grep the files importing `main.js` and change them to importing `Main.bs.js`. - -## (Optional) Step 5: Cleanup - -If you prefer more advanced, rigidly typed `payload` and `school`, feel free to do so: - - - -```res example -type school -type student -type payload = { - student: student -} - -@module external school: school = "school" -@send external getStudentById: (school, int) => student = "getStudentById" - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload.student - } else { - school->getStudentById(defaultId) - } -} -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We've: - -- introduced an opaque types for `school` and `student` to prevent misusages their values -- typed the payload as a record with only the `student` field -- typed `getStudentById` as the sole method of `student` - -Check that the `.bs.js` output didn't change. How rigidly to type your JavaScript code is up to you; we recommend not typing them too elaborately; it's sometime an endless chase, and produces diminishing returns, especially considering that the elaborate-ness might turn off your potential teammates. - -## Tips & Tricks - -In the same vein of idea, **resist the urge to write your own wrapper functions for the JS code you're converting**. Use [`external`s](external), which are guaranteed to be erased in the output. And avoid trying to take the occasion to convert JS data structures into ReScript-specific data structures like variant or list. **This isn't the time for that**. - -The moment you produce extra conversion code in the output, your skeptical teammate's mental model might switch from "I recognize this output" to "this conversion might be introducing more problems than it solves. Why are we testing ReScript again?". Then you've lost. - -## Conclusion - -- Paste the JS code into a new ReScript file as embedded raw JS code. -- Compile and keep the output file open. Check and diff against original JS file. Free regression tests. -- Always make sure your file is syntactically valid. Don't worry about fixing types before that. -- (Ab)use [object](object.md) accesses to quickly convert things over. -- Optionally clean up the types for robustness. -- Don't go overboard and turn off your boss and fellow teammates. -- Proudly display that you've conserved the semantics and performance characteristics during the conversion by showing your teammates the eerily familiar output. -- Get promoted for introducing a new technology the safer, mature way. diff --git a/pages/docs/manual/v10.0.0/editor-plugins.mdx b/pages/docs/manual/v10.0.0/editor-plugins.mdx deleted file mode 100644 index fc2dbb2ce..000000000 --- a/pages/docs/manual/v10.0.0/editor-plugins.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: "Editor Plugins" -description: "List of ReScript editor plugins" -canonical: "/docs/manual/latest/editor-plugins" ---- - -# Editor Plugins - -- [VSCode](https://marketplace.visualstudio.com/items?itemName=chenglou92.rescript-vscode) -- [Sublime Text](https://github.com/rescript-lang/rescript-sublime) -- [Vim/Neovim](https://github.com/rescript-lang/vim-rescript) - -## Community Supported - -We don't officially support these; use them at your own risk! - -- [Neovim Tree-sitter](https://github.com/nkrkv/nvim-treesitter-rescript) -- [Atom](https://atom.io/packages/ide-rescript) -- [IDEA](https://github.com/reasonml-editor/reasonml-idea-plugin) -- [Emacs](https://github.com/reasonml-editor/reason-mode) (only legacy `v8.0.0` Reason/OCaml syntax support) diff --git a/pages/docs/manual/v10.0.0/embed-raw-javascript.mdx b/pages/docs/manual/v10.0.0/embed-raw-javascript.mdx deleted file mode 100644 index f89d61f2f..000000000 --- a/pages/docs/manual/v10.0.0/embed-raw-javascript.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: "Embed Raw JavaScript" -description: "Utility syntax to for raw JS usage in ReScript" -canonical: "/docs/manual/latest/embed-raw-javascript" ---- - -# Embed Raw JavaScript - -## Paste Raw JS Code - -First thing first. If you're ever stuck learning ReScript, remember that you can always just paste raw JavaScript code into our source file: - - - -```res example -%%raw(` -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m) -} -`) -``` - -```js -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m); -} -``` - - - -The `%%raw` special ReScript call takes your code string and pastes it as-is into the output. **You've now technically written your first ReScript file!** - -(The back tick syntax is a multiline string, similar to JavaScript's. Except for us, no escaping is needed inside the string. More on string in a later section.) - -While `%%raw` lets you embed top-level raw JS code, `%raw` lets you embed expression-level JS code: - - - -```res example -let add = %raw(` - function(a, b) { - console.log("hello from raw JavaScript!"); - return a + b - } -`) - -Js.log(add(1, 2)) -``` - -```js -var add = function (a, b) { - console.log("hello from raw JavaScript!"); - return a + b; -}; - -console.log(add(1, 2)); -``` - - - -The above code: - -- declared a ReScript variable `add`, -- with the raw JavaScript value of a function declaration, -- then called that function in ReScript. - -If your boss is ever worried that your teammates can't adopt ReScript, just let them keep writing JavaScript inside ReScript files =). - -## Debugger - -You can also drop a `%debugger` expression in a body: - - - -```res example -let f = (x, y) => { - %debugger - x + y -} -``` - -```js -function f(x, y) { - debugger; - return (x + y) | 0; -} -``` - - - -Output: - -```js -function f(x, y) { - debugger; // JavaScript developer tools will set an breakpoint and stop here - x + y; -} -``` - -## Tips & Tricks - -Embedding raw JS snippets isn't the best way to experience ReScript, though it's also highly useful if you're just starting out. As a matter of fact, the first few ReScript projects were converted through: - -- pasting raw JS snippets inside a file -- examining the JS output (identical to the old hand-written JS) -- gradually extract a few values and functions and making sure the output still looks OK - -At the end, we get a fully safe, converted ReScript file whose JS output is clean enough that we can confidently assert that no new bug has been introduced during the conversion process. - -We have a small guide on this iteration [here](converting-from-js.md). Feel free to peruse it later. diff --git a/pages/docs/manual/v10.0.0/exception.mdx b/pages/docs/manual/v10.0.0/exception.mdx deleted file mode 100644 index 706be048e..000000000 --- a/pages/docs/manual/v10.0.0/exception.mdx +++ /dev/null @@ -1,269 +0,0 @@ ---- -title: "Exception" -description: "Exceptions and exception handling in ReScript" -canonical: "/docs/manual/latest/exception" ---- - -# Exception - -Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!). - -## Usage - - - -```res prelude -let getItem = (item: int) => - if (item === 3) { - // return the found item here - 1 - } else { - raise(Not_found) - } - -let result = - try { - getItem(2) - } catch { - | Not_found => 0 // Default value if getItem throws - } -``` - -```js -var Caml_js_exceptions = require("./stdlib/caml_js_exceptions.js"); - -function getItem(item) { - if (item === 3) { - return 1; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error(), - }; -} - -var result; - -try { - result = getItem(2); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - result = 0; - } else { - throw exn; - } -} -``` - - - -Note that the above is just for demonstration purposes; in reality, you'd return an `option` directly from `getItem` and avoid the `try` altogether. - -You can directly match on exceptions _while_ getting another return value from a function: - - - -```res prelude -switch List.find(i => i === 4, list{1, 2, 3}) { -| item => Js.log(item) -| exception Not_found => Js.log("No such item found!") -} -``` - -```js -var List = require("./stdlib/list.js"); -var Caml_js_exceptions = require("./stdlib/caml_js_exceptions.js"); - -var exit = 0; - -var item; - -try { - item = List.find( - function (i) { - return i === 4; - }, - { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */ 0, - }, - }, - }, - ); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -You can also make your own exceptions like you'd make a variant (exceptions need to be capitalized too). - - - -```res example -exception InputClosed(string) -// later on -raise(InputClosed("The stream has closed!")) -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var InputClosed = Caml_exceptions.create("MyFile.InputClosed"); - -throw { - RE_EXN_ID: InputClosed, - _1: "The stream has closed!", - Error: new Error(), -}; -``` - - - -## Catching JS Exceptions - -To distinguish between JavaScript exceptions and ReScript exceptions, ReScript namespaces JS exceptions under the `Js.Exn.Error(payload)` variant. To catch an exception thrown from the JS side: - -Throw an exception from JS: - -```js -// Example.js - -exports.someJsFunctionThatThrows = () => { - throw new Error("A Glitch in the Matrix!"); -}; -``` - -Then catch it from ReScript: - -```res -// import the method in Example.js -@module("./Example") -external someJsFunctionThatThrows: () => unit = "someJsFunctionThatThrows" - -try { - // call the external method - someJSFunctionThatThrows() -} catch { -| Js.Exn.Error(obj) => - switch Js.Exn.message(obj) { - | Some(m) => Js.log("Caught a JS exception! Message: " ++ m) - | None => () - } -} -``` - -The `obj` here is of type `Js.Exn.t`, intentionally opaque to disallow illegal operations. To operate on `obj`, do like the code above by using the standard library's [`Js.Exn`](api/js/exn) module's helpers. - -## Raise a JS Exception - -`raise(MyException)` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Js.Exn.raiseError`: - - - -```res example -let myTest = () => { - Js.Exn.raiseError("Hello!") -} -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); - -function myTest() { - return Js_exn.raiseError("Hello!"); -} -``` - - - -Then you can catch it from the JS side: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.message); // "Hello!" -} -``` - -## Catch ReScript Exceptions from JS - -The previous section is less useful than you think; to let your JS code work with your exception-throwing ReScript code, the latter doesn't actually need to throw a JS exception. ReScript exceptions can be used by JS code! - - - -```res example -exception BadArgument({myMessage: string}) - -let myTest = () => { - raise(BadArgument({myMessage: "Oops!"})) -} -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var BadArgument = Caml_exceptions.create("Playground.BadArgument"); - -function myTest() { - throw { - RE_EXN_ID: BadArgument, - myMessage: "Oops!", - Error: new Error(), - }; -} -``` - - - -Then, in your JS: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.myMessage); // "Oops!" - console.log(e.Error.stack); // the stack trace -} -``` - -> Note: `RE_EXN_ID` is an internal field for bookkeeping purposes. Don't use it on the JS side. Use the other fields. - -The above `BadArgument` exception takes an inline record type. We special-case compile the exception as `{RE_EXN_ID, myMessage, Error}` for good ergonomics. If the exception instead took ordinary positional arguments, l like the standard library's `Invalid_argument("Oops!")`, which takes a single argument, the argument is compiled to JS as the field `_1` instead. A second positional argument would compile to `_2`, etc. - -## Tips & Tricks - -When you have ordinary variants, you often don't **need** exceptions. For example, instead of throwing when `item` can't be found in a collection, try to return an `option` (`None` in this case) instead. - -### Catch Both ReScript and JS Exceptions in the Same `catch` Clause - -```res -try { - someOtherJSFunctionThatThrows() -} catch { -| Not_found => ... // catch a ReScript exception -| Invalid_argument(_) => ... // catch a second ReScript exception -| Js.Exn.Error(obj) => ... // catch the JS exception -} -``` - -This technically works, but hopefully you don't ever have to work with such code... diff --git a/pages/docs/manual/v10.0.0/extensible-variant.mdx b/pages/docs/manual/v10.0.0/extensible-variant.mdx deleted file mode 100644 index 933bfb186..000000000 --- a/pages/docs/manual/v10.0.0/extensible-variant.mdx +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: "Extensible Variant" -description: "Extensible Variants in ReScript" -canonical: "/docs/manual/latest/extensible-variant" ---- - -# Extensible Variant - -Variant types are usually constrained to a fixed set of constructors. There may be very rare cases where you still want to be able to add constructors to a variant type even after its initial type declaration. For this, we offer extensible variant types. - -## Definition and Usage - - - -```res example -type t = .. - -type t += Other - -type t += - | Point(float, float) - | Line(float, float, float, float) -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var Other = Caml_exceptions.create("Playground.Other"); - -var Point = Caml_exceptions.create("Playground.Point"); - -var Line = Caml_exceptions.create("Playground.Line"); -``` - - - -The `..` in the type declaration above defines an extensible variant `type t`. The `+=` operator is then used to add constructors to the given type. - -**Note:** Don't forget the leading `type` keyword when using the `+=` operator! - -## Pattern Matching Caveats - -Extensible variants are open-ended, so the compiler will not be able to exhaustively pattern match all available cases. You will always need to provide a default `_` case for every `switch` expression. - - - -```res -let print = v => - switch v { - | Point(x, y) => Js.log2("Point", (x, y)) - | Line(ax, ay, bx, by) => Js.log2("Line", (ax, ay, bx, by)) - | Other - | _ => Js.log("Other") - } -``` - -```js -function print(v) { - if (v.RE_EXN_ID === Point) { - console.log("Point", [v._1, v._2]); - } else if (v.RE_EXN_ID === Line) { - console.log("Line", [v._1, v._2, v._3, v._4]); - } else { - console.log("Other"); - } -} -``` - - - -## Tips & Tricks - -**Fun fact:** In ReScript, [exceptions](./exception) are actually extensible variants under the hood, so `exception UserError(string)` is equivalent to `type exn += UserError(string)`. It's one of the very few use-case where extensible variants make sense. - -We usually recommend sticking with common [variants](./variant) as much as possible to reap the benefits of exhaustive pattern matching. diff --git a/pages/docs/manual/v10.0.0/external.mdx b/pages/docs/manual/v10.0.0/external.mdx deleted file mode 100644 index 03be86931..000000000 --- a/pages/docs/manual/v10.0.0/external.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: "External (Bind to Any JS Library)" -description: "The external keyword" -canonical: "/docs/manual/latest/external" ---- - -# External (Bind to Any JS Library) - -`external` is the primary ReScript feature for bringing in and using JavaScript values. - -`external` is like a let binding, but: - -- The right side of `=` isn't a value; it's the name of the JS value you're referring to. -- The type for the binding is mandatory, since we need to know what the type of that JS value is. -- Can only exist at the top level of a file or module. - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -``` - -```js -// Empty output -``` - - - -There are several kinds of `external`s, differentiated and/or augmented through the [attribute](attribute.md) they carry. This page deals with the general, shared mechanism behind most `external`s. The different are documented in their respective pages later. A few notable ones: - -- `@val`, `@scope`: [bind to global JS values](bind-to-global-js-values). -- `@module`: [bind to JS imported/exported values](import-from-export-to-js). -- `@send`: [bind to JS methods](bind-to-js-function). - -You can also use our [Syntax Lookup](/syntax-lookup) tool to find them. - -Related: see also our [list of external decorators](interop-cheatsheet#list-of-decorators). - -## Usage - -Once declared, you can use an `external` as a normal value, just like a let binding. - -## Tips & Tricks - -`external` + ReScript objects are a wonderful combination for quick prototyping. Check the JS output tab: - - - -```res example -// The type of document is just some random type 'a -// that we won't bother to specify -@val external document: 'a = "document" - -// call a method -document["addEventListener"](."mouseup", _event => { - Js.log("clicked!") -}) - -// get a property -let loc = document["location"] - -// set a property -document["location"]["href"] = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); - -var loc = document.location; - -document.location.href = "rescript-lang.org"; -``` - - - -We've specified `document`'s type as `'a`, aka a placeholder type that's polymorphic. Any value can be passed there, so you're not getting much type safety (except the inferences at various call sites). However, this is excellent for quickly getting started using a JavaScript library in ReScript **without needing the equivalent of a repository of typed bindings** like TypeScript's `DefinitelyTyped` repo. - -However, if you want to more rigidly bind to the JavaScript library you want, keep reading the next few interop pages. - -## Performance & Output Readability - -`external`s declarations are inlined into their callers during compilation, **and completely disappear from the JS output**. This means any time you use one, you can be sure that you're not incurring extra JavaScript \<-> ReScript conversion cost. - -Additionally, no extra ReScript-specific runtime is better for output readability. - -> **Note:** do also use `external`s and the `@blabla` attributes in the interface files. Otherwise the inlining won't happen. - -## Design Decisions - -ReScript takes interoperating with existing code very seriously. Our type system has very strong guarantees. However, such strong feature also means that, without a great interop system, it'd be very hard to gradually convert a codebase over to ReScript. Fortunately, our interop are comprehensive and cooperate very well with most existing JavaScript code. - -The combination of a sound type system + great interop means that we get the benefits of a traditional gradual type system regarding incremental codebase coverage & conversion, without the downside of such gradual type system: complex features to support existing patterns, slow analysis, diminishing return in terms of type coverage, etc. diff --git a/pages/docs/manual/v10.0.0/faq.mdx b/pages/docs/manual/v10.0.0/faq.mdx deleted file mode 100644 index 7913c5de7..000000000 --- a/pages/docs/manual/v10.0.0/faq.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: "FAQ" -description: "Frequently asked questions about ReScript and its ecosystem" -canonical: "/docs/manual/latest/faq" ---- - -# Frequently Asked Questions - -**What's the goal of this project?** - -We aim to provide the best typed language experience for the JavaScript platform. - -**What’s the relationship with BuckleScript?** - -BuckleScript is ReScript's old branding, with a sharper focus on proper JS support and familiarity which we previously couldn't achieve to the degree we wanted, due to us needing to cater to various different crowds. - -**What’s ReScript's relationship with OCaml?** - -We reuse and adjust the excellent type system and lots of other high quality components from OCaml for JS experience. -Additionally, ReScript provides its own syntax, build system, IDE, backend, JS interop, extra language features, etc. - -The ReScript toolchain is developed using OCaml, however, the version of ReScript is decoupled against the version of OCaml, -ReScript compiler should build against any reasonable modern version of OCaml compiler. - -For the majority of ReScript users, they don't need to learn OCaml or use OCaml toolchain to be productive in ReScript. - -**What’s the relationship with Reason?** - -See [here](/blog/bucklescript-is-rebranding). Reason is a syntax layer for OCaml that BuckleScript also adopted. The current ReScript compiler also supports the old Reason syntax v3.6 for backward compatibility. We will support it for a long time to make sure existing users do not get breaking changes. - -**I come from Reason/OCaml. Will ReScript keep supporting X?** - -Please see our [blog post](/blog/a-note-on-bucklescripts-future-commitments) on this matter. - -**Where can I see the docs in old Reason/OCaml syntax?** - -Switch the doc version to `v8.0.0` in the sidebar on the left! - -**Will ReScript support native compilation eventually?** - -Our focus is a solid JS story right now. In the future, if there’s strong demand, we might consider it. - -**What’s the current state of ReScript?** - -Currently, we're actively working on the editor support. - -**When will we get the `async/await` keywords?** - -See our answer on the [Async & Promise](promise) page's intro. - -**Why create a new syntax?** - -The existing Reason syntax is owned by a different team with a different vision. Reason aims to be 100% compatible with OCaml syntax and to support all versions of OCaml. In the last few years, we've drawn the conclusion that it’s very hard to deliver such goal without sacrificing user experience. The other reason is that we feel it’s better to have the same vision as a team so that we can make more coherent decisions. - -**Who is behind the project?** - -The ReScript team (Hongbo, Cheng, Cristiano, Maxim, Patrick, Ricky). - -**We have a new forum; will we also have our own Discord?** - -Not now. We've found that too much important information get casually passed in Discord then lost within the noise. We prefer folks to communicate on the [forum](https://forum.rescript-lang.org). This is nicer to the less active members. - -The team doesn't use the old Discord anymore. We encourage you to move your questions to the forum instead. diff --git a/pages/docs/manual/v10.0.0/function.mdx b/pages/docs/manual/v10.0.0/function.mdx deleted file mode 100644 index d66c3324e..000000000 --- a/pages/docs/manual/v10.0.0/function.mdx +++ /dev/null @@ -1,648 +0,0 @@ ---- -title: "Function" -description: "Function syntax in ReScript" -canonical: "/docs/manual/latest/function" ---- - -# Function - -_Cheat sheet for the full function syntax at the end_. - -ReScript functions are declared with an arrow and return an expression, just like JS functions. They compile to clean JS functions too. - - - -```res prelude -let greet = (name) => "Hello " ++ name -``` - -```js -function greet(name) { - return "Hello " + name; -} -``` - - - -This declares a function and assigns to it the name `greet`, which you can call like so: - - - -```res example -greet("world!") // "Hello world!" -``` - -```js -greet("world!"); -``` - - - -Multi-arguments functions have arguments separated by comma: - - - -```res example -let add = (x, y, z) => x + y + z -add(1, 2, 3) // 6 -``` - -```js -function add(x, y, z) { - return (((x + y) | 0) + z) | 0; -} -``` - - - -For longer functions, you'd surround the body with a block: - - - -```res example -let greetMore = (name) => { - let part1 = "Hello" - part1 ++ " " ++ name -} -``` - -```js -function greetMore(name) { - return "Hello " + name; -} -``` - - - -If your function has no argument, just write `let greetMore = () => {...}`. - -## Labeled Arguments - -Multi-arguments functions, especially those whose arguments are of the same type, can be confusing to call. - - - -```res -let addCoordinates = (x, y) => { - // use x and y here -} -// ... -addCoordinates(5, 6) // which is x, which is y? -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can attach labels to an argument by prefixing the name with the `~` symbol: - - - -```res -let addCoordinates = (~x, ~y) => { - // use x and y here -} -// ... -addCoordinates(~x=5, ~y=6) -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can provide the arguments in **any order**: - - - -```res -addCoordinates(~y=6, ~x=5) -``` - -```js -addCoordinates(5, 6); -``` - - - -The `~x` part in the declaration means the function accepts an argument labeled `x` and can refer to it in the function body by the same name. You can also refer to the arguments inside the function body by a different name for conciseness: - - - -```res -let drawCircle = (~radius as r, ~color as c) => { - setColor(c) - startAt(r, r) - // ... -} - -drawCircle(~radius=10, ~color="red") -``` - -```js -function drawCircle(r, c) { - setColor(c); - return startAt(r, r); -} - -drawCircle(10, "red"); -``` - - - -As a matter of fact, `(~radius)` is just a shorthand for `(~radius as radius)`. - -Here's the syntax for typing the arguments: - - - -```res -let drawCircle = (~radius as r: int, ~color as c: string) => { - // code here -} -``` - -```js -function drawCircle(r, c) { - // code here -} -``` - - - -## Optional Labeled Arguments - -Labeled function arguments can be made optional during declaration. You can then omit them when calling the function. - - - -```res -// radius can be omitted -let drawCircle = (~color, ~radius=?, ()) => { - setColor(color) - switch radius { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - } -} -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -function drawCircle(color, radius, param) { - setColor(color); - if (radius === undefined) { - return startAt(1, 1); - } - var r_ = Caml_option.valFromOption(radius); - return startAt(r_, r_); -} -``` - - - -When given in this syntax, `radius` is **wrapped** in the standard library's `option` type, defaulting to `None`. If provided, it'll be wrapped with a `Some`. So `radius`'s type value is `None | Some(int)` here. - -More on `option` type [here](null-undefined-option.md). - -**Note** for the sake of the type system, whenever you have an optional argument, you need to ensure that there's also at least one positional argument (aka non-labeled, non-optional argument) after it. If there's none, provide a dummy `unit` (aka `()`) argument. - -### Signatures and Type Annotations - -Functions with optional labeled arguments can be confusing when it comes to signature and type annotations. Indeed, the type of an optional labeled argument looks different depending on whether you're calling the function, or working inside the function body. Outside the function, a raw value is either passed in (`int`, for example), or left off entirely. Inside the function, the parameter is always there, but its value is an option (`option`). This means that the type signature is different, depending on whether you're writing out the function type, or the parameter type annotation. The first being a raw value, and the second being an option. - -If we get back to our previous example and both add a signature and type annotations to its argument, we get this: - - - -```res -let drawCircle: (~color: color, ~radius: int=?, unit) => unit = - (~color: color, ~radius: option=?, ()) => { - setColor(color) - switch radius { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - } - } -``` - -```js -function drawCircle(color, radius, param) { - setColor(color); - if (radius !== undefined) { - return startAt(radius, radius); - } else { - return startAt(1, 1); - } -} -``` - - - -The first line is the function's signature, we would define it like that in an interface file (see [Signatures](module.md#signatures)). The function's signature describes the types that the **outside world** interacts with, hence the type `int` for `radius` because it indeed expects an `int` when called. - -In the second line, we annotate the arguments to help us remember the types of the arguments when we use them **inside** the function's body, here indeed `radius` will be an `option` inside the function. - -So if you happen to struggle when writing the signature of a function with optional labeled arguments, try to remember this! - -### Explicitly Passed Optional - -Sometimes, you might want to forward a value to a function without knowing whether the value is `None` or `Some(a)`. Naively, you'd do: - - - -```res -let result = - switch payloadRadius { - | None => drawCircle(~color, ()) - | Some(r) => drawCircle(~color, ~radius=r, ()) - } -``` - -```js -var r = payloadRadius; - -var result = - r !== undefined - ? drawCircle(color, Caml_option.valFromOption(r), undefined) - : drawCircle(color, undefined); -``` - - - -This quickly gets tedious. We provide a shortcut: - - - -```res -let result = drawCircle(~color, ~radius=?payloadRadius, ()) -``` - -```js -var result = drawCircle(1, undefined, undefined); -``` - - - -This means "I understand `radius` is optional, and that when I pass it a value it needs to be an `int`, but I don't know whether the value I'm passing is `None` or `Some(val)`, so I'll pass you the whole `option` wrapper". - -### Optional with Default Value - -Optional labeled arguments can also be provided a default value. In this case, they aren't wrapped in an `option` type. - - - -```res -let drawCircle = (~radius=1, ~color, ()) => { - setColor(color) - startAt(radius, radius) -} -``` - -```js -function drawCircle(radiusOpt, color, param) { - var radius = radiusOpt !== undefined ? radiusOpt : 1; - setColor(color); - return startAt(radius, radius); -} -``` - - - -## Recursive Functions - -ReScript chooses the sane default of preventing a function to be called recursively within itself. To make a function recursive, add the `rec` keyword after the `let`: - - - -```res example -let rec neverTerminate = () => neverTerminate() -``` - -```js -function neverTerminate(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -A simple recursive function may look like this: - - - -```res example -// Recursively check every item on the list until one equals the `item` -// argument. If a match is found, return `true`, otherwise return `false` -let rec listHas = (list, item) => - switch list { - | list{} => false - | list{a, ...rest} => a === item || listHas(rest, item) - } -``` - -```js -function listHas(_list, item) { - while (true) { - var list = _list; - if (!list) { - return false; - } - if (list.hd === item) { - return true; - } - _list = list.tl; - continue; - } -} -``` - - - -Recursively calling a function is bad for performance and the call stack. However, ReScript intelligently compiles [tail recursion](https://stackoverflow.com/questions/33923/what-is-tail-recursion) into a fast JavaScript loop. Try checking the JS output of the above code! - -### Mutually Recursive Functions - -Mutually recursive functions start like a single recursive function using the -`rec` keyword, and then are chained together with `and`: - - - -```res example -let rec callSecond = () => callFirst() -and callFirst = () => callSecond() -``` - -```js -function callSecond(_param) { - while (true) { - _param = undefined; - continue; - } -} - -function callFirst(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -## Uncurried Function - -ReScript's functions are curried by default, which is one of the few performance penalties we pay in the compiled JS output. The compiler does a best-effort job at removing those currying whenever possible. However, in certain edge cases, you might want guaranteed uncurrying. In those cases, put a dot in the function's parameter list: - - - -```res example -let add = (. x, y) => x + y - -add(. 1, 2) -``` - -```js -function add(x, y) { - return (x + y) | 0; -} - -add(1, 2); -``` - - - -If you write down the uncurried function's type, you'll add a dot there as well. - -**Note**: both the declaration site and the call site need to have the uncurry annotation. That's part of the guarantee/requirement. - -**This feature seems trivial**, but is actually one of our most important features, as a primarily functional language. We encourage you to use it if you'd like to remove any mention of `Curry` runtime in the JS output. - -## Async/Await (from v10.1) - -Just as in JS, an async function can be declared by adding `async` before the definition, and `await` can be used in the body of such functions. -The output looks like idiomatic JS: - - - -```res example -let getUserName = async (userId) => userId - -let greetUser = async (userId) => { - let name = await getUserName(userId) - "Hello " ++ name ++ "!" -} -``` - -```js -async function greetUser(userId) { - var name = await getUserName(userId); - return "Hello " + name + "!"; -} -``` - - - -The return type of `getUser` is inferred to be `promise`. -Similarly, `await getUserName(userId)` returns a `string` when the function returns `promise`. -Using `await` outside of an `async` function (including in a non-async callback to an async function) is an error. - -### Ergonomic error handling - -Error handling is done by simply using `try`/`catch`, or a switch with an `exception` case, just as in functions that are not async. -Both JS exceptions and exceptions defined in ReScript can be caught. The compiler takes care of packaging JS exceptions into the builtin `JsError` exception: - - - -```res example -exception SomeReScriptException - -let somethingThatMightThrow = async () => raise(SomeReScriptException) - -let someAsyncFn = async () => { - switch await somethingThatMightThrow() { - | data => Some(data) - | exception JsError(_) => None - | exception SomeReScriptException => None - } -} -``` - -```js -var SomeReScriptException = /* @__PURE__ */ Caml_exceptions.create( - "Example.SomeReScriptException", -); - -async function someAsyncFn(param) { - var data; - try { - data = await somethingThatMightThrow(undefined); - } catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "JsError") { - return; - } - if (exn.RE_EXN_ID === SomeReScriptException) { - return; - } - throw exn; - } - return data; -} -``` - - - -## The ignore() Function - -Occasionally you may want to ignore the return value of a function. ReScript provides an `ignore()` function that discards the value of its argument and returns `()`: - - - -```res -mySideEffect()->Promise.catch(handleError)->ignore - -Js.Global.setTimeout(myFunc, 1000)->ignore -``` - -```js -$$Promise.$$catch(mySideEffect(), function (prim) { - return handleError(prim); -}); - -setTimeout(function (prim) { - myFunc(); -}, 1000); -``` - - - -## Tips & Tricks - -Cheat sheet for the function syntaxes: - -### Declaration - -```res -// anonymous function -(x, y) => 1 -// bind to a name -let add = (x, y) => 1 - -// labeled -let add = (~first as x, ~second as y) => x + y -// with punning sugar -let add = (~first, ~second) => first + second - -// labeled with default value -let add = (~first as x=1, ~second as y=2) => x + y -// with punning -let add = (~first=1, ~second=2) => first + second - -// optional -let add = (~first as x=?, ~second as y=?) => switch x {...} -// with punning -let add = (~first=?, ~second=?) => switch first {...} -``` - -#### With Type Annotation - -```res -// anonymous function -(x: int, y: int): int => 1 -// bind to a name -let add = (x: int, y: int): int => 1 - -// labeled -let add = (~first as x: int, ~second as y: int) : int => x + y -// with punning sugar -let add = (~first: int, ~second: int) : int => first + second - -// labeled with default value -let add = (~first as x: int=1, ~second as y: int=2) : int => x + y -// with punning sugar -let add = (~first: int=1, ~second: int=2) : int => first + second - -// optional -let add = (~first as x: option=?, ~second as y: option=?) : int => switch x {...} -// with punning sugar -// note that the caller would pass an `int`, not `option` -// Inside the function, `first` and `second` are `option`. -let add = (~first: option=?, ~second: option=?) : int => switch first {...} -``` - -### Application - -```res -add(x, y) - -// labeled -add(~first=1, ~second=2) -// with punning sugar -add(~first, ~second) - -// application with default value. Same as normal application -add(~first=1, ~second=2) - -// explicit optional application -add(~first=?Some(1), ~second=?Some(2)) -// with punning -add(~first?, ~second?) -``` - -#### With Type Annotation - -```res -// labeled -add(~first=1: int, ~second=2: int) -// with punning sugar -add(~first: int, ~second: int) - -// application with default value. Same as normal application -add(~first=1: int, ~second=2: int) - -// explicit optional application -add(~first=?Some(1): option, ~second=?Some(2): option) -// no punning sugar when you want to type annotate -``` - -### Standalone Type Signature - -```res -// first arg type, second arg type, return type -type add = (int, int) => int - -// labeled -type add = (~first: int, ~second: int) => int - -// labeled -type add = (~first: int=?, ~second: int=?, unit) => int -``` - -#### In Interface Files - -To annotate a function from the implementation file (`.res`) in your interface file (`.resi`): - -```res sig -let add: (int, int) => int -``` - -The type annotation part is the same as the previous section on With Type Annotation. - -**Don't** confuse `let add: myType` with `type add = myType`. When used in `.resi` interface files, the former exports the binding `add` while annotating it as type `myType`. The latter exports the type `add`, whose value is the type `myType`. diff --git a/pages/docs/manual/v10.0.0/generate-converters-accessors.mdx b/pages/docs/manual/v10.0.0/generate-converters-accessors.mdx deleted file mode 100644 index 3a37b42b9..000000000 --- a/pages/docs/manual/v10.0.0/generate-converters-accessors.mdx +++ /dev/null @@ -1,518 +0,0 @@ ---- -title: "Generate Converters & Helpers" -description: "All about the @deriving decorator, and how to generate code from types" -canonical: "/docs/manual/latest/generate-converters-accessors" ---- - -# Generate Converters & Helpers - -**Note**: if you're looking for: - -- `@deriving(jsConverter)` for records -- `@deriving({jsConverter: newType})` for records -- `@deriving(jsConverter)` for polymorphic variants - -These particular ones are no longer needed. Select a doc version lower than `9.0` in the sidebar to see their old docs. - - - -When using ReScript, you will sometimes come into situations where you want to - -- Automatically generate functions that convert between ReScript's internal and JS runtime values (e.g. variants). -- Convert a record type into an abstract type with generated creation, accessor and method functions. -- Generate some other helper functions, such as functions from record attribute names. - -You can use the `@deriving` decorator for different code generation scenarios. All different options and configurations will be discussed on this page. - -**Note:** Please be aware that extensive use of code generation might make it harder to understand your programs (since the code being generated is not visible in the source code, and you just need to know what kind of functions / values a decorator generates). - -## Generate Functions & Plain Values for Variants - -Use `@deriving(accessors)` on a variant type to create accessor functions for its constructors. - - - -```res -@deriving(accessors) -type action = - | Click - | Submit(string) - | Cancel; -``` - -```js -function submit(param_0) { - return /* Submit */ [param_0]; -} - -var click = /* Click */ 0; - -var cancel = /* Cancel */ 1; - -exports.click = click; -exports.submit = submit; -exports.cancel = cancel; -``` - - - -Variants constructors with payloads generate functions, payload-less constructors generate plain integers (the internal representation of variants). - -**Note**: - -- The generated accessors are lower-cased. -- You can now use these helpers on the JavaScript side! But don't rely on their actual values please. - -### Usage - -```res -let s = submit("hello"); /* gives Submit("hello") */ -``` - -This is useful: - -- When you're passing the accessor function as a higher-order function (which plain variant constructors aren't). -- When you'd like the JS side to use these values & functions opaquely and pass you back a variant constructor (since JS has no such thing). - -Please note that in case you just want to _pipe a payload into a constructor_, you don't need to generate functions for that. Use the `->` syntax instead, e.g. `"test"->Submit`. - -## Generate Field Accessors for Records - -Use `@deriving(accessors)` on a record type to create accessors for its record field names. - - - -```res -@deriving(accessors) -type pet = {name: string} - -let pets = [{name: "bob"}, {name: "bob2"}] - -pets - ->Belt.Array.map(name) - ->Js.Array2.joinWith("&") - ->Js.log -``` - -```js -function name(param) { - return param.name; -} - -var pets = [ - { - name: "bob", - }, - { - name: "bob2", - }, -]; - -console.log(Belt_Array.map(pets, name).join("&")); -``` - - - -## Generate Converters for JS Integer Enums and Variants - -Use `@deriving(jsConverter)` on a variant type to create converter functions that allow back and forth conversion between JS integer enum and ReScript variant values. - -```res -@deriving(jsConverter) -type fruit = - | Apple - | Orange - | Kiwi - | Watermelon; -``` - -This option causes `jsConverter` to, again, generate functions of the following types: - -```resi -let fruitToJs: fruit => int; - -let fruitFromJs: int => option; -``` - -For `fruitToJs`, each fruit variant constructor would map into an integer, starting at 0, in the order they're declared. - -For `fruitFromJs`, the return value is an `option`, because not every int maps to a constructor. - -You can also attach a `@as(1234)` to each constructor to customize their output. - -### Usage - -```res -@deriving(jsConverter) -type fruit = - | Apple - | @as(10) Orange - | @as(100) Kiwi - | Watermelon - -let zero = fruitToJs(Apple) /* 0 */ - -switch fruitFromJs(100) { -| Some(Kiwi) => Js.log("this is Kiwi") -| _ => Js.log("received something wrong from the JS side") -} -``` - -**Note**: by using `@as` here, all subsequent number encoding changes. `Apple` is still `0`, `Orange` is `10`, `Kiwi` is `100` and `Watermelon` is **`101`**! - -### More Safety - -Similar to the JS object \<-> record deriving, you can hide the fact that the JS enum are ints by using the same `newType` option with `@deriving(jsConverter)`: - -```res -@deriving({jsConverter: newType}) -type fruit = - | Apple - | @as(100) Kiwi - | Watermelon; -``` - -This option causes `@deriving(jsConverter)` to generate functions of the following types: - -```resi -let fruitToJs: fruit => abs_fruit; - -let fruitFromJs: abs_fruit => fruit; -``` - -For `fruitFromJs`, the return value, unlike the previous non-abstract type case, doesn't contain an `option`, because there's no way a bad value can be passed into it; the only creator of `abs_fruit` values is `fruitToJs`! - -#### Usage - -```res -@deriving({jsConverter: newType}) -type fruit = - | Apple - | @as(100) Kiwi - | Watermelon - -let opaqueValue = fruitToJs(Apple) - -@module("myJSFruits") external jsKiwi: abs_fruit = "iSwearThisIsAKiwi" -let kiwi = fruitFromJs(jsKiwi) - -let error = fruitFromJs(100) /* nope, can't take a random int */ -``` - -## Convert Record Type to Abstract Record - -> **Note**: For ReScript >= v7, we recommend using [plain records to compile to JS objects](bind-to-js-object#bind-to-record-like-js-objects). -> This feature might still be useful for certain scenarios, but the ergonomics might be worse - -Use `@deriving(abstract)` on a record type to expand the type into a creation, and a set of getter / setter functions for fields and methods. - -Usually you'd just use ReScript records to compile to JS objects of the same shape. There is still one particular use-case left where the `@deriving(abstract)` convertion is still useful: Whenever you need compile a record with an optional field where the JS object attribute shouldn't show up in the resulting JS when undefined (e.g. `{name: "Carl", age: undefined}` vs `{name: "Carl"}`). Check the [Optional Labels](#optional-labels) section for more infos on this particular scenario. - -### Usage Example - -```res -@deriving(abstract) -type person = { - name: string, - age: int, - job: string, -}; - -@val external john : person = "john"; -``` - -**Note**: the `person` type is **not** a record! It's a record-looking type that uses the record's syntax and type-checking. The `@deriving(abstract)` decorator turns it into an "abstract type" (aka you don't know what the actual value's shape). - -### Creation - -You don't have to bind to an existing `person` object from the JS side. You can also create such `person` JS object from ReScript's side. - -Since `@deriving(abstract)` turns the above `person` record into an abstract type, you can't directly create a person record as you would usually. This doesn't work: `{name: "Joe", age: 20, job: "teacher"}`. - -Instead, you'd use the **creation function** of the same name as the record type, implicitly generated by the `@deriving(abstract)` annotation: - - - -```res -let joe = person(~name="Joe", ~age=20, ~job="teacher") -``` - -```js -var joe = { - name: "Joe", - age: 20, - job: "teacher", -}; -``` - - - -Note how in the example above there is no JS runtime overhead. - -#### Rename Fields - -Sometimes you might be binding to a JS object with field names that are invalid in ReScript. Two examples would be `{type: "foo"}` (reserved keyword in ReScript) and `{"aria-checked": true}`. Choose a valid field name then use `@as` to circumvent this: - - - -```res -@deriving(abstract) -type data = { - @as("type") type_: string, - @as("aria-label") ariaLabel: string, -}; - -let d = data(~type_="message", ~ariaLabel="hello"); -``` - -```js -var d = { - type: "message", - "aria-label": "hello", -}; -``` - - - -#### Optional Labels - -You can omit fields during the creation of the object: - - - -```res -@deriving(abstract) -type person = { - @optional name: string, - age: int, - job: string, -}; - -let joe = person(~age=20, ~job="teacher", ()); -``` - -```js -var joe = { - age: 20, - job: "teacher", -}; -``` - - - -Optional values that are not defined, will not show up as an attribute in the resulting JS object. In the example above, you will see that `name` was omitted. - -**Note** that the `@optional` tag turned the `name` field optional. Merely typing `name` as `option` wouldn't work. - -**Note**: now that your creation function contains optional fields, we mandate an unlabeled `()` at the end to indicate that [you've finished applying the function](function#optional-labeled-arguments). - -### Accessors - -Again, since `@deriving(abstract)` hides the actual record shape, you can't access a field using e.g. `joe.age`. We remediate this by generating getter and setters. - -#### Read - -One getter function is generated per `@deriving(abstract)` record type field. In the above example, you'd get 3 functions: `nameGet`, `ageGet`, `jobGet`. They take in a `person` value and return `string`, `int`, `string` respectively: - -```res -let twenty = ageGet(joe) -``` - -Alternatively, you can use the [Pipe](pipe) operator (`->`) for a nicer-looking access syntax: - -```res -let twenty = joe->ageGet -``` - -If you prefer shorter names for the getter functions, we also support a `light` setting: - -```res -@deriving({abstract: light}) -type person = { - name: string, - age: int, -} - -let joe = person(~name="Joe", ~age=20) -let joeName = name(joe) -``` - -The getter functions will now have the same names as the object fields themselves. - -#### Write - -A `@deriving(abstract)` value is immutable by default. To mutate such value, you need to first mark one of the abstract record field as `mutable`, the same way you'd mark a normal record as mutable: - -```res -@deriving(abstract) -type person = { - name: string, - mutable age: int, - job: string, -} -``` - -Then, a setter of the name `ageSet` will be generated. Use it like so: - -```res -let joe = person(~name="Joe", ~age=20, ~job="teacher"); -ageSet(joe, 21); -``` - -Alternatively, with the Pipe First syntax: - -```res -joe->ageSet(21) -``` - -### Methods - -You can attach arbitrary methods onto a type (_any_ type, as a matter of fact. Not just `@deriving(abstract)` record types). See [Object Method](bind-to-js-function#object-method) in the "Bind to JS Function" section for more infos. - -### Tips & Tricks - -You can leverage `@deriving(abstract)` for finer-grained access control. - -#### Mutability - -You can mark a field as mutable in the implementation (`.res`) file, while _hiding_ such mutability in the interface file: - -```res -/* test.res */ -@deriving(abstract) -type cord = { - @optional mutable x: int, - y: int, -}; -``` - -```resi -/* test.resi */ -@deriving(abstract) -type cord = { - @optional x: int, - y: int, -}; -``` - -Tada! Now you can mutate inside your own file as much as you want, and prevent others from doing so! - -#### Hide the Creation Function - -Mark the record as `private` to disable the creation function: - -```res -@deriving(abstract) -type cord = private { - @optional x: int, - y: int, -} -``` - -The accessors are still there, but you can no longer create such data structure. Great for binding to a JS object while preventing others from creating more such object! - -#### Use submodules to prevent naming collisions and binding shadowing - -Oftentimes you will have multiple abstract types with similar attributes. Since -ReScript will expand all abstract getter, setter and creation functions in the -same scope where the type is defined, you will eventually run into value shadowing problems. - -**For example:** - -```res -@deriving(abstract) -type person = {name: string} - -@deriving(abstract) -type cat = { - name: string, - isLazy: bool, -}; - -let person = person(~name="Alice") - -/* Error: This expression has type person but an expression was expected - of type cat */ -person->nameGet() -``` - -To get around this issue, you can use modules to group a type with its related -functions and later use them via local open statements: - -```res -module Person = { - @deriving(abstract) - type t = {name: string} -} - -module Cat = { - @deriving(abstract) - type t = { - name: string, - isLazy: bool, - } -} - -let person = Person.t(~name="Alice") -let cat = Cat.t(~name="Snowball", ~isLazy=true) - -/* We can use each nameGet function separately now */ -let shoutPersonName = { - open Person - person->nameGet->Js.String.toUpperCase -} - -/* Note how we use a local `open Cat` expression to - get access to Cat's nameGet function */ -let whisperCatName = { - open Cat - cat->nameGet->Js.String.toLowerCase -} -``` - -## Convert External into JS Object Creation Function - -Use `@obj` on an `external` binding to create a function that, when called, will evaluate to a JS object with fields corresponding to the function's parameter labels. - -This is very handy because you can make some of those labelled parameters optional and if you don't pass them in, the output object won't include the corresponding fields. Thus you can use it to dynamically create objects with the subset of fields you need at runtime. - -For example, suppose you need a JavaScript object like this: - -```js -var homeRoute = { - type: "GET", - path: "/", - action: () => console.log("Home"), - // options: ... -}; -``` - -But only the first three fields are required; the options field is optional. You can declare the binding function like so: - -```res -@obj -external route: ( - ~\"type": string, - ~path: string, - ~action: list => unit, - ~options: {..}=?, - unit, -) => _ = "" -``` - -**Note**: the ` = ""` part at the end is just a dummy placeholder, due to syntactic limitations. It serves no purpose currently. - -This function has four labelled parameters (the fourth one optional), one unlabelled parameter at the end (which we mandate for functions with [optional parameters](function#optional-labeled-arguments), and one parameter (`\"type"`) that required quoting to [avoid clashing](use-illegal-identifier-names) with the reserved `type` keyword. - -Also of interest is the return type: `_`, which tells ReScript to automatically infer the full type of the JS object, sparing you the hassle of writing down the type manually! - -The function is called like so: - -```res -let homeRoute = route( - ~\"type"="GET", - ~path="/", - ~action=_ => Js.log("Home"), - (), -) -``` diff --git a/pages/docs/manual/v10.0.0/import-export.mdx b/pages/docs/manual/v10.0.0/import-export.mdx deleted file mode 100644 index 965a1b983..000000000 --- a/pages/docs/manual/v10.0.0/import-export.mdx +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: "Import & Export" -description: "Importing / exporting in ReScript modules" -canonical: "/docs/manual/latest/import-export" ---- - -# Import & Export - -## Import a Module/File - -Unlike JavaScript, ReScript doesn't have or need import statements: - - - -```res -// Inside School.res -let studentMessage = Student.message -``` - -```js -var Student = require("./Student.bs"); -var studentMessage = Student.message; -``` - - - -The above code refers to the `message` binding in the file `Student.res`. Every ReScript file is also a module, so accessing another file's content is the same as accessing another module's content! - -A ReScript project's file names need to be unique. - -## Export Stuff - -By default, every file's type declaration, binding and module is exported, aka publicly usable by another file. **This also means those values, once compiled into JS, are immediately usable by your JS code**. - -To only export a few selected things, use a `.resi` [interface file](module.md#signatures). - -## Work with JavaScript Import & Export - -To see how to import JS modules and export stuff for JS consumption, see the JavaScript Interop section's [Import from/Export to JS](import-from-export-to-js.md). diff --git a/pages/docs/manual/v10.0.0/import-from-export-to-js.mdx b/pages/docs/manual/v10.0.0/import-from-export-to-js.mdx deleted file mode 100644 index 3465a3cc5..000000000 --- a/pages/docs/manual/v10.0.0/import-from-export-to-js.mdx +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: "Import from / Export to JS" -description: "Importing / exporting JS module content in ReScript" -canonical: "/docs/manual/latest/import-from-export-to-js" ---- - -# Import from/Export to JS - -You've seen how ReScript's idiomatic [Import & Export](import-export.md) works. This section describes how we work with importing stuff from JavaScript and exporting stuff for JavaScript consumption. - -**Note**: due to JS ecosystem's module compatibility issues, our advice of keeping your ReScript file's compiled JS output open in a tab applies here **more than ever**, as you don't want to subtly output the wrong JS module import/export code, on top of having to deal with Babel/Webpack/Jest/Node's CommonJS\<->ES6 compatibility shims. - -In short: **make sure your bindings below output what you'd have manually written in JS**. - -## Output Format - -We support 2 JavaScript import/export formats: - -- CommonJS: `require('myFile')` and `module.exports = ...`. -- ES6 modules: `import * from 'MyReScriptFile'` and `export let ...`. - -The format is [configurable in via `bsconfig.json`](build-configuration.md#package-specs). - -## Import From JavaScript - -### Import a JavaScript Module's Named Export - -Use the `module` [external](external.md): - - - -```res example -// Import nodejs' path.dirname -@module("path") external dirname: string => string = "dirname" -let root = dirname("/User/github") // returns "User" -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - -```js -import * as Path from "path"; -var root = Path.dirname("/User/github"); -``` - - - -Here's what the `external` does: - -- `@module("path")`: pass the name of the JS module; in this case, `"path"`. The string can be anything: `"./src/myJsFile"`, `"@myNpmNamespace/myLib"`, etc. -- `external`: the general keyword for declaring a value that exists on the JS side. -- `dirname`: the binding name you'll use on the ReScript side. -- `string => string`: the type signature of `dirname`. Mandatory for `external`s. -- `= "dirname"`: the name of the variable inside the `path` JS module. There's repetition in writing the first and second `dirname`, because sometime the binding name you want to use on the ReScript side is different than the variable name the JS module exported. - -### Import a JavaScript Module As a Single Value - -By omitting the string argument to `module`, you bind to the whole JS module: - - - -```res example -@module external leftPad: string => int => string = "./leftPad" -let paddedResult = leftPad("hi", 5) -``` - -```js -var LeftPad = require("./leftPad"); -var paddedResult = LeftPad("hi", 5); -``` - -```js -import * as LeftPad from "./leftPad"; -var paddedResult = LeftPad("hi", 5); -``` - - - -Depending on whether you're compiling ReScript to CommonJS or ES6 module, **this feature will generate subtly different code**. Please check both output tabs to see the difference. The ES6 output here would be wrong! - -### Import an ES6 Default Export - -Use the value `"default"` on the right hand side: - - - -```res example -@module("./student") external studentName: string = "default" -Js.log(studentName) -``` - -```js -import Student from "./student"; -var studentName = Student; -``` - - - -## Export To JavaScript - -### Export a Named Value - -As mentioned in ReScript's idiomatic [Import & Export](import-export.md), every let binding and module is exported by default to other ReScript modules (unless you use a `.resi` [interface file](module#signatures)). If you open up the compiled JS file, you'll see that these values can also directly be used by a _JavaScript_ file too. - -### Export an ES6 Default Value - -If your JS project uses ES6 modules, you're likely exporting & importing some default values: - -```js -// student.js -export default name = "Al"; -``` - -```js -// teacher.js -import studentName from "student.js"; -``` - -A JavaScript default export is really just syntax sugar for a named export implicitly called `default` (now you know!). So to export a default value from ReScript, you can just do: - - - -```res example -// ReScriptStudent.res -let default = "Bob" -``` - -```js -var $$default = "Bob"; - -exports.$$default = $$default; -exports.default = $$default; -// informal transpiler-compatible marker of a default export compiled from ES6 -exports.__esModule = true; -``` - -```js -var $$default = "Bob"; - -export { $$default, $$default as default }; -``` - - - -You can then import this default export as usual on the JS side: - -```js -// teacher2.js -import studentName from "ReScriptStudent.js"; -``` - -If your JavaScript's ES6 default import is transpiled by Babel/Webpack/Jest into CommonJS `require`s, we've taken care of that too! See the CommonJS output tab for `__esModule`. diff --git a/pages/docs/manual/v10.0.0/inlining-constants.mdx b/pages/docs/manual/v10.0.0/inlining-constants.mdx deleted file mode 100644 index 5673c1e93..000000000 --- a/pages/docs/manual/v10.0.0/inlining-constants.mdx +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: "Inlining Constants" -description: "Inlining constants" -canonical: "/docs/manual/latest/inlining-constants" ---- - -# Inlining Constants - -Sometime, in the JavaScript output, you might want a certain value to be forcefully inlined. For example: - -```js -if (process.env.mode === "development") { - console.log("Dev-only code here!"); -} -``` - -The reason is that your JavaScript bundler (e.g. Webpack) might turn that into: - -```js -if ("production" === "development") { - console.log("Dev-only code here!"); -} -``` - -Then your subsequent Uglifyjs optimization would remove that entire `if` block. This is how projects like ReactJS provide a development mode code with plenty of dev warnings, while ensuring that the uglified (minified) production code is free of those expensive blocks. - -So, in ReScript, producing that example `if (process.env.mode === 'development')` output is important. This first try doesn't work: - - - -```res example -@val external process: 'a = "process" - -let mode = "development" - -if (process["env"]["mode"] === mode) { - Js.log("Dev-only code here!") -} -``` - -```js -var mode = "development"; - -if (process.env.mode === mode) { - console.log("Dev-only code here!"); -} -``` - - - -The JS output shows `if (process.env.mode === mode)`, which isn't what we wanted. To inline `mode`'s value, use `@inline`: - - - -```res example -@val external process: 'a = "process" - -@inline -let mode = "development" - -if (process["env"]["mode"] === mode) { - Js.log("Dev-only code here!") -} -``` - -```js -if (process.env.mode === "development") { - console.log("Dev-only code here!"); -} -``` - - - -Now your resulting JS code can pass through Webpack and Uglifyjs like the rest of your JavaScript code, and that whole `console.log` can be removed. - -The inlining currently only works for **string, float and boolean**. - -## Tips & Tricks - -This is **not** an optimization. This is an edge-case feature for folks who absolutely need particular values inlined for a JavaScript post-processing step, like conditional compilation. Beside the difference in code that the conditional compilation might end up outputting, there's no performance difference between inlining and not inlining simple values in the eyes of a JavaScript engine. diff --git a/pages/docs/manual/v10.0.0/installation.mdx b/pages/docs/manual/v10.0.0/installation.mdx deleted file mode 100644 index da0a5ae9b..000000000 --- a/pages/docs/manual/v10.0.0/installation.mdx +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: "Installation" -description: "ReScript installation and setup instructions" -canonical: "/docs/manual/latest/installation" ---- - -# Installation - -## Prerequisites - -- [Node.js](https://nodejs.org/) version >= 14 -- [npm](https://docs.npmjs.com/cli/) (which comes with Node.js) or [Yarn](https://yarnpkg.com/) - -## New Project - -```sh -git clone https://github.com/rescript-lang/rescript-project-template -cd rescript-project-template -npm install -npm run res:build -node src/Demo.bs.js -``` - -That compiles your ReScript into JavaScript, then uses Node.js to run said JavaScript. **We recommend you use our unique workflow of keeping a tab open for the generated `.bs.js` file**, so that you can learn how ReScript transforms into JavaScript. Not many languages output clean JavaScript code you can inspect and learn from! - -During development, instead of running `npm run res:build` each time to compile, use `npm run res:dev` to start a watcher that recompiles automatically after file changes. - -## Integrate Into an Existing JS Project - -If you already have a JavaScript project into which you'd like to add ReScript: - -- Install ReScript locally: - ```sh - npm install rescript - ``` -- Create a ReScript build configuration at the root: - ```json - { - "name": "your-project-name", - "sources": [ - { - "dir": "src", // update this to wherever you're putting ReScript files - "subdirs": true - } - ], - "package-specs": [ - { - "module": "es6", - "in-source": true - } - ], - "suffix": ".bs.js", - "bs-dependencies": [] - } - ``` - See [Build Configuration](build-configuration) for more details on `bsconfig.json`. -- Add convenience `npm` scripts to `package.json`: - ```json - "scripts": { - "res:build": "rescript", - "res:dev": "rescript build -w" - } - ``` - -Since ReScript compiles to clean readable JS files, the rest of your existing toolchain (e.g. Babel and Webpack) should just work! - -Helpful guides: - -- [Converting from JS](converting-from-js). -- [Shared Data Types](shared-data-types). -- [Import from/Export to JS](import-from-export-to-js). - -### Integrate with a ReactJS Project - -To start a [rescript-react](/docs/react/latest/introduction) app, or to integrate ReScript into an existing ReactJS app, follow the instructions [here](/docs/react/latest/installation). diff --git a/pages/docs/manual/v10.0.0/interop-cheatsheet.mdx b/pages/docs/manual/v10.0.0/interop-cheatsheet.mdx deleted file mode 100644 index 7e713fee6..000000000 --- a/pages/docs/manual/v10.0.0/interop-cheatsheet.mdx +++ /dev/null @@ -1,259 +0,0 @@ ---- -title: "Interop Cheatsheet" -description: "Cheatsheet for various interop scenarios in ReScript" -canonical: "/docs/manual/latest/interop-cheatsheet" ---- - -# Interop Cheatsheet - -This is a glossary with examples. All the features are described by later pages. - -## List of Decorators - -> **Note:** In ReScript \<8.3, all our attributes started with the `bs.` prefix. This is no longer needed and our formatter automatically removes them in newer ReScript versions. - - - -### Attributes - -- `@as`: [here](attribute#usage), [here](bind-to-js-function#fixed-arguments), [here](bind-to-js-function#constrain-arguments-better) and [here](generate-converters-accessors#usage-3) -- [`@deriving`](generate-converters-accessors#generate-functions--plain-values-for-variants) -- [`@get`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@get_index`](bind-to-js-object#bind-using-special-bs-getters--setters) - -- [`@inline`](inlining-constants) -- [`@int`](bind-to-js-function#constrain-arguments-better) - -- [`@module`](import-from-export-to-js#import-a-javascript-modules-content) -- [`@new`](bind-to-js-object#bind-to-a-js-object-thats-a-class) -- [`@obj`](generate-converters-accessors#convert-external-into-js-object-creation-function) -- [`@optional`](generate-converters-accessors#optional-labels) -- [`@return`](bind-to-js-function#function-nullable-return-value-wrapping) -- `@send`: [here](bind-to-js-function#object-method) and [here](pipe#js-method-chaining) -- [`@scope`](bind-to-global-js-values#global-modules) -- [`@set`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@set_index`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@variadic`](bind-to-js-function#variadic-function-arguments) -- [`@string`](bind-to-js-function#constrain-arguments-better) -- [`@this`](bind-to-js-function#modeling-this-based-callbacks) -- [`@uncurry`](bind-to-js-function#extra-solution) -- [`@unwrap`](bind-to-js-function#trick-2-polymorphic-variant--bsunwrap) -- [`@val`](bind-to-global-js-values#global-modules) - -- [`@deprecated`](attribute#usage) -- [`genType`](https://github.com/reason-association/genType) -- [`@JSX`](jsx) -- `@react.component`: [here](/docs/react/latest/introduction) and [here](https://github.com/reasonml/reason-react) -- [`@warning`](attribute#usage) -- [`@unboxed`](unboxed) - -### Extension Points - -- [`%debugger`](embed-raw-javascript#debugger) -- [`%external`](bind-to-global-js-values#special-global-values) - - -- [`%raw`](embed-raw-javascript#paste-raw-js-code) -- [`%re`](primitive-types#regular-expression) - -## Raw JS - - - -```res example -let add = %raw("(a, b) => a + b") -%%raw("const a = 1") -``` - -```js -var add = (a, b) => a + b; -const a = 1; -``` - - - -## Global Value - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -``` - -```js -// Empty output -``` - - - -## Global Module's Value - - - -```res example -@val @scope("Math") -external random: unit => float = "random" - -let someNumber = random() - -@val @scope(("window", "location", "ancestorOrigins")) -external length: int = "length" -``` - -```js -var someNumber = Math.random(); -``` - - - -## Nullable - - - -```res example -let a = Some(5) // compiles to 5 -let b = None // compiles to undefined -``` - -```js -var a = 5; -var b; -``` - - - -Handling a value that can be `undefined` and `null`, by ditching the `option` type and using `Js.Nullable.t`: - - - -```res example -let jsNull = Js.Nullable.null -let jsUndefined = Js.Nullable.undefined -let result1: Js.Nullable.t = Js.Nullable.return("hello") -let result2: Js.Nullable.t = Js.Nullable.fromOption(Some(10)) -let result3: option = Js.Nullable.toOption(Js.Nullable.return(10)) -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); -var Js_null_undefined = require("./stdlib/js_null_undefined.js"); - -var jsNull = null; -var jsUndefined; -var result1 = "hello"; -var result2 = Js_null_undefined.fromOption(10); -var result3 = Caml_option.nullable_to_opt(10); -``` - - - -## JS Object - -- [Bind to a JS object as a ReScript record](bind-to-js-object#bind-to-record-like-js-objects). -- [Bind to a JS object that acts like a hash map](bind-to-js-object#bind-to-hash-map-like-js-object). -- [Bind to a JS object that's a class](bind-to-js-object#bind-to-a-js-object-thats-a-class). - -## Function - -### Object Method & Chaining - - - -```res example -@send external map: (array<'a>, 'a => 'b) => array<'b> = "map" -@send external filter: (array<'a>, 'a => 'b) => array<'b> = "filter" -[1, 2, 3] - ->map(a => a + 1) - ->filter(a => mod(a, 2) == 0) - ->Js.log -``` - -```js -console.log( - [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }), -); -``` - - - -### Variadic Arguments - - - -```res example -@module("path") @variadic -external join: array => string = "join" -``` - -```js -// Empty output -``` - - - -### Polymorphic Function - - - -```res example -@module("Drawing") external drawCat: unit => unit = "draw" -@module("Drawing") external drawDog: (~giveName: string) => unit = "draw" -``` - -```js -// Empty output -``` - - - - - -```res example -@val -external padLeft: ( - string, - @unwrap [ - | #Str(string) - | #Int(int) - ]) - => string = "padLeft" - -padLeft("Hello World", #Int(4)) -padLeft("Hello World", #Str("Message from ReScript: ")) -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -## JS Module Interop - -[See here](import-from-export-to-js.md) - -## Dangerous Type Cast - -Final escape hatch converter. Do not abuse. - - - -```res example -external convertToFloat: int => float = "%identity" -let age = 10 -let gpa = 2.1 +. convertToFloat(age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - diff --git a/pages/docs/manual/v10.0.0/interop-with-js-build-systems.mdx b/pages/docs/manual/v10.0.0/interop-with-js-build-systems.mdx deleted file mode 100644 index 00d36b028..000000000 --- a/pages/docs/manual/v10.0.0/interop-with-js-build-systems.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Interop with JS Build Systems" -description: "Documentation on how to interact with existing JS build systems" -canonical: "/docs/manual/latest/interop-with-js-build-systems" ---- - -# Interop with JS Build Systems - -If you come from JS, chances are that you already have a build system in your existing project. Here's an overview of the role `rescript` would play in your build pipeline, if you want to introduce some ReScript code. - -> **Please** try not to wrap `rescript` into your own incremental build framework. ReScript's compilation is very hard to get right, and you'll inevitably run into stale or badly performing builds (therefore erasing much of our value proposition) if you create your own meta layer on top. - -## Popular JS Build Systems - -The JS ecosystem uses a few build systems: [browserify](http://browserify.org/), [rollup](https://github.com/rollup/rollup), [webpack](https://webpack.js.org/), etc. The latter's probably the most popular of the three (as of 2019 =P). These build systems do both the compilation and the linking (aka, bundling many files into one or few files). - -`rescript` only take care of the compilation step; it maps one `.res`/`.resi` file into one JS output file. As such, in theory, no build system integration is needed from our side. From e.g. the webpack watcher's perspective, the JS files ReScript generates are almost equivalent to your hand-written JS files. We also recommend **that you initially check in those ReScript-generated JS files**, as this workflow means: - -- You can introduce ReScript silently into your codebase without disturbing existing infra. -- You have a **visual** diff of the performance & correctness of your JS file when you update the `.res` files and the JS artifacts change. -- You can let teammates hot-patch the JS files in emergency situations, without needing to first start learning ReScript. -- You can remove ReScript completely from your codebase and things will still work (in case your company decides to stop using us for whatever reason). - -For what it's worth, you can also turn `rescript` into an automated step in your build pipeline, e.g. into a Webpack loader; but such approach is error-prone and therefore discouraged. - -### Tips & Tricks - -You can make ReScript JS files look even more idiomatic through the in-source + bs suffix config in `bsconfig.json`: - -```json -{ - "package-specs": { - "module": "commonjs", // or whatever module system your project uses - "in-source": true - }, - "suffix": ".bs.js" -} -``` - -This will: - -- Generate the JS files alongside your ReScript source files. -- Use the file extension `.bs.js`, so that you can require these files on the JS side through `require('./MyFile.bs')`, without needing a loader. - -## Use Loaders on ReScript Side - -"What if my build system uses a CSS/png/whatever loader and I'd like to use it in ReScript?" - -Loaders are indeed troublesome; in the meantime, please use e.g. `%raw("require('./myStyles.css')")` at the top of your file. This just uses [`raw`](embed-raw-javascript.md) to compile the snippet into an actual JS require. - -## Getting Project's Dependencies - -`rescript` generates one `MyFile.d` file per `MyFile` source file; you'll find them in `lib/bs`. These are human readable, machine-friendly list of the dependencies of said `MyFile`. You can read into them for your purpose (though mind the IO overhead). Use these files instead of creating your own dependency graph; we did the hard work of tracking the dependencies as best as possible (including inner modules, `open`s, module names overlap, etc). - -## Run Script Per File Built - -See [js-post-build](build-configuration#js-post-build). Though please use it sparingly; if you hook up a node.js script after each file built, you'll incur the node startup time per file! diff --git a/pages/docs/manual/v10.0.0/introduction.mdx b/pages/docs/manual/v10.0.0/introduction.mdx deleted file mode 100644 index ab8764d7b..000000000 --- a/pages/docs/manual/v10.0.0/introduction.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: "Introduction" -description: "The hows and whys of ReScript" -canonical: "/docs/manual/latest/introduction" ---- - -# ReScript - -Ever wanted a language like JavaScript, but without the warts, with a great type system, and with a lean build toolchain that doesn't waste your time? - -ReScript looks like JS, acts like JS, and compiles to the highest quality of clean, readable and performant JS, directly runnable in browsers and Node. - -**This means you can pick up ReScript and access the vast JavaScript ecosystem and tooling as if you've known ReScript for a long time!** - -**ReScript is the language for folks who don't necessarily love JavaScript, but who still acknowledge its importance**. - -## Difference vs TypeScript - -We respect TypeScript very much and think that it's a positive force in the JavaScript ecosystem. ReScript shares some of the same goals as TypeScript, but is different enough regarding some important nuances: - -- TypeScript's (admittedly noble) goal is to cover the entire JavaScript feature set and more. **ReScript covers only a curated subset of JavaScript**. For example, we emphasize plain data + functions over classes, clean [pattern matching](pattern-matching-destructuring.md) over fragile `if`s and virtual dispatches, [proper data modeling](variant.md) over string abuse, etc. JavaScript supersets will only grow larger over time; ReScript doesn't. \* - -- Consequently, TypeScript's type system is necessarily complex, pitfalls-ridden, potentially requires tweaking, sometimes slow, and requires quite a bit of noisy annotations that often feel like manual bookkeeping rather than clear documentation. In contrast, ReScript's type system: - - Is deliberately curated to be a simple subset most folks will have an easier time to use. - - Has **no** pitfalls, aka the type system is "sound" (the types will always be correct). E.g. If a type isn't marked as nullable, its value will never lie and let through some `undefined` value silently. **ReScript code has no null/undefined errors**. - - Is the same for everyone. No knobs, no bikeshedding opportunity. - - Runs extremely fast precisely thanks to its simplicity and curation. It's one of the fastest compiler & build system toolchains for JavaScript development. - - **Doesn't need type annotations**. Annotate as much or as little as you'd like. The types are inferred by the language (and, again, are guaranteed correct). - -- Migrating to TypeScript is done "breadth-first," whereas migrating to ReScript is done "depth-first." You can convert your codebase to TypeScript by "turning it on" for all files and annotate here and there; but how much type safety did you gain? How do you measure it? Type errors can still slip in and out of the converted pieces. For ReScript, our interop features draw clear boundaries: there's pure ReScript code, and there's JS interop code. Every piece of converted ReScript code is 100% clean. You'd convert file by file and each conversion increases your safety monotonically. - -\* When you absolutely need to write or interoperate with free-for-all JavaScript, we expose enough escape hatches for you. - -## Other Highlights - -Aside from the aforementioned simple, robust and fast type system, ReScript presents a few more advantages. - -### Faster than JavaScript - -JavaScript's been aggressively optimized by talented engineers over a long span. Unfortunately, even for seasoned JS devs, it can be hard to know how to properly leverage JS's performance. ReScript's type system and compiler naturally guides you toward writing code that's very often performant by default, with good leverage of various Just-In-Time optimizations (hidden classes, inline caching, avoiding deopts, etc). - -A widespread adage to write fast JavaScript code is to write as if there's a type system (in order to trigger JS engines' good optimization heuristics); ReScript gives you a real one and generates code that's friendly to optimizations by default. - -### High Quality Dead Code Elimination - -The JavaScript ecosystem is very reliant on dependencies. Shipping the final product inevitably drags in a huge amount of code, lots of which the project doesn't actually use. These regions of dead code impact loading, parsing and interpretation speed. ReScript provides powerful dead code elimination at all levels: - -- Function- and module-level code elimination is facilitated by the well-engineered type system and purity analysis. -- At the global level, ReScript generates code that is naturally friendly to dead code elimination done by bundling tools such as [Rollup](https://github.com/rollup/rollup) and [Closure Compiler](https://developers.google.com/closure/compiler/), after its own sophisticated elimination pass. -- The same applies for ReScript's own tiny runtime (which is written in ReScript itself). - -### Tiny JS Output - -A `Hello world` ReScript program generates **20 bytes** of JS code. Additionally, the standard library pieces you require in are only included when needed. - -### Fast Iteration Loop - -ReScript's build time is **one or two orders of magnitude** faster than alternatives. In its watcher mode, the build system usually finishes before you switch screen from the editor to the terminal tab (two digits of milliseconds). A fast iteration cycle reduces the need of keeping one's mental state around longer; this in turn allows one to stay in the flow longer and more often. - -### Readable Output & Great Interop - -Unreadable JavaScript code generated from other compiled-to-js languages makes it so that it could be, practically speaking: - -- Hard to debug (cryptic stack trace, mangled variable names) -- Hard to learn from (non-straightforward mapping of concepts from one language to another) -- Hard to profile for performance (unclear what runtime performance cost there is) -- Hard to integrate with existing hand-written JS code - -ReScript's JS output is very readable. This is especially important while learning, where users might want to understand how the code's compiled, and to audit for bugs. - -This characteristic, combined with a fully-featured JS interop system, allows ReScript code to be inserted into an existing JavaScript codebase almost unnoticed. - -### Preservation of Code Structure - -ReScript maps one source file to one JavaScript output file. This eases the integration of existing tools such as bundlers and test runners. You can even start writing a single file without much change to your build setup. Each file's code structure is approximately preserved, too. - -## Conclusion - -We hope the above gave you enough of an idea of ReScript and its differentiators. Feel free to [try it online](/try) to get a feel! diff --git a/pages/docs/manual/v10.0.0/json.mdx b/pages/docs/manual/v10.0.0/json.mdx deleted file mode 100644 index 55c0efee3..000000000 --- a/pages/docs/manual/v10.0.0/json.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: "JSON" -description: "Interacting with JSON in ReScript" -canonical: "/docs/manual/latest/json" ---- - -# JSON - -## Parse - -Bind to JavaScript's `JSON.parse` and type the return value as the type you're expecting: - - - -```res example -// declare the shape of the json you're binding to -type data = {names: array} - -// bind to JS' JSON.parse -@scope("JSON") @val -external parseIntoMyData: string => data = "parse" - -let result = parseIntoMyData(`{"names": ["Luke", "Christine"]}`) -let name1 = result.names[0] -``` - -```js -var result = JSON.parse('{"names": ["Luke", "Christine"]}'); -var name1 = result.names[0]; -``` - - - -Where `data` can be any type you assume the JSON is. As you can see, this compiles to a straightforward `JSON.parse` call. As with regular JS, this is convenient, but has no guarantee that e.g. the data is correctly shaped, or even syntactically valid. Slightly dangerous. - -## Stringify - -Use `Js.Json.stringify`: - - - -```res example -Js.log(Js.Json.stringifyAny(["Amy", "Joe"])) -``` - -```js -console.log(JSON.stringify(["Amy", "Joe"])); -``` - - - -## Advanced - -The [Js.Json](api/js/json) module provides slightly safer, low-level building blocks for power users who want to parse JSON on a per-field basis. See the examples in the API docs. diff --git a/pages/docs/manual/v10.0.0/jsx.mdx b/pages/docs/manual/v10.0.0/jsx.mdx deleted file mode 100644 index 8d74da834..000000000 --- a/pages/docs/manual/v10.0.0/jsx.mdx +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: "JSX" -description: "JSX syntax in ReScript and React" -canonical: "/docs/manual/latest/jsx" ---- - -# JSX - -Would you like some HTML syntax in your ReScript? If not, quickly skip over this section and pretend you didn't see anything! - -ReScript supports the JSX syntax, with some slight differences compared to the one in [ReactJS](https://facebook.github.io/react/docs/introducing-jsx.html). ReScript JSX isn't tied to ReactJS; they translate to normal function calls: - -**Note** for [ReScriptReact](https://rescript-lang.org/docs/react/latest/introduction) readers: this isn't what ReScriptReact turns JSX into, in the end. See Usage section for more info. - -## Capitalized - - - -```res - -``` - -```js -React.createElement(MyComponent, { - name: "ReScript", -}); -``` - - - -becomes - - - -```res -MyComponent.createElement(~name="ReScript", ~children=list{}, ()) -``` - -```js -React.createElement(MyComponent, { - name: "ReScript", -}); -``` - - - -## Uncapitalized - - - -```res -
child1 child2
-``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - -
- -becomes - - - -```res -div(~onClick=handler, ~children=list{child1, child2}, ()) -``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - - - -## Fragment - - - -```res -<> child1 child2 -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -becomes - - - -```res -list{child1, child2} -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -### Children - - - -```res - child1 child2 -``` - -```js -React.createElement(MyComponent, { children: null }, child1, child2); -``` - - - -This is the syntax for passing a list of two items, `child1` and `child2`, to the children position. It transforms to a list containing `child1` and `child2`: - - - -```res -MyComponent.createElement(~children=list{child1, child2}, ()) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(null, undefined), - child1, - child2, -); -``` - - - -**Note** again that this isn't the transform for ReScriptReact; ReScriptReact turns the final list into an array. But the idea still applies. - -So naturally, ` myChild ` is transformed to `MyComponent.createElement(~children=list{myChild}, ())`. I.e. whatever you do, the arguments passed to the children position will be wrapped in a list. - -## Usage - -See [ReScriptReact Elements & JSX](https://rescript-lang.org/docs/react/latest/elements-and-jsx) for an example application of JSX, which transforms the above calls into a ReScriptReact-specific call. - -Here's a JSX tag that shows most of the features. - - - -```res - -
{React.string("hello")}
-
-``` - -```js -React.createElement(MyComponent, { - children: React.createElement("div", undefined, "hello"), - booleanAttribute: true, - stringAttribute: "string", - intAttribute: 1, - forcedOptional: "hello", - onClick: handleClick, -}); -``` - -
- -## Departures From JS JSX - -- Attributes and children don't mandate `{}`, but we show them anyway for ease of learning. Once you format your file, some of them go away and some turn into parentheses. -- Props spread is supported, but there are some restrictions (see below). -- Punning! - -### Spread Props (from v10.1) - -JSX props spread is supported now, but in a stricter way than in JS. - - - -```res - -``` - -```js -React.createElement(Comp, { - a: "a", - b: "b", -}); -``` - - - -Multiple spreads are not allowed: - - - -```res - -``` - - - -The spread must be at the first position, followed by other props: - - - -```res - -``` - - - -### Punning - -"Punning" refers to the syntax shorthand for when a label and a value are the same. For example, in JavaScript, instead of doing `return {name: name}`, you can do `return {name}`. - -JSX supports punning. `` is just a shorthand for ``. The formatter will help you format to the punned syntax whenever possible. This is convenient in the cases where there are lots of props to pass down: - - - -```res - -``` - -```js -React.createElement(MyComponent, { - isLoading: true, - text: text, - onClick: onClick, -}); -``` - - - -Consequently, a JSX component can cram in a few more props before reaching for extra libraries solutions that avoids props passing. - -**Note** that this is a departure from ReactJS JSX, which does **not** have punning. ReactJS' `` desugars to ``, in order to conform to DOM's idioms and for backward compatibility. - -## Tip & Tricks - -For library authors wanting to take advantage of the JSX: the `@JSX` attribute is a hook for potential ppx macros to spot a function wanting to format as JSX. Once you spot the function, you can turn it into any other expression. - -This way, everyone gets to benefit the JSX syntax without needing to opt into a specific library using it, e.g. ReScriptReact. - -JSX calls supports the features of [labeled arguments](function.md#labeled-arguments): optional, explicitly passed optional and optional with default. diff --git a/pages/docs/manual/v10.0.0/lazy-values.mdx b/pages/docs/manual/v10.0.0/lazy-values.mdx deleted file mode 100644 index 5ef3ab575..000000000 --- a/pages/docs/manual/v10.0.0/lazy-values.mdx +++ /dev/null @@ -1,128 +0,0 @@ ---- -title: "Lazy Value" -description: "Data type for deferred computation in ReScript" -canonical: "/docs/manual/latest/lazy-values" ---- - -# Lazy Value - -If you have some expensive computations you'd like to **defer and cache** subsequently, you can wrap it with `lazy`: - - - -```res prelude -// Read the directory, only once -let expensiveFilesRead = lazy({ - Js.log("Reading dir") - Node.Fs.readdirSync("./pages") -}) -``` - -```js -var Fs = require("fs"); - -var expensiveFilesRead = { - LAZY_DONE: false, - VAL: function () { - console.log("Reading dir"); - return Fs.readdirSync("./pages"); - }, -}; -``` - - - -Check the JS Output tab: that `expensiveFilesRead`'s code isn't executed yet, even though you declared it! You can carry it around without fearing that it'll run the directory read. - -**Note**: a lazy value is **not** a [shared data type](shared-data-types.md). Don't rely on its runtime representation in your JavaScript code. - -## Execute The Lazy Computation - -To actually run the lazy value's computation, use `Lazy.force` from the globally available `Lazy` module: - - - -```res example -// First call. The computation happens -Js.log(Lazy.force(expensiveFilesRead)) // logs "Reading dir" and the directory content - -// Second call. Will just return the already calculated result -Js.log(Lazy.force(expensiveFilesRead)) // logs the directory content -``` - -```js -console.log(CamlinternalLazy.force(expensiveFilesRead)); - -console.log(CamlinternalLazy.force(expensiveFilesRead)); -``` - - - -The first time `Lazy.force` is called, the expensive computation happens and the result is **cached**. The second time, the cached value is directly used. - -**You can't re-trigger the computation after the first `force` call**. Make sure you only use a lazy value with computations whose results don't change (e.g. an expensive server request whose response is always the same). - -Instead of using `Lazy.force`, you can also use [pattern matching](pattern-matching-destructuring.md) to trigger the computation: - - - -```res example -switch expensiveFilesRead { -| lazy(result) => Js.log(result) -} -``` - -```js -var result = CamlinternalLazy.force(expensiveFilesRead); -``` - - - -Since pattern matching also works on a `let` binding, you can also do: - - - -```res example -let lazy(result) = expensiveFilesRead -Js.log(result) -``` - -```js -var result = CamlinternalLazy.force(expensiveFilesRead); -console.log(result); -``` - - - -## Exception Handling - -For completeness' sake, our files read example might raise an exception because of `readdirSync`. Here's how you'd handle it: - - - -```res example -let result = try { - Lazy.force(expensiveFilesRead) -} catch { -| Not_found => [] // empty array of files -} -``` - -```js -var result; - -try { - result = CamlinternalLazy.force(expensiveFilesRead); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - result = []; - } else { - throw exn; - } -} -``` - - - -Though you should probably handle the exception inside the lazy computation itself. diff --git a/pages/docs/manual/v10.0.0/let-binding.mdx b/pages/docs/manual/v10.0.0/let-binding.mdx deleted file mode 100644 index 2f20a679a..000000000 --- a/pages/docs/manual/v10.0.0/let-binding.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -title: "Let Binding" -description: "Let binding syntax for binding to values in ReScript" -canonical: "/docs/manual/latest/let-binding" ---- - -# Let Binding - -A "let binding", in other languages, might be called a "variable declaration". `let` _binds_ values to names. They can be seen and referenced by code that comes _after_ them. - - - -```res example -let greeting = "hello!" -let score = 10 -let newScore = 10 + score -``` - -```js -var greeting = "hello!"; -var score = 10; -var newScore = 20; -``` - - - -## Block Scope - -Bindings can be scoped through `{}`. - - - -```res example -let message = { - let part1 = "hello" - let part2 = "world" - part1 ++ " " ++ part2 -} -// `part1` and `part2` are not accessible here! -``` - -```js -var message = "hello world"; -``` - - - -The value of the last line of a scope is implicitly returned. - -### Design Decisions - -ReScript's `if`, `while` and functions all use the same block scoping mechanism. The code below works **not** because of some special "if scope"; but simply because it's the same scope syntax and feature you just saw: - - - -```res -if displayGreeting { - let message = "Enjoying the docs so far?" - Js.log(message) -} -// `message` not accessible here! -``` - -```js -if (displayGreeting) { - console.log("Enjoying the docs so far?"); -} -``` - - - -## Bindings Are Immutable - -Let bindings are "immutable", aka "cannot change". This helps our type system deduce and optimize much more than other languages (and in turn, help you more). - -## Binding Shadowing - -The above restriction might sound impractical at first. How would you change a value then? Usually, 2 ways: - -The first is to realize that many times, what you want isn't to mutate a variable's value. For example, this JavaScript pattern: - -```js -var result = 0; -result = calculate(result); -result = calculateSomeMore(result); -``` - -...is really just to comment on intermediate steps. You didn't need to mutate `result` at all! You could have just written this JS: - -```js -var result1 = 0; -var result2 = calculate(result1); -var result3 = calculateSomeMore(result2); -``` - -In ReScript, this obviously works too: - - - -```res -let result1 = 0 -let result2 = calculate(result1) -let result3 = calculateSomeMore(result2) -``` - -```js -var result1 = 0; -var result2 = calculate(0); -var result3 = calculateSomeMore(result2); -``` - - - -Additionally, reusing the same let binding name overshadows the previous bindings with the same name. So you can write this too: - - - -```res -let result = 0 -let result = calculate(result) -let result = calculateSomeMore(result) -``` - -```js -var result = calculate(0); -var result$1 = calculateSomeMore(result); -``` - - - -(Though for the sake of clarity, we don't recommend this). - -As a matter of fact, even this is valid code: - - - -```res example -let result = "hello" -Js.log(result) // prints "hello" -let result = 1 -Js.log(result) // prints 1 -``` - -```js -var result = 1; -console.log("hello"); -console.log(1); -``` - - - -The binding you refer to is whatever's the closest upward. No mutation here! -If you need _real_ mutation, e.g. passing a value around, have it modified by many pieces of code, we provide a slightly heavier [mutation feature](mutation.md). - -## Private let bindings - -Private let bindings are introduced in the release [7.2](https://rescript-lang.org/blog/bucklescript-release-7-2). - -In the module system, everything is public by default, -the only way to hide some values is by providing a separate signature to -list public fields and their types: - -```res -module A: { - let b: int -} = { - let a = 3 - let b = 4 -} -``` - -`%%private` gives you an option to mark private fields directly - -```res -module A = { - %%private(let a = 3) - let b = 4 -} -``` - -`%%private` also applies to file level modules, so in some cases, -users do not need to provide a separate interface file just to hide some particular values. - -Note interface files are still recommended as a general best practice since they give you better -separate compilation units and also they're better for documentation. - -Still, `%%private` is useful in the following scenarios: - -- **Code generators.** Some code generators want to hide some values but it is sometimes very hard or time consuming for code generators to synthesize the types for public fields. - -- **Quick prototyping.** During prototyping, we still want to hide some values, but the interface file is not stable yet. `%%private` provides you such convenience. diff --git a/pages/docs/manual/v10.0.0/libraries.mdx b/pages/docs/manual/v10.0.0/libraries.mdx deleted file mode 100644 index 57876b799..000000000 --- a/pages/docs/manual/v10.0.0/libraries.mdx +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: "Libraries & Publishing" -description: "Install & publish ReScript packages" -canonical: "/docs/manual/latest/libraries" ---- - -# Libraries & Publishing - -ReScript libraries are just like JavaScript libraries: published & hosted on [NPM](http://npmjs.com). You can reuse your `npm`, `yarn` and `package.json`-related tools to manage them! - -## Tips & Tricks - -### Publish - -We recommend you to check in your compiled JavaScript output, for its [various benefits](interop-with-js-build-systems.md#popular-js-build-systems). If not, then at least consider publishing the JavaScript output by un-ignoring them in your [npmignore](https://docs.npmjs.com/cli/v7/using-npm/developers#keeping-files-out-of-your-package). This way, your published ReScript package comes with plain JavaScript files that JS users can consume. If your project's good, JS users might not even realize that they've installed a library written in ReScript! - -In case your library is only consumed by JS users, you may want to check out our [external stdlib](./build-external-stdlib) configuration as well. - -### Find Libraries - -Search `rescript`-related packages on NPM, or use our [Package Index](/packages). - -If you can't find what you're looking for, remember that **you don't need a wrapper** to use a JS library: - -- Most JS data types, such as array and objects, [map over cleanly to ReScript and vice-versa](shared-data-types.md). -- You also have access to the familiar [JS API](api/js). -- You can use a JavaScript library without needing to install dedicated binding libraries. Check the [`external`](external) page. diff --git a/pages/docs/manual/v10.0.0/migrate-from-bucklescript-reason.mdx b/pages/docs/manual/v10.0.0/migrate-from-bucklescript-reason.mdx deleted file mode 100644 index e263708d7..000000000 --- a/pages/docs/manual/v10.0.0/migrate-from-bucklescript-reason.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: "Migrate to ReScript Syntax" -description: "Instructions on upgrading from Reason to ReScript" -canonical: "/docs/manual/latest/migrate-to-new-syntax" ---- - -# Migrate from BuckleScript/Reason - -ReScript is a rebranding and cleanup of BuckleScript (since `v8.2.0`) & Reason (`v3.6`) that enables us to ship a tighter compile-to-JS stack with more coherent documentation & tools. If you're an existing user of BuckleScript & Reason, here's the gist: - -- ReScript is mostly just BuckleScript rebranded, with a new syntax that's like the Reason syntax, but catered more toward the JavaScript crowd. -- All your existing code will keep working even if you don't upgrade. - -## Upgrade Your Codebase - -There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial, backward-compatible and can be done on a per-file basis: - -``` -npm install rescript@9 - -# Also works with .rei / .ml / .mli / etc -npx rescript convert src/MyFile.re -``` - -Enjoy the improved experience! - -### Upgrade Individual Folders - -This is useful for per-directory conversions: - -```console -# *.rei, *.ml, *.mli,.... -for f in your-folder/**/*.re; do; node_modules/.bin/rescript convert $f && rm $f; done; -``` - -### Upgrade an Entire Codebase - -In case you are confident in converting your codebase in one step, use the following: - -``` -npx rescript convert -all -``` - -## Difference With Old Reason - -- Complete removal of semicolon (you can still write them). -- No need for parentheses around `if`, `switch` and `try`. -- Type arguments: from `option(int)` to `option`. -- Old interpolated string: from `{j|hello ${name}|j}` to `` `hello ${name}` ``. Now with proper unicode support! -- New interpolated string: `` `hello world` ``. Also supports multiline and unicode. `"hello world"` string is now singleline. -- Polymorphic variants: from `` `red`` to `#red`. -- Arrays: from `[|1,2,3|]` to `[1,2,3]`. In JS, arrays are the right default. -- Lists: from `[1,2,3]` to `list[1,2,3]` (_8.1.1 update_: now it is `list{1, 2, 3}`). This ties with upcoming plans to access containers in a uniform way: `set[...]` and `map[...]`. Maybe temporary. -- Exception: from `try (compute()) { | Not_found => Js.log("oops")}` to `try compute() catch { | Not_found => Js.log("oops")}`. -- First class module: from `(module S: Student)` to `module(S: Student)`. -- No custom infix operator for now (including `mod`). -- Object access: from `settings##visible #= true` to `settings["visible"] = true`. Rejoice! -- Object: from `Js.t({"age": int})` to just `{"age": int}`. The `Js.t` part is now unneeded. -- Attribute: from `[@myAttribute "hello"]` to `@myAttribute("hello")`. From `[%re bla]` to `%re(bla)`. -- Removed dereference syntax `result^`. Just use `result.contents`. -- `fun` pattern matching syntax removed. -- Type declaration is non-recursive by default, consistent with let bindings. To have recursive types, use `type rec myList<'a> = Nil | Cons('a, myList<'a>)`. -- Use any words, including reserved keywords, as your identifier name: `let \"try" = true`. diff --git a/pages/docs/manual/v10.0.0/module.mdx b/pages/docs/manual/v10.0.0/module.mdx deleted file mode 100644 index 3accd8c44..000000000 --- a/pages/docs/manual/v10.0.0/module.mdx +++ /dev/null @@ -1,584 +0,0 @@ ---- -title: "Module" -description: "ReScript modules, module signatures and interface files" -canonical: "/docs/manual/latest/module" ---- - -# Module - -## Basics - -**Modules are like mini files**! They can contain type definitions, `let` -bindings, nested modules, etc. - -### Creation - -To create a module, use the `module` keyword. The module name must start with a -**capital letter**. Whatever you could place in a `.res` file, you may place -inside a module definition's `{}` block. - - - -```res example -module School = { - type profession = Teacher | Director - - let person1 = Teacher - let getProfession = (person) => - switch person { - | Teacher => "A teacher" - | Director => "A director" - } -} -``` - -```js -function getProfession(person) { - if (person) { - return "A director"; - } else { - return "A teacher"; - } -} - -var School = { - person1: /* Teacher */ 0, - getProfession: getProfession, -}; -``` - - - -A module's contents (including types!) can be accessed much like a record's, -using the `.` notation. This demonstrates modules' utility for namespacing. - - - -```res -let anotherPerson: School.profession = School.Teacher -Js.log(School.getProfession(anotherPerson)) /* "A teacher" */ -``` - -```js -var anotherPerson = /* Teacher */ 0; -console.log("A teacher"); -``` - - - -Nested modules work too. - - - -```res example -module MyModule = { - module NestedModule = { - let message = "hello" - } -} - -let message = MyModule.NestedModule.message -``` - -```js -var NestedModule = { - message: message, -}; - -var MyModule = { - NestedModule: NestedModule, -}; - -var message = MyModule.NestedModule.message; -``` - - - -### `open`ing a module - -Constantly referring to a value/type in a module can be tedious. Instead, we can "open" a module and refer to its contents without always prepending them with the -module's name. Instead of writing: - - - -```res -let p = School.getProfession(School.person1) -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -We can write: - - - -```res -open School -let p = getProfession(person1) -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -The content of `School` module are made visible (**not** copied into the file, but simply made visible!) in scope. `profession`, `getProfession` and `person1` will thus correctly be found. - -**Use `open` this sparingly, it's convenient, but makes it hard to know where some values come from**. You should usually use `open` in a local scope: - - - -```res -let p = { - open School - getProfession(person1) -} -/* School's content isn't visible here anymore */ -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -### Use `open!` to ignore shadow warnings - -There are situations where `open` will cause a warning due to existing identifiers (bindings, types) being redefined. Use `open!` to explicitly tell the compiler that this is desired behavior. - -```res -let map = (arr, value) => { - value -} - -// opening Js.Array2 would shadow our previously defined `map` -// `open!` will explicitly turn off the automatic warning -open! Js.Array2 -let arr = map([1,2,3], (a) => { a + 1}) -``` - -**Note:** Same as with `open`, don't overuse `open!` statements if not necessary. Use (sub)modules to prevent shadowing issues. - -### Destructuring modules - -**Since 9.0.2** - -As an alternative to `open`ing a module, you can also destructure a module's functions and values into separate let bindings (similarly on how we'd destructure an object in JavaScript). - - - -```res -module User = { - let user1 = "Anna" - let user2 = "Franz" -} - -// Destructure by name -let {user1, user2} = module(User) - -// Destructure with different alias -let {user1: anna, user2: franz} = module(User) -``` - -```js -var user1 = "Anna"; - -var user2 = "Franz"; - -var User = { - user1: user1, - user2: user2, -}; -``` - - - -**Note:** You can't extract types with module destructuring — use a type alias instead (`type user = User.myUserType`). - -### Extending modules - -Using `include` in a module statically "spreads" a module's content into a new one, thus often fulfill the role of "inheritance" or "mixin". - -**Note**: this is equivalent to a compiler-level copy paste. **We heavily discourage `include`**. Use it as last resort! - - - -```res example -module BaseComponent = { - let defaultGreeting = "Hello" - let getAudience = (~excited) => excited ? "world!" : "world" -} - -module ActualComponent = { - /* the content is copied over */ - include BaseComponent - /* overrides BaseComponent.defaultGreeting */ - let defaultGreeting = "Hey" - let render = () => defaultGreeting ++ " " ++ getAudience(~excited=true) -} -``` - -```js -function getAudience(excited) { - if (excited) { - return "world!"; - } else { - return "world"; - } -} - -var BaseComponent = { - defaultGreeting: "Hello", - getAudience: getAudience, -}; - -var defaultGreeting = "Hey"; - -function render(param) { - return "Hey world!"; -} - -var ActualComponent = { - getAudience: getAudience, - defaultGreeting: defaultGreeting, - render: render, -}; -``` - - - -**Note**: `open` and `include` are very different! The former brings a module's content into your current scope, so that you don't have to refer to a value by prefixing it with the module's name every time. The latter **copies over** the definition of a module statically, then also do an `open`. - -### Every `.res` file is a module - -Every ReScript file is itself compiled to a module of the same name as the file name, capitalized. The file `React.res` implicitly forms a module `React`, which can be seen by other source files. - -**Note**: ReScript file names should, by convention, be capitalized so that their casing matches their module name. Uncapitalized file names are not invalid, but will be implicitly transformed into a capitalized module name. I.e. `file.res` will be compiled into the module `File`. To simplify and minimize the disconnect here, the convention is therefore to capitalize file names. - -## Signatures - -A module's type is called a "signature", and can be written explicitly. If a -module is like a `.res` (implementation) file, then a module's signature is like -a `.resi` (interface) file. - -### Creation - -To create a signature, use the `module type` keyword. The signature name must start with a -**capital letter**. Whatever you could place in a `.resi` file, you may place -inside a signature definition's `{}` block. - - - -```res example -/* Picking up previous section's example */ -module type EstablishmentType = { - type profession - let getProfession: profession => string -} -``` - -```js -// Empty output -``` - - - -A signature defines the list of requirements that a module must satisfy in order -for that module to match the signature. Those requirements are of the form: - -- `let x: int` requires a `let` binding named `x`, of type `int`. -- `type t = someType` requires a type field `t` to be equal to `someType`. -- `type t` requires a type field `t`, but without imposing any requirements on the actual, concrete type of `t`. We'd use `t` in other entries in the signature to describe relationships, e.g. `let makePair: t => (t, t)` but we cannot, for example, assume that `t` is an `int`. This gives us great, enforced abstraction abilities. - -To illustrate the various kinds of type entries, consider the above signature -`EstablishmentType` which requires that a module: - -- Declare a type named `profession`. -- Must include a function that takes in a value of the type `profession` and returns a string. - -**Note**: - -Modules of the type `EstablishmentType` can contain more fields than the -signature declares, just like the module `School` in the previous section (if we -choose to assign it the type `EstablishmentType`. Otherwise, `School` exposes -every field). This effectively makes the `person1` field an enforced -implementation detail! Outsiders can't access it, since it's not present in the -signature; the signature **constrained** what others can access. - -The type `EstablishmentType.profession` is **abstract**: it doesn't have a -concrete type; it's saying "I don't care what the actual type is, but it's used -as input to `getProfession`". This is useful to fit many modules under the same -interface: - - - -```res -module Company: EstablishmentType = { - type profession = CEO | Designer | Engineer | ... - - let getProfession = (person) => ... - let person1 = ... - let person2 = ... -} -``` - -```js -function getProfession(person) { - ... -} - -var person1 = ... - -var person2 = ... - -var Company = { - getProfession: getProfession, - person1: person1, - person2: person2 -}; -``` - - - -It's also useful to hide the underlying type as an implementation detail others -can't rely on. If you ask what the type of `Company.profession` is, instead of -exposing the variant, it'll only tell you "it's `Company.profession`". - -### Extending module signatures - -Like modules themselves, module signatures can also be extended by other module signatures using `include`. Again, **heavily discouraged**: - - - -```res example -module type BaseComponent = { - let defaultGreeting: string - let getAudience: (~excited: bool) => string -} - -module type ActualComponent = { - /* the BaseComponent signature is copied over */ - include BaseComponent - let render: unit => string -} -``` - -```js -// Empty output -``` - - - -**Note**: `BaseComponent` is a module **type**, not an actual module itself! - -If you do not have a defined module type, you can extract it from an actual module -using `include (module type of ActualModuleName)`. For example, we can extend the -`List` module from the standard library, which does not define a module -type. - - - -```res example -module type MyList = { - include (module type of List) - let myListFun: list<'a> => list<'a> -} -``` - -```js -// Empty output -``` - - - -### Every `.resi` file is a signature - -Similar to how a `React.res` file implicitly defines a module `React`, a file -`React.resi` implicitly defines a signature for `React`. If `React.resi` isn't -provided, the signature of `React.res` defaults to exposing all the fields of the -module. Because they don't contain implementation files, `.resi` files are used -in the ecosystem to also document the public API of their corresponding modules. - - - -```res example -/* file React.res (implementation. Compiles to module React) */ -type state = int -let render = (str) => str -``` - -```js -function render(str) { - return str; -} -``` - - - -```res sig -/* file React.resi (interface. Compiles to the signature of React.res) */ -type state = int -let render: string => string -``` - -## Module Functions (functors) - -Modules can be passed to functions! It would be the equivalent of passing a file -as a first-class item. However, modules are at a different "layer" of the -language than other common concepts, so we can't pass them to _regular_ -functions. Instead, we pass them to special functions called "functors". - -The syntax for defining and using functors is very much like the syntax -for defining and using regular functions. The primary differences are: - -- Functors use the `module` keyword instead of `let`. -- Functors take modules as arguments and return a module. -- Functors _require_ annotating arguments. -- Functors must start with a capital letter (just like modules/signatures). - -Here's an example `MakeSet` functor, that takes in a module of the type -`Comparable` and returns a new set that can contain such comparable items. - - - -```res prelude -module type Comparable = { - type t - let equal: (t, t) => bool -} - -module MakeSet = (Item: Comparable) => { - // let's use a list as our naive backing data structure - type backingType = list - let empty = list{} - let add = (currentSet: backingType, newItem: Item.t): backingType => - // if item exists - if List.exists(x => Item.equal(x, newItem), currentSet) { - currentSet // return the same (immutable) set (a list really) - } else { - list{ - newItem, - ...currentSet // prepend to the set and return it - } - } -} -``` - -```js -var List = require("./stdlib/list.js"); - -function MakeSet(Item) { - var add = function (currentSet, newItem) { - if ( - List.exists(function (x) { - return Item.equal(x, newItem); - }, currentSet) - ) { - return currentSet; - } else { - return { - hd: newItem, - tl: currentSet, - }; - } - }; - return { - empty: /* [] */ 0, - add: add, - }; -} -``` - - - -Functors can be applied using function application syntax. In this case, we're -creating a set, whose items are pairs of integers. - - - -```res example -module IntPair = { - type t = (int, int) - let equal = ((x1: int, y1: int), (x2, y2)) => x1 == x2 && y1 == y2 - let create = (x, y) => (x, y) -} - -/* IntPair abides by the Comparable signature required by MakeSet */ -module SetOfIntPairs = MakeSet(IntPair) -``` - -```js -function equal(param, param$1) { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } -} - -function create(x, y) { - return [x, y]; -} - -var IntPair = { - equal: equal, - create: create, -}; - -var SetOfIntPairs = { - empty: /* [] */ 0, - add: add, -}; -``` - - - -### Module functions types - -Like with module types, functor types also act to constrain and hide what we may -assume about functors. The syntax for functor types are consistent with those -for function types, but with types capitalized to represent the signatures of -modules the functor accepts as arguments and return values. In the -previous example, we're exposing the backing type of a set; by giving `MakeSet` -a functor signature, we can hide the underlying data structure! - - - -```res -module type Comparable = ... - -module type MakeSetType = (Item: Comparable) => { - type backingType - let empty: backingType - let add: (backingType, Item.t) => backingType -} - -module MakeSet: MakeSetType = (Item: Comparable) => { - ... -} -``` - -```js -// Empty output -``` - - - -## Exotic Module Filenames - -**Since 8.3** - -It is possible to use non-conventional characters in your filenames (which is sometimes needed for specific JS frameworks). Here are some examples: - -- `src/Button.ios.res` -- `pages/[id].res` - -Please note that modules with an exotic filename will not be accessible from other ReScript modules. - -## Tips & Tricks - -Modules and functors are at a different "layer" of language than the rest (functions, let bindings, data structures, etc.). For example, you can't easily pass them into a tuple or record. Use them judiciously, if ever! Lots of times, just a record or a function is enough. diff --git a/pages/docs/manual/v10.0.0/mutation.mdx b/pages/docs/manual/v10.0.0/mutation.mdx deleted file mode 100644 index d7bbf3d03..000000000 --- a/pages/docs/manual/v10.0.0/mutation.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: "Mutation" -description: "Imperative and mutative programming capabilities in ReScript" -canonical: "/docs/manual/latest/mutation" ---- - -# Mutation - -ReScript has great traditional imperative & mutative programming capabilities. You should use these features sparingly, but sometimes they allow your code to be more performant and written in a more familiar pattern. - -## Mutate Let-binding - -Let-bindings are immutable, but you can wrap it with a `ref`, exposed as a record with a single mutable field in the standard library: - - - -```res prelude -let myValue = ref(5) -``` - -```js -var myValue = { - contents: 5, -}; -``` - - - -## Usage - -You can get the actual value of a `ref` box through accessing its `contents` field: - - - -```res example -let five = myValue.contents // 5 -``` - -```js -var five = myValue.contents; -``` - - - -Assign a new value to `myValue` like so: - - - -```res example -myValue.contents = 6 -``` - -```js -myValue.contents = 6; -``` - - - -We provide a syntax sugar for this: - - - -```res example -myValue := 6 -``` - -```js -myValue.contents = 6; -``` - - - -Note that the previous binding `five` stays `5`, since it got the underlying item on the `ref` box, not the `ref` itself. - -**Note**: you might see in the JS output tabs above that `ref` allocates an object. Worry not; local, non-exported `ref`s allocations are optimized away. - -## Tip & Tricks - -Before reaching for `ref`, know that you can achieve lightweight, local "mutations" through [overriding let bindings](let-binding.md#binding-shadowing). diff --git a/pages/docs/manual/v10.0.0/newcomer-examples.mdx b/pages/docs/manual/v10.0.0/newcomer-examples.mdx deleted file mode 100644 index 360c86fab..000000000 --- a/pages/docs/manual/v10.0.0/newcomer-examples.mdx +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: "Newcomer Examples" -description: "Quick examples for users new to ReScript" -canonical: "/docs/manual/latest/newcomer-examples" ---- - -# Newcomer Examples - - - -An example is worth a thousand words. - -This section is dedicated to newcomers trying to figure out general idioms & conventions. If you're a beginner who's got a good idea for an example, please suggest an edit! - -## Use the [`option` type](null-undefined-option.md) - - - -```res example -let possiblyNullValue1 = None -let possiblyNullValue2 = Some("Hello") - -switch possiblyNullValue2 { -| None => Js.log("Nothing to see here.") -| Some(message) => Js.log(message) -} -``` - -```js -var possiblyNullValue1; -var possiblyNullValue2 = "Hello"; - -if (possiblyNullValue2 !== undefined) { - console.log(possiblyNullValue2); -} else { - console.log("Nothing to see here."); -} -``` - - - -## Create a Parametrized Type - - - -```res example -type universityStudent = {gpa: float} - -type response<'studentType> = { - status: int, - student: 'studentType, -} -``` - -```js -// Empty output -``` - - - -## Creating a JS Object - - - -```res example -let student1 = { - "name": "John", - "age": 30, -} -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -Or using [record](record.md): - - - -```res example -type payload = { - name: string, - age: int, -} - -let student1 = { - name: "John", - age: 30, -} -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -## Modeling a JS Module with Default Export - -See [here](import-from-export-to-js.md#import-a-javascript-module-itself-es6-module-format). - -## Checking for JS nullable types using the `option` type - -For a function whose argument is passed a JavaScript value that's potentially `null` or `undefined`, it's idiomatic to convert it to an `option`. The conversion is done through the helper functions in ReScript's [`Js.Nullable`](api/js/nullable#t) module. In this case, `toOption`: - - - -```res example -let greetByName = (possiblyNullName) => { - let optionName = Js.Nullable.toOption(possiblyNullName) - switch optionName { - | None => "Hi" - | Some(name) => "Hello " ++ name - } -} -``` - -```js -function greetByName(possiblyNullName) { - if (possiblyNullName == null) { - return "Hi"; - } else { - return "Hello " + possiblyNullName; - } -} -``` - - - -This check compiles to `possiblyNullName == null` in JS, so checks for the presence of `null` or `undefined`. diff --git a/pages/docs/manual/v10.0.0/null-undefined-option.mdx b/pages/docs/manual/v10.0.0/null-undefined-option.mdx deleted file mode 100644 index 125cc874d..000000000 --- a/pages/docs/manual/v10.0.0/null-undefined-option.mdx +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: "Null, Undefined and Option" -description: "JS interop with nullable and optional values in ReScript" -canonical: "/docs/manual/latest/null-undefined-option" ---- - -# Null, Undefined and Option - -ReScript itself doesn't have the notion of `null` or `undefined`. This is a _great_ thing, as it wipes out an entire category of bugs. No more `undefined is not a function`, and `cannot access someAttribute of undefined`! - -However, the **concept** of a potentially nonexistent value is still useful, and safely exists in our language. - -We represent the existence and nonexistence of a value by wrapping it with the `option` type. Here's its definition from the standard library: - - - -```res example -type option<'a> = None | Some('a) -``` - -```js -// Empty output -``` - - - -It means "a value of type option is either None (representing nothing) or that actual value wrapped in a Some". - -**Note** how the `option` type is just a regular [variant](variant.md). - -## Example - -Here's a normal value: - - - -```res example -let licenseNumber = 5 -``` - -```js -var licenseNumber = 5; -``` - - - -To represent the concept of "maybe null", you'd turn this into an `option` type by wrapping it. For the sake of a more illustrative example, we'll put a condition around it: - - - -```res -let licenseNumber = - if personHasACar { - Some(5) - } else { - None - } -``` - -```js -var licenseNumber = personHasACar ? 5 : undefined; -``` - - - -Later on, when another piece of code receives such value, it'd be forced to handle both cases through [pattern matching](pattern-matching-destructuring.md): - - - -```res -switch licenseNumber { -| None => - Js.log("The person doesn't have a car") -| Some(number) => - Js.log("The person's license number is " ++ Js.Int.toString(number)) -} -``` - -```js -var number = licenseNumber; - -if (number !== undefined) { - console.log("The person's license number is " + number.toString()); -} else { - console.log("The person doesn't have a car"); -} -``` - - - -By turning your ordinary number into an `option` type, and by forcing you to handle the `None` case, the language effectively removed the possibility for you to mishandle, or forget to handle, a conceptual `null` value! **A pure ReScript program doesn't have null errors**. - -## Interoperate with JavaScript `undefined` and `null` - -The `option` type is common enough that we special-case it when compiling to JavaScript: - - - -```res example -let x = Some(5) -``` - -```js -var x = 5; -``` - - - -simply compiles down to `5`, and - - - -```res example -let x = None -``` - -```js -var x; -``` - - - -compiles to `undefined`! If you've got e.g. a string in JavaScript that you know might be `undefined`, type it as `option` and you're done! Likewise, you can send a `Some(5)` or `None` to the JS side and expect it to be interpreted correctly =) - -### Caveat 1 - -The option-to-undefined translation isn't perfect, because on our side, `option` values can be composed: - - - -```res example -let x = Some(Some(Some(5))) -``` - -```js -var x = 5; -``` - - - -This still compiles to `5`, but this gets troublesome: - - - -```res example -let x = Some(None) -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -var x = Caml_option.some(undefined); -``` - -(See output tab). - - - -What's this `Caml_option.some` thing? Why can't this compile to `undefined`? Long story short, when dealing with a polymorphic `option` type (aka `option<'a>`, for any `'a`), many operations become tricky if we don't mark the value with some special annotation. If this doesn't make sense, don't worry; just remember the following rule: - -- **Never, EVER, pass a nested `option` value (e.g. `Some(Some(Some(5)))`) into the JS side.** -- **Never, EVER, annotate a value coming from JS as `option<'a>`. Always give the concrete, non-polymorphic type.** - -### Caveat 2 - -Unfortunately, lots of times, your JavaScript value might be _both_ `null` or `undefined`. In that case, you unfortunately can't type such value as e.g. `option`, since our `option` type only checks for `undefined` and not `null` when dealing with a `None`. - -#### Solution: More Sophisticated `undefined` & `null` Interop - -To solve this, we provide access to more elaborate `null` and `undefined` helpers through the [`Js.Nullable`](api/js/nullable) module. This somewhat works like an `option` type, but is different from it. - -#### Examples - -To create a JS `null`, use the value `Js.Nullable.null`. To create a JS `undefined`, use `Js.Nullable.undefined` (you can naturally use `None` too, but that's not the point here; the `Js.Nullable.*` helpers wouldn't work with it). - -If you're receiving, for example, a JS string that can be `null` and `undefined`, type it as: - - - -```res example -@module("MyConstant") external myId: Js.Nullable.t = "myId" -``` - -```js -// Empty output -``` - - - -To create such a nullable string from our side (presumably to pass it to the JS side, for interop purpose), do: - - - -```res example -@module("MyIdValidator") external validate: Js.Nullable.t => bool = "validate" -let personId: Js.Nullable.t = Js.Nullable.return("abc123") - -let result = validate(personId) -``` - -```js -var MyIdValidator = require("MyIdValidator"); -var personId = "abc123"; -var result = MyIdValidator.validate(personId); -``` - - - -The `return` part "wraps" a string into a nullable string, to make the type system understand and track the fact that, as you pass this value around, it's not just a string, but a string that can be `null` or `undefined`. - -#### Convert to/from `option` - -`Js.Nullable.fromOption` converts from a `option` to `Js.Nullable.t`. `Js.Nullable.toOption` does the opposite. diff --git a/pages/docs/manual/v10.0.0/object.mdx b/pages/docs/manual/v10.0.0/object.mdx deleted file mode 100644 index 7277fa163..000000000 --- a/pages/docs/manual/v10.0.0/object.mdx +++ /dev/null @@ -1,202 +0,0 @@ ---- -title: "Object" -description: "Interoping with JS objects in ReScript" -canonical: "/docs/manual/latest/object" ---- - -# Object - -ReScript objects are like [records](record.md), but: - -- No type declaration needed. -- Structural and more polymorphic, [unlike records](record.md#record-types-are-found-by-field-name). -- Doesn't support updates unless the object comes from the JS side. -- Doesn't support [pattern matching](pattern-matching-destructuring). - - - -Although ReScript records compile to clean JavaScript objects, ReScript objects are a better candidate for emulating/binding to JS objects, as you'll see. - -## Type Declaration - -**Optional**, unlike for records. The type of an object is inferred from the value, so you never really need to write down its type definition. Nevertheless, here's its type declaration syntax: - - - -```res prelude -type person = { - "age": int, - "name": string -}; -``` - -```js -// Empty output -``` - - - -Visually similar to record type's syntax, with the field names quoted. - - - -## Creation - -To create a new object: - - - -```res example -let me = { - "age": 5, - "name": "Big ReScript" -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -**Note**: as said above, unlike for record, this `me` value does **not** try to find a conforming type declaration with the field `"age"` and `"name"`; rather, the type of `me` is inferred as `{"age": int, "name": string}`. This is convenient, but also means this code passes type checking without errors: - - - -```res -type person = { - "age": int -}; - -let me = { - "age": "hello!" // age is a string. No error. -} -``` - -```js -var me = { - age: "hello!", -}; -``` - - - -Since the type checker doesn't try to match `me` with the type `person`. If you ever want to force an object value to be of a predeclared object type, just annotate the value: - -```res -let me: person = { - "age": "hello!" -} -``` - -Now the type system will error properly. - -## Access - - - -```res -let age = me["age"] -``` - -```js -var age = me["age"]; -``` - - - -## Update - -Disallowed unless the object is a binding that comes from the JavaScript side. In that case, use `=` - - - -```res example -type student = { - @set "age": int, - @set "name": string, -} -@module("MyJSFile") external student1: student = "student1" - -student1["name"] = "Mary" -``` - -```js -var MyJSFile = require("MyJSFile"); -MyJSFile.student1.name = "Mary"; -``` - - - -## Combine Types - -You can spread one object type definition into another using `...`: - - - -```res example -type point2d = { - "x": float, - "y": float, -} -type point3d = { - ...point2d, - "z": float, -} - -let myPoint: point3d = { - "x": 1.0, - "y": 2.0, - "z": 3.0, -} -``` - -```js -var myPoint = { - x: 1.0, - y: 2.0, - z: 3.0, -}; -``` - - - -This only works with object types, not object values! - -## Tips & Tricks - -Since objects don't require type declarations, and since ReScript infers all the types for you, you get to very quickly and easily (and dangerously) bind to any JavaScript API. Check the JS output tab: - - - -```res example -// The type of document is just some random type 'a -// that we won't bother to specify -@val external document: 'a = "document" - -// call a method -document["addEventListener"](. "mouseup", _event => { - Js.log("clicked!") -}) - -// get a property -let loc = document["location"] - -// set a property -document["location"]["href"] = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); -var loc = document.location; -document.location.href = "rescript-lang.org"; -``` - - - -The `external` feature and the usage of this trick are also documented in the [external](external#tips--tricks) section later. It's an excellent way to start writing some ReScript code without worrying about whether bindings to a particular library exists. diff --git a/pages/docs/manual/v10.0.0/overview.mdx b/pages/docs/manual/v10.0.0/overview.mdx deleted file mode 100644 index 7c13d3ab0..000000000 --- a/pages/docs/manual/v10.0.0/overview.mdx +++ /dev/null @@ -1,254 +0,0 @@ ---- -title: "Overview" -metaTitle: "Language Features Overview" -description: "A quick overview on ReScript's syntax" -canonical: "/docs/manual/latest/overview" ---- - -# Overview - -## Comparison to JS - -### Semicolon - -| JavaScript | ReScript | -| ---------------------------------- | -------------------- | -| Rules enforced by linter/formatter | No semicolon needed! | - -### Comments - -| JavaScript | ReScript | -| -------------------- | -------------------------------- | -| `// Line comment` | Same | -| `/* Comment */` | Same | -| `/** Doc Comment */` | `/** Before Types/Values */` | -| | `/*** Standalone Doc Comment */` | - -### Variable - -| JavaScript | ReScript | -| ----------------------- | ------------------------------------- | -| `const x = 5;` | `let x = 5` | -| `var x = y;` | No equivalent (thankfully) | -| `let x = 5; x = x + 1;` | `let x = ref(5); x := x.contents + 1` | - -### String & Character - -| JavaScript | ReScript | -| ------------------------ | --------------------- | -| `"Hello world!"` | Same | -| `'Hello world!'` | Strings must use `"` | -| `"hello " + "world"` | `"hello " ++ "world"` | -| `` `hello ${message}` `` | Same | - -### Boolean - -| JavaScript | ReScript | -| ------------------------------------ | ---------------------------------------------- | -| `true`, `false` | Same | -| `!true` | Same | -| `\|\|`, `&&`, `<=`, `>=`, `<`, `>` | Same | -| `a === b`, `a !== b` | Same | -| No deep equality (recursive compare) | `a == b`, `a != b` | -| `a == b` | No equality with implicit casting (thankfully) | - -### Number - -| JavaScript | ReScript | -| ----------- | ------------ | -| `3` | Same \* | -| `3.1415` | Same | -| `3 + 4` | Same | -| `3.0 + 4.5` | `3.0 +. 4.5` | -| `5 % 3` | `mod(5, 3)` | - -\* JS has no distinction between integer and float. - -### Object/Record - -| JavaScript | ReScript | -| ------------------- | --------------------------------------- | -| no types | `type point = {x: int, mutable y: int}` | -| `{x: 30, y: 20}` | Same | -| `point.x` | Same | -| `point.y = 30;` | Same | -| `{...point, x: 30}` | Same | - -### Array - -| JavaScript | ReScript | -| ------------------ | --------------------- | -| `[1, 2, 3]` | Same | -| `myArray[1] = 10` | Same | -| `[1, "Bob", true]` | `(1, "Bob", true)` \* | - -\* Heterogenous arrays in JS are disallowed for us. Use tuple instead. - -### Null - -| JavaScript | ReScript | -| ------------------- | --------- | -| `null`, `undefined` | `None` \* | - -\* Again, only a spiritual equivalent; we don't have nulls, nor null bugs! But we do have an `option` type for when you actually need nullability. - -### Function - -| JavaScript | ReScript | -| ------------------------------- | ---------------------------- | -| `arg => retVal` | Same | -| `function named(arg) {...}` | `let named = (arg) => {...}` | -| `const f = function(arg) {...}` | `let f = (arg) => {...}` | -| `add(4, add(5, 6))` | Same | - -### Async Function / Await - -| JavaScript | ReScript | -| --------------------------------------- | -------------------------------------------------- | -| `async (arg) => {...}` | Same | -| `async function named(arg) {...}` | `let named = async (arg) => {...}` | -| `await somePromise` | Same | -| `async (arg): Promise => {...}` | `async (): string => {...}` (note the return type) | - -### Blocks - - - - - - - - - - - - - - -
JavaScriptReScript
-
-          {`const myFun = (x, y) => {
-  const doubleX = x + x;
-  const doubleY = y + y;
-  return doubleX + doubleY;
-};`}
-        
-
-
-          {`let myFun = (x, y) => {
-  let doubleX = x + x
-  let doubleY = y + y
-  doubleX + doubleY
-}`}
-        
-
- -### If-else - -| JavaScript | ReScript | -| --------------------- | --------------------------------------------------------------------------------- | -| `if (a) {b} else {c}` | `if a {b} else {c}` \* | -| `a ? b : c` | Same | -| `switch` | `switch` but [super-powered pattern matching!](pattern-matching-destructuring.md) | - -\* Our conditionals are always expressions! You can write `let result = if a {"hello"} else {"bye"}` - -### Destructuring - -| JavaScript | ReScript | -| ----------------------------- | --------------------------------- | -| `const {a, b} = data` | `let {a, b} = data` | -| `const [a, b] = data` | let [a, b] = data \* | -| `const {a: aa, b: bb} = data` | `let {a: aa, b: bb} = data` | - -\* Gives good compiler warning that `data` might not be of length 2. - -### Loop - -| JavaScript | ReScript | -| ------------------------------------- | ---------------------------- | -| `for (let i = 0; i <= 10; i++) {...}` | `for i in 0 to 10 {...}` | -| `for (let i = 10; i >= 0; i--) {...}` | `for i in 10 downto 0 {...}` | -| `while (true) {...}` | `while true {...}` | - -### JSX - -| JavaScript | ReScript | -| ----------------------------------------- | -------------------------- | -| `` | Same | -| `` | `` \* | -| `` | `` | -| No children spread | `...children` | - -\* Argument punning! - -### Exception - -| JavaScript | ReScript | -| ----------------------------------------- | --------------------------------- | -| `throw new SomeError(...)` | `raise(SomeError(...))` | -| `try {a} catch (Err) {...} finally {...}` | `try a catch { \| Err => ...}` \* | - -\* No finally. - -### Blocks - -The last expression of a block delimited by `{}` implicitly returns (including function body). In JavaScript, this can only be simulated via an immediately-invoked function expression (since function bodies have their own local scope). - - - - - - - - - - - - - - -
JavaScriptReScript
-
-          {`let result = (function() {
-  const x = 23;
-  const y = 34;
-  return x + y;
-})();`}
-        
-
-
-          {`let result = {
-  let x = 23
-  let y = 34
-  x + y
-}`}
-        
-
- -## Common Features' JS Output - -| Feature | Example | JavaScript Output | -| ------------------------------- | ------------------------------------ | ------------------------------------------ | -| String | `"Hello"` | `"Hello"` | -| String Interpolation | `` `Hello ${message}` `` | `"Hello " + message` | -| Character (disrecommended) | `'x'` | `120` (char code) | -| Integer | `23`, `-23` | `23`, `-23` | -| Float | `23.0`, `-23.0` | `23.0`, `-23.0` | -| Integer Addition | `23 + 1` | `23 + 1` | -| Float Addition | `23.0 +. 1.0` | `23.0 + 1.0` | -| Integer Division/Multiplication | `2 / 23 * 1` | `2 / 23 * 1` | -| Float Division/Multiplication | `2.0 /. 23.0 *. 1.0` | `2.0 / 23.0 * 1.0` | -| Float Exponentiation | `2.0 ** 3.0` | `Math.pow(2.0, 3.0)` | -| String Concatenation | `"Hello " ++ "World"` | `"Hello " + "World"` | -| Comparison | `>`, `<`, `>=`, `<=` | `>`, `<`, `>=`, `<=` | -| Boolean operation | `!`, `&&`, `\|\|` | `!`, `&&`, `\|\|` | -| Shallow and deep Equality | `===`, `==` | `===`, `==` | -| List (disrecommended) | `list{1, 2, 3}` | `{hd: 1, tl: {hd: 2, tl: {hd: 3, tl: 0}}}` | -| List Prepend | `list{a1, a2, ...oldList}` | `{hd: a1, tl: {hd: a2, tl: theRest}}` | -| Array | `[1, 2, 3]` | `[1, 2, 3]` | -| Record | `type t = {b: int}; let a = {b: 10}` | `var a = {b: 10}` | -| Multiline Comment | `/* Comment here */` | Not in output | -| Single line Comment | `// Comment here` | Not in output | - -_Note that this is a cleaned-up comparison table; a few examples' JavaScript output are slightly different in reality._ diff --git a/pages/docs/manual/v10.0.0/pattern-matching-destructuring.mdx b/pages/docs/manual/v10.0.0/pattern-matching-destructuring.mdx deleted file mode 100644 index eb8ec29da..000000000 --- a/pages/docs/manual/v10.0.0/pattern-matching-destructuring.mdx +++ /dev/null @@ -1,901 +0,0 @@ ---- -title: "Pattern Matching / Destructuring" -description: "Pattern matching and destructuring complex data structures in ReScript" -canonical: "/docs/manual/latest/pattern-matching-destructuring" ---- - -# Pattern Matching / Destructuring - -One of ReScript's **best** feature is our pattern matching. Pattern matching combines 3 brilliant features into one: - -- Destructuring. -- `switch` based on shape of data. -- Exhaustiveness check. - -We'll dive into each aspect below. - -## Destructuring - -Even JavaScript has destructuring, which is "opening up" a data structure to extract the parts we want and assign variable names to them: - - - -```res example -let coordinates = (10, 20, 30) -let (x, _, _) = coordinates -Js.log(x) // 10 -``` - -```js -var coordinates = [10, 20, 30]; -var x = 10; -console.log(10); -``` - - - -Destructuring works with most built-in data structures: - - - -```res -// Record -type student = {name: string, age: int} -let student1 = {name: "John", age: 10} -let {name} = student1 // "John" assigned to `name` - -// Variant -type result = - | Success(string) -let myResult = Success("You did it!") -let Success(message) = myResult // "You did it!" assigned to `message` -``` - -```js -var student1 = { - name: "John", - age: 10, -}; -var name = "John"; - -var myResult = /* Success */ { - _0: "You did it!", -}; -var message = "You did it!"; - -var myArray = [1, 2, 3]; -if (myArray.length !== 2) { - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 14, 4], - Error: new Error(), - }; -} -var item1 = myArray[0]; -var item2 = myArray[1]; - -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */ 0, - }, - }, -}; -// ... -``` - - - -You can also use destructuring anywhere you'd usually put a binding: - - - -```res example -type result = - | Success(string) -let displayMessage = (Success(m)) => { - // we've directly extracted the success message - // string by destructuring the parameter - Js.log(m) -} -displayMessage(Success("You did it!")) -``` - -```js -function displayMessage(m) { - console.log(m._0); -} - -displayMessage( - /* Success */ { - _0: "You did it!", - }, -); -``` - - - -For a record, you can rename the field while destructuring: - - - -```res -let {name: n} = student1 // "John" assigned to `n` -``` - -```js -var n = "John"; -``` - - - -You _can_ in theory destructure array and list at the top level too: - -```res -let myArray = [1, 2, 3] -let [item1, item2, _] = myArray -// 1 assigned to `item1`, 2 assigned to `item2`, 3rd item ignored - -let myList = list{1, 2, 3} -let list{head, ...tail} = myList -// 1 assigned to `head`, `list{2, 3}` assigned to tail -``` - -But the array example is **highly disrecommended** (use tuple instead) and the list example will error on you. They're only there for completeness' sake. As you'll see below, the proper way of using destructuring array and list is using `switch`. - -## `switch` Based on Shape of Data - -While the destructuring aspect of pattern matching is nice, it doesn't really change the way you think about structuring your code. One paradigm-changing way of thinking about your code is to execute some code based on the shape of the data. - -Consider a variant: - - - -```res prelude -type payload = - | BadResult(int) - | GoodResult(string) - | NoResult -``` - -```js -// Empty output -``` - - - -We'd like to handle each of the 3 cases differently. For example, print a success message if the value is `GoodResult(...)`, do something else when the value is `NoResult`, etc. - -In other languages, you'd end up with a series of if-elses that are hard to read and error-prone. In ReScript, you can instead use the supercharged `switch` pattern matching facility to destructure the value while calling the right code based on what you destructured: - - - -```res example -let data = GoodResult("Product shipped!") -switch data { -| GoodResult(theMessage) => - Js.log("Success! " ++ theMessage) -| BadResult(errorCode) => - Js.log("Something's wrong. The error code is: " ++ Js.Int.toString(errorCode)) -| NoResult => - Js.log("Bah.") -} -``` - -```js -var data = { - TAG: /* GoodResult */ 1, - _0: "Product shipped!", -}; - -if (typeof data === "number") { - console.log("Bah."); -} else if (data.TAG === /* BadResult */ 0) { - console.log( - "Something's wrong. The error code is: " + "Product shipped!".toString(), - ); -} else { - console.log("Success! Product shipped!"); -} -``` - - - -In this case, `message` will have the value `"Success! Product shipped!"`. - -Suddenly, your if-elses that messily checks some structure of the value got turned into a clean, compiler-verified, linear list of code to execute based on exactly the shape of the value. - -### Complex Examples - -Here's a real-world scenario that'd be a headache to code in other languages. Given this data structure: - - - -```res prelude -type status = Vacations(int) | Sabbatical(int) | Sick | Present -type reportCard = {passing: bool, gpa: float} -type person = - | Teacher({ - name: string, - age: int, - }) - | Student({ - name: string, - status: status, - reportCard: reportCard, - }) -``` - -```js -// Empty output -``` - - - -Imagine this requirement: - -- Informally greet a person who's a teacher and if his name is Mary or Joe. -- Greet other teachers formally. -- If the person's a student, congratulate him/her score if they passed the semester. -- If the student has a gpa of 0 and is on vacations or sabbatical, display a different message. -- A catch-all message for a student. - -ReScript can do this easily! - - - -```res prelude -let person1 = Teacher({name: "Jane", age: 35}) - -let message = switch person1 { -| Teacher({name: "Mary" | "Joe"}) => - `Hey, still going to the party on Saturday?` -| Teacher({name}) => - // 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!` -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - `Come back in ${Js.Int.toString(daysLeft)} days!` -| Student({status: Sick}) => - `How are you feeling?` -| Student({name}) => - `Good luck next semester ${name}!` -} -``` - -```js -var person1 = { - TAG: /* Teacher */ 0, - name: "Jane", - age: 35, -}; - -var message; - -if (person1.TAG) { - var match$1 = person1.status; - var name = person1.name; - var match$2 = person1.reportCard; - message = match$2.passing - ? "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!" - : typeof match$1 === "number" - ? match$1 !== 0 - ? "Good luck next semester " + name + "!" - : "How are you feeling?" - : person1.reportCard.gpa !== 0.0 - ? "Good luck next semester " + name + "!" - : "Come back in " + match$1._0.toString() + " days!"; -} else { - var name$1 = person1.name; - switch (name$1) { - case "Joe": - case "Mary": - message = "Hey, still going to the party on Saturday?"; - break; - default: - message = "Hello " + name$1 + "."; - } -} -``` - - - -**Note** how we've: - -- drilled deep down into the value concisely -- using a **nested pattern check** `"Mary" | "Joe"` and `Vacations | Sabbatical` -- while extracting the `daysLeft` number from the latter case -- and assigned the greeting to the binding `message`. - -Here's another example of pattern matching, this time on an inline tuple. - - - -```res -type animal = Dog | Cat | Bird -let categoryId = switch (isBig, myAnimal) { -| (true, Dog) => 1 -| (true, Cat) => 2 -| (true, Bird) => 3 -| (false, Dog | Cat) => 4 -| (false, Bird) => 5 -} -``` - -```js -var categoryId = isBig ? (myAnimal + 1) | 0 : myAnimal >= 2 ? 5 : 4; -``` - - - -**Note** how pattern matching on a tuple is equivalent to a 2D table: - -| isBig \ myAnimal | Dog | Cat | Bird | -| ---------------- | --- | --- | ---- | -| true | 1 | 2 | 3 | -| false | 4 | 4 | 5 | - -### Fall-Through Patterns - -The nested pattern check, demonstrated in the earlier `person` example, also works at the top level of a `switch`: - - - -```res prelude -let myStatus = Vacations(10) - -switch myStatus { -| Vacations(days) -| Sabbatical(days) => Js.log(`Come back in ${Js.Int.toString(days)} days!`) -| Sick -| Present => Js.log("Hey! How are you?") -} -``` - -```js -var myStatus = { - TAG: /* Vacations */ 0, - _0: 10, -}; - -if (typeof myStatus === "number") { - console.log("Hey! How are you?"); -} else { - console.log("Come back in " + (10).toString() + " days!"); -} -``` - - - -Having multiple cases fall into the same handling can clean up certain types of logic. - -### Ignore Part of a Value - -If you have a value like `Teacher(payload)` where you just want to pattern match on the `Teacher` part and ignore the `payload` completely, you can use the `_` wildcard like this: - - - -```res example -switch person1 { -| Teacher(_) => Js.log("Hi teacher") -| Student(_) => Js.log("Hey student") -} -``` - -```js -if (person1.TAG) { - console.log("Hey student"); -} else { - console.log("Hi teacher"); -} -``` - - - -`_` also works at the top level of the `switch`, serving as a catch-all condition: - - - -```res example -switch myStatus { -| Vacations(_) => Js.log("Have fun!") -| _ => Js.log("Ok.") -} -``` - -```js -if (typeof myStatus === "number" || myStatus.TAG) { - console.log("Ok."); -} else { - console.log("Have fun!"); -} -``` - - - -**Do not** abuse a top-level catch-all condition. Instead, prefer writing out all the cases: - - - -```res example -switch myStatus { -| Vacations(_) => Js.log("Have fun!") -| Sabbatical(_) | Sick | Present => Js.log("Ok.") -} -``` - -```js -if (typeof myStatus === "number" || myStatus.TAG) { - console.log("Ok."); -} else { - console.log("Have fun!"); -} -``` - - - -Slightly more verbose, but a one-time writing effort. This helps when you add a new variant case e.g. `Quarantined` to the `status` type and need to update the places that pattern match on it. A top-level wildcard here would have accidentally and silently continued working, potentially causing bugs. - -### If Clause - -Sometime, you want to check more than the shape of a value. You want to also run some arbitrary check on it. You might be tempted to write this: - - - -```res example -switch person1 { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) => - if gpa < 0.5 { - Js.log("What's happening") - } else { - Js.log("Heyo") - } -} -``` - -```js -if (person1.TAG) { - if (person1.reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -`switch` patterns support a shortcut for the arbitrary `if` check, to keep your pattern linear-looking: - - - -```res example -switch person1 { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) if gpa < 0.5 => - Js.log("What's happening") -| Student(_) => - // fall-through, catch-all case - Js.log("Heyo") -} -``` - -```js -if (person1.TAG) { - if (person1.reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -**Note:** Rescript versions < 9.0 had a `when` clause, not an `if` clause.  Rescript 9.0 changed `when` to `if`.  (`when` may still work, but is deprecated.) - -### Match on Exceptions - -If the function throws an exception (covered later), you can also match on _that_, in addition to the function's normally returned values. - - - -```res -switch List.find(i => i === theItem, myItems) { -| item => Js.log(item) -| exception Not_found => Js.log("No such item found!") -} -``` - -```js -var exit = 0; - -var item; - -try { - item = List.find(function (i) { - return i === theItem; - }, myItems); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -### Match on Array - - - -```res example -let students = ["Jane", "Harvey", "Patrick"] -switch students { -| [] => Js.log("There are no students") -| [student1] => - Js.log("There's a single student here: " ++ student1) -| manyStudents => - // display the array of names - Js.log2("The students are: ", manyStudents) -} -``` - -```js -var students = ["Jane", "Harvey", "Patrick"]; - -var len = students.length; - -if (len !== 1) { - if (len !== 0) { - console.log("The students are: ", students); - } else { - console.log("There are no students"); - } -} else { - var student1 = students[0]; - console.log("There's a single student here: " + student1); -} -``` - - - -### Match on List - -Pattern matching on list is similar to array, but with the extra feature of extracting the tail of a list (all elements except the first one): - - - -```res example -let rec printStudents = (students) => { - switch students { - | list{} => () // done - | list{student} => Js.log("Last student: " ++ student) - | list{student1, ...otherStudents} => - Js.log(student1) - printStudents(otherStudents) - } -} -printStudents(list{"Jane", "Harvey", "Patrick"}) -``` - -```js -function printStudents(_students) { - while (true) { - var students = _students; - if (!students) { - return; - } - var otherStudents = students.tl; - var student = students.hd; - if (otherStudents) { - console.log(student); - _students = otherStudents; - continue; - } - console.log("Last student: " + student); - return; - } -} - -printStudents({ - hd: "Jane", - tl: { - hd: "Harvey", - tl: { - hd: "Patrick", - tl: /* [] */ 0, - }, - }, -}); -``` - - - -### Small Pitfall - -**Note**: you can only pass literals (i.e. concrete values) as a pattern, not let-binding names or other things. The following doesn't work as expected: - - - -```res example -let coordinates = (10, 20, 30) -let centerY = 20 -switch coordinates { -| (x, centerY, _) => Js.log(x) -} -``` - -```js -var coordinates = [10, 20, 30]; -var centerY = 20; - -console.log(10); -``` - - - -A first time ReScript user might accidentally write that code, assuming that it's matching on `coordinates` when the second value is of the same value as `centerY`. In reality, this is interpreted as matching on coordinates and assigning the second value of the tuple to the name `centerY`, which isn't what's intended. - -## Exhaustiveness Check - -As if the above features aren't enough, ReScript also provides arguably the most important pattern matching feature: **compile-time check of missing patterns**. - -Let's revisit one of the above examples: - - - -```res -let message = switch person1 { -| Teacher({name: "Mary" | "Joe"}) => - `Hey, still going to the party on Saturday?` -| Student({name, reportCard: {passing: true, gpa}}) => - `Congrats ${name}, nice GPA of ${Js.Float.toString(gpa)} you got there!` -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - `Come back in ${Js.Int.toString(daysLeft)} days!` -| Student({status: Sick}) => - `How are you feeling?` -| Student({name}) => - `Good luck next semester ${name}!` -} -``` - -```js -if (person1.TAG) { - var match$1 = person1.status; - var name = person1.name; - var match$2 = person1.reportCard; - if (match$2.passing) { - "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!"; - } else if (typeof match$1 === "number") { - if (match$1 !== 0) { - "Good luck next semester " + name + "!"; - } else { - ("How are you feeling?"); - } - } else if (person1.reportCard.gpa !== 0.0) { - "Good luck next semester " + name + "!"; - } else { - "Come back in " + match$1._0.toString() + " days!"; - } -} else { - switch (person1.name) { - case "Joe": - case "Mary": - break; - default: - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 13, 0], - Error: new Error(), - }; - } -} -``` - - - -Did you see what we removed? This time, we've omitted the handling of the case where `person1` is `Teacher({name})` when `name` isn't Mary or Joe. - -Failing to handle every scenario of a value likely constitutes the majority of program bugs out there. This happens very often when you refactor a piece of code someone else wrote. Fortunately for ReScript, the compiler will tell you so: - -``` -Warning 8: this pattern-matching is not exhaustive. -Here is an example of a value that is not matched: -Some({name: ""}) -``` - -**BAM**! You've just erased an entire category of important bugs before you even ran the code. In fact, this is how most of nullable values is handled: - - - -```res example -let myNullableValue = Some(5) - -switch myNullableValue { -| Some(v) => Js.log("value is present") -| None => Js.log("value is absent") -} -``` - -```js -var myNullableValue = 5; - -if (myNullableValue !== undefined) { - console.log("value is present"); -} else { - console.log("value is absent"); -} -``` - - - -If you don't handle the `None` case, the compiler warns. No more `undefined` bugs in your code! - -## Conclusion & Tips & Tricks - -Hopefully you can see how pattern matching is a game changer for writing correct code, through the concise destructuring syntax, the proper conditions handling of `switch`, and the static exhaustiveness check. - -Below is some advice: - -Avoid using the wildcard `_` unnecessarily. Using the wildcard `_` will bypass the compiler's exhaustiveness check. Consequently, the compiler will not be able to notify you of probable errors when you add a new case to a variant. Try only using `_` against infinite possibilities, e.g. string, int, etc. - -Use the `if` clause sparingly. - -**Flatten your pattern-match whenever you can**. This is a real bug remover. Here's a series of examples, from worst to best: - - - -```res example -let optionBoolToBool = opt => { - if opt == None { - false - } else if opt === Some(true) { - true - } else { - false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt === undefined) { - return false; - } else { - return opt === true; - } -} -``` - - - -Now that's just silly =). Let's turn it into pattern-matching: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | None => false - | Some(a) => a ? true : false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Slightly better, but still nested. Pattern-matching allows you to do this: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | None => false - | Some(true) => true - | Some(false) => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Much more linear-looking! Now, you might be tempted to do this: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | Some(true) => true - | _ => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Which is much more concise, but kills the exhaustiveness check mentioned above; refrain from using that. This is the best: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | Some(trueOrFalse) => trueOrFalse - | None => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined) { - return opt; - } else { - return false; - } -} -``` - - - -Pretty darn hard to make a mistake in this code at this point! Whenever you'd like to use an if-else with many branches, prefer pattern matching instead. It's more concise and [performant](variant#design-decisions) too. diff --git a/pages/docs/manual/v10.0.0/pipe.mdx b/pages/docs/manual/v10.0.0/pipe.mdx deleted file mode 100644 index 07da1abc8..000000000 --- a/pages/docs/manual/v10.0.0/pipe.mdx +++ /dev/null @@ -1,258 +0,0 @@ ---- -title: "Pipe" -description: "The Pipe operator (->)" -canonical: "/docs/manual/latest/pipe" ---- - -# Pipe - -ReScript provides a tiny but surprisingly useful operator `->`, called the "pipe", that allows you to "flip" your code inside-out. `a(b)` becomes `b->a`. It's a simple piece of syntax that doesn't have any runtime cost. - -Why would you use it? Imagine you have the following: - - - -```res -validateAge(getAge(parseData(person))) -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -This is slightly hard to read, since you need to read the code from the innermost part, to the outer parts. Use pipe to streamline it: - - - -```res -person - ->parseData - ->getAge - ->validateAge -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -Basically, `parseData(person)` is transformed into `person->parseData`, and `getAge(person->parseData)` is transformed into `person->parseData->getAge`, etc. - -**This works when the function takes more than one argument too**. - - - -```res -a(one, two, three) -``` - -```js -a(one, two, three); -``` - - - -is the same as - - - -```res -one->a(two, three) -``` - -```js -a(one, two, three); -``` - - - -This also works with labeled arguments. - -Pipes are used to emulate object-oriented programming. For example, `myStudent.getName` in other languages like Java would be `myStudent->getName` in ReScript (equivalent to `getName(myStudent)`). This allows us to have the readability of OOP without the downside of dragging in a huge class system just to call a function on a piece of data. - -## Tips & Tricks - -Do **not** abuse pipes; they're a means to an end. Inexperienced engineers sometimes shape a library's API to take advantage of the pipe. This is backwards. - -## JS Method Chaining - -_This section requires understanding of [our binding API](bind-to-js-function.md#object-method)_. - -JavaScript's APIs are often attached to objects, and are often chainable, like so: - -```js -const result = [1, 2, 3].map((a) => a + 1).filter((a) => a % 2 === 0); - -asyncRequest().setWaitDuration(4000).send(); -``` - -Assuming we don't need the chaining behavior above, we'd bind to each case this using [`@send`](/syntax-lookup#send-decorator) from the aforementioned binding API page: - - - -```res prelude -type request -@val external asyncRequest: unit => request = "asyncRequest" -@send external setWaitDuration: (request, int) => request = "setWaitDuration" -@send external send: request => unit = "send" -``` - -```js -// Empty output -``` - - - -You'd use them like this: - - - -```res example -let result = Js.Array2.filter( - Js.Array2.map([1, 2, 3], a => a + 1), - a => mod(a, 2) == 0 -) - -send(setWaitDuration(asyncRequest(), 4000)) -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -This looks much worse than the JS counterpart! Clean it up visually with pipe: - - - -```res example -let result = [1, 2, 3] - ->Js.Array2.map(a => a + 1) - ->Js.Array2.filter(a => mod(a, 2) == 0) - -asyncRequest()->setWaitDuration(4000)->send -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -## Pipe Into Variants - -You can pipe into a variant's constructor as if it was a function: - - - -```res -let result = name->preprocess->Some -``` - -```js -var result = preprocess(name); -``` - - - -We turn this into: - - - -```res -let result = Some(preprocess(name)) -``` - -```js -var result = preprocess(name); -``` - - - -**Note** that using a variant constructor as a function wouldn't work anywhere else beside here. - -## Pipe Placeholders - -A placeholder is written as an underscore and it tells ReScript that you want to fill in an argument of a function later. These two have equivalent meaning: - -```res -let addTo7 = (x) => add3(3, x, 4) -let addTo7 = add3(3, _, 4) -``` - -Sometimes you don't want to pipe the value you have into the first position. In these cases you can mark a placeholder value to show which argument you would like to pipe into. - -Let's say you have a function `namePerson`, which takes a `person` then a `name` argument. If you are transforming a person then pipe will work as-is: - - - -```res -makePerson(~age=47, ()) - ->namePerson("Jane") -``` - -```js -namePerson(makePerson(47), "Jane"); -``` - - - -If you have a name that you want to apply to a person object, you can use a placeholder: - - - -```res -getName(input) - ->namePerson(personDetails, _) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -This allows you to pipe into any positional argument. It also works for named arguments: - - - -```res -getName(input) - ->namePerson(~person=personDetails, ~name=_) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -## Triangle Pipe (Deprecated) - -You might see usages of another pipe, `|>`, in some codebases. These are deprecated. - -Unlike `->` pipe, the `|>` pipe puts the subject as the last (not first) argument of the function. `a |> f(b)` turns into `f(b, a)`. - -For a more thorough discussion on the rationale and differences between the two operators, please refer to the [Data-first and Data-last comparison by Javier Chávarri](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/) diff --git a/pages/docs/manual/v10.0.0/polymorphic-variant.mdx b/pages/docs/manual/v10.0.0/polymorphic-variant.mdx deleted file mode 100644 index 66c88e0e4..000000000 --- a/pages/docs/manual/v10.0.0/polymorphic-variant.mdx +++ /dev/null @@ -1,433 +0,0 @@ ---- -title: "Polymorphic Variant" -description: "The Polymorphic Variant data structure in ReScript" -canonical: "/docs/manual/latest/polymorphic-variant" ---- - -# Polymorphic Variant - -Polymorphic variants (or poly variant) are a cousin of [variant](variant). With these differences: - -- They start with a `#` and the constructor name doesn't need to be capitalized. -- They don't require an explicit type definition. The type is inferred from usage. -- Values of different poly variant types can share the constructors they have in common (aka, poly variants are "structurally" typed, as opposed to ["nominally" typed](variant#variant-types-are-found-by-field-name)). - -They're a convenient and useful alternative to regular variants, but should **not** be abused. See the drawbacks at the end of this page. - -## Creation - -We provide 3 syntaxes for a poly variant's constructor: - - - -```res -let myColor = #red -let myLabel = #"aria-hidden" -let myNumber = #7 -``` - -```js -var myColor = "red"; -var myLabel = "aria-hidden"; -var myNumber = 7; -``` - - - -**Take a look at the output**. Poly variants are _great_ for JavaScript interop. For example, you can use it to model JavaScript string and number enums like TypeScript, but without confusing their accidental usage with regular strings and numbers. - -`myColor` uses the common syntax. The second and third syntaxes are to support expressing strings and numbers more conveniently. We allow the second one because otherwise it'd be invalid syntax since symbols like `-` and others are usually reserved. - -## Type Declaration - -Although **optional**, you can still pre-declare a poly variant type: - -```res -// Note the surrounding square brackets, and # for constructors -type color = [#red | #green | #blue] -``` - -These types can also be inlined, unlike for regular variant: - - - -```res -let render = (myColor: [#red | #green | #blue]) => { - switch myColor { - | #blue => Js.log("Hello blue!") - | #red - | #green => Js.log("Hello other colors") - } -} -``` - -```js -function render(myColor) { - if (myColor === "green" || myColor === "red") { - console.log("Hello other colors"); - } else { - console.log("Hello blue!"); - } -} -``` - - - -**Note**: because a poly variant value's type definition is **inferred** and not searched in the scope, the following snippet won't error: - - - -```res -type color = [#red | #green | #blue] - -let render = myColor => { - switch myColor { - | #blue => Js.log("Hello blue!") - | #green => Js.log("Hello green!") - // works! - | #yellow => Js.log("Hello yellow!") - } -} -``` - -```js -function render(myColor) { - if (myColor === "yellow") { - console.log("Hello yellow!"); - } else if (myColor === "green") { - console.log("Hello green!"); - } else { - console.log("Hello blue!"); - } -} -``` - - - -That `myColor` parameter's type is inferred to be `#red`, `#green` or `#yellow`, and is unrelated to the `color` type. If you intended `myColor` to be of type `color`, annotate it as `myColor: color` in any of the places. - -## Constructor Arguments - -This is similar to a regular variant's [constructor arguments](variant#constructor-arguments): - - - -```res -type account = [ - | #Anonymous - | #Instagram(string) - | #Facebook(string, int) -] - -let me: account = #Instagram("Jenny") -let him: account = #Facebook("Josh", 26) -``` - -```js -var me = { - NAME: "Instagram", - VAL: "Jenny", -}; - -var him = { - NAME: "Facebook", - VAL: ["Josh", 26], -}; -``` - - - -### Combine Types and Pattern Match - -You can use poly variant types within other poly variant types to create a sum of all constructors: - - - -```res -type red = [#Ruby | #Redwood | #Rust] -type blue = [#Sapphire | #Neon | #Navy] - -// Contains all constructors of red and blue. -// Also adds #Papayawhip -type color = [red | blue | #Papayawhip] - -let myColor: color = #Ruby -``` - -```js -var myColor = "Ruby"; -``` - - - -There's also some special [pattern matching](./pattern-matching-destructuring) syntax to match on constructors defined in a specific poly variant type: - - - -```res -// Continuing the previous example above... - -switch myColor { -| #...blue => Js.log("This blue-ish") -| #...red => Js.log("This red-ish") -| other => Js.log2("Other color than red and blue: ", other) -} -``` - -```js -var other = myColor; - -if (other === "Neon" || other === "Navy" || other === "Sapphire") { - console.log("This is blue-ish"); -} else if (other === "Rust" || other === "Ruby" || other === "Redwood") { - console.log("This is red-ish"); -} else { - console.log("Other color than red and blue: ", other); -} -``` - - - -This is a shorter version of: - -```res -switch myColor { -| #Sapphire | #Neon | #Navy => Js.log("This is blue-ish") -| #Ruby | #Redwood | #Rust => Js.log("This is red-ish") -| other => Js.log2("Other color than red and blue: ", other) -} -``` - -## Structural Sharing - -Since poly variants value don't have a source of truth for their type, you can write such code: - - - -```res -type preferredColors = [#white | #blue] - -let myColor: preferredColors = #blue - -let displayColor = v => { - switch v { - | #red => "Hello red" - | #green => "Hello green" - | #white => "Hey white!" - | #blue => "Hey blue!" - } -} - -Js.log(displayColor(myColor)) -``` - -```js -var myColor = "blue"; - -function displayColor(v) { - if (v === "white") { - return "Hey white!"; - } else if (v === "red") { - return "Hello red"; - } else if (v === "green") { - return "Hello green"; - } else { - return "Hey blue!"; - } -} - -console.log(displayColor("blue")); -``` - - - -With a regular variant, the line `displayColor(myColor)` would fail, since it'd complain that the type of `myColor` doesn't match the type of `v`. No problem with poly variant. - -## JavaScript Output - -Poly variants are great for JavaScript interop! You can share their values to JS code, or model incoming JS values as poly variants. - -- `#red` and `#"I am red 😃"` compile to JavaScipt `"red"` and `"I am red 😃"`. -- `#1` compiles to JavaScript `1`. -- Poly variant constructor with 1 argument, like `Instagram("Jenny")` compile to a straightforward `{NAME: "Instagram", VAL: "Jenny"}`. 2 or more arguments like `#Facebook("Josh", 26)` compile to a similar object, but with `VAL` being an array of the arguments. - -### Bind to Functions - -For example, let's assume we want to bind to `Intl.NumberFormat` and want to make sure that our users only pass valid locales, we could define an external binding like this: - - - -```res -type t - -@scope("Intl") @val -external makeNumberFormat: ([#"de-DE" | #"en-GB" | #"en-US"]) => t = "NumberFormat" - -let intl = makeNumberFormat(#"de-DE") -``` - -```js -var intl = Intl.NumberFormat("de-DE"); -``` - - - -The JS output is identical to handwritten JS, but we also get to enjoy type errors if we accidentally write `makeNumberFormat(#"de-DR")`. - -More advanced usage examples for poly variant interop can be found in [Bind to JS Function](bind-to-js-function#constrain-arguments-better). - -### Bind to String Enums - -Let's assume we have a TypeScript module that expresses following enum export: - -```js -// direction.js -enum Direction { - Up = "UP", - Down = "DOWN", - Left = "LEFT", - Right = "RIGHT", -} - -export const myDirection = Direction.Up -``` - -For this particular example, we can also inline poly variant type definitions to design the type for the imported `myDirection` value: - - - -```res -type direction = [ #UP | #DOWN | #LEFT | #RIGHT ] -@module("./direction.js") external myDirection: direction = "myDirection" -``` - -```js -var DirectionJs = require("./direction.js"); - -var myDirection = DirectionJs.myDirection; -``` - - - -Again: since we were using poly variants, the JS Output is practically zero-cost and doesn't add any extra code! - -## Extra Constraints on Types - -The previous poly variant type annotations we've looked at are the regular "closed" kind. However, there's a way to express "I want at least these constructors" (lower bound) and "I want at most these constructors" (upper bound): - -```res -// Only #Red allowed. Closed. -let basic: [#Red] = #Red - -// May contain #Red, or any other value. Open -// here, foreground will actually be inferred as [> #Red | #Green] -let foreground: [> #Red] = #Green - -// The value must be, at most, one of #Red or #Blue -// Only #Red and #Blue are valid values -let background: [< #Red | #Blue] = #Red -``` - -**Note:** We added this info for educational purposes. In most cases you will not want to use any of this stuff, since it makes your APIs pretty unreadable / hard to use. - -### Closed `[` - -This is the simplest poly variant definition, and also the most practical one. Like a common variant type, this one defines an exact set of constructors. - -```res -type rgb = [ #Red | #Green | #Blue ] - -let color: rgb = #Green -``` - -In the example above, `color` will only allow one of the three constructors that are defined in the `rgb` type. This is usually the way how poly variants should be defined. - -In case you want to define a type that is extensible, you'll need to use the lower / upper bound syntax. - -### Lower Bound `[>` - -A lower bound defines the minimum set of constructors a poly variant type is aware of. It is also considered an "open poly variant type", because it doesn't restrict any additional values. - -Here is an example on how to make a minimum set of `basicBlueTones` extensible for a new `color` type: - -```res -type basicBlueTone<'a> = [> #Blue | #DeepBlue | #LightBlue ] as 'a -type color = basicBlueTone<[#Blue | #DeepBlue | #LightBlue | #Purple]> - -let color: color = #Purple - -// This will fail due to missing minimum constructors: -type notWorking = basicBlueTone<[#Purple]> -``` - -Here, the compiler will enforce the user to define `#Blue | #DeepBlue | #LightBlue` as the minimum set of constructors when trying to extend `basicBlueTone<'a>`. - -**Note:** Since we want to define an extensible poly variant, we need to provide a type placeholder `<'a>`, and also add `as 'a` after the poly variant declaration, which essentially means: "Given type `'a` is constraint to the minimum set of constructors (`#Blue | #DeepBlue | #LightBlue`) defined in `basicBlueTone`". - -### Upper Bound `[<` - -The upper bound works in the opposite way than a lower bound: the extending type may only use constructors that are stated in the upper bound constraint. - -Here another example, but with red colors: - -```res -type validRed<'a> = [< #Fire | #Crimson | #Ash] as 'a -type myReds = validRed<[#Ash]> - -// This will fail due to unlisted constructor not defined by the lower bound -type notWorking = validRed<[#Purple]> -``` - -## Coercion - -You can convert a poly variant to a `string` or `int` at no cost: - - - -```res -type company = [#Apple | #Facebook] -let theCompany: company = #Apple - -let message = "Hello " ++ (theCompany :> string) -``` - -```js -var theCompany = "Apple"; -var message = "Hello " + theCompany; -``` - - - -**Note**: for the coercion to work, the poly variant type needs to be closed; you'd need to annotate it, since otherwise, `theCompany` would be inferred as `[> #Apple]`. - -## Tips & Tricks - -### Variant vs Polymorphic Variant - -One might think that polymorphic variants are superior to regular [variants](./variant). As always, there are trade-offs: - -- Due to their "structural" nature, poly variant's type errors might be more confusing. If you accidentally write `#blur` instead of `#blue`, ReScript will still error but can't indicate the correct source as easily. Regular variants' source of truth is the type definition, so the error can't go wrong. -- It's also harder to refactor poly variants. Consider this: - - ```res - let myFruit = #Apple - let mySecondFruit = #Apple - let myCompany = #Apple - ``` - - Refactoring the first one to `#Orange` doesn't mean we should refactor the third one. Therefore, the editor plugin can't touch the second one either. Regular variant doesn't have such problem, as these 2 values presumably come from different variant type definitions. - -- You might lose some nice pattern match checks from the compiler: - - ```res - let myColor = #red - - switch myColor { - | #red => Js.log("Hello red!") - | #blue => Js.log("Hello blue!") - } - ``` - - Because there's no poly variant definition, it's hard to know whether the `#blue` case can be safely removed. - -In most scenarios, we'd recommend to use regular variants over polymorphic variants, especially when you are writing plain ReScript code. In case you want to write zero-cost interop bindings or generate clean JS output, poly variants are oftentimes a better option. diff --git a/pages/docs/manual/v10.0.0/primitive-types.mdx b/pages/docs/manual/v10.0.0/primitive-types.mdx deleted file mode 100644 index c8db038c0..000000000 --- a/pages/docs/manual/v10.0.0/primitive-types.mdx +++ /dev/null @@ -1,193 +0,0 @@ ---- -title: "Primitive Types" -description: "Primitive Data Types in ReScript" -canonical: "/docs/manual/latest/primitive-types" ---- - -# Primitive Types - -ReScript comes with the familiar primitive types like `string`, `int`, `float`, etc. - - - -## String - -ReScript `string`s are delimited using **double** quotes (single quotes are reserved for the character type below). - - - -```res example -let greeting = "Hello world!" -let multilineGreeting = "Hello - world!" -``` - -```js -var greeting = "Hello world!"; -var multilineGreeting = "Hello\n world!"; -``` - - - -To concatenate strings, use `++`: - - - -```res example -let greetings = "Hello " ++ "world!" -``` - -```js -var greetings = "Hello world!"; -``` - - - -### String Interpolation - -There's a special syntax for string that allows - -- multiline string just like before -- no special character escaping -- Interpolation -- Proper unicode handling - - - -```res example -let name = "Joe" - -let greeting = `Hello -World -👋 -${name} -` -``` - -```js -var name = "Joe"; - -var greeting = "Hello\nWorld\n👋\n" + name + "\n"; -``` - - - -This is just like JavaScript's backtick string interpolation, except without needing to escape special characters. - -### Unsafe String Interpolation (Deprecated) - -> ReScript v10.1.4 deprecated unsafe string interpolation and will be removed in v11. - -For interpolation, you'll have to convert the binding (`name` in the example) into a string if it isn't one. If you want the interpolation to implicitly convert a binding into a string, prepend a `j`: - - - -```res example -let age = 10 -let message = j`Today I am $age years old.` -``` - -```js -var message = "Today I am " + 10 + " years old."; -``` - - - -### Usage - -See the familiar `Js.String` API in the [API docs](api/js/string). Since a ReScript string maps to a JavaScript string, you can mix & match the string operations in both standard libraries. - -### Tips & Tricks - -**You have a good type system now!** In an untyped language, you'd often overload the meaning of string by using it as: - -- a unique id: `var BLUE_COLOR = "blue"` -- an identifier into a data structure: `var BLUE = "blue" var RED = "red" var colors = [BLUE, RED]` -- the name of an object field: `person["age"] = 24` -- an enum: `if (audio.canPlayType() === 'probably') {...}` [(ಠ_ಠ)](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType#Return_value) -- other crazy patterns you'll soon find horrible, after getting used to ReScript's alternatives. - -The more you overload the poor string type, the less the type system (or a teammate) can help you! ReScript provides concise, fast and maintainable types & data structures alternatives to the use-cases above (e.g. variants, in a later section). - -## Char - -ReScript has a type for a string with a single letter: - - - -```res example -let firstLetterOfAlphabet = 'a' -``` - -```js -var firstLetterOfAlphabet = /* "a" */ 97; -``` - - - -**Note**: Char doesn't support Unicode or UTF-8 and is therefore not recommended. - -To convert a String to a Char, use `String.get("a", 0)`. To convert a Char to a String, use `String.make(1, 'a')`. - -## Regular Expression - -ReScript regular expressions compile cleanly to their JavaScript counterpart: - - - -```res example -let r = %re("/b/g") -``` - -```js -var r = /b/g; -``` - - - -A regular expression like the above has the type `Js.Re.t`. The [Js.Re](api/js/re) module contains the regular expression helpers you have seen in JS. - -## Boolean - -A ReScript boolean has the type `bool` and can be either `true` or `false`. Common operations: - -- `&&`: logical and. -- `||`: logical or. -- `!`: logical not. -- `<=`, `>=`, `<`, `>` -- `==`: structural equal, compares data structures deeply. `(1, 2) == (1, 2)` is `true`. Convenient, but use with caution. -- `===`: referential equal, compares shallowly. `(1, 2) === (1, 2)` is `false`. `let myTuple = (1, 2); myTuple === myTuple` is `true`. -- `!=`: structural unequal. -- `!==`: referential unequal. - -ReScript's `true/false` compiles into a JavaScript `true/false`. - -## Integers - -32-bits, truncated when necessary. We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [Js.Int](api/js/int) for helper functions. - -**Be careful when you bind to JavaScript numbers!** Since ReScript integers have a much smaller range than JavaScript numbers, data might get lost when dealing with large numbers. In those cases, it’s much safer to bind the numbers as **floats**. Be extra mindful of this when binding to JavaScript Dates and their epoch time. - -To improve readability, you may place underscores in the middle of numeric literals such as `1_000_000`. Note that underscores can be placed anywhere within a number, not just every three digits. - -## Floats - -Float requires other operators: `+.`, `-.`, `*.`, `/.`, etc. Like `0.5 +. 0.6`. See [Js.Float](api/js/float) for helper functions. - -As with integers, you may use underscores within literals to improve readability. - -## Unit - -The `unit` type indicates the absence of a specific value. It has only a single value, `()`, which acts as a placeholder when no other value exists or is needed. It compiles to JavaScript's `undefined` and resembles the `void` type in languages such as C++. What's the point of such a type? - -Consider the `Math.random` function. Its type signature is `unit => float`, which means it receives a `unit` as input and calculates a random `float` as output. You use the function like this - `let x = Math.random()`. Notice `()` as the first and only function argument. - -Imagine a simplified `Console.log` function that prints a message. Its type signature is `string => unit` and you'd use it like this `Console.log("Hello!")`. It takes a string as input, prints it, and then returns nothing useful. When `unit` is the output of a function it means the function performs some kind of side-effect. - -## Unknown - -The `unknown` type represents values with contents that are a mystery or are not 100% guaranteed to be what you think they are. It provides type-safety when interacting with data received from an untrusted source. For example, suppose an external function is supposed to return a `string`. It might. But if the documentation is not accurate or the code has bugs, the function could return `null`, an `array`, or something else you weren't expecting. - -The ReScript type system helps you avoid run-time crashes and unpredicatable behavior by preventing you from using `unknown` in places that expect a `string` or `int` or some other type. The ReScript core libraries also provide utility functions to help you inspect `unknown` values and access their contents. In some cases you may need a JSON parsing library to convert `unknown` values to types you can safely use. - -Consider using `unknown` when receiving data from [external JavaScript functions](/docs/manual/latest/bind-to-js-function) diff --git a/pages/docs/manual/v10.0.0/project-structure.mdx b/pages/docs/manual/v10.0.0/project-structure.mdx deleted file mode 100644 index 93e77f0f0..000000000 --- a/pages/docs/manual/v10.0.0/project-structure.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Project Structure" -description: "Notes on project structure and other rough ReScript guidelines" -canonical: "/docs/manual/latest/project-structure" ---- - -# Project Structure - -These are the existing, non-codified community practices that are currently propagated through informal agreement. We might remove some of them at one point, and enforce some others. Right now, they're just recommendations for ease of newcomers. - -## File Casing - -Capitalized file names (aka first letter upper-cased). - -**Justification**: Module names can only be capitalized. Newcomers often ask how a file maps to a module, and why `draw.res` maps to the module `Draw`, and sometimes try to refer to a module through uncapitalized identifiers. Using `Draw.res` makes this mapping more straightforward. It also helps certain file names that'd be awkward in uncapitalized form: `uRI.res`. - -## Ignore `.merlin` File - -This is generated by the build system and you should not have to manually edit it. Don't check it into the repo. - -**Justification**: `.merlin` is for editor tooling. The file contains absolute paths, which are also not cross-platform (e.g. Windows paths are different). - -## Folders - -Try not to have too many nested folders. Keep your project flat, and have fewer files (reminder: you can use nested modules). - -**Justification**: The file system is a _tree_, but your code's dependencies are a _graph_. Because of that, any file & folder organization is usually imperfect. While it's still valuable to group related files together in a folder, the time wasted debating & getting decision paralysis over these far outweight their benefits. We'll always recommend you to Get Work Done instead of debating about these issues. - -## Third-party Dependencies - -Keep them to a minimum. - -**Justification**: A compiled, statically typed language cannot model its dependencies easily by muddling along like in a dynamic language, especially when we're still piggy-backing on NPM/Yarn (to reduce learning overhead in the medium-term). Keeping dependencies simple & lean helps reduce possibility of conflicts (e.g. two diamond dependencies, or clashing interfaces). - -## Documentation - -Have them. Spend more effort making them great (examples, pitfalls) and professional rather than _just_ fancy-looking. Do use examples, and avoid using names such as `foo` and `bar`. There's always more concrete names (it's an example, no need to be abstract/generalized just yet. The API docs will do this plentily). For blog posts, don't repeat the docs themselves, describe the _transition_ from old to new, and why (e.g. "it was a component, now it's a function, because ..."). - -**Justification**: It's hard for newcomers to distinguish between a simple/decent library and one that's fancy-looking. For the sake of the community, don't try too hard to one-up each other's libraries. Do spread the words, but use your judgement too. - -## PPX & Other Meta-tools - -Keep them to a minimum. PPX, unless used in renown cases (printer, accessors and serializer/deserializer generation), can cause big learning churn for newcomers; on top of the syntax, semantics, types, build tool & FFI that they already have to learn, learning per-library custom transformations of the code is an extra step. More invasive macros makes the code itself less semantically meaningful too, since the essence would be hiding somewhere else. - -## Paradigm - -Don't abuse overly fancy features. Do leave some breathing room for future APIs but don't over-architect things. - -**Justification**: Simple code helps newcomers understand and potentially contribute to your code. Contributing is the best way for them to learn. The extra help you receive might also surpass the gain of using a slightly more clever language trick. But do try new language tricks in some of more casual projects! You might discover new ways of architecting code. - -## Publishing - -If it's a wrapper for a JS library, don't publish the JS artifacts. If it's a legit library, publish the artifacts in lib/js if you think JS consumers might use it. This is especially the case when you gradually convert a JS lib to ReScript while not breaking existing JS consumers. - -Do put the keywords `"rescript"` in your package.json `keywords` field. This allows us to find the library much more easily for future purposes. - -**Justification**: Be nice to JS consumers of your library. They're your future ReScripters. diff --git a/pages/docs/manual/v10.0.0/promise.mdx b/pages/docs/manual/v10.0.0/promise.mdx deleted file mode 100644 index c8fe215c7..000000000 --- a/pages/docs/manual/v10.0.0/promise.mdx +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: "Promises" -description: "JS Promise handling in ReScript" -canonical: "/docs/manual/latest/promise" ---- - -# Promise - -> **Note:** Starting from ReScript 10.1 and above, we recommend using [async / await](./async-await) when interacting with Promises. - -## `promise` type - -**Since 10.1** - -In ReScript, every JS promise is represented with the globally available `promise<'a>` type. For ReScript versions < 10.1, use its original alias `Js.Promise.t<'a>` instead. - -Here's a usage example in a function signature: - -```resi -// User.resi file - -type user = {name: string} - -let fetchUser: string => promise -``` - -To work with promise values (instead of using `async` / `await`) you may want to use the built-in `Js.Promise2` module. - -## Js.Promise2 - -A builtin module to create, chain and manipulate promises. - -> **Note:** This is an intermediate replacement for the `Js.Promise` module. It is designed to work with the `->` operator and should be used in favour of it's legacy counterpart. We are aware that the `Belt`, `Js` and `Js.xxx2` situation is confusing; a proper solution will hopefully be part of our upcoming `v11` release. - -### Creating a promise - -```res -let p1 = Js.Promise2.make((~resolve, ~reject) => { - // We use uncurried functions for resolve / reject - // for cleaner JS output without unintended curry calls - resolve(. "hello world") -}) - -let p2 = Js.Promise2.resolve("some value") - -// You can only reject `exn` values for streamlined catch handling -exception MyOwnError(string) -let p3 = Js.Promise2.reject(MyOwnError("some rejection")) -``` - -### Access the contents and transform a promise - -```res -let logAsyncMessage = () => { - open Js.Promise2 - Js.Promise2.resolve("hello world") - ->then(msg => { - // then callbacks require the result to be resolved explicitly - resolve("Message: " ++ msg) - }) - ->then(msg => { - Js.log(msg) - - // Even if there is no result, we need to use resolve() to return a promise - resolve() - }) - ->ignore // Requires ignoring due to unhandled return value -} -``` - -For comparison, the `async` / `await` version of the same code would look like this: - -```res -let logAsyncMessage = async () => { - let msg = await Js.Promise2.resolve("hello world") - Js.log(`Message: ${msg}`) -} -``` - -Needless to say, the async / await version offers better ergonomics and less opportunities to run into type issues. - -### Run multiple promises in parallel - -In case you want to launch multiple promises in parallel, use `Js.Promise2.all`: - - - -```res -@val -external fetchMessage: string => promise = "global.fetchMessage" - -let logAsyncMessage = async () => { - let messages = await Js.Promise2.all([fetchMessage("message1"), fetchMessage("message2")]) - - Js.log(Js.Array2.joinWith(messages, ", ")) -} -``` - -```js -async function logAsyncMessage(param) { - var messages = await Promise.all([ - global.fetchMessage("message1"), - global.fetchMessage("message2"), - ]); - console.log(messages.join(", ")); -} - -export { logAsyncMessage }; -``` - - - -## Js.Promise module (legacy - do not use) - -> **Note:** The `Js.Promise` bindings are following the outdated data-last convention from a few years ago. We kept those APIs for backwards compatibility. Either use `Js.Promise2` or a third-party promise binding instead. - -ReScript has built-in support for [JavaScript promises](api/js/promise). The 3 functions you generally need are: - -- `Js.Promise.resolve: 'a => Js.Promise.t<'a>` -- `Js.Promise.then_: ('a => Js.Promise.t<'b>, Js.Promise.t<'a>) => Js.Promise.t<'b>` -- `Js.Promise.catch: (Js.Promise.error => Js.Promise.t<'a>, Js.Promise.t<'a>) => Js.Promise.t<'a>` - -Additionally, here's the type signature for creating a promise on the ReScript side: - -```res -Js.Promise.make: ( - ( - ~resolve: (. 'a) => unit, - ~reject: (. exn) => unit - ) => unit -) => Js.Promise.t<'a> -``` - -This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](function.md#uncurried-function) (with a dot). `make` returns the created promise. - -### Usage - -Using the [pipe operator](pipe.md): - - - -```res example -let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2)) - -myPromise->Js.Promise.then_(value => { - Js.log(value) - Js.Promise.resolve(value + 2) -}, _)->Js.Promise.then_(value => { - Js.log(value) - Js.Promise.resolve(value + 3) -}, _)->Js.Promise.catch(err => { - Js.log2("Failure!!", err) - Js.Promise.resolve(-2) -}, _) -``` - -```js -var myPromise = new Promise(function (resolve, reject) { - return resolve(2); -}); - -myPromise - .then(function (value) { - console.log(value); - return Promise.resolve((value + 2) | 0); - }) - .then(function (value) { - console.log(value); - return Promise.resolve((value + 3) | 0); - }) - .catch(function (err) { - console.log("Failure!!", err); - return Promise.resolve(-2); - }); -``` - - diff --git a/pages/docs/manual/v10.0.0/record.mdx b/pages/docs/manual/v10.0.0/record.mdx deleted file mode 100644 index 02787cc8a..000000000 --- a/pages/docs/manual/v10.0.0/record.mdx +++ /dev/null @@ -1,460 +0,0 @@ ---- -title: "Record" -description: "Record types in ReScript" -canonical: "/docs/manual/latest/record" ---- - -# Record - -Records are like JavaScript objects but: - -- are immutable by default -- have fixed fields (not extensible) - -## Type Declaration - -A record needs a mandatory type declaration: - - - -```res prelude -type person = { - age: int, - name: string, -} -``` - -```js -// Empty output -``` - - - -## Creation - -To create a `person` record (declared above): - - - -```res prelude -let me = { - age: 5, - name: "Big ReScript" -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -When you create a new record value, ReScript tries to find a record type declaration that conforms to the shape of the value. So the `me` value here is inferred as of type `person`. - -The type is found by looking above the `me` value. **Note**: if the type instead resides in another file or module, you need to explicitly indicate which file or module it is: - - - -```res example -// School.res -type person = {age: int, name: string} -``` - -```js -// Empty output -``` - - - - - -```res -// Example.res - -let me: School.person = {age: 20, name: "Big ReScript"} -/* or */ -let me2 = {School.age: 20, name: "Big ReScript"} -``` - -```js -var me = { - age: 20, - name: "Big ReScript", -}; -var me2 = { - age: 20, - name: "Big ReScript", -}; -``` - - - -In both `me` and `me2` the record definition from `School` is found. The first one, `me` with the regular type annotation, is preferred. - -## Access - -Use the familiar dot notation: - - - -```res example -let name = me.name -``` - -```js -var name = "Big ReScript"; -``` - - - -## Immutable Update - -New records can be created from old records with the `...` spread operator. The original record isn't mutated. - - - -```res example -let meNextYear = {...me, age: me.age + 1} -``` - -```js -var meNextYear = { - age: 21, - name: "Big ReScript", -}; -``` - - - -**Note**: spread cannot add new fields to the record value, as a record's shape is fixed by its type. - -## Mutable Update - -Record fields can optionally be mutable. This allows you to efficiently update those fields in-place with the `=` operator. - - - -```res example -type person = { - name: string, - mutable age: int -} - -let baby = {name: "Baby ReScript", age: 5} -baby.age = baby.age + 1 // `baby.age` is now 6. Happy birthday! -``` - -```js -var baby = { - name: "Baby ReScript", - age: 5, -}; - -baby.age = (baby.age + 1) | 0; -``` - - - -Fields not marked with `mutable` in the type declaration cannot be mutated. - -## JavaScript Output - -ReScript records compile to straightforward JavaScript objects; see the various JS output tabs above. - -## Optional Record Fields - -ReScript [`v10`](/blog/release-10-0-0#experimental-optional-record-fields) introduced optional record fields. This means that you can define fields that can be omitted when creating the record. It looks like this: - - - -```res example -type person = { - age: int, - name?: string -} -``` - -```js -// Empty output -``` - - - -Notice how `name` has a suffixed `?`. That means that the field itself is _optional_. - -### Creation - -You can omit any optional fields when creating a record. Not setting an optional field will default the field's value to `None`: - - - -```res example -type person = { - age: int, - name?: string -} - -let me = { - age: 5, - name: "Big ReScript" -} - -let friend = { - age: 7 -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; - -var friend = { - age: 7, -}; -``` - - - -This has consequences for pattern matching, which we'll expand a bit on soon. - -## Immutable Update - -Updating an optional field via an immutable update above lets you set that field value without needing to care whether it's optional or not. - - - -```res example -type person = { - age: int, - name?: string -} - -let me = { - age: 123, - name: "Hello" -} - -let withoutName = { - ...me, - name: "New Name" -} -``` - -```js -import * as Caml_obj from "./stdlib/caml_obj.js"; - -var me = { - age: 123, - name: "Hello", -}; - -var newrecord = Caml_obj.obj_dup(me); - -newrecord.name = "New Name"; - -var withoutName = newrecord; -``` - - - -However, if you want to set the field to an optional value, you prefix that value with `?`: - - - -```res example -type person = { - age: int, - name?: string -} - -let me = { - age: 123, - name: "Hello" -} - -let maybeName = Some("My Name") - -let withoutName = { - ...me, - name: ?maybeName -} -``` - -```js -import * as Caml_obj from "./stdlib/caml_obj.js"; - -var me = { - age: 123, - name: "Hello", -}; - -var maybeName = "My Name"; - -var newrecord = Caml_obj.obj_dup(me); - -newrecord.name = maybeName; - -var withoutName = newrecord; -``` - - - -You can unset an optional field's value via that same mechanism by setting it to `?None`. - -### Pattern Matching on Optional Fields - -[Pattern matching](pattern-matching-destructuring), one of ReScript's most important features, has two caveats when you deal with optional fields. - -When matching on the value directly, it's an `option`. Example: - - - -```res -type person = { - age: int, - name?: string, -} - -let me = { - age: 123, - name: "Hello", -} - -let isRescript = switch me.name { -| Some("ReScript") => true -| Some(_) | None => false -} -``` - -```js -var isRescript; - -isRescript = "Hello" === "ReScript" ? true : false; - -var me = { - age: 123, - name: "Hello", -}; -``` - - - -But, when matching on the field as part of the general record structure, it's treated as the underlying, non-optional value: - - - -```res -type person = { - age: int, - name?: string, -} - -let me = { - age: 123, - name: "Hello", -} - -let isRescript = switch me { -| {name: "ReScript"} => true -| _ => false -} - -``` - -```js -var isRescript; - -isRescript = "Hello" === "ReScript" ? true : false; - -var me = { - age: 123, - name: "Hello", -}; -``` - - - -Sometimes you _do_ want to know whether the field was set or not. You can tell the pattern matching engine about that by prefixing your option match with `?`, like this: - - - -```res -type person = { - age: int, - name?: string, -} - -let me = { - age: 123, - name: "Hello", -} - -let nameWasSet = switch me { -| {name: ?None} => false -| {name: ?Some(_)} => true -} -``` - -```js -var nameWasSet = true; - -var me = { - age: 123, - name: "Hello", -}; -``` - - - -## Tips & Tricks - -### Record Types Are Found By Field Name - -With records, you **cannot** say "I'd like this function to take any record type, as long as they have the field `age`". The following **won't work as intended**: - - - -```res -type person = {age: int, name: string} -type monster = {age: int, hasTentacles: bool} - -let getAge = (entity) => entity.age -``` - -```js -function getAge(entity) { - return entity.age; -} -``` - - - -Instead, `getAge` will infer that the parameter `entity` must be of type `monster`, the closest record type with the field `age`. The following code's last line fails: - -```res -let kraken = {age: 9999, hasTentacles: true} -let me = {age: 5, name: "Baby ReScript"} - -getAge(kraken) -getAge(me) // type error! -``` - -The type system will complain that `me` is a `person`, and that `getAge` only works on `monster`. If you need such capability, use ReScript objects, described [here](object.md). - -### Optional Fields in Records Can Be Useful for Bindings - -Many JavaScript APIs tend to have large configuration objects that can be a bit annoying to model as records, since you previously always needed to specify all record fields when creating a record. - -Optional record fields, introduced in [`v10`](/blog/release-10-0-0#experimental-optional-record-fields), is intended to help with this. Optional fields will let you avoid having to specify all fields, and let you just specify the one's you care about. A significant improvement in ergonomics for bindings and other APIs with for example large configuration objects. - -## Design Decisions - -After reading the constraints in the previous sections, and if you're coming from a dynamic language background, you might be wondering why one would bother with record in the first place instead of straight using object, since the former needs explicit typing and doesn't allow different records with the same field name to be passed to the same function, etc. - -1. The truth is that most of the times in your app, your data's shape is actually fixed, and if it's not, it can potentially be better represented as a combination of variant (introduced next) + record instead. -2. Since a record type is resolved through finding that single explicit type declaration (we call this "nominal typing"), the type error messages end up better than the counterpart ("structural typing", like for tuples). This makes refactoring easier; changing a record type's fields naturally allows the compiler to know that it's still the same record, just misused in some places. Otherwise, under structural typing, it might get hard to tell whether the definition site or the usage site is wrong. diff --git a/pages/docs/manual/v10.0.0/reserved-keywords.mdx b/pages/docs/manual/v10.0.0/reserved-keywords.mdx deleted file mode 100644 index 2798ed507..000000000 --- a/pages/docs/manual/v10.0.0/reserved-keywords.mdx +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: "Reserved Keyword" -description: "All reserved keywords in ReScript" -canonical: "/docs/manual/latest/reserved-keywords" ---- - -# Reserved Keywords - -> **Note**: Some of these words are reserved purely for backward compatibility. -> -> If you _need_ to use one of these names as binding and/or field name, see [Use Illegal Identifier Names](use-illegal-identifier-names.md). - -- `and` -- `as` -- `assert` - - - - - -- `constraint` - - - - -- `else` - - -- `exception` -- `external` - -- `false` -- `for` - - - - -- `if` -- `in` -- `include` - - - -- `lazy` -- `let` - -- `module` -- `mutable` - - - - - - -- `of` -- `open` - - - - - -- `rec` - - - - -- `switch` - - - -- `true` -- `try` -- `type` - - - - -- `when` -- `while` -- `with` diff --git a/pages/docs/manual/v10.0.0/scoped-polymorphic-types.mdx b/pages/docs/manual/v10.0.0/scoped-polymorphic-types.mdx deleted file mode 100644 index 5f6cb6a7d..000000000 --- a/pages/docs/manual/v10.0.0/scoped-polymorphic-types.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: "Scoped Polymorphic Types" -description: "Scoped Polymorphic Types in ReScript" -canonical: "/docs/manual/latest/scoped-polymorphic-types" ---- - -# Scoped Polymorphic Types - -Scoped Polymorphic Types in ReScript are functions with the capability to handle arguments of any type within a specific scope. This feature is particularly valuable when working with JavaScript APIs, as it allows your functions to accommodate diverse data types while preserving ReScript's strong type checking. - -## Definition and Usage - -Scoped polymorphic types in ReScript offer a flexible and type-safe way to handle diverse data types within specific scopes. This documentation provides an example to illustrate their usage in a JavaScript context. - -### Example: Logging API - -Consider a logging example within a JavaScript context that processes various data types: - -```js -const logger = { - log: (data) => { - if (typeof data === "string") { - /* handle string */ - } else if (typeof data === "number") { - /* handle number */ - } else { - /* handle other types */ - } - }, -}; -``` - -In ReScript, we can bind to this function as a record with a scoped polymorphic function type: - -```res prelude -type logger = { log: 'a. 'a => unit } - -@module("jsAPI") external getLogger: unit => logger = "getLogger" -``` - -The `logger` type represents a record with a single field `log`, which is a scoped polymorphic function type `'a. 'a => unit`. The `'a` indicates a type variable that can be any type within the scope of the `log` function. - -Now, we can utilize the function obtained from `getLogger`: - - - -```res example -let myLogger = getLogger() - -myLogger.log("Hello, ReScript!") -myLogger.log(42) -``` - -```js -var myLogger = JsAPI.getLogger(); - -myLogger.log("Hello, ReScript!"); -myLogger.log(42); -``` - - - -In this example, we create an instance of the logger by calling `getLogger()`, and then we can use the `log` function on the `myLogger` object to handle different data types. - -## Limitations of Normal Polymorphic Types - -Let's consider the same logging example in ReScript, but this time using normal polymorphic types: - -```res -type logger<'a> = { log: 'a => unit} - -@module("jsAPI") external getLogger: unit => logger<'a> = "getLogger" -``` - -In this case, the `logger` type is a simple polymorphic function type `'a => unit`. However, when we attempt to use this type in the same way as before, we encounter an issue: - -```res -let myLogger = getLogger() - -myLogger.log("Hello, ReScript!") -myLogger.log(42) // Type error! -``` - -The problem arises because the type inference in ReScript assigns a concrete type to the `logger` function based on the first usage. In this example, after the first call to `myLogger`, the compiler infers the type `logger` for `myLogger`. Consequently, when we attempt to pass an argument of type `number` in the next line, a type error occurs because it conflicts with the inferred type `logger`. - -In contrast, scoped polymorphic types, such as `'a. 'a => unit`, overcome this limitation by allowing type variables within the scope of the function. They ensure that the type of the argument is preserved consistently within that scope, regardless of the specific value used in the first invocation. - -## Limitations of Scoped Polymorphic Types - -Scoped polymorphic types work only when they are directly applied to let-bindings or record fields (as demonstrated in the logger example above). They can neither be applied to function bodies, nor to separate type definitions: - -```res -exception Abort - -let testExn: 'a. unit => 'a = () => raise(Abort) // Works! - -let testExn2 = (): 'a. 'a = raise(Abort) // Syntax error! -type fn = 'a. 'a => unit // Syntax error! -``` diff --git a/pages/docs/manual/v10.0.0/shared-data-types.mdx b/pages/docs/manual/v10.0.0/shared-data-types.mdx deleted file mode 100644 index 9c01c5c38..000000000 --- a/pages/docs/manual/v10.0.0/shared-data-types.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Shared Data Types" -description: "Data types that share runtime presentation between JS and ReScript" -canonical: "/docs/manual/latest/shared-data-types" ---- - -# Shared Data Types - -ReScript's built-in values of type `string`, `float`, `array` and a few others have a rather interesting property: they compile to the exact same value in JavaScript! - -This means that if you're passing e.g. a ReScript string to the JavaScript side, the JS side can directly use it as a native JS string. It also means that you can import a JS string and pretend it's a native ReScript string. - -Unlike most compiled-to-js languages, in ReScript, **you don't need to write data converters back and forth for most of our values**! - -**Shared, bidirectionally usable types**: - -- String. ReScript strings are JavaScript strings, vice-versa. (Caveat: only our backtick string `` `hello 👋 ${personName}` `` supports unicode and interpolation). -- Float. ReScript floats are JS numbers, vice-versa. -- Array. In addition to the [JS Array API](api/js/array), we provide our own [Belt.Array](api/belt/array#set) API too. -- Tuple. Compiles to a JS array. You can treat a fixed-sized, heterogenous JS array as ReScript tuple too. -- Boolean. -- Record. Record compiles to JS object. Therefore you can also treat JS objects as records. If they're too dynamic, consider modeling them on the ReScript side as a hashmap/dictionary [`Js.Dict`](api/js/dict) or a ReScript object. -- Object. ReScript objects are JavaScript objects, vice-versa. -- Function. They compile to clean JS functions. -- Module. ReScript files are considered top-level modules, and are compiled to JS files 1 to 1. Nested modules are compiled to JavaScript objects. -- Polymorphic variants. -- Unit. The `unit` type, which has a single value `()`, compiles to `undefined` too. Likewise, you can treat an incoming JS `undefined` as `()` if that's the only value it'll ever be. - -**Types that are slightly different than JS, but that you can still use from JS**: - -- Int. **Ints are 32-bits**! Be careful, you can potentially treat them as JS numbers and vice-versa, but if the number's large, then you better treat JS numbers as floats. For example, we bind to Js.Date using `float`s. -- Option. The `option` type's `None` value compiles into JS `undefined`. The `Some` value, e.g. `Some(5)`, compiles to `5`. Likewise, you can treat an incoming JS `undefined` as `None`. **JS `null` isn't handled here**. If your JS value can be `null`, use [Js.Nullable](api/js/nullable) helpers. -- Exception. -- Variant. Check the compiled JavaScript output of variant to see its shape. We don't recommend exporting a ReScript variant for pure JS usage, since they're harder to read as plain JS code, but you can do it. -- List, which is just a regular variant. - -**Non-shared types (aka internal types)**: - -- Character. -- Int64. -- Lazy values. -- Everything else. - -Many of these are stable, which means that you can still serialize/deserialize them as-is without manual conversions. But we discourage actively peeking into their structure otherwise. - -These types require manual conversions if you want to export them for JS consumption. For a seamless JS/TypeScript/Flow integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand. diff --git a/pages/docs/manual/v10.0.0/try.mdx b/pages/docs/manual/v10.0.0/try.mdx deleted file mode 100644 index 6e250decc..000000000 --- a/pages/docs/manual/v10.0.0/try.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: "Try" -description: "Try ReScript via Command Line" -canonical: "/docs/manual/latest/try" ---- - -## Try Online - -Our [Playground](/try) lets you try ReScript online, and comes with [ReScript-React](/docs/react/latest/introduction) preinstalled. diff --git a/pages/docs/manual/v10.0.0/tuple.mdx b/pages/docs/manual/v10.0.0/tuple.mdx deleted file mode 100644 index 0ddd78fc6..000000000 --- a/pages/docs/manual/v10.0.0/tuple.mdx +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: "Tuple" -description: "Tuple types and values in ReScript" -canonical: "/docs/manual/latest/tuple" ---- - -# Tuple - -Tuples are a ReScript-specific data structure that doesn't exist in JavaScript. They are: - -- immutable -- ordered -- fix-sized at creation time -- heterogeneous (can contain different types of values) - - - -```res example -let ageAndName = (24, "Lil' ReScript") -let my3dCoordinates = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -Tuples' types can be used in type annotations as well. Tuple types visually resemble tuples values. - - - -```res prelude -let ageAndName: (int, string) = (24, "Lil' ReScript") -// a tuple type alias -type coord3d = (float, float, float) -let my3dCoordinates: coord3d = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -**Note**: there's no tuple of size 1. You'd just use the value itself. - -## Usage - -To get a specific member of a tuple, destructure it: - - - -```res example -let (_, y, _) = my3dCoordinates // now you've retrieved y -``` - -```js -var y = 30.5; -``` - - - -The `_` means you're ignoring the indicated members of the tuple. - -Tuples aren't meant to be updated mutatively. You'd create new ones by destructuring the old ones: - - - -```res example -let coordinates1 = (10, 20, 30) -let (c1x, _, _) = coordinates1 -let coordinates2 = (c1x + 50, 20, 30) -``` - -```js -var coordinates1 = [10, 20, 30]; -var c1x = 10; -var coordinates2 = [60, 20, 30]; -``` - - - -## Tips & Tricks - -You'd use tuples in handy situations that pass around multiple values without too much ceremony. For example, to return many values: - - - -```res -let getCenterCoordinates = () => { - let x = doSomeOperationsHere() - let y = doSomeMoreOperationsHere() - (x, y) -} -``` - -```js -function getCenterCoordinates(param) { - var x = doSomeOperationsHere(undefined); - var y = doSomeMoreOperationsHere(undefined); - return [x, y]; -} -``` - - - -Try to keep the usage of tuple **local**. For data structures that are long-living and passed around often, prefer a **record**, which has named fields. diff --git a/pages/docs/manual/v10.0.0/type.mdx b/pages/docs/manual/v10.0.0/type.mdx deleted file mode 100644 index 7a8436aa8..000000000 --- a/pages/docs/manual/v10.0.0/type.mdx +++ /dev/null @@ -1,292 +0,0 @@ ---- -title: "Type" -description: "Types and type definitions in ReScript" -canonical: "/docs/manual/latest/type" ---- - -# Type - -Types are the highlight of ReScript! They are: - -- **Strong**. A type can't change into another type. In JavaScript, your variable's type might change when the code runs (aka at runtime). E.g. a `number` variable might change into a `string` sometimes. This is an anti-feature; it makes the code much harder to understand when reading or debugging. -- **Static**. ReScript types are erased after compilation and don't exist at runtime. Never worry about your types dragging down performance. You don't need type info during runtime; we report all the information (especially all the type errors) during compile time. Catch the bugs earlier! -- **Sound**. This is our biggest differentiator versus many other typed languages that compile to JavaScript. Our type system is guaranteed to **never** be wrong. Most type systems make a guess at the type of a value and show you a type in your editor that's sometimes incorrect. We don't do that. We believe that a type system that is sometimes incorrect can end up dangerous due to expectation mismatches. -- **Fast**. Many developers underestimate how much of their project's build time goes into type checking. Our type checker is one of the fastest around. -- **Inferred**. You don't have to write down the types! ReScript can deduce them from their values. Yes, it might seem magical that we can deduce all of your program's types, without incorrectness, without your manual annotation, and do so quickly. Welcome to ReScript =). - -The following sections explore more of our type system. - -## Inference - -This let-binding doesn't contain any written type: - - - -```res example -let score = 10 -let add = (a, b) => a + b -``` - -```js -var score = 10; -function add(a, b) { - return (a + b) | 0; -} -``` - - - -ReScript knows that `score` is an `int`, judging by the value `10`. This is called **inference**. Likewise, it also knows that the `add` function takes 2 `int`s and returns an `int`, judging from the `+` operator, which works on ints. - -## Type Annotation - -But you can also optionally write down the type, aka annotate your value: - - - -```res example -let score: int = 10 -``` - -```js -var score = 10; -``` - - - -If the type annotation for `score` doesn't correspond to our inferred type for it, we'll show you an error during compilation time. We **won't** silently assume your type annotation is correct, unlike many other languages. - -You can also wrap any expression in parentheses and annotate it: - - - -```res -let myInt = 5 -let myInt: int = 5 -let myInt = (5: int) + (4: int) -let add = (x: int, y: int) : int => x + y -let drawCircle = (~radius as r: int): circleType => /* code here */ -``` - -```js -var myInt = 9; -function add(x, y) { - return (x + y) | 0; -} -function drawCircle(r) { - /* code here */ -} -``` - - - -Note: in the last line, `(~radius as r: int)` is a labeled argument. More on this in the [function](function.md) page. - -## Type Alias - -You can refer to a type by a different name. They'll be equivalent: - - - -```res example -type scoreType = int -let x: scoreType = 10 -``` - -```js -var x = 10; -``` - - - -## Type Parameter (Aka Generic) - -Types can accept parameters, akin to generics in other languages. The parameters' names **need** to start with `'`. - -The use-case of a parameterized type is to kill duplications. Before: - - - -```res example -// this is a tuple of 3 items, explained next -type intCoordinates = (int, int, int) -type floatCoordinates = (float, float, float) - -let a: intCoordinates = (10, 20, 20) -let b: floatCoordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -After: - - - -```res example -type coordinates<'a> = ('a, 'a, 'a) - -let a: coordinates = (10, 20, 20) -let b: coordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -Note that the above codes are just contrived examples for illustration purposes. Since the types are inferred, you could have just written: - - - -```res example -let buddy = (10, 20, 20) -``` - -```js -var buddy = [10, 20, 20]; -``` - - - -The type system infers that it's a `(int, int, int)`. Nothing else needed to be written down. - -Type arguments appear in many places. Our `array<'a>` type is such a type that requires a type parameter. - - - -```res example -// inferred as `array` -let greetings = ["hello", "world", "how are you"] -``` - -```js -// inferred as `array` -var greetings = ["hello", "world", "how are you"]; -``` - - - -If types didn't accept parameters, the standard library would need to define the types `arrayOfString`, `arrayOfInt`, `arrayOfTuplesOfInt`, etc. That'd be tedious. - -Types can receive many arguments, and be composable. - - - - - -```res example -type result<'a, 'b> = - | Ok('a) - | Error('b) - -type myPayload = {data: string} - -type myPayloadResults<'errorType> = array> - -let payloadResults: myPayloadResults = [ - Ok({data: "hi"}), - Ok({data: "bye"}), - Error("Something wrong happened!") -] -``` - -```js -var payloadResults = [ - { - TAG: /* Ok */ 0, - _0: { data: "hi" }, - }, - { - TAG: /* Ok */ 0, - _0: { data: "bye" }, - }, - { - TAG: /* Error */ 1, - _0: "Something wrong happened!", - }, -]; -``` - - - -## Recursive Types - -Just like a function, a type can reference itself within itself using `rec`: - - - -```res example -type rec person = { - name: string, - friends: array -} -``` - -```js -// Empty output -``` - - - -## Mutually Recursive Types - -Types can also be _mutually_ recursive through `and`: - - - -```res example -type rec student = {taughtBy: teacher} -and teacher = {students: array} -``` - -```js -// Empty output -``` - - - -## Type Escape Hatch - -ReScript's type system is robust and does not allow dangerous, unsafe stuff like implicit type casting, randomly guessing a value's type, etc. However, out of pragmatism, we expose a single escape hatch for you to "lie" to the type system: - - - -```res -external myShadyConversion: myType1 => myType2 = "%identity" -``` - -```js -// Empty output -``` - - - -This declaration converts a `myType1` of your choice to `myType2` of your choice. You can use it like so: - - - -```res example -external convertToFloat : int => float = "%identity" -let age = 10 -let gpa = 2.1 +. convertToFloat(age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - - -Obviously, do **not** abuse this feature. Use it tastefully when you're working with existing, overly dynamic JS code, for example. - -More on externals [here](external.md). - -**Note**: this particular `external` is the only one that isn't preceded by a `@` [attribute](attribute.md). diff --git a/pages/docs/manual/v10.0.0/unboxed.mdx b/pages/docs/manual/v10.0.0/unboxed.mdx deleted file mode 100644 index 85a053a22..000000000 --- a/pages/docs/manual/v10.0.0/unboxed.mdx +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: "Unboxed" -description: "Unbox a wrapper" -canonical: "/docs/manual/latest/unboxed" ---- - -# Unboxed - -Consider a ReScript variant with a single payload, and a record with a single field: - - - -```res -type name = Name(string) -let studentName = Name("Joe") - -type greeting = {message: string} -let hi = {message: "hello!"} -``` - -```js -var studentName = /* Name */ { - _0: "Joe", -}; - -var hi = { - message: "hello!", -}; -``` - - - -If you check the JavaScript output, you'll see the `studentName` and `hi` JS object, as expected (see the [variant JS output](variant#javascript-output) and [record JS output](record#javascript-output) sections for details). - -For performance and certain JavaScript interop situations, ReScript offers a way to unwrap (aka unbox) the JS object wrappers from the output for records with a single field and variants with a single constructor and single payload. Annotate their type declaration with the attribute `@unboxed`: - - - -```res -@unboxed -type name = Name(string) -let studentName = Name("Joe") - -@unboxed -type greeting = {message: string} -let hi = {message: "hello!"} -``` - -```js -var studentName = "Joe"; - -var hi = "hello!"; -``` - - - -Check the new output! Clean. - -## Usage - -Why would you ever want a variant or a record with a single payload? Why not just... pass the payload? Here's one use-case for variant. - -Suppose you have a game with a local/global coordinate system: - - - -```res example -type coordinates = {x: float, y: float} - -let renderDot = (coordinates) => { - Js.log3("Pretend to draw at:", coordinates.x, coordinates.y) -} - -let toWorldCoordinates = (localCoordinates) => { - { - x: localCoordinates.x +. 10., - y: localCoordinates.x +. 20., - } -} - -let playerLocalCoordinates = {x: 20.5, y: 30.5} - -renderDot(playerLocalCoordinates) -``` - -```js -function renderDot(coordinates) { - console.log("Pretend to draw at:", coordinates.x, coordinates.y); -} - -function toWorldCoordinates(localCoordinates) { - return { - x: localCoordinates.x + 10, - y: localCoordinates.x + 20, - }; -} - -var playerLocalCoordinates = { - x: 20.5, - y: 30.5, -}; - -renderDot(playerLocalCoordinates); -``` - - - -Oops, that's wrong! `renderDot` should have taken global coordinates, not local ones... Let's prevent passing the wrong kind of coordinates: - - - -```res example -type coordinates = {x: float, y: float} -@unboxed type localCoordinates = Local(coordinates) -@unboxed type worldCoordinates = World(coordinates) - -let renderDot = (World(coordinates)) => { - Js.log3("Pretend to draw at:", coordinates.x, coordinates.y) -} - -let toWorldCoordinates = (Local(coordinates)) => { - World({ - x: coordinates.x +. 10., - y: coordinates.x +. 20., - }) -} - -let playerLocalCoordinates = Local({x: 20.5, y: 30.5}) - -// This now errors! -// renderDot(playerLocalCoordinates) -// We're forced to do this instead: -renderDot(playerLocalCoordinates->toWorldCoordinates) -``` - -```js -function renderDot(coordinates) { - console.log("Pretend to draw at:", coordinates.x, coordinates.y); -} - -function toWorldCoordinates(coordinates) { - return { - x: coordinates.x + 10, - y: coordinates.x + 20, - }; -} - -var playerLocalCoordinates = { - x: 20.5, - y: 30.5, -}; - -renderDot(toWorldCoordinates(playerLocalCoordinates)); -``` - - - -Now `renderDot` only takes `worldCoordinates`. Through a nice combination of using distinct variant types + argument destructuring, we've achieved better safety **without compromising on performance**: the `unboxed` attribute compiled to clean, variant-wrapper-less JS code! Check the output. - -As for a record with a single field, the use-cases are a bit more edgy. We won't mention them here. diff --git a/pages/docs/manual/v10.0.0/use-illegal-identifier-names.mdx b/pages/docs/manual/v10.0.0/use-illegal-identifier-names.mdx deleted file mode 100644 index b1fc91e98..000000000 --- a/pages/docs/manual/v10.0.0/use-illegal-identifier-names.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: "Use Illegal Identifier Names" -description: "Handling (JS) naming collisions in ReScript" -canonical: "/docs/manual/latest/use-illegal-identifier-names" ---- - -# Use Illegal Identifier Names - -Sometime, for e.g. a let binding or a record field, you might want to use: - -- A capitalized name. -- A name that contains illegal characters (e.g. emojis, hyphen, space). -- A name that's one of ReScript's reserved keywords. - -We provide an escape hatch syntax for these cases: - - - -```res example -let \"my-🍎" = 10 - -type element = { - \"aria-label": string -} - -let myElement = { - \"aria-label": "close" -} - -let label = myElement.\"aria-label" - -let calculate = (~\"Props") => { - \"Props" + 1 -} -``` - -```js -var my$$unknown$unknown$unknown$unknown = 10; - -var myElement = { - "aria-label": "close", -}; - -var label = myElement["aria-label"]; - -function calculate(Props) { - return (Props + 1) | 0; -} -``` - - - -See the output. **Use them only when necessary**, for interop with JavaScript. This is a last-resort feature. If you abuse this, many of the compiler guarantees will go away. diff --git a/pages/docs/manual/v10.0.0/variant.mdx b/pages/docs/manual/v10.0.0/variant.mdx deleted file mode 100644 index 649d97b4c..000000000 --- a/pages/docs/manual/v10.0.0/variant.mdx +++ /dev/null @@ -1,370 +0,0 @@ ---- -title: "Variant" -description: "Variant data structures in ReScript" -canonical: "/docs/manual/latest/variant" ---- - -# Variant - -So far, most of ReScript's data structures might look familiar to you. This section introduces an extremely important, and perhaps unfamiliar, data structure: variant. - -Most data structures in most languages are about "this **and** that". A variant allows us to express "this **or** that". - - - -```res example -type myResponse = - | Yes - | No - | PrettyMuch - -let areYouCrushingIt = Yes -``` - -```js -var areYouCrushingIt = /* Yes */ 0; -``` - - - -`myResponse` is a variant type with the cases `Yes`, `No` and `PrettyMuch`, which are called "variant constructors" (or "variant tag"). The `|` bar separates each constructor. - -**Note**: a variant's constructors need to be capitalized. - -## Variant Needs an Explicit Definition - -If the variant you're using is in a different file, bring it into scope like you'd do [for a record](record.md#record-needs-an-explicit-definition): - - - -```res example -// Zoo.res -type animal = Dog | Cat | Bird -``` - -```js -// Empty output -``` - - - - - -```res -// Example.res -let pet: Zoo.animal = Dog // preferred -// or -let pet2 = Zoo.Dog -``` - -```js -var pet = /* Dog */ 0; -var pet2 = /* Dog */ 0; -``` - - - -## Constructor Arguments - -A variant's constructors can hold extra data separated by comma. - - - -```res prelude -type account = - | None - | Instagram(string) - | Facebook(string, int) -``` - -```js -// Empty output -``` - - - -Here, `Instagram` holds a `string`, and `Facebook` holds a `string` and an `int`. Usage: - - - -```res example -let myAccount = Facebook("Josh", 26) -let friendAccount = Instagram("Jenny") -``` - -```js -var myAccount = { - TAG: /* Facebook */ 1, - _0: "Josh", - _1: 26, -}; -var friendAccount = { - TAG: /* Instagram */ 0, - _0: "Jenny", -}; -``` - - - -### Labeled Variant Payloads (Inline Record) - -If a variant payload has multiple fields, you can use a record-like syntax to label them for better readability: - - - -```res example -type user = - | Number(int) - | Id({name: string, password: string}) - -let me = Id({name: "Joe", password: "123"}) -``` - -```js -var me = { - TAG: /* Id */ 1, - name: "Joe", - password: "123", -}; -``` - - - -This is technically called an "inline record", and only allowed within a variant constructor. You cannot inline a record type declaration anywhere else in ReScript. - -Of course, you can just put a regular record type in a variant too: - - - -```res example -type u = {name: string, password: string} -type user = - | Number(int) - | Id(u) - -let me = Id({name: "Joe", password: "123"}) -``` - -```js -var me = { - TAG: /* Id */ 1, - _0: { - name: "Joe", - password: "123", - }, -}; -``` - - - -The output is slightly uglier and less performant than the former. - -### Pattern Matching On Variant - -See the [Pattern Matching/Destructuring](pattern-matching-destructuring) section later. - -## JavaScript Output - -A variant value compiles to 3 possible JavaScript outputs depending on its type declaration: - -- If the variant value is a constructor with no payload, it compiles to a number. -- If it's a constructor with a payload, it compiles to an object with the field `TAG` and the field `_0` for the first payload, `_1` for the second payload, etc. -- An exception to the above is a variant whose type declaration contains only a single constructor with payload. In that case, the constructor compiles to an object without the `TAG` field. -- Labeled variant payloads (the inline record trick earlier) compile to an object with the label names instead of `_0`, `_1`, etc. The object might or might not have the `TAG` field as per previous rule. - -Check the output in these examples: - - - -```res example -type greeting = Hello | Goodbye -let g1 = Hello -let g2 = Goodbye - -type outcome = Good | Error(string) -let o1 = Good -let o2 = Error("oops!") - -type family = Child | Mom(int, string) | Dad (int) -let f1 = Child -let f2 = Mom(30, "Jane") -let f3 = Dad(32) - -type person = Teacher | Student({gpa: float}) -let p1 = Teacher -let p2 = Student({gpa: 99.5}) - -type s = {score: float} -type adventurer = Warrior(s) | Wizard(string) -let a1 = Warrior({score: 10.5}) -let a2 = Wizard("Joe") -``` - -```js -var g1 = /* Hello */ 0; -var g2 = /* Goodbye */ 1; - -var o1 = /* Good */ 0; -var o2 = /* Error */ { - _0: "oops!", -}; - -var f1 = /* Child */ 0; -var f2 = { - TAG: /* Mom */ 0, - _0: 30, - _1: "Jane", -}; -var f3 = { - TAG: /* Dad */ 1, - _0: 32, -}; - -var p1 = /* Teacher */ 0; -var p2 = /* Student */ { - gpa: 99.5, -}; - -var a1 = { - TAG: /* Warrior */ 0, - _0: { - score: 10.5, - }, -}; -var a2 = { - TAG: /* Wizard */ 1, - _0: "Joe", -}; -``` - - - -## Tips & Tricks - -**Be careful** not to confuse a constructor carrying 2 arguments with a constructor carrying a single tuple argument: - - - -```res example -type account = - | Facebook(string, int) // 2 arguments -type account2 = - | Instagram((string, int)) // 1 argument - happens to be a 2-tuple -``` - -```js -// Empty output -``` - - - -### Variants Must Have Constructors - -If you come from an untyped language, you might be tempted to try `type myType = int | string`. This isn't possible in ReScript; you'd have to give each branch a constructor: `type myType = Int(int) | String(string)`. The former looks nice, but causes lots of trouble down the line. - -### Interop with JavaScript - -_This section assumes knowledge about our JavaScript interop. Skip this if you haven't felt the itch to use variants for wrapping JS functions yet_. - -Quite a few JS libraries use functions that can accept many types of arguments. In these cases, it's very tempting to model them as variants. For example, suppose there's a `myLibrary.draw` JS function that takes in either a `number` or a `string`. You might be tempted to bind it like so: - - - -```res example -// reserved for internal usage -@module("myLibrary") external draw : 'a => unit = "draw" - -type animal = - | MyFloat(float) - | MyString(string) - -let betterDraw = (animal) => - switch animal { - | MyFloat(f) => draw(f) - | MyString(s) => draw(s) - } - -betterDraw(MyFloat(1.5)) -``` - -```js -var MyLibrary = require("myLibrary"); - -function betterDraw(animal) { - MyLibrary.draw(animal._0); -} - -betterDraw({ - TAG: /* MyFloat */ 0, - _0: 1.5, -}); -``` - - - -**Try not to do that**, as this generates extra noisy output. Alternatively, define two `external`s that both compile to the same JS call: - - - -```res example -@module("myLibrary") external drawFloat: float => unit = "draw" -@module("myLibrary") external drawString: string => unit = "draw" -``` - -```js -// Empty output -``` - - - -ReScript also provides [a few other ways](bind-to-js-function.md#modeling-polymorphic-function) to do this. - -### Variant Types Are Found By Field Name - -Please refer to this [record section](record#tips--tricks). Variants are the same: a function can't accept an arbitrary constructor shared by two different variants. Again, such feature exists; it's called a polymorphic variant. We'll talk about this in the future =). - -## Design Decisions - -Variants, in their many forms (polymorphic variant, open variant, GADT, etc.), are likely _the_ feature of a type system such as ReScript's. The aforementioned `option` variant, for example, obliterates the need for nullable types, a major source of bugs in other languages. Philosophically speaking, a problem is composed of many possible branches/conditions. Mishandling these conditions is the majority of what we call bugs. **A type system doesn't magically eliminate bugs; it points out the unhandled conditions and asks you to cover them**\*. The ability to model "this or that" correctly is crucial. - -For example, some folks wonder how the type system can safely eliminate badly formatted JSON data from propagating into their program. They don't, not by themselves! But if the parser returns the `option` type `None | Some(actualData)`, then you'd have to handle the `None` case explicitly in later call sites. That's all there is. - -Performance-wise, a variant can potentially tremendously speed up your program's logic. Here's a piece of JavaScript: - -```js -let data = 'dog' -if (data === 'dog') { - ... -} else if (data === 'cat') { - ... -} else if (data === 'bird') { - ... -} -``` - -There's a linear amount of branch checking here (`O(n)`). Compare this to using a ReScript variant: - - - -```res example -type animal = Dog | Cat | Bird -let data = Dog -switch data { -| Dog => Js.log("Wof") -| Cat => Js.log("Meow") -| Bird => Js.log("Kashiiin") -} -``` - -```js -console.log("Wof"); - -var data = /* Dog */ 0; -``` - - - -The compiler sees the variant, then - -1. conceptually turns them into `type animal = 0 | 1 | 2` -2. compiles `switch` to a constant-time jump table (`O(1)`). diff --git a/pages/docs/manual/v10.0.0/warning-numbers.mdx b/pages/docs/manual/v10.0.0/warning-numbers.mdx deleted file mode 100644 index 80800170d..000000000 --- a/pages/docs/manual/v10.0.0/warning-numbers.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: "Warning Numbers" -description: "Available compiler warning numbers in ReScript" -canonical: "/docs/manual/latest/warning-numbers" ---- - -import { make as WarningTable } from "src/components/WarningTable.mjs"; - -# Warning Numbers - -You can configure which warnings the ReScript compiler generates -[in the build configuration](/docs/manual/latest/build-configuration#warnings) or -using the [`@warning()`](/syntax-lookup#expression-warning-decorator) or the [`@@warning()`](/syntax-lookup#module-warning-decorator) decorator. - - diff --git a/pages/docs/manual/v11.0.0/api.mdx b/pages/docs/manual/v11.0.0/api.mdx deleted file mode 100644 index 79f9fdbd1..000000000 --- a/pages/docs/manual/v11.0.0/api.mdx +++ /dev/null @@ -1,18 +0,0 @@ -# Introduction - -## ReScript Core - -[Core](api/core) is ReScript's new standard library. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is recommended to use with uncurried mode. - -In ReScript 11, it is shipped as a separate npm package `@rescript/core` that is added to your project as per the [installation instructions](/docs/manual/latest/installation). In future ReScript versions, it will be included with the `rescript` npm package itself. - -## Additional Libraries - -ReScript ships with these two additional modules in its standard library: - -- [Belt](api/belt): immutable collections and extra helpers not available in JavaScript / [Core](api/core). -- [Dom](api/dom): Dom related types and modules. Contains our standardized types used by various userland DOM bindings. - -## Legacy Modules - -The [Js](api/js) module is superseded by [Core](api/core). diff --git a/pages/docs/manual/v11.0.0/api/[...slug].js b/pages/docs/manual/v11.0.0/api/[...slug].js deleted file mode 100644 index 16be65f8b..000000000 --- a/pages/docs/manual/v11.0.0/api/[...slug].js +++ /dev/null @@ -1,18 +0,0 @@ -import { - getStaticPathsByVersion, - getStaticPropsByVersion, -} from "src/ApiDocs.mjs"; - -import APIDocs from "src/ApiDocs.mjs"; - -export async function getStaticProps(ctx) { - return await getStaticPropsByVersion({ ...ctx, version: "v11.0.0" }); -} - -export async function getStaticPaths(ctx) { - return await getStaticPathsByVersion("v11.0.0"); -} - -export default function Comp(props) { - return ; -} diff --git a/pages/docs/manual/v11.0.0/array-and-list.mdx b/pages/docs/manual/v11.0.0/array-and-list.mdx deleted file mode 100644 index 2b53d02b3..000000000 --- a/pages/docs/manual/v11.0.0/array-and-list.mdx +++ /dev/null @@ -1,211 +0,0 @@ ---- -title: "Array & List" -description: "Arrays and List data structures" -canonical: "/docs/manual/v11.0.0/array-and-list" ---- - -# Array and List - -## Array - -Arrays are our main ordered data structure. They work the same way as JavaScript arrays: they can be randomly accessed, dynamically resized, updated, etc. - - - -```res example -let myArray = ["hello", "world", "how are you"] -``` - -```js -var myArray = ["hello", "world", "how are you"]; -``` - - - -ReScript arrays' items must have the same type, i.e. homogeneous. - -### Usage - -#### Access - -Accessing items in an array will return an `option` and can be done like so: - - - -```res example -let myArray = ["hello", "world", "how are you"] - -let firstItem = myArray[0] // Some("hello") - -let tenthItem = myArray->Array.get(10) // None -``` - -```js -var myArray = ["hello", "world", "how are you"]; - -var firstItem = myArray[0]; - -var tenthItem = myArray[10]; -``` - - - -The behavior of returning an `option` is new to V11 when you have [Core](api/core) open. -It provides a safer way to access array items, which is especially useful when you're not sure if the index is out of bounds. -If you would like to not use an `option`, you can use [`Array.getUnsafe`](api/core/array#value-getUnsafe). - -#### Update - -Items in an array can be updated by assigning a value to an index or using a function: - - - -```res example -let myArray = ["hello", "world", "how are you"] - -myArray[0] = "hey" // now ["hey", "world", "how are you"] - -myArray->Array.push("?") // ["hey", "world", "how are you", "?"] - -myArray->Array.set(0, "bye") // ["bye", "world", "how are you", "?"] -``` - -```js -var myArray = ["hello", "world", "how are you"]; - -myArray[0] = "hey"; - -myArray.push("?"); - -myArray[0] = "bye"; -``` - - - -### Array spreads - -**Since 11.1** - -You can spread arrays of the the same type into new arrays, just like in JavaScript: - - - -```res example -let y = [1, 2] -let x = [4, 5, ...y] -let x2 = [4, 5, ...y, 7, ...y] -let x3 = [...y] -``` - -```javascript -var Belt_Array = require("rescript/lib/js/belt_Array.js"); - -var y = [1, 2]; - -var x = Belt_Array.concatMany([[4, 5], y]); - -var x2 = Belt_Array.concatMany([[4, 5], y, [7], y]); - -var x3 = Belt_Array.concatMany([y]); -``` - - - -> Note that array spreads compiles to `Belt.Array.concatMany` right now. This is likely to change to native array spreads in the future. - -## List - -ReScript provides a singly linked list too. Lists are: - -- immutable -- fast at prepending items -- fast at getting the head -- slow at everything else - - - -```res example -let myList = list{1, 2, 3} -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; -``` - - - -Like arrays, lists' items need to be of the same type. - -### Usage - -You'd use list for its resizability, its fast prepend (adding at the head), and its fast split, all of which are immutable and relatively efficient. - -Do **not** use list if you need to randomly access an item or insert at non-head position. Your code would end up obtuse and/or slow. - -The standard lib provides a [List module](api/core/list). - -#### Immutable Prepend - -Use the spread syntax: - - - -```res prelude -let myList = list{1, 2, 3} -let anotherList = list{0, ...myList} -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; - -var anotherList = { - hd: 0, - tl: myList, -}; -``` - - - -`myList` didn't mutate. `anotherList` is now `list{0, 1, 2, 3}`. This is efficient (constant time, not linear). `anotherList`'s last 3 elements are shared with `myList`! - -**Note that `list{a, ...b, ...c}` was a syntax error** before compiler v10.1. In general, the pattern should be used with care as its performance and allocation overhead are linear (`O(n)`). - -#### Access - -`switch` (described in the [pattern matching section](pattern-matching-destructuring.md)) is usually used to access list items: - - - -```res example -let message = - switch myList { - | list{} => "This list is empty" - | list{a, ...rest} => "The head of the list is the string " ++ Int.toString(a) - } -``` - -```js -var message = myList - ? "The head of the list is the string " + (1).toString() - : "This list is empty"; -``` - - diff --git a/pages/docs/manual/v11.0.0/async-await.mdx b/pages/docs/manual/v11.0.0/async-await.mdx deleted file mode 100644 index 56ce487bb..000000000 --- a/pages/docs/manual/v11.0.0/async-await.mdx +++ /dev/null @@ -1,325 +0,0 @@ ---- -title: "Async / Await" -description: "Async / await for asynchronous operations" -canonical: "/docs/manual/v11.0.0/async-await" ---- - - - -
- -```res prelude -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" -@val external sendAnalytics: string => promise = "GlobalAPI.sendAnalytics" -``` - -
- - - -# Async / Await - -ReScript comes with `async` / `await` support to make asynchronous, `Promise` based code easier to read and write. This feature is very similar to its JS equivalent, so if you are already familiar with JS' `async` / `await`, you will feel right at home. - -## How it looks - -Let's start with a quick example to show-case the syntax: - - - -```res -// Some fictive functionality that offers asynchronous network actions -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" -@val external sendAnalytics: string => promise = "GlobalAPI.sendAnalytics" - -// We use the `async` keyword to allow the use of `await` in the function body -let logUserDetails = async (userId: string) => { - // We use `await` to fetch the user email from our fictive user endpoint - let email = await fetchUserMail(userId) - - await sendAnalytics(`User details have been logged for ${userId}`) - - Console.log(`Email address for user ${userId}: ${email}`) -} -``` - -```js -async function logUserDetails(userId) { - var email = await GlobalAPI.fetchUserMail(userId); - await GlobalAPI.sendAnalytics( - "User details have been logged for " + userId + "", - ); - console.log("Email address for user " + userId + ": " + email + ""); -} -``` - - - -As we can see above, an `async` function is defined via the `async` keyword right before the function's parameter list. In the function body, we are now able to use the `await` keyword to explicitly wait for a `Promise` value and assign its content to a let binding `email`. - -You will probably notice that this looks very similar to `async` / `await` in JS, but there are still a few details that are specific to ReScript. The next few sections will go through all the details that are specific to the ReScript type system. - -## Basics - -- You may only use `await` in `async` function bodies -- `await` may only be called on a `promise` value -- `await` calls are expressions, therefore they can be used in pattern matching (`switch`) -- A function returning a `promise<'a>` is equivalent to an `async` function returning a value `'a` (important for writing signature files and bindings) -- `promise` values and types returned from an `async` function don't auto-collapse into a "flat promise" like in JS (more on this later) - -## Types and `async` functions - -### `async` function type signatures - -Function type signatures (i.e defined in signature files) don't require any special keywords for `async` usage. Whenever you want to type an `async` function, use a `promise` return type. - -```resi -// Demo.resi - -let fetchUserMail: string => promise -``` - -The same logic applies to type definitions in `.res` files: - -```res example -// function type -type someAsyncFn = int => promise - -// Function type annotation -let fetchData: string => promise = async (userId) => { - await fetchUserMail(userId) -} -``` - -**BUT:** When typing `async` functions in your implementation files, you need to omit the `promise<'a>` type: - -```res -// This function is compiled into a `string => promise` type. -// The promise<...> part is implicitly added by the compiler. -let fetchData = async (userId: string): string => { - await fetchUserMail("test") -} -``` - -For completeness reasons, let's expand the full signature and inline type definitions in one code snippet: - -```res -// Note how the inline return type uses `string`, while the type definition uses `promise` -let fetchData: string => promise = async (userId: string): string { - await fetchUserMail(userId) -} -``` - -**Note:** In a practical scenario you'd either use a type signature, or inline types, not both at the same time. In case you are interested in the design decisions, check out [this discussion](https://github.com/rescript-lang/rescript/pull/5913#issuecomment-1359003870). - -### Promises don't auto-collapse in async functions - -In JS, nested promises (i.e. `promise>`) will automatically collapse into a flat promise (`promise<'a>`). This is not the case in ReScript. Use the `await` function to manually unwrap any nested promises within an `async` function instead. - -```res -let fetchData = async (userId: string): string => { - // We can't just return the result of `fetchUserMail`, otherwise we'd get a - // type error due to our function return type of type `string` - await fetchUserMail(userId) -} -``` - -## Error handling - -You may use `try / catch` or `switch` to handle exceptions during async execution. - -```res -// For simulation purposes -let authenticate = async () => { - raise(Exn.raiseRangeError("Authentication failed.")) -} - -let checkAuth = async () => { - try { - await authenticate() - } catch { - | Exn.Error(e) => - switch Exn.message(e) { - | Some(msg) => Console.log("JS error thrown: " ++ msg) - | None => Console.log("Some other exception has been thrown") - } - } -} -``` - -Note how we are essentially catching JS errors the same way as described in our [Exception](exception#catch-rescript-exceptions-from-js) section. - -You may unify error and value handling in a single switch as well: - -```res -let authenticate = async () => { - raise(Exn.raiseRangeError("Authentication failed.")) -} - -let checkAuth = async () => { - switch await authenticate() { - | _ => Console.log("ok") - | exception Exn.Error(e) => - switch Exn.message(e) { - | Some(msg) => Console.log("JS error thrown: " ++ msg) - | None => Console.log("Some other exception has been thrown") - } - } -} -``` - -**Important:** When using `await` with a `switch`, always make sure to put the actual await call in the `switch` expression, otherwise your `await` error will not be caught. - -## Piping `await` calls - -You may want to pipe the result of an `await` call right into another function. -This can be done by wrapping your `await` calls in a new `{}` closure. - - - -```res example -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" - -let fetchData = async () => { - let mail = {await fetchUserMail("1234")}->String.toUpperCase - Console.log(`All upper-cased mail: ${mail}`) -} -``` - -```js -async function fetchData(param) { - var mail = (await GlobalAPI.fetchUserMail("1234")).toUpperCase(); - console.log("All upper-cased mail: " + mail + ""); -} -``` - - - -Note how the original closure was removed in the final JS output. No extra allocations! - -## Pattern matching on `await` calls - -`await` calls are just another kind of expression, so you can use `switch` pattern matching for more complex logic. - - - -```res example -@val external fetchUserMail: string => promise = "GlobalAPI.fetchUserMail" - -let fetchData = async () => { - switch (await fetchUserMail("user1"), await fetchUserMail("user2")) { - | (user1Mail, user2Mail) => { - Console.log("user 1 mail: " ++ user1Mail) - Console.log("user 2 mail: " ++ user2Mail) - } - - | exception JsError(err) => Console.log2("Some error occurred", err) - } -} -``` - -```js -async function fetchData(param) { - var val; - var val$1; - try { - val = await GlobalAPI.fetchUserMail("user1"); - val$1 = await GlobalAPI.fetchUserMail("user2"); - } catch (raw_err) { - var err = Caml_js_exceptions.internalToOCamlException(raw_err); - if (err.RE_EXN_ID === "JsError") { - console.log("Some error occurred", err._1); - return; - } - throw err; - } - console.log("user 1 mail: " + val); - console.log("user 2 mail: " + val$1); -} -``` - - - -## `await` multiple promises - -We can utilize the `Promise` module to handle multiple promises. E.g. let's use `Promise.all` to wait for multiple promises before continuing the program: - -```res -let pauseReturn = (value, timeout) => { - Promise.make((resolve, _reject) => { - setTimeout(() => { - resolve(value) - }, timeout)->ignore - }) -} - -let logMultipleValues = async () => { - let promise1 = pauseReturn("value1", 2000) - let promise2 = pauseReturn("value2", 1200) - let promise3 = pauseReturn("value3", 500) - - let all = await Promise.all([promise1, promise2, promise3]) - - switch all { - | [v1, v2, v3] => Console.log(`All values: ${v1}, ${v2}, ${v3}`) - | _ => Console.log("this should never happen") - } -} -``` - -## JS Interop with `async` functions - -`async` / `await` practically works with any function that returns a `promise<'a>` value. Map your `promise` returning function via an `external`, and use it in an `async` function as usual. - -Here's a full example of using the MDN `fetch` API, using `async` / `await` to simulate a login: - -```res -// A generic Response type for typing our fetch requests -module Response = { - type t<'data> - @send external json: t<'data> => promise<'data> = "json" -} - -// A binding to our globally available `fetch` function. `fetch` is a -// standardized function to retrieve data from the network that is available in -// all modern browsers. -@val @scope("globalThis") -external fetch: ( - string, - 'params, -) => promise, "error": Nullable.t}>> = - "fetch" - -// We now use our asynchronous `fetch` function to simulate a login. -// Note how we use `await` with regular functions returning a `promise`. -let login = async (email: string, password: string) => { - let body = { - "email": email, - "password": password, - } - - let params = { - "method": "POST", - "headers": { - "Content-Type": "application/json", - }, - "body": Json.stringifyAny(body), - } - - try { - let response = await fetch("https://reqres.in/api/login", params) - let data = await response->Response.json - - switch Nullable.toOption(data["error"]) { - | Some(msg) => Error(msg) - | None => - switch Nullable.toOption(data["token"]) { - | Some(token) => Ok(token) - | None => Error("Didn't return a token") - } - } - } catch { - | _ => Error("Unexpected network error occurred") - } -} -``` diff --git a/pages/docs/manual/v11.0.0/attribute.mdx b/pages/docs/manual/v11.0.0/attribute.mdx deleted file mode 100644 index 36ca8933b..000000000 --- a/pages/docs/manual/v11.0.0/attribute.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: "Attribute (Decorator)" -description: "Annotations in ReScript" -canonical: "/docs/manual/v11.0.0/attribute" ---- - -# Attribute (Decorator) - -Like many other languages, ReScript allows annotating a piece of code to express extra functionality. Here's an example: - - - -```res -@inline -let mode = "dev" - -let mode2 = mode -``` - -```js -var mode2 = "dev"; -``` - - - -The `@inline` annotation tells `mode`'s value to be inlined into its usage sites (see output). We call such annotation "attribute" (or "decorator" in JavaScript). - -An attribute starts with `@` and goes before the item it annotates. In the above example, it's hooked onto the let binding. - -## Usage - -> **Note:** In previous versions (< 8.3) all our interop related attributes started with a `bs.` prefix (`bs.module`, `bs.val`). Our formatter will automatically drop them in newer ReScript versions. - -You can put an attribute almost anywhere. You can even add extra data to them by using them visually like a function call. Here are a few famous attributes (explained in other sections): - - - -```res -@@warning("-27") - - -@unboxed -type a = Name(string) - -@val external message: string = "message" - -type student = { - age: int, - @as("aria-label") ariaLabel: string, -} - -@deprecated -let customDouble = foo => foo * 2 - -@deprecated("Use SomeOther.customTriple instead") -let customTriple = foo => foo * 3 -``` - -```js - -``` - - - -1. `@@warning("-27")` is a standalone attribute that annotates the entire file. Those attributes start with `@@`. Here, it carries the data `"-27"`. You can find a full list of all available warnings [here](./warning-numbers). -2. `@unboxed` annotates the type definition. -3. `@val` annotates the `external` statement. -4. `@as("aria-label")` annotates the `ariaLabel` record field. -5. `@deprecated` annotates the `customDouble` expression. This shows a warning while compiling telling consumers to not rely on this method long-term. -6. `@deprecated("Use SomeOther.customTriple instead")` annotates the `customTriple` expression with a string to describe the reason for deprecation. - -For a list of all decorators and their usage, please refer to the [Syntax Lookup](/syntax-lookup) page. - -## Extension Point - -There's a second category of attributes, called "extension points" (a remnant term of our early systems): - - - -```res -%raw("var a = 1") -``` - -```js -var a = 1; -``` - - - -Extension points are attributes that don't _annotate_ an item; they _are_ the item. Usually they serve as placeholders for the compiler to implicitly substitute them with another item. - -Extension points start with `%`. A standalone extension point (akin to a standalone regular attribute) starts with `%%`. - -For a list of all extension points and their usage, please refer to the [Syntax Lookup](/syntax-lookup) page. diff --git a/pages/docs/manual/v11.0.0/bind-to-global-js-values.mdx b/pages/docs/manual/v11.0.0/bind-to-global-js-values.mdx deleted file mode 100644 index 99c985502..000000000 --- a/pages/docs/manual/v11.0.0/bind-to-global-js-values.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: "Bind to Global JS Values" -description: "JS interop with global JS values in ReScript" -canonical: "/docs/manual/v11.0.0/bind-to-global-js-values" ---- - -# Bind to Global JS Values - -**First**, make sure the value you'd like to model doesn't already exist in our [provided API](api/core). - -Some JS values, like `setTimeout`, live in the global scope. You can bind to them like so: - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -@val external clearTimeout: float => unit = "clearTimeout" -``` - -```js -// Empty output -``` - - - -(We already provide `setTimeout`, `clearTimeout` and others in the [Core API](api/core) module). - -This binds to the JavaScript [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrworkerGlobalScope/setTimeout) methods and the corresponding `clearTimeout`. The `external`'s type annotation specifies that `setTimeout`: - -- Takes a function that accepts `unit` and returns `unit` (which on the JS side turns into a function that accepts nothing and returns nothing aka `undefined`), -- and an integer that specifies the duration before calling said function, -- returns a number that is the timeout's ID. This number might be big, so we're modeling it as a float rather than the 32-bit int. - -### Tips & Tricks - -**The above isn't ideal**. See how `setTimeout` returns a `float` and `clearTimeout` accepts one. There's no guarantee that you're passing the float created by `setTimeout` into `clearTimeout`! For all we know, someone might pass it `Math.random()` into the latter. - -We're in a language with a great type system now! Let's leverage a popular feature to solve this problem: abstract types. - - - -```res example -type timerId -@val external setTimeout: (unit => unit, int) => timerId = "setTimeout" -@val external clearTimeout: timerId => unit = "clearTimeout" - -let id = setTimeout(() => Console.log("hello"), 100) -clearTimeout(id) -``` - -```js -var id = setTimeout(function (param) { - console.log("hello"); -}, 100); - -clearTimeout(id); -``` - - - -Clearly, `timerId` is a type that can only be created by `setTimeout`! Now we've guaranteed that `clearTimeout` _will_ be passed a valid ID. Whether it's a number under the hood is now a mere implementation detail. - -Since `external`s are inlined, we end up with JS output as readable as hand-written JS. - -## Global Modules - -If you want to bind to a value inside a global module, e.g. `Math.random`, attach a `scope` to your `val` external: - - - -```res example -@scope("Math") @val external random: unit => float = "random" -let someNumber = random() -``` - -```js -var someNumber = Math.random(); -``` - - - -you can bind to an arbitrarily deep object by passing a tuple to `scope`: - - - -```res example -@val @scope(("window", "location", "ancestorOrigins")) -external length: int = "length" -``` - -```js -// Empty output -``` - - - -This binds to `window.location.ancestorOrigins.length`. - -## Special Global Values - -Global values like `__filename` and `__DEV__` don't always exist; you can't even model them as an `option`, since the mere act of referring to them in ReScript (then compiled into JS) would trigger the usual `Uncaught ReferenceError: __filename is not defined` error in e.g. the browser environment. - -For these troublesome global values, ReScript provides a special approach: `%external(a_single_identifier)`. - - - -```res example -switch %external(__DEV__) { -| Some(_) => Console.log("dev mode") -| None => Console.log("production mode") -} -``` - -```js -var match = typeof __DEV__ === "undefined" ? undefined : __DEV__; - -if (match !== undefined) { - console.log("dev mode"); -} else { - console.log("production mode"); -} -``` - - - -That first line's `typeof` check won't trigger a JS ReferenceError. - -Another example: - - - -```res example -switch %external(__filename) { -| Some(f) => Console.log(f) -| None => Console.log("non-node environment") -}; -``` - -```js -var match = typeof __filename === "undefined" ? undefined : __filename; - -if (match !== undefined) { - console.log(match); -} else { - console.log("non-node environment"); -} -``` - - - - diff --git a/pages/docs/manual/v11.0.0/bind-to-js-function.mdx b/pages/docs/manual/v11.0.0/bind-to-js-function.mdx deleted file mode 100644 index 150f5d656..000000000 --- a/pages/docs/manual/v11.0.0/bind-to-js-function.mdx +++ /dev/null @@ -1,504 +0,0 @@ ---- -title: "Bind to JS Function" -description: "JS interop with functions in ReScript" -canonical: "/docs/manual/v11.0.0/bind-to-js-function" ---- - -# Function - -Binding a JS function is like binding any other value: - - - -```res example -// Import nodejs' path.dirname -@module("path") external dirname: string => string = "dirname" -let root = dirname("/User/github") // returns "User" -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - - - -We also expose a few special features, described below. - -## Labeled Arguments - -ReScript has [labeled arguments](function.md#labeled-arguments) (that can also be optional). These work on an `external` too! You'd use them to _fix_ a JS function's unclear usage. Assuming we're modeling this: - -```js -// MyGame.js - -function draw(x, y, border) { - // suppose `border` is optional and defaults to false -} -draw(10, 20); -draw(20, 20, true); -``` - -It'd be nice if on ReScript's side, we can bind & call `draw` while labeling things a bit: - - - -```res example -@module("MyGame") -external draw: (~x: int, ~y: int, ~border: bool=?) => unit = "draw" - -draw(~x=10, ~y=20, ~border=true) -draw(~x=10, ~y=20) -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, true); -MyGame.draw(10, 20, undefined); -``` - - - -We've compiled to the same function, but now the usage is much clearer on the ReScript side thanks to labels! - -Note that you can freely reorder the labels on the ReScript side; they'll always correctly appear in their declaration order in the JavaScript output: - - - -```res example -@module("MyGame") -external draw: (~x: int, ~y: int, ~border: bool=?) => unit = "draw" - -draw(~x=10, ~y=20) -draw(~y=20, ~x=10) -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, undefined); -MyGame.draw(10, 20, undefined); -``` - - - -## Object Method - -Functions attached to JS objects (other than JS modules) require a special way of binding to them, using `send`: - - - -```res example -type document // abstract type for a document object -@send external getElementById: (document, string) => Dom.element = "getElementById" -@val external doc: document = "document" - -let el = getElementById(doc, "myId") -``` - -```js -var el = document.getElementById("myId"); -``` - - - -In a `send`, the object is always the first argument. Actual arguments of the method follow (this is a bit what modern OOP objects are really). - -### Chaining - -Ever used `foo().bar().baz()` chaining ("fluent api") in JS OOP? We can model that in ReScript too, through the [pipe operator](pipe.md). - -### Nested function call - -`@send` can also accept a `@scope(("itemOne","itemTwo"))` to access a function on a nested property. - - -```res example -type stripe - -@module("stripe") @new -external make: string => stripe = "default" - -type createSession = {} - -type sessionResult - -@send -@scope(("checkout", "sessions")) -external createCheckoutSession: (stripe, createSession) => -Promise.t = "create" - -let stripe = make("sk\_...") -let session = stripe->createCheckoutSession({}) - -```` -```js -import Stripe from "stripe"; - -var stripe = new Stripe("sk_..."); -var session = stripe.checkout.sessions.create({}); -```` - - - -## Variadic Function Arguments - -You might have JS functions that take an arbitrary amount of arguments. ReScript supports modeling those, under the condition that the arbitrary arguments part is homogenous (aka of the same type). If so, add `variadic` to your `external`. - - - -```res example -@module("path") @variadic -external join: array => string = "join" - -let v = join(["a", "b"]) -``` - -```js -var Path = require("path"); -var v = Path.join("a", "b"); -``` - - - -`module` will be explained in [Import from/Export to JS](import-from-export-to-js.md). - -## Modeling Polymorphic Function - -Apart from the above special-case, JS functions in general are often arbitrarily overloaded in terms of argument types and number. How would you bind to those? - -### Trick 1: Multiple `external`s - -If you can exhaustively enumerate the many forms an overloaded JS function can take, simply bind to each differently: - - - -```res example -@module("MyGame") external drawCat: unit => unit = "draw" -@module("MyGame") external drawDog: (~giveName: string) => unit = "draw" -@module("MyGame") external draw: (string, ~useRandomAnimal: bool) => unit = "draw" -``` - -```js -// Empty output -``` - - - -Note how all three externals bind to the same JS function, `draw`. - -### Trick 2: Polymorphic Variant + `unwrap` - -If you have the irresistible urge of saying "if only this JS function argument was a variant instead of informally being either `string` or `int`", then good news: we do provide such `external` features through annotating a parameter as a polymorphic variant! Assuming you have the following JS function you'd like to bind to: - -```js -function padLeft(value, padding) { - if (typeof padding === "number") { - return Array(padding + 1).join(" ") + value; - } - if (typeof padding === "string") { - return padding + value; - } - throw new Error(`Expected string or number, got '${padding}'.`); -} -``` - -Here, `padding` is really conceptually a variant. Let's model it as such. - - - -```res example -@val -external padLeft: ( - string, - @unwrap [ - | #Str(string) - | #Int(int) - ]) - => string = "padLeft" -padLeft("Hello World", #Int(4)) -padLeft("Hello World", #Str("Message from ReScript: ")) -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -Obviously, the JS side couldn't have an argument that's a polymorphic variant! But here, we're just piggy backing on poly variants' type checking and syntax. The secret is the `@unwrap` annotation on the type. It strips the variant constructors and compile to just the payload's value. See the output. - -## Constrain Arguments Better - -Consider the Node `fs.readFileSync`'s second argument. It can take a string, but really only a defined set: `"ascii"`, `"utf8"`, etc. You can still bind it as a string, but we can use poly variants + `string` to ensure that our usage's more correct: - - - -```res example -@module("fs") -external readFileSync: ( - ~name: string, - @string [ - | #utf8 - | @as("ascii") #useAscii - ], -) => string = "readFileSync" - -readFileSync(~name="xx.txt", #useAscii) -``` - -```js -var Fs = require("fs"); -Fs.readFileSync("xx.txt", "ascii"); -``` - - - -- Attaching `@string` to the whole poly variant type makes its constructor compile to a string of the same name. -- Attaching a `@as("bla")` to a constructor lets you customize the final string. - -And now, passing something like `"myOwnUnicode"` or other variant constructor names to `readFileSync` would correctly error. - -Aside from string, you can also compile an argument to an int, using `int` instead of `string` in a similar way: - - - -```res example -@val -external testIntType: ( - @int [ - | #onClosed - | @as(20) #onOpen - | #inBinary - ]) - => int = "testIntType" -testIntType(#inBinary) -``` - -```js -testIntType(21); -``` - - - -`onClosed` compiles to `0`, `onOpen` to `20` and `inBinary` to **`21`**. - -## Unknown for type safety - -It is best practice to inspect data received from untrusted external functions to ensure it contains what you expect. This helps avoid run-time crashes and unexpected behavior. If you're certain about what an external function returns, simply assert the return value as `string` or `array` or whatever you want it to be. Otherwise use `unknown`. The ReScript type system will prevent you from using an `unknown` until you first inspect it and "convert" it using JSON parsing utilities or similar tools. - -Consider the example below of two external functions that access the value of a property on a JavaScript object. `getPropertyUnsafe` returns an `'a`, which means "anything you want it to be." ReScript allows you to use this value as a `string` or `array` or any other type. Quite convenient! But if the property is missing or contains something unexpected, your code might break. You can make the binding more safe by changing `'a` to `string` or `option<'a>`, but this doesn't completely eliminate the problem. - -The `getPropertySafe` function returns an `unknown`, which could be `null` or a `string` or anything else. But ReScript prevents you from using this value inappropriately until it has been safely parsed. - -```res example -@get_index external getPropertyUnsafe: ({..}, string) => 'a = "" -@get_index external getPropertySafe: ({..}, string) => unknown = "" - -let person = {"name": "Bob", "age": 12} - -let greeting1 = "Hello, " ++ getPropertyUnsafe(person, "name") // works (this time!) -// let greeting2 = "Hello, " ++ getPropertySafe(person, "name") // syntax error -``` - -## Special-case: Event Listeners - -One last trick with polymorphic variants: - - - -```res example -type readline - -@send -external on: ( - readline, - @string [ - | #close(unit => unit) - | #line(string => unit) - ] - ) - => readline = "on" - -let register = rl => - rl - ->on(#close(event => ())) - ->on(#line(line => Console.log(line))); -``` - -```js -function register(rl) { - return rl - .on("close", function ($$event) {}) - .on("line", function (line) { - console.log(line); - }); -} -``` - - - - - -## Fixed Arguments - -Sometimes it's convenient to bind to a function using an `external`, while passing predetermined argument values to the JS function: - - - -```res example -@val -external processOnExit: ( - @as("exit") _, - int => unit -) => unit = "process.on" - -processOnExit(exitCode => - Console.log("error code: " ++ Int.toString(exitCode)) -); -``` - -```js -process.on("exit", function (exitCode) { - console.log("error code: " + exitCode.toString()); -}); -``` - - - -The `@as("exit")` and the placeholder `_` argument together indicates that you want the first argument to compile to the string `"exit"`. You can also use any JSON literal with `as`: ``@as(json`true`)``, ``@as(json`{"name": "John"}`)``, etc. - -## Ignore arguments - -You can also explicitly "hide" `external` function parameters in the JS output, which may be useful if you want to add type constraints to other parameters without impacting the JS side: - - - -```res -@val external doSomething: (@ignore 'a, 'a) => unit = "doSomething" - -doSomething("this only shows up in ReScript code", "test") -``` - -```js -doSomething("test"); -``` - - - -**Note:** It's a pretty niche feature, mostly used to map to polymorphic JS APIs. - -## Modeling `this`-based Callbacks - -Many JS libraries have callbacks which rely on this (the source), for example: - -```js -x.onload = function (v) { - console.log(this.response + v); -}; -``` - -Here, `this` would point to `x` (actually, it depends on how `onload` is called, but we digress). It's not correct to declare `x.onload` of type `(. unit) -> unit`. Instead, we introduced a special attribute, `this`, which allows us to type `x` as so: - - - -```res example -type x -@val external x: x = "x" -@set external setOnload: (x, @this ((x, int) => unit)) => unit = "onload" -@get external resp: x => int = "response" -setOnload(x, @this (o, v) => Console.log(resp(o) + v)) -``` - -```js -x.onload = function (v) { - var o = this; - console.log((o.response + v) | 0); -}; -``` - - - -`@this` reserves the first parameter for the `this` value, and for arity of 0, there is no need for a redundant `unit` type. - -## Function Nullable Return Value Wrapping - -For JS functions that return a value that can also be `undefined` or `null`, we provide `@return(...)`. To automatically convert that value to an `option` type (recall that ReScript `option` type's `None` value only compiles to `undefined` and not `null`). - - - -```res example -type element -type dom - -@send @return(nullable) -external getElementById: (dom, string) => option = "getElementById" - -let test = dom => { - let elem = dom->(getElementById("haha")) - switch (elem) { - | None => 1 - | Some(_ui) => 2 - } -} -``` - -```js -function test(dom) { - var elem = dom.getElementById("haha"); - if (elem == null) { - return 1; - } else { - console.log(elem); - return 2; - } -} -``` - - - -`return(nullable)` attribute will automatically convert `null` and `undefined` to `option` type. - -Currently 4 directives are supported: `null_to_opt`, `undefined_to_opt`, `nullable` and `identity`. - - - -`identity` will make sure that compiler will do nothing about the returned value. It is rarely used, but introduced here for debugging purpose. - -## Tagged template functions - -**Since 11.1** - -**Experimental** You can easily bind to [JS tagged template functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates). -Tag functions in JS expect as input an array of strings and variadic parameters for the arguments of the interpolation. -To bind to those functions in ReScript, the binding signature must have two arrays as arguments, -the first one being an array of strings and the second can be an array of anything. -You add the `@taggedTemplate` annotation and you're good to go! - - - -```res example -// see https://bun.sh/docs/runtime/shell -type result = {exitCode: int} -@module("bun") @taggedTemplate -external sh: (array, array) => promise = "$" - -let filename = "index.res" -let result = await sh`ls ${filename}` -``` - -```js -import * as $$Bun from "bun"; -var filename = "index.res"; -var result = await $$Bun.$`ls ${filename}`; -``` - - - -Notice that it gets compiled to tagged template literals in JS, which allows -to use JS tools that only work on the literals and not by calling directly the tag function. - -There are plenty of useful JS tools you can bind to, like [`gql`](https://github.com/apollographql/graphql-tag), -[`sql`](https://github.com/porsager/postgres), [`css`](https://github.com/mayank99/ecsstatic) and a lot others! diff --git a/pages/docs/manual/v11.0.0/bind-to-js-object.mdx b/pages/docs/manual/v11.0.0/bind-to-js-object.mdx deleted file mode 100644 index e70dd591b..000000000 --- a/pages/docs/manual/v11.0.0/bind-to-js-object.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -title: "Bind to JS Object" -description: "Interop with JS objects in ReScript" -canonical: "/docs/manual/v11.0.0/bind-to-js-object" ---- - -# Bind to JS Object - -JavaScript objects are a combination of several use-cases: - -- As a "record" or "struct" in other languages (like ReScript and C). -- As a hash map. -- As a class. -- As a module to import/export. - -ReScript cleanly separates the binding methods for JS object based on these 4 use-cases. This page documents the first three. Binding to JS module objects is described in the [Import from/Export to JS](import-from-export-to-js.md) section. - - - -## Bind to Record-like JS Objects - -### Bind Using ReScript Record - -If your JavaScript object has fixed fields, then it's conceptually like a ReScript record. Since a ReScript record compiles to a clean JavaScript object, you can definitely type a JS object as a ReScript record! - - - -```res example -type person = { - name: string, - friends: array, - age: int, -} - -@module("MySchool") external john: person = "john" - -let johnName = john.name -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -External is documented [here](external.md). `@module` is documented [here](import-from-export-to-js.md). - -If you want or need to use different field names on the ReScript and the JavaScript side, you can use the `@as` decorator: - - - -```res example -type action = { - @as("type") type_: string -} - -let action = {type_: "ADD_USER"} -``` - -```js -var action = { - type: "ADD_USER", -}; -``` - - - -This is useful to map to JavaScript attribute names that cannot be expressed in ReScript (such as keywords). - -It is also possible to map a ReScript record to a JavaScript array by passing indices to the `@as` decorator: - - - -```res -type t = { - @as("0") foo: int, - @as("1") bar: string, -} - -let value = {foo: 7, bar: "baz"} -``` - -```js -var value = [7, "baz"]; -``` - - - -### Bind Using ReScript Object - -Alternatively, you can use [ReScript object](object.md) to model a JS object too: - - - -```res example -type person = { - "name": string, - "friends": array, - "age": int, -} - -@module("MySchool") external john: person = "john" - -let johnName = john["name"] -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -### Bind Using Special Getter and Setter Attributes - -Alternatively, you can use `get` and `set` to bind to individual fields of a JS object: - - - -```res example -type textarea -@set external setName: (textarea, string) => unit = "name" -@get external getName: textarea => string = "name" -``` - -```js - -``` - - - -You can also use `get_index` and `set_index` to access a dynamic property or an index: - - - -```res example -type t -@new external create: int => t = "Int32Array" -@get_index external get: (t, int) => int = "" -@set_index external set: (t, int, int) => unit = "" - -let i32arr = create(3) -i32arr->set(0, 42) -Console.log(i32arr->get(0)) -``` - -```js -var i32arr = new Int32Array(3); -i32arr[0] = 42; -console.log(i32arr[0]); -``` - - - -## Bind to Hash Map-like JS Object - -If your JavaScript object: - -- might or might not add/remove keys -- contains only values that are of the same type - -Then it's not really an object, it's a hash map. Use [Dict](api/core/dict), which contains operations like `get`, `set`, etc. and cleanly compiles to a JavaScript object still. - -## Bind to a JS Object That's a Class - -Use `new` to emulate e.g. `new Date()`: - - - -```res example -type t -@new external createDate: unit => t = "Date" - -let date = createDate() -``` - -```js -var date = new Date(); -``` - - - -You can chain `new` and `module` if the JS module you're importing is itself a class: - - - -```res example -type t -@new @module external book: unit => t = "Book" -let myBook = book() -``` - -```js -var Book = require("Book"); -var myBook = new Book(); -``` - - diff --git a/pages/docs/manual/v11.0.0/browser-support-polyfills.mdx b/pages/docs/manual/v11.0.0/browser-support-polyfills.mdx deleted file mode 100644 index 5cd65a93f..000000000 --- a/pages/docs/manual/v11.0.0/browser-support-polyfills.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: "Browser Support & Polyfills" -description: "Note on browser support in ReScript" -canonical: "/docs/manual/v11.0.0/browser-support-polyfills" ---- - -# Browser Support & Polyfills - -ReScript compiles to JavaScript **ES5**, with the exception of optionally allowing to compile to ES6's module import & export. - -For [old browsers](https://caniuse.com/#search=typed%20array), you also need to polyfill TypedArray. The following standard library functions require it: - -- `Int64.float_of_bits` -- `Int64.bits_of_float` -- `Int32.float_of_bits` -- `Int32.bits_of_float` - -If you don't use these functions, you're fine. Otherwise, it'll be a runtime failure. diff --git a/pages/docs/manual/v11.0.0/build-configuration-schema.mdx b/pages/docs/manual/v11.0.0/build-configuration-schema.mdx deleted file mode 100644 index 65511b556..000000000 --- a/pages/docs/manual/v11.0.0/build-configuration-schema.mdx +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: "Configuration Schema" -metaTitle: "Build System Configuration Schema" -description: "Schema exploration widget for the ReScript configuration file" -canonical: "/docs/manual/v11.0.0/build-configuration-schema" ---- - -import dynamic from "next/dynamic"; - -export const Docson = dynamic( - () => - import("src/components/Docson").then((comp) => { - return comp.make; - }), - { - ssr: false, - loading: () =>
Loading...
, - }, -); - -export default function BuildConfigurationSchemaPage() { - return ; -} diff --git a/pages/docs/manual/v11.0.0/build-configuration.mdx b/pages/docs/manual/v11.0.0/build-configuration.mdx deleted file mode 100644 index fe83a9f8c..000000000 --- a/pages/docs/manual/v11.0.0/build-configuration.mdx +++ /dev/null @@ -1,245 +0,0 @@ ---- -title: "Configuration" -metaTitle: "Build System Configuration" -description: "Details about the configuration of the ReScript build system (rescript.json)" -canonical: "/docs/manual/v11.0.0/build-configuration" ---- - -# Configuration - -`rescript.json` (or `bsconfig.json` in versions prior ReScript 11) is the single, mandatory build meta file needed for `rescript`. - -**The complete configuration schema is [here](./build-configuration-schema)**. We'll _non-exhaustively_ highlight the important parts in prose below. - -## name, namespace - -`name` is the name of the library, used as its "namespace". You can activate namespacing through `"namespace": true` in your `rescript.json`. Namespacing is almost **mandatory**; we haven't turned it on by default yet to preserve backward-compatibility. - -**Explanation**: by default, your files, once used as a third-party dependency, are available globally to the consumer. E.g. if you have a `Util.res` and the consumer also has a file of the same name, they will clash. Turning on `namespace` avoids this by wrapping all your own project's files into an extra module layer; instead of a global `Util` module, the consumer will see you as `MyProject.Util`. **The namespacing affects your consumers, not yourself**. - -Aka, in ReScript, "namespace" is just a fancy term for an auto-generated module that wraps all your project's files (efficiently and correctly, of course!) for third-party consumption. - -We don't do folder-level namespacing for your own project; all your own file names must be unique. This is a constraint that enables several features such as fast search and easier project reorganization. - -**Note**: the `rescript.json` `name` should be the same as the `package.json` `name`, to avoid confusing corner-cases. However, this means that you can't use a camelCased names such as `MyProject`, since `package.json` and npm forbid you to do so (some file systems are case-insensitive). To have the namespace/module as `MyProject`, write `"name": "my-project"`. ReScript will turn that into the camelCased name correctly. - -**Note on custom namespacing**: if for some reason, you need a namespace that is different from what your `name` will produce, you can directly send a string to the `namespace` option. For example, if your package is a binding named `bs-some-thing`, you can use `"namespace": "some-thing"` to get `SomeThing` namespace instead of `BsSomeThing`. - -## sources - -Your source files need to be specified explicitly (we don't want to accidentally drill down into some unrelated directories). Examples: - -```json -{ - "sources": ["src", "examples"] -} -``` - -```json -{ - "sources": { - "dir": "src", - "subdirs": ["page"] - } -} -``` - -```json -{ - "sources": [ - "examples", - { - "dir": "src", - "subdirs": true // recursively builds every subdirectory - } - ] -} -``` - -You can mark your directories as dev-only (for e.g. tests). These won't be built and exposed to third-parties, or even to other "dev" directories in the same project: - -```json -{ - "sources": { - "dir": "test", - "type": "dev" - } -} -``` - -You can also explicitly allow which modules can be seen from outside. This feature is especially useful for library authors who want to have a single entry point for their users. -Here, the file `src/MyMainModule.res` is exposed to outside consumers, while all other files are private. - -```json -{ - "sources": { - "dir": "src", - "public": ["MyMainModule"] - } -} -``` - -## bs-dependencies, bs-dev-dependencies - -List of ReScript dependencies. Just like `package.json`'s dependencies, they'll be searched in `node_modules`. - -Note that only sources marked with `"type":"dev"` will be able to resolve modules from `bs-dev-dependencies`. - -## pinned-dependencies - -**Since 8.4**: List of pinned dependencies. A pinned dependency will always be rebuilt whenever you build a toplevel package (e.g. your main app) with `rescript`. - -This is useful for working on multiple independent ReScript packages simultaneously. More usage details can be found in our dedicated [pinned dependencies](./build-pinned-dependencies) page. - -## external-stdlib - -**Since 9.0**: This setting allows depending on an externally built stdlib package (instead of a locally built stdlib runtime). Useful for shipping packages that are only consumed in JS or TS without any dependencies to the ReScript development toolchain. - -More details can be found on our [external stdlib](./build-external-stdlib) page. - -## js-post-build - -Hook that's invoked every time a file is recompiled. Good for JS build system interop, but please use it **sparingly**. Calling your custom command for every recompiled file slows down your build and worsens the building experience for even third-party users of your lib. - -Example: - -```json -{ - "js-post-build": { - "cmd": "/path/to/node ../../postProcessTheFile.js" - } -} -``` - -Note that the path resolution for the command (`node` in this case) is done so: - -- `/myCommand` is resolved into `/myCommand` -- `package/myCommand` is resolved into `node_modules/package/myCommand` -- `./myCommand` is resolved into `myProjectRoot/myCommand` -- `myCommand` is just called as `myCommand`, aka a globally available executable. But note that ReScript doesn't read into your shell's environment, so if you put e.g. `node`, it won't find it unless you specify an absolute path. Alternatively, add `#!/usr/local/bin/node` to the top of your script to directly call it without prepending `node`. - -The command itself is called from inside `lib/bs`. - -## package-specs - -Output to either CommonJS (the default) or JavaScript module. Example: - -```json -{ - "package-specs": { - "module": "commonjs", - "in-source": true - } -} -``` - -- `"module": "commonjs"` generates output as CommonJS format. -- `"module": "esmodule"` generates output as JavaScript module format. Will be default value in next major. -- `"in-source": true` generates output alongside source files. If you omit it, it'll generate the artifacts into `lib/js`. The output directory is not configurable otherwise. - -This configuration only applies to you, when you develop the project. When the project is used as a third-party library, the consumer's own `rescript.json` `package-specs` overrides the configuration here, logically. - -## suffix - -**Since 11.0**: The suffix can now be freely chosen. However, we still suggest you stick to the convention and use -one of the following: - -- `".js` -- `".mjs"` -- `".cjs"` -- `".res.js"` -- `".res.mjs"` -- `".res.cjs"` - -### Design Decisions - -Generating JS files with the `.res.js` suffix means that, on the JS side, you can do `const myReScriptFile = require('./TheFile.res.js')`. The benefits: - -- It's immediately clear that we're dealing with a generated JS file here. -- It avoids clashes with a potential `TheFile.js` file in the same folder. -- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**. - -## uncurried - -**Since 11.0**: While we strongly encourage all users to use uncurried mode, it is still possible to opt out. Just set `"uncurried"` to `false` to get the old behavior back: - -```json -{ - "uncurried": false -} -``` - -More details can be found in the [blogpost about "Uncurried Mode"](/blog/uncurried-mode). - -## warnings - -Selectively turn on/off certain warnings and/or turn them into hard errors. Example: - -```json -{ - "warnings": { - "number": "-44-102", - "error": "+5" - } -} -``` - -Turn off warning `44` and `102` (polymorphic comparison). Turn warning `5` (partial application whose result has function type and is ignored) into a hard error. - -The warning numbers are shown in the build output when they're triggered. See [Warning Numbers](./warning-numbers) for the complete list. - -## bsc-flags - -Extra flags to pass to the compiler. For advanced usages. - -- `-open ABC` opens the module `ABC` for each file in the project. `ABC` can either be a dependency, namespaced project or local module of the current project. - -## gentypeconfig - -To enable genType, set `"gentypeconfig"` at top level in the project's `rescript.json`. - -```json -{ - "gentypeconfig": { - "module": "esmodule", - "moduleResolution": "node", - "generatedFileExtension": ".gen.tsx", - "debug": { - "all": false, - "basic": false - } - } -} -``` - -`generatedFileExtension`: File extension used for genType generated files (defaults to `".gen.tsx"`) - -`module`: Module format used for the generated `*.gen.tsx` files (supports `"esmodule"` and `"commonjs"`) - -`moduleResolution`: Module resolution strategy used in genType outputs. This may be required for compatibility with TypeScript projects. Specify the value as the same in `tsconfig.json`. - -- `"node"`(default): Drop extensions in import paths. -- `"node16"`: Use TS output's extension. This provides compatibility with projects using `"moduleResolution": "node16"` and ES Modules. -- `"bundler"`: Use TS input's extension. This provides compatibility with projects using `"moduleResolution": "bundler"` and ES Modules. This also requires TS v5.0+ and `compilerOptions.allowImportingTsExtensions` to `true` - -`debug`: Enable debug logs. - -### Deprecated options - -`language`: the `language` setting is not required from compiler v10.1. - -`shims`: Required only if one needs to export certain basic ReScript data types to JS when one cannot modify the sources to add annotations (e.g. exporting ReScript lists), and if the types are not first-classed in genType. - -## Environment Variables - -We heavily disrecommend the usage of environment variables, but for certain cases, they're justified. - -### Error Output Coloring: `NINJA_ANSI_FORCED` - -This is mostly for other programmatic usage of `rescript` where outputting colors is not desired. - -When `NINJA_ANSI_FORCED` is set to `1`: `rescript` produces color. -When `NINJA_ANSI_FORCED` is set to `0`: `rescript` doesn't produce color. -When `NINJA_ANSI_FORCED` is not set: `rescript` might or might not produce color, depending on a smart detection of where it's outputted. - -> Note that the underlying compiler will always be passed `-color always`. See more details in [this issue](https://github.com/rescript-lang/rescript/issues/2984#issuecomment-410669163). diff --git a/pages/docs/manual/v11.0.0/build-external-stdlib.mdx b/pages/docs/manual/v11.0.0/build-external-stdlib.mdx deleted file mode 100644 index 55d4b65f6..000000000 --- a/pages/docs/manual/v11.0.0/build-external-stdlib.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: "External Stdlib" -metaTitle: "External Stdlib" -description: "Configuring an external ReScript stdlib package" -canonical: "/docs/manual/v11.0.0/build-external-stdlib" ---- - -# External Stdlib - -**Since 9.0** - -Your ReScript project depends on the `rescript` package as a [`devDependency`](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file), which includes our compiler, build system and runtime like `Belt`. However, you had to move it to `dependency` in `package.json` if you publish your code: - -- To Docker or other low-storage deployment devices. -- For pure JS/TS consumers who probably won't install `rescript` in their own project. - -In these cases, the size or mere presence of `rescript` can be troublesome, since it includes not just our necessary runtime like `Belt`, but also our compiler and build system. - -To solve that, we now publish our runtime as a standalone package at [`@rescript/std`](https://www.npmjs.com/package/@rescript/std), whose versions mirror `rescript`'s. Now you can keep `rescript` as a `devDependency` and have only `@rescript/std` as your runtime `dependency`. - -**This is an advanced feature**. Please only use it in the aforementioned scenarios. If you already use a JS bundler with dead code elimination, you might not need this feature. - -## Configuration - -Say you want to publish a JS-only ReScript 9.0 library. Install the packages like this: - -```sh -npm install rescript@11.0.1 --save-dev -npm install @rescript/std@11.0.1 -``` - -Then add this to `rescript.json`: - -```json -{ - // ... - "external-stdlib": "@rescript/std" -} -``` - -Now the compiled JS code will import using the path defined by `external-stdlib`. Check the JS output tab: - - - -```res -Array.forEach([1, 2, 3], num => Console.log(num)) -``` - -```js -// Note the require path starting with "@rescript/std". -var Belt_Array = require("@rescript/std/lib/js/belt_Array.js"); - -Belt_Array.forEach([1, 2, 3], function (num) { - console.log(num); -}); -``` - - - -**Make sure the version number of `rescript` and `@rescript/std` match in your `package.json`** to avoid running into runtime issues due to mismatching stdlib assumptions. diff --git a/pages/docs/manual/v11.0.0/build-overview.mdx b/pages/docs/manual/v11.0.0/build-overview.mdx deleted file mode 100644 index f638ebc51..000000000 --- a/pages/docs/manual/v11.0.0/build-overview.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "Overview" -metaTitle: "Build System Overview" -description: "Documentation about the ReScript build system and its toolchain" -canonical: "/docs/manual/v11.0.0/build-overview" ---- - -# Build System Overview - -ReScript comes with a build system, [`rescript`](https://www.npmjs.com/package/rescript), that's fast, lean and used as the authoritative build system of the community. - -Every ReScript project needs a build description file, `rescript.json`. - -## Options - -See `rescript help`: - -``` -❯ rescript help -Usage: rescript - -`rescript` is equivalent to `rescript build` - -Options: - -v, -version display version number - -h, -help display help - -Subcommands: - build - clean - format - convert - dump - help - -Run `rescript -h` for subcommand help. Examples: - rescript build -h - rescript format -h -``` - -## Build Project - -Each build will create build artifacts from your project's source files. - -**To build a project (including its dependencies / pinned-dependencies)**, run: - -```sh -rescript -``` - -Which is an alias for `rescript build`. - -To keep a build watcher, run: - -```sh -rescript -w -``` - -Any new file change will be picked up and the build will re-run. - -**Note**: third-party libraries (in `node_modules`, or via `pinned-dependencies`) aren't watched, as doing so may exceed the node.js watcher count limit. - -**Note 2**: In case you want to set up a project in a JS-monorepo-esque approach (`npm` and `yarn` workspaces) where changes in your sub packages should be noticed by the build, you will need to define pinned dependencies in your main project's `rescript.json`. More details [here](./build-pinned-dependencies). - -## Clean Project - -If you ever get into a stale build for edge-case reasons, use: - -```sh -rescript clean -``` - -## Compile with stricter errors in CI - -**Since 11.1** - -You may want to compile your project with stricter rules for production, than when developing. With the `-warn-error` build flag, this can easily be done, for instance in a continuous integration script. E.g.: - -```sh -rescript -warn-error +110 -``` - -Here, warning number 110, which is triggered when a [`%todo`](/syntax-lookup#todo) has been found, gets promoted to an error. The full list of warning numbers can be found [here](/docs/manual/latest/warning-numbers). diff --git a/pages/docs/manual/v11.0.0/build-performance.mdx b/pages/docs/manual/v11.0.0/build-performance.mdx deleted file mode 100644 index cf04a3dfc..000000000 --- a/pages/docs/manual/v11.0.0/build-performance.mdx +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: "Performance" -metaTitle: "Build Performance" -description: "ReScript build performance and measuring tools" -canonical: "/docs/manual/v11.0.0/build-performance" ---- - -# Build Performance - -ReScript considers performance at install time, build time and run time as a serious feature; it's one of those things you don't notice until you realize it's missing. - -## Profile Your Build - -Sometime your build can be slow due to some confused infra setups. We provide an interactive visualization of your build's performance via `bstracing`: - -```sh -./node_modules/.bin/bstracing -``` - -Run the above command at your ReScript project's root; it'll spit out a JSON file you can drag and drop into `chrome://tracing`. - -import Image from "src/components/Image"; - - - -## Under the Hood - -ReScript itself uses a build system under the hood, called [Ninja](https://ninja-build.org). Ninja is like Make, but cross-platform, minimal, focuses on perf and destined to be more of a low-level building block than a full-blown build system. In this regard, Ninja's a great implementation detail for `rescript`. - -ReScript reads into `rescript.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level compiler commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build. - -## The JS Wrapper - -`rescript` itself is a Node.js wrapper which takes care of some miscellaneous tasks, plus the watcher. The lower-level, watcher-less, fast native `rescript` is called `rescript.exe`. It's located at `node_modules/rescript/{your-platform}/rescript.exe`. - -If you don't need the watcher, you can run said `rescript.exe`. This side-steps Node.js' long startup time, which can be in the order of `100ms`. Our editor plugin finds and uses this native `rescript.exe` for better performance. - -## Numbers - -Raw `rescript.exe` build on a small project should be around `70ms`. This doubles when you use the JS `rescript` wrapper which comes with a watcher, which is practically faster since you don't manually run the build at every change (though you should opt for the raw `rescript.exe` for programmatic usage, e.g. inserting rescript into your existing JS build pipeline). - -No-op build (when no file's changed) should be around `15ms`. Incremental rebuild (described soon) of a single file in a project is around `70ms` too. - -Cleaning the artifacts should be instantaneous. - -### Extreme Test - -We've stress-tested `rescript.exe` on a big project of 10,000 files (2 directories, 5000 files each, first 5000 no dependencies, last 5000 10 dependencies on files from the former directory) using https://github.com/rescript-lang/build-benchmark, on a Retina Macbook Pro Early 2015 (3.1 GHz Intel Core i7). - - - -- No-op build of 10k files: `800ms` (the minimum amount of time required to check the mtimes of 10k files). -- Clean build: \<3 minutes. -- Incremental build: depends on the number of the dependents of the file. No dependent means `1s`. - -### Stability - -`rescript` is a file-based build system. We don't do in-memory build, even if that speeds up the build a lot. In-memory builds risk memory leaks, out-of-memory errors, corrupt halfway build and others. Our watcher mode stays open for days or months with no leak. - -The watcher is also just a thin file watcher that calls `rescript.exe`. We don't like babysitting daemon processes. - -## Incrementality & Correctness - -ReScript doesn't take whole seconds to run every time. The bulk of the build performance comes from incremental build, aka re-building a previously built project when a few files changed. - -In short, thanks to our compiler and the build system's architecture, we're able to **only build what's needed**. E.g. if `MyFile.res` isn't changed, then it's not recompiled. You can roughly emulate such incrementalism in languages like JavaScript, but the degree of correctness is unfortunately low. For example, if you rename or move a JS file, then the watcher might get confused and not pick up the "new" file or fail to clean things up correctly, resulting in you needing to clean your build and restart anew, which defeats the purpose. - -Say goodbye to stale build from your JavaScript ecosystem! - -## Speed Up Incremental Build - -ReScript uses the concept of interface files (`.resi`) (or, equivalently, [module signatures](module.md#signatures)). Exposing only what you need naturally speeds up incremental builds. E.g. if you change a `.res` file whose corresponding `.resi` file doesn't expose the changed part, then you've reduced the amount of dependent files you have to rebuild. - -## Programmatic Usage - -Unfortunately, JS build systems are usually the bottleneck for building a JS project nowadays. Having parts of the build blazingly fast doesn't matter much if the rest of the build takes seconds or literally minutes. Here are a few suggestions: - -- Convert more files into ReScript =). Fewer files going through fewer parts of the JS pipeline helps a ton. -- Careful with bringing in more dependencies: libraries, syntax transforms (e.g. the unofficially supported PPX), build step loaders, etc. The bulk of these dragging down the editing & building experience might out-weight the API benefits they provide. - -## Hot Reloading - -Hot reloading refers to maintaining a dev server and listening to file changes in a way that allows the server to pipe some delta changes right into the currently running browser page. This provides a relatively fast iteration workflow while working in specific frameworks. - -However, hot reloading is fragile by nature, and counts on the occasional inconsistencies (bad state, bad eval, etc.) and the heavy devserver setup/config being less of a hassle than the benefits it provides. We err on the side of caution and stability in general, and decided not to provide a built-in hot reloading _yet_. **Note**: you can still use the hot reloading facility provided by your JS build pipeline. diff --git a/pages/docs/manual/v11.0.0/build-pinned-dependencies.mdx b/pages/docs/manual/v11.0.0/build-pinned-dependencies.mdx deleted file mode 100644 index a2b87299c..000000000 --- a/pages/docs/manual/v11.0.0/build-pinned-dependencies.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: "Pinned Dependencies" -metaTitle: "Pinned Dependencies" -description: "Handling multiple packages within one ReScript project with pinned dependencies" -canonical: "/docs/manual/v11.0.0/build-pinned-dependencies" ---- - -# Pinned Dependencies - -Usually we'd recommend to use ReScript in a single-codebase style by using one `rescript.json` file for your whole codebase. - -There are scenarios where you still want to connect and build multiple independent ReScript packages for one main project though (`npm` workspaces-like "monorepos"). This is where `pinned-dependencies` come into play. - -## Package Types - -Before we go into detail, let's first explain all the different package types recognized by the build system: - -- Toplevel (this is usually the final app you are building, which has dependencies to other packages) -- Pinned dependencies (these are your local packages that should always rebuild when you build your toplevel, those should be listed in `bs-dependencies` and `pinned-dependencies`) -- Normal dependencies (these are packages that are consumed from npm and listed via `bs-dependencies`) - -Whenever a package is being built (`rescript build`), the build system will build the toplevel package with its pinned-dependencies. So any changes made in a pinned dependency will automatically be reflected in the final app. - -## Build System Package Rules - -The build system respects the following rules for each package type: - -**Toplevel** - -- Warnings reported -- Warn-error respected -- Builds dev dependencies -- Builds pinned dependencies -- Runs custom rules -- Package-specs like JavaScript module or CommonJS overrides all its dependencies - -**Pinned dependencies** - -- Warnings reported -- Warn-error respected -- Ignores pinned dependencies -- Builds dev dependencies -- Runs custom rules - -**Normal dependencies** - -- Warnings, warn-error ignored -- Ignores dev directories -- Ignores pinned dependencies -- Ignores custom generator rules - -So with that knowledge in mind, let's dive into some more concrete examples to see our pinned dependencies in action. - -## Examples - -### Yarn workspaces - -Let's assume we have a codebase like this: - -``` -myproject/ - app/ - - src/App.res - - rescript.json - common/ - - src/Header.res - - rescript.json - myplugin/ - - src/MyPlugin.res - - rescript.json - package.json -``` - -Our `package.json` file within our codebase root would look like this: - -```json -{ - "name": "myproject", - "private": true, - "workspaces": { - "packages": ["app", "common", "myplugin"] - } -} -``` - -Our `app` folder would be our toplevel package, consuming our `common` and `myplugin` packages as `pinned-dependencies`. The configuration for `app/rescript.json` looks like this: - -```json -{ - "name": "app", - "version": "1.0.0", - "sources": { - "dir": "src", - "subdirs": true - }, - /* ... */ - "bs-dependencies": ["common", "myplugin"], - "pinned-dependencies": ["common", "myplugin"] - /* ... */ -} -``` - -Now, whenever we are running `rescript build` within our `app` package, the compiler would always rebuild any changes within its pinned dependencies as well. - -**Important:** ReScript will not rebuild any `pinned-dependencies` in watch mode! This is due to the complexity of file watching, so you'd need to set up your own file-watcher process that runs `rescript build` on specific file changes. diff --git a/pages/docs/manual/v11.0.0/control-flow.mdx b/pages/docs/manual/v11.0.0/control-flow.mdx deleted file mode 100644 index 72baa2f27..000000000 --- a/pages/docs/manual/v11.0.0/control-flow.mdx +++ /dev/null @@ -1,221 +0,0 @@ ---- -title: "If-Else & Loops" -description: "If, else, ternary, for, and while" -canonical: "/docs/manual/v11.0.0/control-flow" ---- - -# If-Else & Loops - -ReScript supports `if`, `else`, ternary expression (`a ? b : c`), `for` and `while`. - -ReScript also supports our famous pattern matching, which will be covered in [its own section](pattern-matching-destructuring.md) - -## If-Else & Ternary - -Unlike its JavaScript counterpart, ReScript's `if` is an expression; they evaluate to their body's content: - - - -```res -let message = if isMorning { - "Good morning!" -} else { - "Hello!" -} -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**Note:** an `if-else` expression without the final `else` branch implicitly gives `()` (aka the `unit` type). So this: - - - -```res -if showMenu { - displayMenu() -} -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -is basically the same as: - - - -```res -if showMenu { - displayMenu() -} else { - () -} -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -Here's another way to look at it. This is clearly wrong: - -```res -let result = if showMenu { - 1 + 2 -} -``` - -It'll give a type error, saying basically that the implicit `else` branch has the type `unit` while the `if` branch has type `int`. Intuitively, this makes sense: what would `result`'s value be, if `showMenu` was `false`? - -We also have ternary sugar, but **we encourage you to prefer if-else when possible**. - - - -```res -let message = isMorning ? "Good morning!" : "Hello!" -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**`if-else` and ternary are much less used** in ReScript than in other languages; [Pattern-matching](pattern-matching-destructuring.md) kills a whole category of code that previously required conditionals. - -## For Loops - -For loops iterate from a starting value up to (and including) the ending value. - - - -```res -for i in startValueInclusive to endValueInclusive { - Console.log(i) -} -``` - -```js -for (var i = startValueInclusive; i <= endValueInclusive; ++i) { - console.log(i); -} -``` - - - - - -```res example -// prints: 1 2 3, one per line -for x in 1 to 3 { - Console.log(x) -} -``` - -```js -for (var x = 1; x <= 3; ++x) { - console.log(x); -} -``` - - - -You can make the `for` loop count in the opposite direction by using `downto`. - - - -```res -for i in startValueInclusive downto endValueInclusive { - Console.log(i) -} -``` - -```js -for (var i = startValueInclusive; i >= endValueInclusive; --i) { - console.log(i); -} -``` - - - - - -```res example -// prints: 3 2 1, one per line -for x in 3 downto 1 { - Console.log(x) -} -``` - -```js -for (var x = 3; x >= 1; --x) { - console.log(x); -} -``` - - - -## While Loops - -While loops execute its body code block while its condition is true. - - - -```res -while testCondition { - // body here -} -``` - -```js -while (testCondition) { - // body here -} -``` - - - -### Tips & Tricks - -There's no loop-breaking `break` keyword (nor early `return` from functions, for that matter) in ReScript. However, we can break out of a while loop easily through using a [mutable binding](mutation.md). - - - -```res example -let break = ref(false) - -while !break.contents { - if Math.random() > 0.3 { - break := true - } else { - Console.log("Still running") - } -} -``` - -```js -var $$break = { - contents: false, -}; - -while (!$$break.contents) { - if (Math.random() > 0.3) { - $$break.contents = true; - } else { - console.log("Still running"); - } -} -``` - - diff --git a/pages/docs/manual/v11.0.0/converting-from-js.mdx b/pages/docs/manual/v11.0.0/converting-from-js.mdx deleted file mode 100644 index 8f88cbef3..000000000 --- a/pages/docs/manual/v11.0.0/converting-from-js.mdx +++ /dev/null @@ -1,313 +0,0 @@ ---- -title: "Converting from JS" -description: "How to convert to ReScript with an existing JS codebase" -canonical: "/docs/manual/v11.0.0/converting-from-js" ---- - -# Converting from JS - -ReScript offers a unique project conversion methodology which: - -- Ensures minimal disruption to your teammates (very important!). -- Remove the typical friction of verifying conversion's correctness and performance guarantees. -- Doesn't force you to search for pre-made binding libraries made by others. **ReScript doesn't need the equivalent of TypeScript's `DefinitelyTyped`**. - -## Step 1: Install ReScript - -Run `npm install rescript` on your project, then imitate our [New Project](installation#new-project) workflow by adding a `rescript.json` at the root. Then start `npx rescript -w`. - -## Step 2: Copy Paste the Entire JS File - -Let's work on converting a file called `src/main.js`. - -```js -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -``` - -First, copy the entire file content over to a new file called `src/Main.res` by using our [`%%raw` JS embedding trick](embed-raw-javascript): - - - -```res example -%%raw(` -const school = require('school'); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -`) -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} - -/* Not a pure module */ -``` - - - -Add this file to `rescript.json`: - -```json - "sources": { - "dir" : "src", - "subdirs" : true - }, -``` - -Open an editor tab for `src/Main.res.js`. Do a command-line `diff -u src/main.js src/Main.res.js`. Aside from whitespaces, you should see only minimal, trivial differences. You're already a third of the way done! - -**Always make sure** that at each step, you keep the ReScript output `.res.js` file open to compare against the existing JavaScript file. Our compilation output is very close to your hand-written JavaScript; you can simply eye the difference to catch conversion bugs! - -## Step 3: Extract Parts into Idiomatic ReScript - -Let's turn the `defaultId` variable into a ReScript let-binding: - - - -```res example -let defaultId = 10 - -%%raw(` -const school = require('school'); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -`) -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -const school = require('school'); - -function queryResult(usePayload, payload) { - if usePayload { - return payload.student - } else { - return school.getStudentById(defaultId) - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -/* Not a pure module */ -``` - - - -Check the output. Diff it. Code still works. Moving on! Extract the function: - - - -```res -%%raw(` -const school = require('school'); -`) - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload.student - } else { - school.getStudentById(defaultId) - } -} -``` - -```js - -``` - - - -Format the code: `./node_modules/.bin/rescript format src/Main.res`. - -We have a type error: "The record field student can't be found". That's fine! **Always ensure your code is syntactically valid first**. Fixing type errors comes later. - -## Step 4: Add `external`s, Fix Types - -The previous type error is caused by `payload`'s record declaration (which supposedly contains the field `student`) not being found. Since we're trying to convert as quickly as possible, let's use our [object](object) feature to avoid needing type declaration ceremonies: - - - -```res -%%raw(` -const school = require('school'); -`) - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload["student"] - } else { - school["getStudentById"](defaultId) - } -} -``` - -```js - -``` - - - -Now this triggers the next type error, that `school` isn't found. Let's use [`external`](external) to bind to that module: - - - -```res example -@module external school: 'whatever = "school" - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload["student"] - } else { - school["getStudentById"](defaultId) - } -} -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We hurrily typed `school` as a polymorphic `'whatever` and let its type be inferred by its usage below. The inference is technically correct, but within the context of bringing it a value from JavaScript, slightly dangerous. This is just the interop trick we've shown in the [`external`](external) page. - -Anyway, the file passes the type checker again. Check the `.res.js` output, diff with the original `.js`; we've now converted a file over to ReScript! - -Now, you can delete the original, hand-written `main.js` file, and grep the files importing `main.js` and change them to importing `Main.res.js`. - -## (Optional) Step 5: Cleanup - -If you prefer more advanced, rigidly typed `payload` and `school`, feel free to do so: - - - -```res example -type school -type student -type payload = { - student: student -} - -@module external school: school = "school" -@send external getStudentById: (school, int) => student = "getStudentById" - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload.student - } else { - school->getStudentById(defaultId) - } -} -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We've: - -- introduced an opaque types for `school` and `student` to prevent misuse of their values -- typed the payload as a record with only the `student` field -- typed `getStudentById` as the sole method of `student` - -Check that the `.res.js` output didn't change. How rigidly to type your JavaScript code is up to you; we recommend not typing them too elaborately; it's sometime an endless chase, and produces diminishing returns, especially considering that the elaborate-ness might turn off your potential teammates. - -## Tips & Tricks - -In the same vein of idea, **resist the urge to write your own wrapper functions for the JS code you're converting**. Use [`external`s](external), which are guaranteed to be erased in the output. And avoid trying to take the occasion to convert JS data structures into ReScript-specific data structures like variant or list. **This isn't the time for that**. - -The moment you produce extra conversion code in the output, your skeptical teammate's mental model might switch from "I recognize this output" to "this conversion might be introducing more problems than it solves. Why are we testing ReScript again?". Then you've lost. - -## Conclusion - -- Paste the JS code into a new ReScript file as embedded raw JS code. -- Compile and keep the output file open. Check and diff against original JS file. Free regression tests. -- Always make sure your file is syntactically valid. Don't worry about fixing types before that. -- (Ab)use [object](object.md) accesses to quickly convert things over. -- Optionally clean up the types for robustness. -- Don't go overboard and turn off your boss and fellow teammates. -- Proudly display that you've conserved the semantics and performance characteristics during the conversion by showing your teammates the eerily familiar output. -- Get promoted for introducing a new technology the safer, mature way. diff --git a/pages/docs/manual/v11.0.0/editor-plugins.mdx b/pages/docs/manual/v11.0.0/editor-plugins.mdx deleted file mode 100644 index 357af4d04..000000000 --- a/pages/docs/manual/v11.0.0/editor-plugins.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: "Editor Plugins" -description: "List of ReScript editor plugins" -canonical: "/docs/manual/v11.0.0/editor-plugins" ---- - -# Editor Plugins - -- [VSCode](https://marketplace.visualstudio.com/items?itemName=chenglou92.rescript-vscode) -- [Sublime Text](https://github.com/rescript-lang/rescript-sublime) -- [Vim/Neovim](https://github.com/rescript-lang/vim-rescript) - -## Community Supported - -We don't officially support these; use them at your own risk! - -- [Neovim Tree-sitter](https://github.com/nkrkv/nvim-treesitter-rescript) -- [IDEA](https://github.com/reasonml-editor/reasonml-idea-plugin) -- [Emacs](https://github.com/jjlee/rescript-mode) -- [Zed](https://github.com/humaans/rescript-zed) diff --git a/pages/docs/manual/v11.0.0/embed-raw-javascript.mdx b/pages/docs/manual/v11.0.0/embed-raw-javascript.mdx deleted file mode 100644 index c43b393b9..000000000 --- a/pages/docs/manual/v11.0.0/embed-raw-javascript.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: "Embed Raw JavaScript" -description: "Utility syntax to for raw JS usage in ReScript" -canonical: "/docs/manual/v11.0.0/embed-raw-javascript" ---- - -# Embed Raw JavaScript - -## Paste Raw JS Code - -First thing first. If you're ever stuck learning ReScript, remember that you can always just paste raw JavaScript code into our source file: - - - -```res example -%%raw(` -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m) -} -`) -``` - -```js -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m); -} -``` - - - -The `%%raw` special ReScript call takes your code string and pastes it as-is into the output. **You've now technically written your first ReScript file!** - -(The back tick syntax is a multiline string, similar to JavaScript's. Except for us, no escaping is needed inside the string. More on string in a later section.) - -While `%%raw` lets you embed top-level raw JS code, `%raw` lets you embed expression-level JS code: - - - -```res example -let add = %raw(` - function(a, b) { - console.log("hello from raw JavaScript!"); - return a + b - } -`) - -Console.log(add(1, 2)) -``` - -```js -var add = function (a, b) { - console.log("hello from raw JavaScript!"); - return a + b; -}; - -console.log(add(1, 2)); -``` - - - -The above code: - -- declared a ReScript variable `add`, -- with the raw JavaScript value of a function declaration, -- then called that function in ReScript. - -If your boss is ever worried that your teammates can't adopt ReScript, just let them keep writing JavaScript inside ReScript files =). - -## Debugger - -You can also drop a `%debugger` expression in a body: - - - -```res example -let f = (x, y) => { - %debugger - x + y -} -``` - -```js -function f(x, y) { - debugger; - return (x + y) | 0; -} -``` - - - -Output: - -```js -function f(x, y) { - debugger; // JavaScript developer tools will set an breakpoint and stop here - x + y; -} -``` - -## Tips & Tricks - -Embedding raw JS snippets isn't the best way to experience ReScript, though it's also highly useful if you're just starting out. As a matter of fact, the first few ReScript projects were converted through: - -- pasting raw JS snippets inside a file -- examining the JS output (identical to the old hand-written JS) -- gradually extract a few values and functions and making sure the output still looks OK - -At the end, we get a fully safe, converted ReScript file whose JS output is clean enough that we can confidently assert that no new bug has been introduced during the conversion process. - -We have a small guide on this iteration [here](converting-from-js.md). Feel free to peruse it later. diff --git a/pages/docs/manual/v11.0.0/equality-comparison.mdx b/pages/docs/manual/v11.0.0/equality-comparison.mdx deleted file mode 100644 index 5f984a8e8..000000000 --- a/pages/docs/manual/v11.0.0/equality-comparison.mdx +++ /dev/null @@ -1,137 +0,0 @@ ---- -title: "Equality and Comparison" -description: "Handling equality and comparison checks" -canonical: "/docs/manual/v11.0.0/equality-comparison" ---- - -# Equality and Comparison - -ReScript has shallow equality `===`, deep equality `==`, and comparison operators `>`, `>=`, `<`, and `<=`. - -## Shallow equality - -The shallow equality operator `===` compares two values and either compiles to `===` or a `bool` if the equality is known to the compiler. -It behaves the same as the strict equality operator `===` in JavaScript. - -Using `===` will never add a runtime cost. - - - -```res -let t1 = 1 === 1 // true -let t2 = "foo" === "foo" // true -let t3 = { "foo": "bar" } === { "foo": "bar"} // false - -let doStringsMatch = (s1: string, s2: string) => s1 === s2 -``` - -```js -var t1 = true; -var t2 = "foo" === "foo"; -var t3 = { foo: "bar" } === { foo: "bar" }; - -function doStringsMatch(s1, s2) { - return s1 === s2; -} -``` - - - -## Deep equality - -ReScript has the deep equality operator `==` to check deep equality of two items, which is very different from the loose equality operator like `==` in JavaScript. - -When using `==` in ReScript it will never compile to `==` in JavaScript, -it will either compile to `===`, a runtime call to an internal function that deeply compares the equality, or a `bool` if the equality is known to the compiler. - - - -```res -let t1 = 1 == 1 // true -let t2 = "foo" == "foo" // true -let t3 = { "foo": "bar" } == { "foo": "bar"} // true - -let doStringsMatch = (s1: string, s2: string) => s1 == s2 -``` - -```js -import * as Caml_obj from "./stdlib/caml_obj.js"; - -var t1 = true; -var t2 = true; -var t3 = Caml_obj.equal({ foo: "bar" }, { foo: "bar" }); - -function doStringsMatch(s1, s2) { - return s1 === s2; -} -``` - - - -`==` will compile to `===` (or a `bool` if the compiler can determine equality) when: - -- Comparing `string`, `char`, `int`, `float`, `bool`, or `unit` -- Comparing variants or polymorphic variants that do not have constructor values - -`==` will compile to a runtime check for deep equality when: - -- Comparing `array`, `tuple`, `list`, `object`, `record`, or regular expression `Re.t` -- Comparing variants or polymorphic variants that have constructor values - -> When using `==` pay close attention to the JavaScript output if you're not sure what `==` will compile to. - -## Comparison - -ReScript has operators for comparing values that compile to the the same operator in JS, a runtime check using an internal function, or a `bool` if the equality is known to the compiler, - -| operator | comparison | -| -------- | --------------------- | -| `>` | greater than | -| `>=` | greater than or equal | -| `<` | less than | -| `<=` | less than or equal | - -Comparison can be done on any type. - -An operator will compile to the same operator (or a `bool` if the compiler can determine equality) when: - -- Comparing `int`, `float`, `string`, `char`, `bool` - -An operator will compile to a runtime check for deep equality when: - -- Comparing `array`, `tuple`, `list`, `object`, `record`, or regular expression (`Re.t`) -- Comparing variants or polymorphic variants - - - -```res -let compareInt = (a: int, b: int) => a > b -let t1 = 1 > 10 -let compareArray = (a: array, b: array) => a > b -let compareOptions = (a: option, b: option) => a < b -``` - -```js -import * as Caml_obj from "./stdlib/caml_obj.js"; - -function compareInt(a, b) { - return a > b; -} - -var t1 = false; - -var compareArray = Caml_obj.greaterthan; - -var compareOptions = Caml_obj.lessthan; -``` - - - -## Performance of runtime equality checks - -The runtime equality check ReScript uses is quite fast and should be adequate for almost all use cases. -For small objects it can be 2x times faster than alternative deep compare functions such as Lodash's [`_.isEqual`](https://lodash.com/docs/4.17.15#isEqual). - -For larger objects instead of using `==` you could manually use a faster alternative such as [fast-deep-compare](https://www.npmjs.com/package/fast-deep-equal), or write a custom comparator function. - -[This repo](https://github.com/jderochervlk/rescript-perf) has benchmarks comparing results of different libraries compared to ReScript's built-in equality function. diff --git a/pages/docs/manual/v11.0.0/exception.mdx b/pages/docs/manual/v11.0.0/exception.mdx deleted file mode 100644 index d7106db75..000000000 --- a/pages/docs/manual/v11.0.0/exception.mdx +++ /dev/null @@ -1,505 +0,0 @@ ---- -title: "Exception" -description: "Exceptions and exception handling in ReScript" -canonical: "/docs/manual/v11.0.0/exception" ---- - -# Exception - -Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!). Consider using the [`option`](null-undefined-option.mdx) or [`result`](api/core/result) type for recoverable errors. - -You can create your own exceptions like you'd make a variant (exceptions need to be capitalized too). - - - -```res example -exception InputClosed(string) -// later on -raise(InputClosed("The stream has closed!")) -``` - -```js -import * as Caml_exceptions from "./stdlib/caml_exceptions.js"; - -var InputClosed = /* @__PURE__ */ Caml_exceptions.create( - "Playground.InputClosed", -); - -throw { - RE_EXN_ID: InputClosed, - _1: "The stream has closed!", - Error: new Error(), -}; -``` - - - -## Built-in Exceptions - -ReScript has some built-in exceptions: - -### `Not_found` - - - -```res prelude -let getItem = (item: int) => - if (item === 3) { - // return the found item here - 1 - } else { - raise(Not_found) - } - -let result = - try { - getItem(2) - } catch { - | Not_found => 0 // Default value if getItem throws - } -``` - -```js -import * as Caml_js_exceptions from "./stdlib/caml_js_exceptions.js"; - -function getItem(item) { - if (item === 3) { - return 1; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error(), - }; -} - -var result; - -try { - result = getItem(2); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - result = 0; - } else { - throw exn; - } -} -``` - - - -Note that the above is just for demonstration purposes; in reality, you'd return an `option` directly from `getItem` and avoid the `try` altogether. - -You can directly match on exceptions _while_ getting another return value from a function: - - - -```res prelude -switch list{1, 2, 3}->List.getExn(4) { -| item => Console.log(item) -| exception Not_found => Console.log("No such item found!") -} -``` - -```js -import * as Core__List from "./stdlib/core__List.js"; -import * as Caml_js_exceptions from "./stdlib/caml_js_exceptions.js"; - -var exit = 0; - -var item; - -try { - item = Core__List.getExn( - { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */ 0, - }, - }, - }, - 4, - ); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -### `Invalid_argument` - -Used to check if argument is valid. This exception takes a string. - - -```res example -let divide = (a, b) => - if b == 0 { - raise(Invalid_argument("Denominator is zero")) - } else { - a / b - } - -// catch error -try divide(2, 0)->Console.log catch { -| Invalid_argument(msg) => Console.log(msg) // Denominator is zero -} - -```` - -```js -import * as Caml_int32 from "./stdlib/caml_int32.js"; -import * as Caml_js_exceptions from "./stdlib/caml_js_exceptions.js"; - -function divide(a, b) { - if (b === 0) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Denominator is zero", - Error: new Error() - }; - } - return Caml_int32.div(a, b); -} - -try { - console.log(divide(2, 0)); -} -catch (raw_msg){ - var msg = Caml_js_exceptions.internalToOCamlException(raw_msg); - if (msg.RE_EXN_ID === "Invalid_argument") { - console.log(msg._1); - } else { - throw msg; - } -} -```` - - - -### `Assert_failure` - -Raise when you use `assert(condition)` and `condition` is false. The arguments -are the location of the `assert` in the source code (file name, line number, column number). - - - -```res example -let decodeUser = (json: JSON.t) => - switch json { - | Object(userDict) => - switch (userDict->Dict.get("name"), userDict->Dict.get("age")) { - | (Some(String(name)), Some(Number(age))) => (name, age->Float.toInt) - | _ => assert(false) - } - | _ => assert(false) - } - - -try decodeUser(%raw("{}"))->Console.log catch { -| Assert_failure(loc) => Console.log(loc) // ("filename", line, col) -} -``` - -```js -mport * as Caml_js_exceptions from "./stdlib/caml_js_exceptions.js"; - -function decodeUser(json) { - if (!Array.isArray(json) && (json === null || typeof json !== "object") && typeof json !== "number" && typeof json !== "string" && typeof json !== "boolean") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "playground.res", - 8, - 9 - ], - Error: new Error() - }; - } - if (typeof json === "object" && !Array.isArray(json)) { - var match = json["name"]; - var match$1 = json["age"]; - if (match !== undefined && !(!Array.isArray(match) && (match === null || typeof match !== "object") && typeof match !== "number" && typeof match !== "string" && typeof match !== "boolean") && typeof match === "string" && match$1 !== undefined && !(!Array.isArray(match$1) && (match$1 === null || typeof match$1 !== "object") && typeof match$1 !== "number" && typeof match$1 !== "string" && typeof match$1 !== "boolean") && typeof match$1 === "number") { - return [ - match, - match$1 | 0 - ]; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "playground.res", - 6, - 11 - ], - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "playground.res", - 8, - 9 - ], - Error: new Error() - }; -} - -try { - console.log(decodeUser({})); -} -catch (raw_loc){ - var loc = Caml_js_exceptions.internalToOCamlException(raw_loc); - if (loc.RE_EXN_ID === "Assert_failure") { - console.log(loc._1); - } else { - throw loc; - } -} -``` - - - -### `Failure` - -Exception raised to signal that the given arguments do not make sense. This -exception takes a string as an argument. - - -```res example -let isValidEmail = email => { - let hasAtSign = String.includes(email, "@") - let hasDot = String.includes(email, ".") - if !(hasAtSign && hasDot) { - raise(Failure("Invalid email address")) - } else { - true - } -} - -let isValid = try isValidEmail("rescript.org") catch { -| Failure(msg) => { -Console.error(msg) -false -} -} - -```` - -```js -import * as Caml_js_exceptions from "./stdlib/caml_js_exceptions.js"; - -function isValidEmail(email) { - var hasAtSign = email.includes("@"); - var hasDot = email.includes("."); - if (hasAtSign && hasDot) { - return true; - } - throw { - RE_EXN_ID: "Failure", - _1: "Invalid email address", - Error: new Error() - }; -} - -var isValid; - -try { - isValid = isValidEmail("rescript.org"); -} -catch (raw_msg){ - var msg = Caml_js_exceptions.internalToOCamlException(raw_msg); - if (msg.RE_EXN_ID === "Failure") { - console.error(msg._1); - isValid = false; - } else { - throw msg; - } -} -```` - - - -### `Division_by_zero` - -Exception raised by integer division and remainder operations when their second argument is zero. - - -```res example -// ReScript raise `Division_by_zero` if the denominator is zero -let result = try Some(10 / 0) catch { -| Division_by_zero => None -} - -Console.log(result) // None - -```` - -```js -import * as Caml_int32 from "./stdlib/caml_int32.js"; -import * as Caml_js_exceptions from "./stdlib/caml_js_exceptions.js"; - -var result; - -try { - result = Caml_int32.div(10, 0); -} -catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Division_by_zero") { - result = undefined; - } else { - throw exn; - } -} - -console.log(result); -```` - - - -## Catching JS Exceptions - -To distinguish between JavaScript exceptions and ReScript exceptions, ReScript namespaces JS exceptions under the `Exn.Error(payload)` variant. To catch an exception thrown from the JS side: - -Throw an exception from JS: - -```js -// Example.js - -exports.someJsFunctionThatThrows = () => { - throw new Error("A Glitch in the Matrix!"); -}; -``` - -Then catch it from ReScript: - -```res -// import the method in Example.js -@module("./Example") -external someJsFunctionThatThrows: () => unit = "someJsFunctionThatThrows" - -try { - // call the external method - someJSFunctionThatThrows() -} catch { -| Exn.Error(obj) => - switch Exn.message(obj) { - | Some(m) => Console.log("Caught a JS exception! Message: " ++ m) - | None => () - } -} -``` - -The `obj` here is of type `Exn.t`, intentionally opaque to disallow illegal operations. To operate on `obj`, do like the code above by using the standard library's [`Exn`](api/js/exn) module's helpers. - -## Raise a JS Exception - -`raise(MyException)` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Exn.raiseError`: - - - -```res example -let myTest = () => { - Exn.raiseError("Hello!") -} -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); - -function myTest() { - return Js_exn.raiseError("Hello!"); -} -``` - - - -Then you can catch it from the JS side: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.message); // "Hello!" -} -``` - -## Catch ReScript Exceptions from JS - -The previous section is less useful than you think; to let your JS code work with your exception-throwing ReScript code, the latter doesn't actually need to throw a JS exception. ReScript exceptions can be used by JS code! - - - -```res example -exception BadArgument({myMessage: string}) - -let myTest = () => { - raise(BadArgument({myMessage: "Oops!"})) -} -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var BadArgument = Caml_exceptions.create("Playground.BadArgument"); - -function myTest() { - throw { - RE_EXN_ID: BadArgument, - myMessage: "Oops!", - Error: new Error(), - }; -} -``` - - - -Then, in your JS: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.myMessage); // "Oops!" - console.log(e.Error.stack); // the stack trace -} -``` - -> Note: `RE_EXN_ID` is an internal field for bookkeeping purposes. Don't use it on the JS side. Use the other fields. - -The above `BadArgument` exception takes an inline record type. We special-case compile the exception as `{RE_EXN_ID, myMessage, Error}` for good ergonomics. If the exception instead took ordinary positional arguments, l like the standard library's `Invalid_argument("Oops!")`, which takes a single argument, the argument is compiled to JS as the field `_1` instead. A second positional argument would compile to `_2`, etc. - -## Tips & Tricks - -When you have ordinary variants, you often don't **need** exceptions. For example, instead of throwing when `item` can't be found in a collection, try to return an `option` (`None` in this case) instead. - -### Catch Both ReScript and JS Exceptions in the Same `catch` Clause - -```res -try { - someOtherJSFunctionThatThrows() -} catch { -| Not_found => ... // catch a ReScript exception -| Invalid_argument(_) => ... // catch a second ReScript exception -| Exn.Error(obj) => ... // catch the JS exception -} -``` - -This technically works, but hopefully you don't ever have to work with such code... diff --git a/pages/docs/manual/v11.0.0/extensible-variant.mdx b/pages/docs/manual/v11.0.0/extensible-variant.mdx deleted file mode 100644 index f0dc25598..000000000 --- a/pages/docs/manual/v11.0.0/extensible-variant.mdx +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: "Extensible Variant" -description: "Extensible Variants in ReScript" -canonical: "/docs/manual/v11.0.0/extensible-variant" ---- - -# Extensible Variant - -Variant types are usually constrained to a fixed set of constructors. There may be very rare cases where you still want to be able to add constructors to a variant type even after its initial type declaration. For this, we offer extensible variant types. - -## Definition and Usage - - - -```res example -type t = .. - -type t += Other - -type t += - | Point(float, float) - | Line(float, float, float, float) -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var Other = Caml_exceptions.create("Playground.Other"); - -var Point = Caml_exceptions.create("Playground.Point"); - -var Line = Caml_exceptions.create("Playground.Line"); -``` - - - -The `..` in the type declaration above defines an extensible variant `type t`. The `+=` operator is then used to add constructors to the given type. - -**Note:** Don't forget the leading `type` keyword when using the `+=` operator! - -## Pattern Matching Caveats - -Extensible variants are open-ended, so the compiler will not be able to exhaustively pattern match all available cases. You will always need to provide a default `_` case for every `switch` expression. - - - -```res -let print = v => - switch v { - | Point(x, y) => Console.log2("Point", (x, y)) - | Line(ax, ay, bx, by) => Console.log2("Line", (ax, ay, bx, by)) - | Other - | _ => Console.log("Other") - } -``` - -```js -function print(v) { - if (v.RE_EXN_ID === Point) { - console.log("Point", [v._1, v._2]); - } else if (v.RE_EXN_ID === Line) { - console.log("Line", [v._1, v._2, v._3, v._4]); - } else { - console.log("Other"); - } -} -``` - - - -## Tips & Tricks - -**Fun fact:** In ReScript, [exceptions](./exception) are actually extensible variants under the hood, so `exception UserError(string)` is equivalent to `type exn += UserError(string)`. It's one of the very few use-case where extensible variants make sense. - -We usually recommend sticking with common [variants](./variant) as much as possible to reap the benefits of exhaustive pattern matching. diff --git a/pages/docs/manual/v11.0.0/external.mdx b/pages/docs/manual/v11.0.0/external.mdx deleted file mode 100644 index 89dfe53f9..000000000 --- a/pages/docs/manual/v11.0.0/external.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: "External (Bind to Any JS Library)" -description: "The external keyword" -canonical: "/docs/manual/v11.0.0/external" ---- - -# External (Bind to Any JS Library) - -`external` is the primary ReScript feature for bringing in and using JavaScript values. - -`external` is like a let binding, but: - -- The right side of `=` isn't a value; it's the name of the JS value you're referring to. -- The type for the binding is mandatory, since we need to know what the type of that JS value is. -- Can only exist at the top level of a file or module. - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -``` - -```js -// Empty output -``` - - - -There are several kinds of `external`s, differentiated and/or augmented through the [attribute](attribute.md) they carry. This page deals with the general, shared mechanism behind most `external`s. The different `external`s are documented in their respective pages later. A few notable ones: - -- `@val`, `@scope`: [bind to global JS values](bind-to-global-js-values). -- `@module`: [bind to JS imported/exported values](import-from-export-to-js). -- `@send`: [bind to JS methods](bind-to-js-function). - -You can also use our [Syntax Lookup](/syntax-lookup) tool to find them. - -Related: see also our [list of external decorators](interop-cheatsheet#list-of-decorators). - -## Usage - -Once declared, you can use an `external` as a normal value, just like a let binding. - -## Tips & Tricks - -`external` + ReScript objects are a wonderful combination for quick prototyping. Check the JS output tab: - - - -```res example -// The type of document is just some random type 'a -// that we won't bother to specify -@val external document: 'a = "document" - -// call a method -document["addEventListener"]("mouseup", _event => { - Console.log("clicked!") -}) - -// get a property -let loc = document["location"] - -// set a property -document["location"]["href"] = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); - -var loc = document.location; - -document.location.href = "rescript-lang.org"; -``` - - - -We've specified `document`'s type as `'a`, aka a placeholder type that's polymorphic. Any value can be passed there, so you're not getting much type safety (except the inferences at various call sites). However, this is excellent for quickly getting started using a JavaScript library in ReScript **without needing the equivalent of a repository of typed bindings** like TypeScript's `DefinitelyTyped` repo. - -However, if you want to more rigidly bind to the JavaScript library you want, keep reading the next few interop pages. - -## Performance & Output Readability - -`external`s declarations are inlined into their callers during compilation, **and completely disappear from the JS output**. This means any time you use one, you can be sure that you're not incurring extra JavaScript \<-> ReScript conversion cost. - -Additionally, no extra ReScript-specific runtime is better for output readability. - -> **Note:** do also use `external`s and the `@blabla` attributes in the interface files. Otherwise the inlining won't happen. - -## Design Decisions - -ReScript takes interoperating with existing code very seriously. Our type system has very strong guarantees. However, such strong feature also means that, without a great interop system, it'd be very hard to gradually convert a codebase over to ReScript. Fortunately, our interop are comprehensive and cooperate very well with most existing JavaScript code. - -The combination of a sound type system + great interop means that we get the benefits of a traditional gradual type system regarding incremental codebase coverage & conversion, without the downside of such gradual type system: complex features to support existing patterns, slow analysis, diminishing return in terms of type coverage, etc. diff --git a/pages/docs/manual/v11.0.0/faq.mdx b/pages/docs/manual/v11.0.0/faq.mdx deleted file mode 100644 index a2c6ec366..000000000 --- a/pages/docs/manual/v11.0.0/faq.mdx +++ /dev/null @@ -1,67 +0,0 @@ ---- -title: "FAQ" -description: "Frequently asked questions about ReScript and its ecosystem" -canonical: "/docs/manual/v11.0.0/faq" ---- - -# Frequently Asked Questions - -**What's the goal of this project?** - -We aim to provide the best typed language experience for the JavaScript platform. - -**What’s the relationship with BuckleScript?** - -BuckleScript is ReScript's old branding, with a sharper focus on proper JS support and familiarity which we previously couldn't achieve to the degree we wanted, due to us needing to cater to various different crowds. - -**What’s ReScript's relationship with OCaml?** - -We reuse and adjust the excellent type system and lots of other high quality components from OCaml for JS experience. -Additionally, ReScript provides its own syntax, build system, IDE, backend, JS interop, extra language features, etc. - -The ReScript toolchain is developed using OCaml, however, the version of ReScript is decoupled against the version of OCaml, -ReScript compiler should build against any reasonable modern version of OCaml compiler. - -For the majority of ReScript users, they don't need to learn OCaml or use OCaml toolchain to be productive in ReScript. - -**What’s the relationship with Reason?** - -See [here](/blog/bucklescript-is-rebranding). Reason is a syntax layer for OCaml that BuckleScript also adopted. The current ReScript compiler also supports the old Reason syntax v3.6 for backward compatibility. We will support it for a long time to make sure existing users do not get breaking changes. - -**I come from Reason/OCaml. Will ReScript keep supporting X?** - -Please see our [blog post](/blog/a-note-on-bucklescripts-future-commitments) on this matter. - -**Where can I see the docs in old Reason/OCaml syntax?** - -Switch the doc version to `v8.0.0` in the sidebar on the left! - -**Will ReScript support native compilation eventually?** - -Our focus is a solid JS story right now. In the future, if there’s strong demand, we might consider it. - -**What’s the current state of ReScript?** - -We're working on the v12.0 release (see [v12 milestone](https://github.com/rescript-lang/rescript/milestone/16)). - -- Move the [Rescript Core](https://github.com/rescript-lang/rescript-core) standard library into the compiler / remove the OCaml standard library -- A new build system tailored to ReScript's needs ([rewatch](https://github.com/teamwalnut/rewatch)) for better monorepo support and even faster compilation speed -- Make it easier to create libraries for consumption from TypeScript with GenType - -**When will we get the `async/await` keywords?** - -async/await has arrived in ReScript 10.1! - -**Why create a new syntax?** - -The existing Reason syntax is owned by a different team with a different vision. Reason aims to be 100% compatible with OCaml syntax and to support all versions of OCaml. In the last few years, we've drawn the conclusion that it’s very hard to deliver such goal without sacrificing user experience. The other reason is that we feel it’s better to have the same vision as a team so that we can make more coherent decisions. - -**Who is behind the project?** - -The ReScript team (Hongbo, Cheng, Cristiano, Maxim, Patrick, Ricky). - -**We have a new forum; will we also have our own Discord?** - -Not now. We've found that too much important information get casually passed in Discord then lost within the noise. We prefer folks to communicate on the [forum](https://forum.rescript-lang.org). This is nicer to the less active members. - -The team doesn't use the old Discord anymore. We encourage you to move your questions to the forum instead. diff --git a/pages/docs/manual/v11.0.0/function.mdx b/pages/docs/manual/v11.0.0/function.mdx deleted file mode 100644 index 24dacc728..000000000 --- a/pages/docs/manual/v11.0.0/function.mdx +++ /dev/null @@ -1,642 +0,0 @@ ---- -title: "Function" -description: "Function syntax in ReScript" -canonical: "/docs/manual/v11.0.0/function" ---- - -# Function - -_Cheat sheet for the full function syntax at the end_. - -ReScript functions are declared with an arrow and return an expression, just like JS functions. They compile to clean JS functions too. - - - -```res prelude -let greet = (name) => "Hello " ++ name -``` - -```js -function greet(name) { - return "Hello " + name; -} -``` - - - -This declares a function and assigns to it the name `greet`, which you can call like so: - - - -```res example -greet("world!") // "Hello world!" -``` - -```js -greet("world!"); -``` - - - -Multi-arguments functions have arguments separated by comma: - - - -```res example -let add = (x, y, z) => x + y + z -add(1, 2, 3) // 6 -``` - -```js -function add(x, y, z) { - return (((x + y) | 0) + z) | 0; -} -``` - - - -For longer functions, you'd surround the body with a block: - - - -```res example -let greetMore = (name) => { - let part1 = "Hello" - part1 ++ " " ++ name -} -``` - -```js -function greetMore(name) { - return "Hello " + name; -} -``` - - - -If your function has no argument, just write `let greetMore = () => {...}`. - -## Labeled Arguments - -Multi-arguments functions, especially those whose arguments are of the same type, can be confusing to call. - - - -```res -let addCoordinates = (x, y) => { - // use x and y here -} -// ... -addCoordinates(5, 6) // which is x, which is y? -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can attach labels to an argument by prefixing the name with the `~` symbol: - - - -```res -let addCoordinates = (~x, ~y) => { - // use x and y here -} -// ... -addCoordinates(~x=5, ~y=6) -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can provide the arguments in **any order**: - - - -```res -addCoordinates(~y=6, ~x=5) -``` - -```js -addCoordinates(5, 6); -``` - - - -The `~x` part in the declaration means the function accepts an argument labeled `x` and can refer to it in the function body by the same name. You can also refer to the arguments inside the function body by a different name for conciseness: - - - -```res -let drawCircle = (~radius as r, ~color as c) => { - setColor(c) - startAt(r, r) - // ... -} - -drawCircle(~radius=10, ~color="red") -``` - -```js -function drawCircle(r, c) { - setColor(c); - return startAt(r, r); -} - -drawCircle(10, "red"); -``` - - - -As a matter of fact, `(~radius)` is just a shorthand for `(~radius as radius)`. - -Here's the syntax for typing the arguments: - - - -```res -let drawCircle = (~radius as r: int, ~color as c: string) => { - // code here -} -``` - -```js -function drawCircle(r, c) { - // code here -} -``` - - - -## Optional Labeled Arguments - -Labeled function arguments can be made optional during declaration. You can then omit them when calling the function. - - - -```res -// radius can be omitted -let drawCircle = (~color, ~radius=?) => { - setColor(color) - switch radius { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - } -} -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -function drawCircle(color, radius) { - setColor(color); - if (radius === undefined) { - return startAt(1, 1); - } - var r_ = Caml_option.valFromOption(radius); - return startAt(r_, r_); -} -``` - - - -When given in this syntax, `radius` is **wrapped** in the standard library's `option` type, defaulting to `None`. If provided, it'll be wrapped with a `Some`. So `radius`'s type value is `None | Some(int)` here. - -More on `option` type [here](null-undefined-option.md). - -### Signatures and Type Annotations - -Functions with optional labeled arguments can be confusing when it comes to signature and type annotations. Indeed, the type of an optional labeled argument looks different depending on whether you're calling the function, or working inside the function body. Outside the function, a raw value is either passed in (`int`, for example), or left off entirely. Inside the function, the parameter is always there, but its value is an option (`option`). This means that the type signature is different, depending on whether you're writing out the function type, or the parameter type annotation. The first being a raw value, and the second being an option. - -If we get back to our previous example and both add a signature and type annotations to its argument, we get this: - - - -```res -let drawCircle: (~color: color, ~radius: int=?) => unit = - (~color: color, ~radius: option=?) => { - setColor(color) - switch radius { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - } - } -``` - -```js -function drawCircle(color, radius) { - setColor(color); - if (radius !== undefined) { - return startAt(radius, radius); - } else { - return startAt(1, 1); - } -} -``` - - - -The first line is the function's signature, we would define it like that in an interface file (see [Signatures](module.md#signatures)). The function's signature describes the types that the **outside world** interacts with, hence the type `int` for `radius` because it indeed expects an `int` when called. - -In the second line, we annotate the arguments to help us remember the types of the arguments when we use them **inside** the function's body, here indeed `radius` will be an `option` inside the function. - -So if you happen to struggle when writing the signature of a function with optional labeled arguments, try to remember this! - -### Explicitly Passed Optional - -Sometimes, you might want to forward a value to a function without knowing whether the value is `None` or `Some(a)`. Naively, you'd do: - - - -```res -let result = - switch payloadRadius { - | None => drawCircle(~color) - | Some(r) => drawCircle(~color, ~radius=r) - } -``` - -```js -var r = payloadRadius; - -var result = - r !== undefined - ? drawCircle(color, Caml_option.valFromOption(r)) - : drawCircle(color); -``` - - - -This quickly gets tedious. We provide a shortcut: - - - -```res -let result = drawCircle(~color, ~radius=?payloadRadius) -``` - -```js -var result = drawCircle(1, undefined); -``` - - - -This means "I understand `radius` is optional, and that when I pass it a value it needs to be an `int`, but I don't know whether the value I'm passing is `None` or `Some(val)`, so I'll pass you the whole `option` wrapper". - -### Optional with Default Value - -Optional labeled arguments can also be provided a default value. In this case, they aren't wrapped in an `option` type. - - - -```res -let drawCircle = (~radius=1, ~color) => { - setColor(color) - startAt(radius, radius) -} -``` - -```js -function drawCircle(radiusOpt, color) { - var radius = radiusOpt !== undefined ? radiusOpt : 1; - setColor(color); - return startAt(radius, radius); -} -``` - - - -## Recursive Functions - -ReScript chooses the sane default of preventing a function to be called recursively within itself. To make a function recursive, add the `rec` keyword after the `let`: - - - -```res example -let rec neverTerminate = () => neverTerminate() -``` - -```js -function neverTerminate(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -A simple recursive function may look like this: - - - -```res example -// Recursively check every item on the list until one equals the `item` -// argument. If a match is found, return `true`, otherwise return `false` -let rec listHas = (list, item) => - switch list { - | list{} => false - | list{a, ...rest} => a === item || listHas(rest, item) - } -``` - -```js -function listHas(_list, item) { - while (true) { - var list = _list; - if (!list) { - return false; - } - if (list.hd === item) { - return true; - } - _list = list.tl; - continue; - } -} -``` - - - -Recursively calling a function is bad for performance and the call stack. However, ReScript intelligently compiles [tail recursion](https://stackoverflow.com/questions/33923/what-is-tail-recursion) into a fast JavaScript loop. Try checking the JS output of the above code! - -### Mutually Recursive Functions - -Mutually recursive functions start like a single recursive function using the -`rec` keyword, and then are chained together with `and`: - - - -```res example -let rec callSecond = () => callFirst() -and callFirst = () => callSecond() -``` - -```js -function callSecond(_param) { - while (true) { - _param = undefined; - continue; - } -} - -function callFirst(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -## Partial Application - -**Since 11.0** - -To partially apply a function, use the explicit `...` syntax. - - -```res -let add = (a, b) => a + b -let addFive = add(5, ...) -``` - -```js -function add(a, b) { - return (a + b) | 0; -} - -function addFive(extra) { - return (5 + extra) | 0; -} -``` - - - -## Async/Await - -Just as in JS, an async function can be declared by adding `async` before the definition, and `await` can be used in the body of such functions. -The output looks like idiomatic JS: - - - -```res example -let getUserName = async (userId) => userId - -let greetUser = async (userId) => { - let name = await getUserName(userId) - "Hello " ++ name ++ "!" -} -``` - -```js -async function greetUser(userId) { - var name = await getUserName(userId); - return "Hello " + name + "!"; -} -``` - - - -The return type of `getUser` is inferred to be `promise`. -Similarly, `await getUserName(userId)` returns a `string` when the function returns `promise`. -Using `await` outside of an `async` function (including in a non-async callback to an async function) is an error. - -### Ergonomic error handling - -Error handling is done by simply using `try`/`catch`, or a switch with an `exception` case, just as in functions that are not async. -Both JS exceptions and exceptions defined in ReScript can be caught. The compiler takes care of packaging JS exceptions into the builtin `JsError` exception: - - - -```res example -exception SomeReScriptException - -let somethingThatMightThrow = async () => raise(SomeReScriptException) - -let someAsyncFn = async () => { - switch await somethingThatMightThrow() { - | data => Some(data) - | exception JsError(_) => None - | exception SomeReScriptException => None - } -} -``` - -```js -var SomeReScriptException = /* @__PURE__ */ Caml_exceptions.create( - "Example.SomeReScriptException", -); - -async function someAsyncFn(param) { - var data; - try { - data = await somethingThatMightThrow(undefined); - } catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "JsError") { - return; - } - if (exn.RE_EXN_ID === SomeReScriptException) { - return; - } - throw exn; - } - return data; -} -``` - - - -## The ignore() Function - -Occasionally you may want to ignore the return value of a function. ReScript provides an `ignore()` function that discards the value of its argument and returns `()`: - - - -```res -mySideEffect()->Promise.catch(handleError)->ignore - -setTimeout(myFunc, 1000)->ignore -``` - -```js -$$Promise.$$catch(mySideEffect(), function (prim) { - return handleError(prim); -}); - -setTimeout(function (prim) { - myFunc(); -}, 1000); -``` - - - -## Tips & Tricks - -Cheat sheet for the function syntaxes: - -### Declaration - -```res -// anonymous function -(x, y) => 1 -// bind to a name -let add = (x, y) => 1 - -// labeled -let add = (~first as x, ~second as y) => x + y -// with punning sugar -let add = (~first, ~second) => first + second - -// labeled with default value -let add = (~first as x=1, ~second as y=2) => x + y -// with punning -let add = (~first=1, ~second=2) => first + second - -// optional -let add = (~first as x=?, ~second as y=?) => switch x {...} -// with punning -let add = (~first=?, ~second=?) => switch first {...} -``` - -#### With Type Annotation - -```res -// anonymous function -(x: int, y: int): int => 1 -// bind to a name -let add = (x: int, y: int): int => 1 - -// labeled -let add = (~first as x: int, ~second as y: int) : int => x + y -// with punning sugar -let add = (~first: int, ~second: int) : int => first + second - -// labeled with default value -let add = (~first as x: int=1, ~second as y: int=2) : int => x + y -// with punning sugar -let add = (~first: int=1, ~second: int=2) : int => first + second - -// optional -let add = (~first as x: option=?, ~second as y: option=?) : int => switch x {...} -// with punning sugar -// note that the caller would pass an `int`, not `option` -// Inside the function, `first` and `second` are `option`. -let add = (~first: option=?, ~second: option=?) : int => switch first {...} -``` - -### Application - -```res -add(x, y) - -// labeled -add(~first=1, ~second=2) -// with punning sugar -add(~first, ~second) - -// application with default value. Same as normal application -add(~first=1, ~second=2) - -// explicit optional application -add(~first=?Some(1), ~second=?Some(2)) -// with punning -add(~first?, ~second?) -``` - -#### With Type Annotation - -```res -// labeled -add(~first=1: int, ~second=2: int) -// with punning sugar -add(~first: int, ~second: int) - -// application with default value. Same as normal application -add(~first=1: int, ~second=2: int) - -// explicit optional application -add(~first=?Some(1): option, ~second=?Some(2): option) -// no punning sugar when you want to type annotate -``` - -### Standalone Type Signature - -```res -// first arg type, second arg type, return type -type add = (int, int) => int - -// labeled -type add = (~first: int, ~second: int) => int - -// labeled -type add = (~first: int=?, ~second: int=?, unit) => int -``` - -#### In Interface Files - -To annotate a function from the implementation file (`.res`) in your interface file (`.resi`): - -```res sig -let add: (int, int) => int -``` - -The type annotation part is the same as the previous section on With Type Annotation. - -**Don't** confuse `let add: myType` with `type add = myType`. When used in `.resi` interface files, the former exports the binding `add` while annotating it as type `myType`. The latter exports the type `add`, whose value is the type `myType`. diff --git a/pages/docs/manual/v11.0.0/generate-converters-accessors.mdx b/pages/docs/manual/v11.0.0/generate-converters-accessors.mdx deleted file mode 100644 index 286a3f2db..000000000 --- a/pages/docs/manual/v11.0.0/generate-converters-accessors.mdx +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: "Generate Converters & Helpers" -description: "All about the @deriving decorator, and how to generate code from types" -canonical: "/docs/manual/v11.0.0/generate-converters-accessors" ---- - -# Generate Converters & Helpers - -**Note**: if you're looking for: - -- `@deriving(jsConverter)` for records -- `@deriving({jsConverter: newType})` for records -- `@deriving(abstract)` for records -- `@deriving(jsConverter)` for plain and polymorphic variants - -These particular ones are no longer needed. Select a doc version lower than `9.0` in the sidebar to see their old docs. - - - -When using ReScript, you will sometimes come into situations where you want to - -- Automatically generate functions that convert between ReScript's internal and JS runtime values (e.g. variants). -- Convert a record type into an abstract type with generated creation, accessor and method functions. -- Generate some other helper functions, such as functions from record attribute names. - -You can use the `@deriving` decorator for different code generation scenarios. All different options and configurations will be discussed on this page. - -**Note:** Please be aware that extensive use of code generation might make it harder to understand your programs (since the code being generated is not visible in the source code, and you just need to know what kind of functions / values a decorator generates). - -## Generate Functions & Plain Values for Variants - -Use `@deriving(accessors)` on a variant type to create accessor functions for its constructors. - - - -```res -@deriving(accessors) -type action = - | Click - | Submit(string) - | Cancel; -``` - -```js -function submit(param_0) { - return /* Submit */ [param_0]; -} - -var click = /* Click */ 0; - -var cancel = /* Cancel */ 1; - -exports.click = click; -exports.submit = submit; -exports.cancel = cancel; -``` - - - -Variants constructors with payloads generate functions, payload-less constructors generate plain integers (the internal representation of variants). - -**Note**: - -- The generated accessors are lower-cased. -- You can now use these helpers on the JavaScript side! But don't rely on their actual values please. - -### Usage - -```res -let s = submit("hello"); /* gives Submit("hello") */ -``` - -This is useful: - -- When you're passing the accessor function as a higher-order function (which plain variant constructors aren't). -- When you'd like the JS side to use these values & functions opaquely and pass you back a variant constructor (since JS has no such thing). - -Please note that in case you just want to _pipe a payload into a constructor_, you don't need to generate functions for that. Use the `->` syntax instead, e.g. `"test"->Submit`. - -## Generate Field Accessors for Records - -Use `@deriving(accessors)` on a record type to create accessors for its record field names. - - - -```res -@deriving(accessors) -type pet = {name: string} - -let pets = [{name: "bob"}, {name: "bob2"}] - -pets - ->Array.map(name) - ->Array.joinWith("&") - ->Console.log -``` - -```js -function name(param) { - return param.name; -} - -var pets = [ - { - name: "bob", - }, - { - name: "bob2", - }, -]; - -console.log(Belt_Array.map(pets, name).join("&")); -``` - - diff --git a/pages/docs/manual/v11.0.0/import-export.mdx b/pages/docs/manual/v11.0.0/import-export.mdx deleted file mode 100644 index 321d89ecf..000000000 --- a/pages/docs/manual/v11.0.0/import-export.mdx +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: "Import & Export" -description: "Importing / exporting in ReScript modules" -canonical: "/docs/manual/v11.0.0/import-export" ---- - -# Import & Export - -## Import a Module/File - -Unlike JavaScript, ReScript doesn't have or need import statements: - - - -```res -// Inside School.res -let studentMessage = Student.message -``` - -```js -var Student = require("./Student.res.js"); -var studentMessage = Student.message; -``` - - - -The above code refers to the `message` binding in the file `Student.res`. Every ReScript file is also a module, so accessing another file's content is the same as accessing another module's content! - -A ReScript project's file names need to be unique. - -## Export Stuff - -By default, every file's type declaration, binding and module is exported, aka publicly usable by another file. **This also means those values, once compiled into JS, are immediately usable by your JS code**. - -To only export a few selected things, use a `.resi` [interface file](module.md#signatures). - -## Work with JavaScript Import & Export - -To see how to import JS modules and export stuff for JS consumption, see the JavaScript Interop section's [Import from/Export to JS](import-from-export-to-js.md). diff --git a/pages/docs/manual/v11.0.0/import-from-export-to-js.mdx b/pages/docs/manual/v11.0.0/import-from-export-to-js.mdx deleted file mode 100644 index a8acee3c2..000000000 --- a/pages/docs/manual/v11.0.0/import-from-export-to-js.mdx +++ /dev/null @@ -1,259 +0,0 @@ ---- -title: "Import from / Export to JS" -description: "Importing / exporting JS module content in ReScript" -canonical: "/docs/manual/v11.0.0/import-from-export-to-js" ---- - -# Import from/Export to JS - -You've seen how ReScript's idiomatic [Import & Export](import-export.md) works. This section describes how we work with importing stuff from JavaScript and exporting stuff for JavaScript consumption. - -If you're looking for react-specific interop guidance, check out the [React JS Interop guide](../../react/latest/import-export-reactjs.mdx). - -**Note**: due to JS ecosystem's module compatibility issues, our advice of keeping your ReScript file's compiled JS output open in a tab applies here **more than ever**, as you don't want to subtly output the wrong JS module import/export code, on top of having to deal with Babel/Webpack/Jest/Node's CommonJS \<-> JavaScript module compatibility shims. - -In short: **make sure your bindings below output what you'd have manually written in JS**. - -## Output Format - -We support 2 JavaScript import/export formats: - -- JavaScript module: `import * from 'MyReScriptFile'` and `export let ...`. -- CommonJS: `require('myFile')` and `module.exports = ...`. - -The format is [configurable in via `rescript.json`](build-configuration.md#package-specs). - -## Import From JavaScript - -### Import a JavaScript Module's Named Export - -Use the `module` [external](external.md): - - - -```res example -// Import nodejs' path.dirname -@module("path") external dirname: string => string = "dirname" -let root = dirname("/User/github") // returns "User" -``` - -```js -import * as Path from "path"; -var root = Path.dirname("/User/github"); -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - - - -Here's what the `external` does: - -- `@module("path")`: pass the name of the JS module; in this case, `"path"`. The string can be anything: `"./src/myJsFile"`, `"@myNpmNamespace/myLib"`, etc. -- `external`: the general keyword for declaring a value that exists on the JS side. -- `dirname`: the binding name you'll use on the ReScript side. -- `string => string`: the type signature of `dirname`. Mandatory for `external`s. -- `= "dirname"`: the name of the variable inside the `path` JS module. There's repetition in writing the first and second `dirname`, because sometime the binding name you want to use on the ReScript side is different than the variable name the JS module exported. - -### Import a JavaScript Module As a Single Value - -By omitting the string argument to `module`, you bind to the whole JS module: - - - -```res example -@module external leftPad: (string, int) => string = "./leftPad" -let paddedResult = leftPad("hi", 5) -``` - -```js -import * as LeftPad from "./leftPad"; -var paddedResult = LeftPad("hi", 5); -``` - -```js -var LeftPad = require("./leftPad"); -var paddedResult = LeftPad("hi", 5); -``` - - - -Depending on whether you're compiling ReScript to JavaScript module or CommonJS, **this feature will generate subtly different code**. Please check both output tabs to see the difference. The JavaScript module output here would be wrong! - -### Import an `default` Export - -Use the value `default` on the right hand side: - - - -```res example -@module("./student") external studentName: string = "default" -Console.log(studentName) -``` - -```js -import Student from "./student"; -var studentName = Student; -``` - - - -### Use Import Attributes - -**Since 11.1** - -[Import attributes](https://github.com/tc39/proposal-import-attributes) can be used in ReScript, as long as ReScript is configured to output JavaScript module. You do that by passing configuration to the `@module` attribute: - - -```rescript -@module({from: "./myJson.json", with: {type_: "json", \"some-exotic-identifier": "someValue"}}) -external myJson: JSON.t = "default" - -Console.log(myJson) - -```` - -```javascript -import MyJsonJson from "./myJson.json" with {"type": "json", "some-exotic-identifier": "someValue"}; - -var myJson = MyJsonJson; - -console.log(myJson); -```` - - - -This above imports the local `./myJson.json` file, adding import attributes. - -This is how it works: - -1. Instead of passing a string or tuple to `@module`, pass a record. -2. This record should have a `from` key. The value of that is where you want the module to be imported from (just like the regular string to `@module` is). -3. It should also have a `with` key, with another record where you put all the import attributes you want emitted. - -Notice `\"some-exotic-identifier"` - you'll need to escape any key that's not a valid ReScript record key. -Also notice `type_`. Since `type` is a reserved keyword in ReScript, you can use `type_` instead. It will be output as `type` in the JavaScript code. - -## Dynamic Import - -Leveraging JavaScript's [dynamic `import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) to reduce bundle size and lazy load code as needed is easy in ReScript. It's also a little bit more convenient than in regular JavaScript because you don't need to keep track of file paths manually with ReScript's module system. - -### Dynamically Importing Parts of a Module - -Use the `import` function to dynamically import a specific part of a module. Put whatever `let` binding you want to import in there, and you'll get a `promise` back resolving to that specific binding. - -Let's look at an example. Imagine the following file `MathUtils.res`: - -```rescript -let add = (a, b) => a + b -let sub = (a, b) => a - b -``` - -Now let's dynamically import the add function in another module, e.g. `App.res`: - - -```rescript -// App.res -let main = async () => { - let add = await import(MathUtils.add) - let onePlusOne = add(1, 1) - -Console.log(onePlusOne) -} - -```` -```javascript -async function main() { - var add = await import("./MathUtils.mjs").then(function(m) { - return m.add; - }); - - var onePlusOne = add(1, 1); - console.log(onePlusOne); -} -```` - - - -### Dynamically Importing an Entire Module - -The syntax for importing a whole module looks a little different, since we are operating on the module syntax level; instead of using `import`, you may simply `await` the module itself: - - -```rescript -// App.res -let main = async () => { - module Utils = await MathUtils - -let twoPlusTwo = Utils.add(2, 2) -Console.log(twoPlusTwo) -} - -```` -```javascript -async function main() { - var Utils = await import("./MathUtils.mjs"); - - var twoPlusTwo = Utils.add(2, 2); - console.log(twoPlusTwo); -} -```` - - - -## Export To JavaScript - -### Export a Named Value - -As mentioned in ReScript's idiomatic [Import & Export](import-export.md), every let binding and module is exported by default to other ReScript modules (unless you use a `.resi` [interface file](module#signatures)). If you open up the compiled JS file, you'll see that these values can also directly be used by a _JavaScript_ file too. - -### Export a `default` Value - -If your JS project uses JavaScript module, you're likely exporting & importing some default values: - -```js -// student.js -export default name = "Al"; -``` - -```js -// teacher.js -import studentName from "student.js"; -``` - -A JavaScript default export is really just syntax sugar for a named export implicitly called `default` (now you know!). So to export a default value from ReScript, you can just do: - - - -```res example -// ReScriptStudent.res -let default = "Bob" -``` - -```js -var $$default = "Bob"; - -exports.$$default = $$default; -exports.default = $$default; -// informal transpiler-compatible marker of a default export compiled from JavaScript module -exports.__esModule = true; -``` - -```js -var $$default = "Bob"; - -export { $$default, $$default as default }; -``` - - - -You can then import this default export as usual on the JS side: - -```js -// teacher2.js -import studentName from "ReScriptStudent.js"; -``` - -If your JavaScript's default import is transpiled by Babel/Webpack/Jest into CommonJS `require`s, we've taken care of that too! See the CommonJS output tab for `__esModule`. diff --git a/pages/docs/manual/v11.0.0/inlining-constants.mdx b/pages/docs/manual/v11.0.0/inlining-constants.mdx deleted file mode 100644 index acb1a9d4a..000000000 --- a/pages/docs/manual/v11.0.0/inlining-constants.mdx +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: "Inlining Constants" -description: "Inlining constants" -canonical: "/docs/manual/v11.0.0/inlining-constants" ---- - -# Inlining Constants - -Sometimes, in the JavaScript output, you might want a certain value to be forcefully inlined. For example: - -```js -if (process.env.mode === "development") { - console.log("Dev-only code here!"); -} -``` - -The reason is that your JavaScript bundler (e.g. Webpack) might turn that into: - -```js -if ("production" === "development") { - console.log("Dev-only code here!"); -} -``` - -Then your subsequent Uglifyjs optimization would remove that entire `if` block. This is how projects like ReactJS provide a development mode code with plenty of dev warnings, while ensuring that the uglified (minified) production code is free of those expensive blocks. - -So, in ReScript, producing that example `if (process.env.mode === 'development')` output is important. This first try doesn't work: - - - -```res example -@val external process: 'a = "process" - -let mode = "development" - -if (process["env"]["mode"] === mode) { - Console.log("Dev-only code here!") -} -``` - -```js -var mode = "development"; - -if (process.env.mode === mode) { - console.log("Dev-only code here!"); -} -``` - - - -The JS output shows `if (process.env.mode === mode)`, which isn't what we wanted. To inline `mode`'s value, use `@inline`: - - - -```res example -@val external process: 'a = "process" - -@inline -let mode = "development" - -if (process["env"]["mode"] === mode) { - Console.log("Dev-only code here!") -} -``` - -```js -if (process.env.mode === "development") { - console.log("Dev-only code here!"); -} -``` - - - -Now your resulting JS code can pass through Webpack and Uglifyjs like the rest of your JavaScript code, and that whole `console.log` can be removed. - -The inlining currently only works for **string, float and boolean**. - -## Tips & Tricks - -This is **not** an optimization. This is an edge-case feature for folks who absolutely need particular values inlined for a JavaScript post-processing step, like conditional compilation. Beside the difference in code that the conditional compilation might end up outputting, there's no performance difference between inlining and not inlining simple values in the eyes of a JavaScript engine. diff --git a/pages/docs/manual/v11.0.0/installation.mdx b/pages/docs/manual/v11.0.0/installation.mdx deleted file mode 100644 index 6ee1eff4a..000000000 --- a/pages/docs/manual/v11.0.0/installation.mdx +++ /dev/null @@ -1,164 +0,0 @@ ---- -title: "Installation" -description: "ReScript installation and setup instructions" -canonical: "/docs/manual/v11.0.0/installation" ---- - -# Installation - -## Notes - -With the instructions below, our new standard library [ReScript Core](https://github.com/rescript-lang/rescript-core) will be included by default. (In ReScript 11, it comes as a separate npm package `@rescript/core`. In future versions, it will be included in the `rescript` npm package itself.) - -## Prerequisites - -- [Node.js](https://nodejs.org/) version >= 14 -- One of the following package managers: - - [npm](https://docs.npmjs.com/cli/) (comes with Node.js) - - [yarn](https://yarnpkg.com/) (yarn versions >1 need to set `nodeLinker: node-modules` in `.yarnrc.yml`) - - [pnpm](https://pnpm.io/) - - [bun](https://bun.sh/) - -## New Project - -The fastest and easiest way to spin up a new ReScript project is with the [create-rescript-app](https://github.com/rescript-lang/create-rescript-app) project generator. You can start it with any of the aforementioned package managers or `npx`. - - - -```sh example -npm create rescript-app@latest -``` - -```sh -npx create-rescript-app -``` - -```sh -yarn create rescript-app -``` - -```sh -pnpm create rescript-app -``` - -```sh -bun create rescript-app -``` - - - -- Follow the steps of the setup. -- Trigger a ReScript build: - ```sh - npm run res:build - ``` -- If you selected the "basic" template, simply run it with: - ```sh - node src/Demo.res.mjs - ``` - -That compiles your ReScript into JavaScript, then uses Node.js to run said JavaScript. - -**When taking your first steps with ReScript, we recommend you use our unique workflow of keeping a tab open for the generated JS file** (`.res.js`/`.res.mjs`), so that you can learn how ReScript transforms into JavaScript. Not many languages output clean JavaScript code you can inspect and learn from! With our [VS Code extension](https://marketplace.visualstudio.com/items?itemName=chenglou92.rescript-vscode), use the command "ReScript: Open the compiled JS file for this implementation file" to open the generated JS file for the currently active ReScript source file. - -During development, instead of running `npm run res:build` each time to compile, use `npm run res:dev` to start a watcher that recompiles automatically after file changes. - -## Integrate Into an Existing JS Project - -If you already have a JavaScript project into which you'd like to add ReScript you can do that in the following ways: - -### Quick Setup - -In the root directory of your project, execute: - - - -```sh -npm create rescript-app@latest -``` - -```sh -npx create-rescript-app -``` - -```sh -yarn create rescript-app -``` - -```sh -pnpm create rescript-app -``` - -```sh -bun create rescript-app -``` - - - -`create-rescript-app` will tell you that a `package.json` file has been detected and ask you if it should install ReScript into your project. Just follow the steps accordingly. - -### Manual Setup - -- Install ReScript locally: - - - - ```sh - npm install rescript @rescript/core - ``` - - ```sh - yarn add rescript @rescript/core - ``` - - ```sh - pnpm install rescript @rescript/core - ``` - - ```sh - bun install rescript @rescript/core - ``` - - - -- Create a ReScript build configuration file (called `rescript.json`) at the root: - ```json - { - "name": "your-project-name", - "sources": [ - { - "dir": "src", // update this to wherever you're putting ReScript files - "subdirs": true - } - ], - "package-specs": [ - { - "module": "esmodule", - "in-source": true - } - ], - "suffix": ".res.js", - "bs-dependencies": ["@rescript/core"], - "bsc-flags": ["-open RescriptCore"] - } - ``` - See [Build Configuration](build-configuration) for more details on `rescript.json`. -- Add convenience `npm` scripts to `package.json`: - ```json - "scripts": { - "res:build": "rescript", - "res:dev": "rescript -w" - } - ``` - -Since ReScript compiles to clean readable JS files, the rest of your existing toolchain (e.g. Babel and Webpack) should just work! - -Helpful guides: - -- [Converting from JS](/docs/manual/latest/converting-from-js). -- [Shared Data Types](shared-data-types). -- [Import from/Export to JS](import-from-export-to-js). - -### Integrate with a ReactJS Project - -To start a [rescript-react](/docs/react/latest/introduction) app, or to integrate ReScript into an existing ReactJS app, follow the instructions [here](/docs/react/latest/installation). diff --git a/pages/docs/manual/v11.0.0/interop-cheatsheet.mdx b/pages/docs/manual/v11.0.0/interop-cheatsheet.mdx deleted file mode 100644 index dafd6051e..000000000 --- a/pages/docs/manual/v11.0.0/interop-cheatsheet.mdx +++ /dev/null @@ -1,284 +0,0 @@ ---- -title: "Interop Cheatsheet" -description: "Cheatsheet for various interop scenarios in ReScript" -canonical: "/docs/manual/v11.0.0/interop-cheatsheet" ---- - -# Interop Cheatsheet - -This is a glossary with examples. All the features are described by later pages. - -## List of Decorators - -> **Note:** In ReScript < 8.3, all our attributes started with the `bs.` prefix. This is no longer needed and our formatter automatically removes them in newer ReScript versions. - - - -### Attributes - -- `@as`: [here](attribute#usage), [here](bind-to-js-function#fixed-arguments), [here](bind-to-js-function#constrain-arguments-better) and [here](generate-converters-accessors#usage-3) -- [`@deriving`](generate-converters-accessors#generate-functions--plain-values-for-variants) -- [`@get`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@get_index`](bind-to-js-object#bind-using-special-bs-getters--setters) - -- [`@inline`](inlining-constants) -- [`@int`](bind-to-js-function#constrain-arguments-better) - -- [`@module`](import-from-export-to-js#import-a-javascript-modules-content) -- [`@new`](bind-to-js-object#bind-to-a-js-object-thats-a-class) -- [`@optional`](generate-converters-accessors#optional-labels) -- [`@return`](bind-to-js-function#function-nullable-return-value-wrapping) -- `@send`: [here](bind-to-js-function#object-method) and [here](pipe#js-method-chaining) -- [`@scope`](bind-to-global-js-values#global-modules) -- [`@set`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@set_index`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@variadic`](bind-to-js-function#variadic-function-arguments) -- [`@string`](bind-to-js-function#constrain-arguments-better) -- [`@this`](bind-to-js-function#modeling-this-based-callbacks) -- [`@uncurry`](bind-to-js-function#extra-solution) -- [`@unwrap`](bind-to-js-function#trick-2-polymorphic-variant--bsunwrap) -- [`@val`](bind-to-global-js-values#global-modules) -- [`@taggedTemplate`](bind-to-js-function#tagged_template-functions) - -- [`@deprecated`](attribute#usage) -- [`genType`](https://github.com/reason-association/genType) -- [`@JSX`](jsx) -- `@react.component`: [here](/docs/react/latest/introduction) and [here](https://github.com/reasonml/reason-react) -- [`@warning`](attribute#usage) -- [`@unboxed`](variant#untagged-variants) - -### Extension Points - -- [`%debugger`](embed-raw-javascript#debugger) -- [`%external`](bind-to-global-js-values#special-global-values) -- [`%raw`](embed-raw-javascript#paste-raw-js-code) -- [`%re`](primitive-types#regular-expression) -- [`%todo`](/syntax-lookup#todo) - -## Raw JS - - - -```res example -let add = %raw("(a, b) => a + b") -%%raw("const a = 1") -``` - -```js -var add = (a, b) => a + b; -const a = 1; -``` - - - -## Global Value - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -``` - -```js -// Empty output -``` - - - -## Global Module's Value - - - -```res example -@val @scope("Math") -external random: unit => float = "random" - -let someNumber = random() - -@val @scope(("window", "location", "ancestorOrigins")) -external length: int = "length" -``` - -```js -var someNumber = Math.random(); -``` - - - -## Nullable - - - -```res example -let a = Some(5) // compiles to 5 -let b = None // compiles to undefined -``` - -```js -var a = 5; -var b; -``` - - - -Handling a value that can be `undefined` and `null`, by ditching the `option` type and using `Nullable.t`: - - - -```res example -let jsNull = Nullable.null -let jsUndefined = Nullable.undefined -let result1: Nullable.t = Nullable.make("hello") -let result2: Nullable.t = Nullable.fromOption(Some(10)) -let result3: option = Nullable.toOption(Nullable.make(10)) -``` - -```js -import * as Caml_option from "./stdlib/caml_option.js"; -import * as Core__Nullable from "./stdlib/core__Nullable.js"; - -var result2 = Core__Nullable.fromOption(10); - -var jsNull = null; - -var jsUndefined; - -var result1 = "hello"; - -var result3 = Caml_option.nullable_to_opt(10); -``` - - - -## JS Object - -- [Bind to a JS object as a ReScript record](bind-to-js-object#bind-to-record-like-js-objects). -- [Bind to a JS object that acts like a hash map](bind-to-js-object#bind-to-hash-map-like-js-object). -- [Bind to a JS object that's a class](bind-to-js-object#bind-to-a-js-object-thats-a-class). - -## Function - -### Object Method & Chaining - - - -```res example -@send external map: (array<'a>, 'a => 'b) => array<'b> = "map" -@send external filter: (array<'a>, 'a => bool) => array<'a> = "filter" -[1, 2, 3] - ->map(a => a + 1) - ->filter(a => mod(a, 2) == 0) - ->Console.log -``` - -```js -console.log( - [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }), -); -``` - - - -### Variadic Arguments - - - -```res example -@module("path") @variadic -external join: array => string = "join" -``` - -```js -// Empty output -``` - - - -### Tagged template functions - - - -```res example -// see https://bun.sh/docs/runtime/shell -type result = {exitCode: int} -@module("bun") @taggedTemplate -external sh: (array, array) => promise = "$" - -let filename = "index.res" -let result = await sh`ls ${filename}` -``` - -```js -import * as $$Bun from "bun"; -var filename = "index.res"; -var result = await $$Bun.$`ls ${filename}`; -``` - - - -### Polymorphic Function - - - -```res example -@module("Drawing") external drawCat: unit => unit = "draw" -@module("Drawing") external drawDog: (~giveName: string) => unit = "draw" -``` - -```js -// Empty output -``` - - - - - -```res example -@val -external padLeft: ( - string, - @unwrap [ - | #Str(string) - | #Int(int) - ]) - => string = "padLeft" - -padLeft("Hello World", #Int(4)) -padLeft("Hello World", #Str("Message from ReScript: ")) -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -## JS Module Interop - -[See here](import-from-export-to-js.md) - -## Dangerous Type Cast - -Final escape hatch converter. Do not abuse. - - - -```res example -external convertToFloat: int => float = "%identity" -let age = 10 -let gpa = 2.1 +. convertToFloat(age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - diff --git a/pages/docs/manual/v11.0.0/interop-with-js-build-systems.mdx b/pages/docs/manual/v11.0.0/interop-with-js-build-systems.mdx deleted file mode 100644 index 35c8c18db..000000000 --- a/pages/docs/manual/v11.0.0/interop-with-js-build-systems.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Interop with JS Build Systems" -description: "Documentation on how to interact with existing JS build systems" -canonical: "/docs/manual/v11.0.0/interop-with-js-build-systems" ---- - -# Interop with JS Build Systems - -If you come from JS, chances are that you already have a build system in your existing project. Here's an overview of the role `rescript` would play in your build pipeline, if you want to introduce some ReScript code. - -> **Please** try not to wrap `rescript` into your own incremental build framework. ReScript's compilation is very hard to get right, and you'll inevitably run into stale or badly performing builds (therefore erasing much of our value proposition) if you create your own meta layer on top. - -## Popular JS Build Systems - -The JS ecosystem uses a few build systems: [vite](https://vite.dev/), [browserify](http://browserify.org/), [rollup](https://github.com/rollup/rollup), [webpack](https://webpack.js.org/), etc. The first one is probably the most popular of the four (as of 2025 =P). These build systems do both the compilation and the linking (aka, bundling many files into one or few files). - -`rescript` only takes care of the compilation step; it maps one `.res`/`.resi` file into one JS output file. As such, in theory, no build system integration is needed from our side. From e.g. the webpack watcher's perspective, the JS files ReScript generates are almost equivalent to your hand-written JS files. We also recommend **that you initially check in those ReScript-generated JS files**, as this workflow means: - -- You can introduce ReScript silently into your codebase without disturbing existing infra. -- You have a **visual** diff of the performance & correctness of your JS file when you update the `.res` files and the JS artifacts change. -- You can let teammates hot-patch the JS files in emergency situations, without needing to first start learning ReScript. -- You can remove ReScript completely from your codebase and things will still work (in case your company decides to stop using us for whatever reason). - -For what it's worth, you can also turn `rescript` into an automated step in your build pipeline, e.g. into a Webpack loader; but such approach is error-prone and therefore discouraged. - -### Tips & Tricks - -You can make ReScript JS files look even more idiomatic through the in-source + bs suffix config in `rescript.json`: - -```json -{ - "package-specs": { - "module": "commonjs", // or whatever module system your project uses - "in-source": true - }, - "suffix": ".res.js" -} -``` - -This will: - -- Generate the JS files alongside your ReScript source files. -- Use the file extension `.res.js`, so that you can require these files on the JS side through `require('./MyFile.res.js')`, without needing a loader. - -## Use Loaders on ReScript Side - -"What if my build system uses a CSS/png/whatever loader and I'd like to use it in ReScript?" - -Loaders are indeed troublesome; in the meantime, please use e.g. `%raw("require('./myStyles.css')")` at the top of your file. This just uses [`raw`](embed-raw-javascript.md) to compile the snippet into an actual JS require. - -## Getting Project's Dependencies - -`rescript` generates one `MyFile.d` file per `MyFile` source file; you'll find them in `lib/bs`. These are human readable, machine-friendly list of the dependencies of said `MyFile`. You can read into them for your purpose (though mind the IO overhead). Use these files instead of creating your own dependency graph; we did the hard work of tracking the dependencies as best as possible (including inner modules, `open`s, module names overlap, etc). - -## Run Script Per File Built - -See [js-post-build](build-configuration#js-post-build). Though please use it sparingly; if you hook up a node.js script after each file built, you'll incur the node startup time per file! diff --git a/pages/docs/manual/v11.0.0/introduction.mdx b/pages/docs/manual/v11.0.0/introduction.mdx deleted file mode 100644 index e65e8ad25..000000000 --- a/pages/docs/manual/v11.0.0/introduction.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: "Introduction" -description: "The hows and whys of ReScript" -canonical: "/docs/manual/v11.0.0/introduction" ---- - -# ReScript - -Ever wanted a language like JavaScript, but without the warts, with a great type system, and with a lean build toolchain that doesn't waste your time? - -ReScript looks like JS, acts like JS, and compiles to the highest quality of clean, readable and performant JS, directly runnable in browsers and Node. - -**This means you can pick up ReScript and access the vast JavaScript ecosystem and tooling as if you've known ReScript for a long time!** - -**ReScript is the language for folks who don't necessarily love JavaScript, but who still acknowledge its importance**. - -## Difference vs TypeScript - -We respect TypeScript very much and think that it's a positive force in the JavaScript ecosystem. ReScript shares some of the same goals as TypeScript, but is different enough regarding some important nuances: - -- TypeScript's (admittedly noble) goal is to cover the entire JavaScript feature set and more. **ReScript covers only a curated subset of JavaScript**. For example, we emphasize plain data + functions over classes, clean [pattern matching](pattern-matching-destructuring.md) over fragile `if`s and virtual dispatches, [proper data modeling](variant.md) over string abuse, etc. JavaScript supersets will only grow larger over time; ReScript doesn't. \* - -- Consequently, TypeScript's type system is necessarily complex, pitfalls-ridden, potentially requires tweaking, sometimes slow, and requires quite a bit of noisy annotations that often feel like manual bookkeeping rather than clear documentation. In contrast, ReScript's type system: - - Is deliberately curated to be a simple subset most folks will have an easier time to use. - - Has **no** pitfalls, aka the type system is "sound" (the types will always be correct). E.g. If a type isn't marked as nullable, its value will never lie and let through some `undefined` value silently. **ReScript code has no null/undefined errors**. - - Is the same for everyone. No knobs, no bikeshedding opportunity. - - Runs extremely fast precisely thanks to its simplicity and curation. It's one of the fastest compiler & build system toolchains for JavaScript development. - - **Doesn't need type annotations**. Annotate as much or as little as you'd like. The types are inferred by the language (and, again, are guaranteed correct). - -- Migrating to TypeScript is done "breadth-first," whereas migrating to ReScript is done "depth-first." You can convert your codebase to TypeScript by "turning it on" for all files and annotate here and there; but how much type safety did you gain? How do you measure it? Type errors can still slip in and out of the converted pieces. For ReScript, our interop features draw clear boundaries: there's pure ReScript code, and there's JS interop code. Every piece of converted ReScript code is 100% clean. You'd convert file by file and each conversion increases your safety monotonically. - -\* When you absolutely need to write or interoperate with free-for-all JavaScript, we expose enough escape hatches for you. - -## Other Highlights - -Aside from the aforementioned simple, robust and fast type system, ReScript presents a few more advantages. - -### Faster than JavaScript - -JavaScript's been aggressively optimized by talented engineers over a long span. Unfortunately, even for seasoned JS devs, it can be hard to know how to properly leverage JS's performance. ReScript's type system and compiler naturally guides you toward writing code that's very often performant by default, with good leverage of various Just-In-Time optimizations (hidden classes, inline caching, avoiding deopts, etc). - -A widespread adage to write fast JavaScript code is to write as if there's a type system (in order to trigger JS engines' good optimization heuristics); ReScript gives you a real one and generates code that's friendly to optimizations by default. - -### High Quality Dead Code Elimination - -The JavaScript ecosystem is very reliant on dependencies. Shipping the final product inevitably drags in a huge amount of code, lots of which the project doesn't actually use. These regions of dead code impact loading, parsing and interpretation speed. ReScript provides powerful dead code elimination at all levels: - -- Function- and module-level code elimination is facilitated by the well-engineered type system and purity analysis. -- At the global level, ReScript generates code that is naturally friendly to dead code elimination done by bundling tools such as [Rollup](https://github.com/rollup/rollup) and [Closure Compiler](https://developers.google.com/closure/compiler/), after its own sophisticated elimination pass. -- The same applies for ReScript's own tiny runtime (which is written in ReScript itself). - -### Tiny JS Output - -A `Hello world` ReScript program generates **20 bytes** of JS code. Additionally, the standard library pieces you require in are only included when needed. - -### Fast Iteration Loop - -ReScript's build time is **one or two orders of magnitude** faster than alternatives. In its watcher mode, the build system usually finishes before you switch screen from the editor to the terminal tab (two digits of milliseconds). A fast iteration cycle reduces the need of keeping one's mental state around longer; this in turn allows one to stay in the flow longer and more often. - -### Readable Output & Great Interop - -Unreadable JavaScript code generated from other compiled-to-js languages makes it so that it could be, practically speaking: - -- Hard to debug (cryptic stack trace, mangled variable names) -- Hard to learn from (non-straightforward mapping of concepts from one language to another) -- Hard to profile for performance (unclear what runtime performance cost there is) -- Hard to integrate with existing hand-written JS code - -ReScript's JS output is very readable. This is especially important while learning, where users might want to understand how the code's compiled, and to audit for bugs. - -This characteristic, combined with a fully-featured JS interop system, allows ReScript code to be inserted into an existing JavaScript codebase almost unnoticed. - -### Preservation of Code Structure - -ReScript maps one source file to one JavaScript output file. This eases the integration of existing tools such as bundlers and test runners. You can even start writing a single file without much change to your build setup. Each file's code structure is approximately preserved, too. - -## Conclusion - -We hope the above gave you enough of an idea of ReScript and its differentiators. Feel free to [try it online](/try) to get a feel! diff --git a/pages/docs/manual/v11.0.0/json.mdx b/pages/docs/manual/v11.0.0/json.mdx deleted file mode 100644 index 3afe1c0eb..000000000 --- a/pages/docs/manual/v11.0.0/json.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "JSON" -description: "Interacting with JSON in ReScript" -canonical: "/docs/manual/v11.0.0/json" ---- - -# JSON - -## Parse - -Bind to JavaScript's `JSON.parse` and type the return value as the type you're expecting: - - - -```res example -// declare the shape of the json you're binding to -type data = {names: array} - -// bind to JS' JSON.parse -@scope("JSON") @val -external parseIntoMyData: string => data = "parse" - -let result = parseIntoMyData(`{"names": ["Luke", "Christine"]}`) -let name1 = result.names[0] -``` - -```js -var result = JSON.parse('{"names": ["Luke", "Christine"]}'); -var name1 = result.names[0]; -``` - - - -Where `data` can be any type you assume the JSON is. As you can see, this compiles to a straightforward `JSON.parse` call. As with regular JS, this is convenient, but has no guarantee that e.g. the data is correctly shaped, or even syntactically valid. Slightly dangerous. - -## Stringify - -Use [`JSON.stringify`](api/core/json#value-stringify) if your data is of type `JSON.t` or [`JSON.stringifyAny`](api/core/json#value-stringifyAny) if it is not. - - - -```res example -Console.log(JSON.stringifyAny(["Amy", "Joe"])) -``` - -```js -console.log(JSON.stringify(["Amy", "Joe"])); -``` - - - -## Import a JSON file - -Use the `@module` attribute to import JSON files directly. - - - -```res example -@module external studentNames: JSON.t = "./students.json" -Console.log(studentNames) -``` - -```js -import * as StudentsJson from "./students.json"; - -var studentNames = StudentsJson; - -console.log(studentNames); -``` - -```js -var StudentsJson = require("./students.json"); - -var studentNames = StudentsJson; - -console.log(studentNames); -``` - - - -## Advanced - -Thanks to untagged variants, JSON can be encoded and decoded idiomatically. Check it out on [the variants page](variant#decoding-and-encoding-json-idiomatically). diff --git a/pages/docs/manual/v11.0.0/jsx.mdx b/pages/docs/manual/v11.0.0/jsx.mdx deleted file mode 100644 index ff39ed805..000000000 --- a/pages/docs/manual/v11.0.0/jsx.mdx +++ /dev/null @@ -1,437 +0,0 @@ ---- -title: "JSX" -description: "JSX syntax in ReScript and React" -canonical: "/docs/manual/v11.0.0/jsx" ---- - -# JSX - -Would you like some HTML syntax in your ReScript? If not, quickly skip over this section and pretend you didn't see anything! - -ReScript supports the JSX syntax, with some slight differences compared to the one in [ReactJS](https://facebook.github.io/react/docs/introducing-jsx.html). ReScript JSX isn't tied to ReactJS; they translate to normal function calls: - -**Note** for [ReScriptReact](https://rescript-lang.org/docs/react/latest/introduction) readers: this isn't what ReScriptReact turns JSX into, in the end. See Usage section for more info. - -## Capitalized - - - -```res - -``` - -```js -React.createElement(MyComponent, { - name: "ReScript", -}); -``` - - - -becomes - - - -```res -MyComponent.createElement(~name="ReScript", ~children=list{}, ()) -``` - -```js -React.createElement(MyComponent, { - name: "ReScript", -}); -``` - - - -## Uncapitalized - - - -```res -
child1 child2
-``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - -
- -becomes - - - -```res -div(~onClick=handler, ~children=list{child1, child2}, ()) -``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - - - -## Fragment - - - -```res -<> child1 child2 -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -becomes - - - -```res -list{child1, child2} -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -### Children - - - -```res - child1 child2 -``` - -```js -React.createElement(MyComponent, { children: null }, child1, child2); -``` - - - -This is the syntax for passing a list of two items, `child1` and `child2`, to the children position. It transforms to a list containing `child1` and `child2`: - - - -```res -MyComponent.createElement(~children=list{child1, child2}, ()) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(null, undefined), - child1, - child2, -); -``` - - - -**Note** again that this isn't the transform for ReScriptReact; ReScriptReact turns the final list into an array. But the idea still applies. - -So naturally, ` myChild ` is transformed to `MyComponent.createElement(~children=list{myChild}, ())`. I.e. whatever you do, the arguments passed to the children position will be wrapped in a list. - -## Usage - -See [ReScriptReact Elements & JSX](https://rescript-lang.org/docs/react/latest/elements-and-jsx) for an example application of JSX, which transforms the above calls into a ReScriptReact-specific call. - -Here's a JSX tag that shows most of the features. - - - -```res - -
{React.string("hello")}
-
-``` - -```js -React.createElement(MyComponent, { - children: React.createElement("div", undefined, "hello"), - booleanAttribute: true, - stringAttribute: "string", - intAttribute: 1, - forcedOptional: "hello", - onClick: handleClick, -}); -``` - -
- -## Departures From JS JSX - -- Attributes and children don't mandate `{}`, but we show them anyway for ease of learning. Once you format your file, some of them go away and some turn into parentheses. -- Props spread is supported, but there are some restrictions (see below). -- Punning! -- Props and tag names have to follow ReScript's restrictions on identifiers at the exception of hyphens for lowercase tags ([see below](#hyphens-in-tag-names)). - -### Spread Props - -**Since 10.1** - -JSX props spread is supported now, but in a stricter way than in JS. - - - -```res - -``` - -```js -React.createElement(Comp, { - a: "a", - b: "b", -}); -``` - - - -Multiple spreads are not allowed: - - - -```res - -``` - - - -The spread must be at the first position, followed by other props: - - - -```res - -``` - - - -### Punning - -"Punning" refers to the syntax shorthand for when a label and a value are the same. For example, in JavaScript, instead of doing `return {name: name}`, you can do `return {name}`. - -JSX supports punning. `` is just a shorthand for ``. The formatter will help you format to the punned syntax whenever possible. This is convenient in the cases where there are lots of props to pass down: - - - -```res - -``` - -```js -React.createElement(MyComponent, { - isLoading: true, - text: text, - onClick: onClick, -}); -``` - - - -Consequently, a JSX component can cram in a few more props before reaching for extra libraries solutions that avoids props passing. - -**Note** that this is a departure from ReactJS JSX, which does **not** have punning. ReactJS' `` desugars to ``, in order to conform to DOM's idioms and for backward compatibility. - -### Hyphens in tag names - -**Since 11.1** - -JSX now supports lowercase tags with hyphens in their name. This allows to bind -to web components. - -Note though that props names can't have hyphens, you should use `@as` to bind to -such props in your custom `JsxDOM.domProps` type ([see generic JSX transform](#generic-jsx-transform-jsx-beyond-react-experimental)). - - - -```res - -``` - -```js -React.createElement("model-viewer", { - "touch-actions": "pan-y", - src: src, -}); -``` - - - -## Generic JSX transform: JSX beyond React (experimental) - -**Since 11.1** - -While ReScript comes with first class support for JSX in React, it's also possible to have ReScript delegate JSX to other frameworks. You do that by configuring a _generic JSX transform_. - -This is what you need to do to use a generic JSX transform: - -1. Make sure you have a ReScript module that [implements the functions and types necessary for the JSX transform](#implementing-a-generic-jsx-transform-module). -2. Configure `rescript.json` to delegated JSX to that module. - -That's it really. We'll expand on each point below. - -### Configuration - -You configure a generic JSX transform by putting any module name in the `module` config of JSX in `rescript.json`. This can be _any valid module name_. Example part from `rescript.json`: - -```json -"jsx": { - "module": "Preact" - }, -``` - -This will now put the `Preact` module in control of the generated JSX calls. The `Preact` module can be defined by anyone - locally in your project, or by a package. As long a it's available in the global scope. The JSX transform will delegate any JSX related code to `Preact`. - -#### What about `@react.component` for components? - -`@react.component` will still be available, and so is a generic `@jsx.component` notation. Both work the same way. - -### Usage Example - -Here's a quick usage example (the actual definition of `Preact.res` comes below): - -First, configure `rescript.json`: - -```json -"jsx": { - "module": "Preact" - }, -``` - -Now you can build Preact components: - -```rescript -// Name.res -@jsx.component // or @react.component if you want -let make = (~name) => Preact.string(`Hello ${name}!`) -``` - -And you can use them just like normal with JSX: - -```rescript -let name = -``` - -#### File level configuration - -You can configure what JSX transform is used at the file level via `@@jsxConfig`, just like before. Like: - -```rescript -@@jsxConfig({module_: "Preact"}) -``` - -This can be convenient if you're mixing different JSX frameworks in the same project. - -### Implementing a generic JSX transform module - -Below is a full list of everything you need in a generic JSX transform module, including code comments to clarify. It's an example implementation of a `Preact` transform, so when doing this for other frameworks you'd of course adapt what you import from, and so on. - -> You can easily copy-paste-and-adapt this to your needs if you're creating bindings to a JSX framework. Most often, all you'll need to change is what the `@module("") external` points to, so the runtime calls point to the correct JS module. - - - -```rescript -// Preact.res -/* Below is a number of aliases to the common `Jsx` module */ -type element = Jsx.element - -type component<'props> = Jsx.component<'props> - -type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> - -@module("preact/jsx-runtime") -external jsx: (component<'props>, 'props) => element = "jsx" - -@module("preact/jsx-runtime") -external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsx" - -@module("preact/jsx-runtime") -external jsxs: (component<'props>, 'props) => element = "jsxs" - -@module("preact/jsx-runtime") -external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs" - -/* These identity functions and static values below are optional, but lets -you move things easily to the `element` type. The only required thing to -define though is `array`, which the JSX transform will output. */ -external array: array => element = "%identity" -@val external null: element = "null" - -external float: float => element = "%identity" -external int: int => element = "%identity" -external string: string => element = "%identity" -external promise: promise => element = "%identity" - -/* These are needed for Fragment (<> ) support */ -type fragmentProps = {children?: element} - -@module("preact/jsx-runtime") external jsxFragment: component = "Fragment" - -/* The Elements module is the equivalent to the ReactDOM module in Preact. This holds things relevant to _lowercase_ JSX elements. */ -module Elements = { - /* Here you can control what props lowercase JSX elements should have. - A base that the React JSX transform uses is provided via JsxDOM.domProps, - but you can make this anything. The editor tooling will support - autocompletion etc for your specific type. */ - type props = JsxDOM.domProps - - @module("preact/jsx-runtime") - external jsx: (string, props) => Jsx.element = "jsx" - - @module("preact/jsx-runtime") - external div: (string, props) => Jsx.element = "jsx" - - @module("preact/jsx-runtime") - external jsxKeyed: (string, props, ~key: string=?, @ignore unit) => Jsx.element = "jsx" - - @module("preact/jsx-runtime") - external jsxs: (string, props) => Jsx.element = "jsxs" - - @module("preact/jsx-runtime") - external jsxsKeyed: (string, props, ~key: string=?, @ignore unit) => Jsx.element = "jsxs" - - external someElement: element => option = "%identity" -} -``` - - - -As you can see, most of the things you'll want to implement will be copy paste from the above. But do note that **everything needs to be there unless explicitly noted** or the transform will fail at compile time. - -To enable this, you need to configure the `jsx` `module` in your `rescript.json`: - -```json -{ - "jsx": { - "version": 4, - "module": "Preact" - } -} -``` - -_value "Preact" is the name of the module that implements the generic JSX transform._ diff --git a/pages/docs/manual/v11.0.0/lazy-values.mdx b/pages/docs/manual/v11.0.0/lazy-values.mdx deleted file mode 100644 index 3c40a5d13..000000000 --- a/pages/docs/manual/v11.0.0/lazy-values.mdx +++ /dev/null @@ -1,131 +0,0 @@ ---- -title: "Lazy Value" -description: "Data type for deferred computation in ReScript" -canonical: "/docs/manual/v11.0.0/lazy-values" ---- - -# Lazy Value - -If you have some expensive computations you'd like to **defer and cache** subsequently, you can wrap it with `lazy`: - - - -```res prelude -@module("node:fs") -external readdirSync: string => array = "readdirSync" - -// Read the directory, only once -let expensiveFilesRead = lazy({ - Console.log("Reading dir") - readdirSync("./pages") -}) -``` - -```js -var Fs = require("fs"); - -var expensiveFilesRead = { - LAZY_DONE: false, - VAL: function () { - console.log("Reading dir"); - return Fs.readdirSync("./pages"); - }, -}; -``` - - - -Check the JS Output tab: that `expensiveFilesRead`'s code isn't executed yet, even though you declared it! You can carry it around without fearing that it'll run the directory read. - -**Note**: a lazy value is **not** a [shared data type](shared-data-types.md). Don't rely on its runtime representation in your JavaScript code. - -## Execute The Lazy Computation - -To actually run the lazy value's computation, use `Lazy.force` from the globally available `Lazy` module: - - - -```res example -// First call. The computation happens -Console.log(Lazy.force(expensiveFilesRead)) // logs "Reading dir" and the directory content - -// Second call. Will just return the already calculated result -Console.log(Lazy.force(expensiveFilesRead)) // logs the directory content -``` - -```js -console.log(CamlinternalLazy.force(expensiveFilesRead)); - -console.log(CamlinternalLazy.force(expensiveFilesRead)); -``` - - - -The first time `Lazy.force` is called, the expensive computation happens and the result is **cached**. The second time, the cached value is directly used. - -**You can't re-trigger the computation after the first `force` call**. Make sure you only use a lazy value with computations whose results don't change (e.g. an expensive server request whose response is always the same). - -Instead of using `Lazy.force`, you can also use [pattern matching](pattern-matching-destructuring.md) to trigger the computation: - - - -```res example -switch expensiveFilesRead { -| lazy(result) => Console.log(result) -} -``` - -```js -var result = CamlinternalLazy.force(expensiveFilesRead); -``` - - - -Since pattern matching also works on a `let` binding, you can also do: - - - -```res example -let lazy(result) = expensiveFilesRead -Console.log(result) -``` - -```js -var result = CamlinternalLazy.force(expensiveFilesRead); -console.log(result); -``` - - - -## Exception Handling - -For completeness' sake, our files read example might raise an exception because of `readdirSync`. Here's how you'd handle it: - - - -```res example -let result = try { - Lazy.force(expensiveFilesRead) -} catch { -| Not_found => [] // empty array of files -} -``` - -```js -var result; - -try { - result = CamlinternalLazy.force(expensiveFilesRead); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - result = []; - } else { - throw exn; - } -} -``` - - - -Though you should probably handle the exception inside the lazy computation itself. diff --git a/pages/docs/manual/v11.0.0/let-binding.mdx b/pages/docs/manual/v11.0.0/let-binding.mdx deleted file mode 100644 index 06081494a..000000000 --- a/pages/docs/manual/v11.0.0/let-binding.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -title: "Let Binding" -description: "Let binding syntax for binding to values in ReScript" -canonical: "/docs/manual/v11.0.0/let-binding" ---- - -# Let Binding - -A "let binding", in other languages, might be called a "variable declaration". `let` _binds_ values to names. They can be seen and referenced by code that comes _after_ them. - - - -```res example -let greeting = "hello!" -let score = 10 -let newScore = 10 + score -``` - -```js -var greeting = "hello!"; -var score = 10; -var newScore = 20; -``` - - - -## Block Scope - -Bindings can be scoped through `{}`. - - - -```res example -let message = { - let part1 = "hello" - let part2 = "world" - part1 ++ " " ++ part2 -} -// `part1` and `part2` not accessible here! -``` - -```js -var message = "hello world"; -``` - - - -The value of the last line of a scope is implicitly returned. - -### Design Decisions - -ReScript's `if`, `while` and functions all use the same block scoping mechanism. The code below works **not** because of some special "if scope"; but simply because it's the same scope syntax and feature you just saw: - - - -```res -if displayGreeting { - let message = "Enjoying the docs so far?" - Console.log(message) -} -// `message` not accessible here! -``` - -```js -if (displayGreeting) { - console.log("Enjoying the docs so far?"); -} -``` - - - -## Bindings Are Immutable - -Let bindings are "immutable", aka "cannot change". This helps our type system deduce and optimize much more than other languages (and in turn, help you more). - -## Binding Shadowing - -The above restriction might sound unpractical at first. How would you change a value then? Usually, 2 ways: - -The first is to realize that many times, what you want isn't to mutate a variable's value. For example, this JavaScript pattern: - -```js -var result = 0; -result = calculate(result); -result = calculateSomeMore(result); -``` - -...is really just to comment on intermediate steps. You didn't need to mutate `result` at all! You could have just written this JS: - -```js -var result1 = 0; -var result2 = calculate(result1); -var result3 = calculateSomeMore(result2); -``` - -In ReScript, this obviously works too: - - - -```res -let result1 = 0 -let result2 = calculate(result1) -let result3 = calculateSomeMore(result2) -``` - -```js -var result1 = 0; -var result2 = calculate(0); -var result3 = calculateSomeMore(result2); -``` - - - -Additionally, reusing the same let binding name overshadows the previous bindings with the same name. So you can write this too: - - - -```res -let result = 0 -let result = calculate(result) -let result = calculateSomeMore(result) -``` - -```js -var result = calculate(0); -var result$1 = calculateSomeMore(result); -``` - - - -(Though for the sake of clarity, we don't recommend this). - -As a matter of fact, even this is valid code: - - - -```res example -let result = "hello" -Console.log(result) // prints "hello" -let result = 1 -Console.log(result) // prints 1 -``` - -```js -var result = 1; -console.log("hello"); -console.log(1); -``` - - - -The binding you refer to is whatever's the closest upward. No mutation here! -If you need _real_ mutation, e.g. passing a value around, have it modified by many pieces of code, we provide a slightly heavier [mutation feature](mutation.md). - -## Private let bindings - -Private let bindings are introduced in the release [7.2](https://rescript-lang.org/blog/bucklescript-release-7-2). - -In the module system, everything is public by default, -the only way to hide some values is by providing a separate signature to -list public fields and their types: - -```res -module A: { - let b: int -} = { - let a = 3 - let b = 4 -} -``` - -`%%private` gives you an option to mark private fields directly - -```res -module A = { - %%private(let a = 3) - let b = 4 -} -``` - -`%%private` also applies to file level modules, so in some cases, -users do not need to provide a separate interface file just to hide some particular values. - -Note interface files are still recommended as a general best practice since they give you better -separate compilation units and also they're better for documentation. - -Still, `%%private` is useful in the following scenarios: - -- **Code generators.** Some code generators want to hide some values but it is sometimes very hard or time consuming for code generators to synthesize the types for public fields. - -- **Quick prototyping.** During prototyping, we still want to hide some values, but the interface file is not stable yet. `%%private` provides you such convenience. diff --git a/pages/docs/manual/v11.0.0/libraries.mdx b/pages/docs/manual/v11.0.0/libraries.mdx deleted file mode 100644 index df230de26..000000000 --- a/pages/docs/manual/v11.0.0/libraries.mdx +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: "Libraries & Publishing" -description: "Install & publish ReScript packages" -canonical: "/docs/manual/v11.0.0/libraries" ---- - -# Libraries & Publishing - -ReScript libraries are just like JavaScript libraries: published & hosted on [NPM](http://npmjs.com). You can reuse your `npm`, `yarn` and `package.json`-related tools to manage them! - -## Tips & Tricks - -### Publish - -We recommend you to check in your compiled JavaScript output, for its [various benefits](interop-with-js-build-systems.md#popular-js-build-systems). If not, then at least consider publishing the JavaScript output by un-ignoring them in your [npmignore](https://docs.npmjs.com/cli/v7/using-npm/developers#keeping-files-out-of-your-package). This way, your published ReScript package comes with plain JavaScript files that JS users can consume. If your project's good, JS users might not even realize that they've installed a library written in ReScript! - -In case your library is only consumed by JS users, you may want to check out our [external stdlib](./build-external-stdlib) configuration as well. - -### Find Libraries - -Search `rescript`-related packages on NPM, or use our [Package Index](/packages). - -If you can't find what you're looking for, remember that **you don't need a wrapper** to use a JS library: - -- Most JS data types, such as array and objects, [map over cleanly to ReScript and vice-versa](shared-data-types.md). -- You also have access to the familiar [Core API](api/core). -- You can use a JavaScript library without needing to install dedicated binding libraries. Check the [`external`](external) page. diff --git a/pages/docs/manual/v11.0.0/migrate-to-v11.mdx b/pages/docs/manual/v11.0.0/migrate-to-v11.mdx deleted file mode 100644 index fbdf3bcb9..000000000 --- a/pages/docs/manual/v11.0.0/migrate-to-v11.mdx +++ /dev/null @@ -1,131 +0,0 @@ ---- -title: "Migrate to v11" -description: "Instructions on upgrading to ReScript 11" -canonical: "/docs/manual/v11.0.0/migrate-to-v11" ---- - -# Migrate to ReScript 11 - -## Foreword - -The ReScript community is proud to introduce ReScript V11 which comes with a ton of new features but also removes a lot of bulk. -A migration to it can be very straightforward, but it can also take some time, depending on your code style or what dependencies you use. - -Please have a look at the full [set of breaking changes](#list-of-all-breaking-changes) below to be able to decide whether this is a task you want to undertake. There is also the possibilty to [opt-out of uncurried mode](#minimal-migration) for now, which is probably the most fundamental change of this release. That and other new and notable features are discussed in the following blogposts: - -- [Better interop with customizable variants](/blog/improving-interop) -- [Enhanced Ergonomics for Record Types](/blog/enhanced-ergonomics-for-record-types) -- [First-class Dynamic Import Support](/blog/first-class-dynamic-import-support) -- [Uncurried Mode](/blog/uncurried-mode) - -## Recommended Migration - -### Uncurried Mode - -For uncurried mode to take effect in ReScript 11 there is nothing to configure, it is activated by default. - -### Adapt suffix - -ReScript 11 now allows having arbitrary suffixes in the generated JavaScript files. However, it is still recommended to stick to using `.res.js`, `.res.mjs` or `.res.cjs`. For more information, read the Build System Configuration about [suffixes](/docs/manual/latest/build-configuration#suffix). - -### rescript.json - -The old configuration filename `bsconfig.json` is deprecated. Rename `bsconfig.json` to `rescript.json` to get rid of the deprecation warning. - -### ReScript Core standard library - -[ReScript Core](https://github.com/rescript-lang/rescript-core) is ReScript's new standard library. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is recommended to use with uncurried mode. - -It will be integrated into the compiler in a future version. In ReScript 11, it still needs to be installed manually: - -```console -$ npm install @rescript/core -``` - -Then add `@rescript/core` to your `rescript.json`'s dependencies: - -```diff - { - "bs-dependencies": [ -+ "@rescript/core" - ] - } -``` - -Open it so it's available in the global scope. - -```diff - { - "bsc-flags": [ -+ "-open RescriptCore", - ] - } -``` - -One major change to be aware of is that array access now returns an `option`. - -```res -let firstItem = myArray[0] // Some("hello") -``` - -If you would like to not use an `option`, you can use [`Array.getUnsafe`](api/core/array#value-getUnsafe). - -For a detailed explanation on migration to ReScript Core, please refer to its [migration guide](https://github.com/rescript-lang/rescript-core#migration). A semi-automated script is available as well. - -See ReScript Core API docs [here](api/core). - -### Removed bindings - -Many Node bindings have been removed from the compiler. Please use [rescript-nodejs](https://github.com/TheSpyder/rescript-nodejs) instead or write your own local bindings. - -## Minimal Migration - -This guide describes the things to do at least to migrate to ReScript 11. - -### Disable uncurried mode - -If you use currying extensively and don't want to bother with adapting your code, or have dependencies that just don't work with uncurried mode yet, just set it to false in your `rescript.json`. - -```json -{ - "uncurried": false -} -``` - -For more information, read the Build System Configuration about [uncurried](/docs/manual/latest/build-configuration#uncurried). - -## List of all breaking changes - -Below is an excerpt from the compiler changelog about all the breaking changes of ReScript 11. - -### Language and Compiler - -- Add smart printer for pipe chains. https://github.com/rescript-lang/rescript/pull/6411 (the formatter will reformat existing code in certain cases) -- Parse `assert` as a regular function. `assert` is no longer a unary expression. Example: before `assert 1 == 2` is parsed as `(assert 1) == 2`, now it is parsed as `assert(1 == 2)`. https://github.com/rescript-lang/rescript/pull/6180 -- Remove support for the legacy Reason syntax. Existing Reason code can be converted to ReScript syntax using ReScript 9 as follows: - - `npx rescript@9 convert ` -- Curried after uncurried is not fused anymore: `(. x) => y => 3` is not equivalent to `(. x, y) => 3` anymore. It's instead equivalent to `(. x) => { y => 3 }`. - Also, `(. int) => string => bool` is not equivalen to `(. int, string) => bool` anymore. - These are only breaking changes for unformatted code. -- Exponentiation operator `**` is now right-associative. `2. ** 3. ** 2.` now compile to `Math.pow(2, Math.pow(3, 2))` and not anymore `Math.pow(Math.pow(2, 3), 2)`. Parentheses can be used to change precedence. -- Stop mangling object field names. If you had objects with field names containing "\_\_" or leading "\_", they won't be mangled in the compiled JavaScript and represented as it is without changes. https://github.com/rescript-lang/rescript/pull/6354 -- `$$default` is no longer exported from the generated JavaScript when using default exports. https://github.com/rescript-lang/rescript/pull/6328 -- `-bs-super-errors` flag has been deprecated along with Super_errors. https://github.com/rescript-lang/rescript/pull/6243 -- Remove unsafe `` j`$(a)$(b)` `` interpolation deprecated in compiler version 10 https://github.com/rescript-lang/rescript/pull/6068 -- `@deriving(jsConverter)` not supported anymore for variant types https://github.com/rescript-lang/rescript/pull/6088 -- New representation for variants, where the tag is a string instead of a number. https://github.com/rescript-lang/rescript/pull/6088 - -### Compiler Libraries - -- Fixed name collision between the newly defined Js.Json.t and the variant constructor in the existing Js.Json.kind type. To address this, the usage of the existing Js.Json.kind type can be updated to Js.Json.Kind.t. https://github.com/rescript-lang/rescript/pull/6317 -- Remove rudimentary node bindings and undocumented `%node` extension. https://github.com/rescript-lang/rescript/pull/6285 -- `@rescript/react` >= 0.12.0-alpha.2 is now required because of the React.fragment's children type fix. https://github.com/rescript-lang/rescript/pull/6238 -- Remove deprecated module `Printexc` - -### Build System and Tools - -- Update watcher rules to recompile only on config and `*.res`/`*.resi`/`*.ml`/`.mli` file changes. Solves the issue of unnecessary recompiles on `.css`, `.ts`, and other unrelated file changes. https://github.com/rescript-lang/rescript/pull/6420 -- Made pinned dependencies transitive: if _a_ is a pinned dependency of _b_ and _b_ is a pinned dependency of _c_, then _a_ is implicitly a pinned dependency of _c_. This change is only breaking if your build process assumes non-transitivity. -- Remove obsolete built-in project templates and the "rescript init" functionality. This is replaced by [create-rescript-app](https://github.com/rescript-lang/create-rescript-app) which is maintained separately. -- Do not attempt to build ReScript from source on npm postinstall for platforms without prebuilt binaries anymore. -- GenType: removed support for `@genType.as` for records and variants which has become unnecessary. Use the language's `@as` instead to channge the runtime representation without requiring any runtime conversion during FFI. https://github.com/rescript-lang/rescript/pull/6099 https://github.com/rescript-lang/rescript/pull/6101 diff --git a/pages/docs/manual/v11.0.0/module-functions.mdx b/pages/docs/manual/v11.0.0/module-functions.mdx deleted file mode 100644 index da14f9b75..000000000 --- a/pages/docs/manual/v11.0.0/module-functions.mdx +++ /dev/null @@ -1,336 +0,0 @@ ---- -title: "Module Functions" -description: "Module Functions in ReScript" -canonical: "/docs/manual/v11.0.0/module-functions" ---- - -# Module Functions - -Module functions can be used to create modules based on types, values, or functions from other modules. -This is a powerful tool that can be used to create abstractions and reusable code that might not be possible with functions, or might have a runtime cost if done with functions. - -This is an advanced part of ReScript and you can generally get by with normal values and functions. - -## Quick example - -Next.js has a `useParams` hook that returns an unknown type, -and it's up to the developer in TypeScript to add a type annotation for the parameters returned by the hook. - -```TS -const params = useParams<{ tag: string; item: string }>() -``` - -In ReScript we can create a module function that will return a typed response for the `useParams` hook. - - -```res example -module Next = { - // define our module function - module MakeParams = (Params: { type t }) => { - @module("next/navigation") - external useParams: unit => Params.t = "useParams" - /* You can use values from the function parameter, such as Params.t */ - } -} - -module Component: { -@react.component -let make: unit => Jsx.element -} = { -// Create a module that matches the module type expected by Next.MakeParams -module P = { -type t = { -tag: string, -item: string, -} -} - -// Create a new module using the Params module we created and the Next.MakeParams module function -module Params = Next.MakeParams(P) - -@react.component -let make = () => { -// Use the functions, values, or types created by the module function -let params = Params.useParams() - -
-

-{React.string("Tag: " ++ params.tag /_ params is fully typed! _/)} -

-

{React.string("Item: " ++ params.item)}

-
-} -} - -```` -```js -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as $$Navigation from "next/navigation"; -import * as JsxRuntime from "react/jsx-runtime"; - -function MakeParams(Params) { - return {}; -} - -var Next = { - MakeParams: MakeParams -}; - -function Playground$Component(props) { - var params = $$Navigation.useParams(); - return JsxRuntime.jsxs("div", { - children: [ - JsxRuntime.jsx("p", { - children: "Tag: " + params.tag - }), - JsxRuntime.jsx("p", { - children: "Item: " + params.item - }) - ] - }); -} - -var Component = { - make: Playground$Component -}; - -export { - Next , - Component , -} -/* next/navigation Not a pure module */ - -```` - - - -## Sharing a type with an external binding - -This becomes incredibly useful when you need to have types that are unique to a project but shared across multiple components. -Let's say you want to create a library with a `getEnv` function to load in environment variables found in `import.meta.env`. - -```res -@val external env: 'a = "import.meta.env" - -let getEnv = () => { - env -} -``` - -It's not possible to define types for this that will work for every project, so we just set it as 'a and the consumer of our library can define the return type. - -```res -type t = {"LOG_LEVEL": string} - -let values: t = getEnv() -``` - -This isn't great and it doesn't take advantage of ReScript's type system and ability to use types without type definitions, and it can't be easily shared across our application. - -We can instead create a module function that can return a module that has contains a `getEnv` function that has a typed response. - -```res -module MakeEnv = ( - E: { - type t - }, -) => { - @val external env: E.t = "import.meta.env" - - let getEnv = () => { - env - } -} -``` - -And now consumers of our library can define the types and create a custom version of the hook for their application. -Notice that in the JavaScript output that the `import.meta.env` is used directly and doesn't require any function calls or runtime overhead. - - -```res -module Env = MakeEnv({ - type t = {"LOG_LEVEL": string} -}) - -let values = Env.getEnv() - -```` -```js -var Env = { - getEnv: getEnv -}; - -var values = import.meta.env; -```` - - - -## Shared functions - -You might want to share functions across modules, like a way to log a value or render it in React. -Here's an example of module function that takes in a type and a transform to string function. - -```res -module MakeDataModule = ( - T: { - type t - let toString: t => string - }, -) => { - type t = T.t - let log = a => Console.log("The value is " ++ T.toString(a)) - - module Render = { - @react.component - let make = (~value) => value->T.toString->React.string - } -} -``` - -You can now take a module with a type of `t` and a `toString` function and create a new module that has the `log` function and the `Render` component. - - -```res -module Person = { - type t = { firstName: string, lastName: string } - let toString = person => person.firstName ++ person.lastName -} - -module PersonData = MakeDataModule(Person) - -```` - -```js -// Notice that none of the JS output references the MakeDataModule function - -function toString(person) { - return person.firstName + person.lastName; -} - -var Person = { - toString: toString -}; - -function log(a) { - console.log("The value is " + toString(a)); -} - -function Person$MakeDataModule$Render(props) { - return toString(props.value); -} - -var Render = { - make: Person$MakeDataModule$Render -}; - -var PersonData = { - log: log, - Render: Render -}; -```` - - - -Now the `PersonData` module has the functions from the `MakeDataModule`. - - -```res -@react.component -let make = (~person) => { - let handleClick = _ => PersonData.log(person) -
- {React.string("Hello ")} - - -
-} -``` -```js -function Person$1(props) { - var person = props.person; - var handleClick = function (param) { - log(person); - }; - return JsxRuntime.jsxs("div", { - children: [ - "Hello ", - JsxRuntime.jsx(Person$MakeDataModule$Render, { - value: person - }), - JsxRuntime.jsx("button", { - children: "Log value to console", - onClick: handleClick - }) - ] - }); -} -``` -
- -## Dependency injection - -Module functions can be used for dependency injection. -Here's an example of injecting in some config values into a set of functions to access a database. - - -```res -module type DbConfig = { - let host: string - let database: string - let username: string - let password: string -} - -module MakeDbConnection = (Config: DbConfig) => { -type client = { -write: string => unit, -read: string => string, -} -@module("database.js") -external makeClient: (string, string, string, string) => client = "makeClient" - -let client = makeClient(Config.host, Config.database, Config.username, Config.password) -} - -module Db = MakeDbConnection({ -let host = "localhost" -let database = "mydb" -let username = "root" -let password = "password" -}) - -let updateDb = Db.client.write("new value") - -```` -```js -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as DatabaseJs from "database.js"; - -function MakeDbConnection(Config) { - var client = DatabaseJs.makeClient(Config.host, Config.database, Config.username, Config.password); - return { - client: client - }; -} - -var client = DatabaseJs.makeClient("localhost", "mydb", "root", "password"); - -var Db = { - client: client -}; - -var updateDb = client.write("new value"); - -export { - MakeDbConnection , - Db , - updateDb , -} -/* client Not a pure module */ -```` - - diff --git a/pages/docs/manual/v11.0.0/module.mdx b/pages/docs/manual/v11.0.0/module.mdx deleted file mode 100644 index 593980ef7..000000000 --- a/pages/docs/manual/v11.0.0/module.mdx +++ /dev/null @@ -1,584 +0,0 @@ ---- -title: "Module" -description: "ReScript modules, module signatures and interface files" -canonical: "/docs/manual/v11.0.0/module" ---- - -# Module - -## Basics - -**Modules are like mini files**! They can contain type definitions, `let` -bindings, nested modules, etc. - -### Creation - -To create a module, use the `module` keyword. The module name must start with a -**capital letter**. Whatever you could place in a `.res` file, you may place -inside a module definition's `{}` block. - - - -```res example -module School = { - type profession = Teacher | Director - - let person1 = Teacher - let getProfession = (person) => - switch person { - | Teacher => "A teacher" - | Director => "A director" - } -} -``` - -```js -function getProfession(person) { - if (person) { - return "A director"; - } else { - return "A teacher"; - } -} - -var School = { - person1: /* Teacher */ 0, - getProfession: getProfession, -}; -``` - - - -A module's contents (including types!) can be accessed much like a record's, -using the `.` notation. This demonstrates modules' utility for namespacing. - - - -```res -let anotherPerson: School.profession = School.Teacher -Console.log(School.getProfession(anotherPerson)) /* "A teacher" */ -``` - -```js -var anotherPerson = /* Teacher */ 0; -console.log("A teacher"); -``` - - - -Nested modules work too. - - - -```res example -module MyModule = { - module NestedModule = { - let message = "hello" - } -} - -let message = MyModule.NestedModule.message -``` - -```js -var NestedModule = { - message: message, -}; - -var MyModule = { - NestedModule: NestedModule, -}; - -var message = MyModule.NestedModule.message; -``` - - - -### `open`ing a module - -Constantly referring to a value/type in a module can be tedious. Instead, we can "open" a module and refer to its contents without always prepending them with the -module's name. Instead of writing: - - - -```res -let p = School.getProfession(School.person1) -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -We can write: - - - -```res -open School -let p = getProfession(person1) -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -The content of `School` module are made visible (**not** copied into the file, but simply made visible!) in scope. `profession`, `getProfession` and `person1` will thus correctly be found. - -**Use `open` this sparingly, it's convenient, but makes it hard to know where some values come from**. You should usually use `open` in a local scope: - - - -```res -let p = { - open School - getProfession(person1) -} -/* School's content isn't visible here anymore */ -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -### Use `open!` to ignore shadow warnings - -There are situations where `open` will cause a warning due to existing identifiers (bindings, types) being redefined. Use `open!` to explicitly tell the compiler that this is desired behavior. - -```res -let map = (arr, value) => { - value -} - -// opening Array would shadow our previously defined `map` -// `open!` will explicitly turn off the automatic warning -open! Array -let arr = map([1,2,3], (a) => { a + 1}) -``` - -**Note:** Same as with `open`, don't overuse `open!` statements if not necessary. Use (sub)modules to prevent shadowing issues. - -### Destructuring modules - -**Since 9.0.2** - -As an alternative to `open`ing a module, you can also destructure a module's functions and values into separate let bindings (similarly on how we'd destructure an object in JavaScript). - - - -```res -module User = { - let user1 = "Anna" - let user2 = "Franz" -} - -// Destructure by name -let {user1, user2} = module(User) - -// Destructure with different alias -let {user1: anna, user2: franz} = module(User) -``` - -```js -var user1 = "Anna"; - -var user2 = "Franz"; - -var User = { - user1: user1, - user2: user2, -}; -``` - - - -**Note:** You can't extract types with module destructuring — use a type alias instead (`type user = User.myUserType`). - -### Extending modules - -Using `include` in a module statically "spreads" a module's content into a new one, thus often fulfill the role of "inheritance" or "mixin". - -**Note**: this is equivalent to a compiler-level copy paste. **We heavily discourage `include`**. Use it as last resort! - - - -```res example -module BaseComponent = { - let defaultGreeting = "Hello" - let getAudience = (~excited) => excited ? "world!" : "world" -} - -module ActualComponent = { - /* the content is copied over */ - include BaseComponent - /* overrides BaseComponent.defaultGreeting */ - let defaultGreeting = "Hey" - let render = () => defaultGreeting ++ " " ++ getAudience(~excited=true) -} -``` - -```js -function getAudience(excited) { - if (excited) { - return "world!"; - } else { - return "world"; - } -} - -var BaseComponent = { - defaultGreeting: "Hello", - getAudience: getAudience, -}; - -var defaultGreeting = "Hey"; - -function render(param) { - return "Hey world!"; -} - -var ActualComponent = { - getAudience: getAudience, - defaultGreeting: defaultGreeting, - render: render, -}; -``` - - - -**Note**: `open` and `include` are very different! The former brings a module's content into your current scope, so that you don't have to refer to a value by prefixing it with the module's name every time. The latter **copies over** the definition of a module statically, then also do an `open`. - -### Every `.res` file is a module - -Every ReScript file is itself compiled to a module of the same name as the file name, capitalized. The file `React.res` implicitly forms a module `React`, which can be seen by other source files. - -**Note**: ReScript file names should, by convention, be capitalized so that their casing matches their module name. Uncapitalized file names are not invalid, but will be implicitly transformed into a capitalized module name. I.e. `file.res` will be compiled into the module `File`. To simplify and minimize the disconnect here, the convention is therefore to capitalize file names. - -## Signatures - -A module's type is called a "signature", and can be written explicitly. If a -module is like a `.res` (implementation) file, then a module's signature is like -a `.resi` (interface) file. - -### Creation - -To create a signature, use the `module type` keyword. The signature name must start with a -**capital letter**. Whatever you could place in a `.resi` file, you may place -inside a signature definition's `{}` block. - - - -```res example -/* Picking up previous section's example */ -module type EstablishmentType = { - type profession - let getProfession: profession => string -} -``` - -```js -// Empty output -``` - - - -A signature defines the list of requirements that a module must satisfy in order -for that module to match the signature. Those requirements are of the form: - -- `let x: int` requires a `let` binding named `x`, of type `int`. -- `type t = someType` requires a type field `t` to be equal to `someType`. -- `type t` requires a type field `t`, but without imposing any requirements on the actual, concrete type of `t`. We'd use `t` in other entries in the signature to describe relationships, e.g. `let makePair: t => (t, t)` but we cannot, for example, assume that `t` is an `int`. This gives us great, enforced abstraction abilities. - -To illustrate the various kinds of type entries, consider the above signature -`EstablishmentType` which requires that a module: - -- Declare a type named `profession`. -- Must include a function that takes in a value of the type `profession` and returns a string. - -**Note**: - -Modules of the type `EstablishmentType` can contain more fields than the -signature declares, just like the module `School` in the previous section (if we -choose to assign it the type `EstablishmentType`. Otherwise, `School` exposes -every field). This effectively makes the `person1` field an enforced -implementation detail! Outsiders can't access it, since it's not present in the -signature; the signature **constrained** what others can access. - -The type `EstablishmentType.profession` is **abstract**: it doesn't have a -concrete type; it's saying "I don't care what the actual type is, but it's used -as input to `getProfession`". This is useful to fit many modules under the same -interface: - - - -```res -module Company: EstablishmentType = { - type profession = CEO | Designer | Engineer | ... - - let getProfession = (person) => ... - let person1 = ... - let person2 = ... -} -``` - -```js -function getProfession(person) { - ... -} - -var person1 = ... - -var person2 = ... - -var Company = { - getProfession: getProfession, - person1: person1, - person2: person2 -}; -``` - - - -It's also useful to hide the underlying type as an implementation detail others -can't rely on. If you ask what the type of `Company.profession` is, instead of -exposing the variant, it'll only tell you "it's `Company.profession`". - -### Extending module signatures - -Like modules themselves, module signatures can also be extended by other module signatures using `include`. Again, **heavily discouraged**: - - - -```res example -module type BaseComponent = { - let defaultGreeting: string - let getAudience: (~excited: bool) => string -} - -module type ActualComponent = { - /* the BaseComponent signature is copied over */ - include BaseComponent - let render: unit => string -} -``` - -```js -// Empty output -``` - - - -**Note**: `BaseComponent` is a module **type**, not an actual module itself! - -If you do not have a defined module type, you can extract it from an actual module -using `include (module type of ActualModuleName)`. For example, we can extend the -`List` module from the standard library, which does not define a module -type. - - - -```res example -module type MyList = { - include (module type of List) - let myListFun: list<'a> => list<'a> -} -``` - -```js -// Empty output -``` - - - -### Every `.resi` file is a signature - -Similar to how a `React.res` file implicitly defines a module `React`, a file -`React.resi` implicitly defines a signature for `React`. If `React.resi` isn't -provided, the signature of `React.res` defaults to exposing all the fields of the -module. Because they don't contain implementation files, `.resi` files are used -in the ecosystem to also document the public API of their corresponding modules. - - - -```res example -/* file React.res (implementation. Compiles to module React) */ -type state = int -let render = (str) => str -``` - -```js -function render(str) { - return str; -} -``` - - - -```res sig -/* file React.resi (interface. Compiles to the signature of React.res) */ -type state = int -let render: string => string -``` - -## Module Functions - -Modules can be passed to functions! It would be the equivalent of passing a file -as a first-class item. However, modules are at a different "layer" of the -language than other common concepts, so we can't pass them to _regular_ -functions. Instead, we pass them to special functions called module functions. - -The syntax for defining and using module functions is very much like the syntax -for defining and using regular functions. The primary differences are: - -- Module functions use the `module` keyword instead of `let`. -- Module functions take modules as arguments and return a module. -- Module functions _require_ annotating arguments. -- Module functions must start with a capital letter (just like modules/signatures). - -Here's an example `MakeSet` module function, that takes in a module of the type -`Comparable` and returns a new set that can contain such comparable items. - - - -```res prelude -module type Comparable = { - type t - let equal: (t, t) => bool -} - -module MakeSet = (Item: Comparable) => { - // let's use a list as our naive backing data structure - type backingType = list - let empty = list{} - let add = (currentSet: backingType, newItem: Item.t): backingType => - // if item exists - if currentSet->List.some(x => Item.equal(x, newItem)) { - currentSet // return the same (immutable) set (a list really) - } else { - list{ - newItem, - ...currentSet // prepend to the set and return it - } - } -} -``` - -```js -var List = require("./stdlib/list.js"); - -function MakeSet(Item) { - var add = function (currentSet, newItem) { - if ( - List.exists(function (x) { - return Item.equal(x, newItem); - }, currentSet) - ) { - return currentSet; - } else { - return { - hd: newItem, - tl: currentSet, - }; - } - }; - return { - empty: /* [] */ 0, - add: add, - }; -} -``` - - - -Module functions can be applied using function application syntax. In this case, we're -creating a set, whose items are pairs of integers. - - - -```res example -module IntPair = { - type t = (int, int) - let equal = ((x1: int, y1: int), (x2, y2)) => x1 == x2 && y1 == y2 - let create = (x, y) => (x, y) -} - -/* IntPair abides by the Comparable signature required by MakeSet */ -module SetOfIntPairs = MakeSet(IntPair) -``` - -```js -function equal(param, param$1) { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } -} - -function create(x, y) { - return [x, y]; -} - -var IntPair = { - equal: equal, - create: create, -}; - -var SetOfIntPairs = { - empty: /* [] */ 0, - add: add, -}; -``` - - - -### Module functions types - -Like with module types, module function types also act to constrain and hide what we may -assume about module functions. The syntax for module function types are consistent with those -for function types, but with types capitalized to represent the signatures of -modules the module functions accepts as arguments and return values. In the -previous example, we're exposing the backing type of a set; by giving `MakeSet` -a module function signature, we can hide the underlying data structure! - - - -```res -module type Comparable = ... - -module type MakeSetType = (Item: Comparable) => { - type backingType - let empty: backingType - let add: (backingType, Item.t) => backingType -} - -module MakeSet: MakeSetType = (Item: Comparable) => { - ... -} -``` - -```js -// Empty output -``` - - - -## Exotic Module Filenames - -**Since 8.3** - -It is possible to use non-conventional characters in your filenames (which is sometimes needed for specific JS frameworks). Here are some examples: - -- `src/Button.ios.res` -- `pages/[id].res` - -Please note that modules with an exotic filename will not be accessible from other ReScript modules. - -## Tips & Tricks - -Modules and module functions are at a different "layer" of language than the rest (functions, let bindings, data structures, etc.). For example, you can't easily pass them into a tuple or record. Use them judiciously, if ever! Lots of times, just a record or a function is enough. diff --git a/pages/docs/manual/v11.0.0/mutation.mdx b/pages/docs/manual/v11.0.0/mutation.mdx deleted file mode 100644 index af69120a8..000000000 --- a/pages/docs/manual/v11.0.0/mutation.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: "Mutation" -description: "Imperative and mutative programming capabilities in ReScript" -canonical: "/docs/manual/v11.0.0/mutation" ---- - -# Mutation - -ReScript has great traditional imperative & mutative programming capabilities. You should use these features sparingly, but sometimes they allow your code to be more performant and written in a more familiar pattern. - -## Mutate Let-binding - -Let-bindings are immutable, but you can wrap it with a `ref`, exposed as a record with a single mutable field in the standard library: - - - -```res prelude -let myValue = ref(5) -``` - -```js -var myValue = { - contents: 5, -}; -``` - - - -## Usage - -You can get the actual value of a `ref` box through accessing its `contents` field: - - - -```res example -let five = myValue.contents // 5 -``` - -```js -var five = myValue.contents; -``` - - - -Assign a new value to `myValue` like so: - - - -```res example -myValue.contents = 6 -``` - -```js -myValue.contents = 6; -``` - - - -We provide a syntax sugar for this: - - - -```res example -myValue := 6 -``` - -```js -myValue.contents = 6; -``` - - - -Note that the previous binding `five` stays `5`, since it got the underlying item on the `ref` box, not the `ref` itself. - -**Note**: you might see in the JS output tabs above that `ref` allocates an object. Worry not; local, non-exported `ref`s allocations are optimized away. - -## Tip & Tricks - -Before reaching for `ref`, know that you can achieve lightweight, local "mutations" through [overriding let bindings](let-binding.md#binding-shadowing). diff --git a/pages/docs/manual/v11.0.0/newcomer-examples.mdx b/pages/docs/manual/v11.0.0/newcomer-examples.mdx deleted file mode 100644 index 1e02b8c5a..000000000 --- a/pages/docs/manual/v11.0.0/newcomer-examples.mdx +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: "Newcomer Examples" -description: "Quick examples for users new to ReScript" -canonical: "/docs/manual/v11.0.0/newcomer-examples" ---- - -# Newcomer Examples - - - -An example is worth a thousand words. - -This section is dedicated to newcomers trying to figure out general idioms & conventions. If you're a beginner who's got a good idea for an example, please suggest an edit! - -## Use the [`option` type](null-undefined-option.md) - - - -```res example -let possiblyNullValue1 = None -let possiblyNullValue2 = Some("Hello") - -switch possiblyNullValue2 { -| None => Console.log("Nothing to see here.") -| Some(message) => Console.log(message) -} -``` - -```js -var possiblyNullValue1; -var possiblyNullValue2 = "Hello"; - -if (possiblyNullValue2 !== undefined) { - console.log(possiblyNullValue2); -} else { - console.log("Nothing to see here."); -} -``` - - - -## Create a Parametrized Type - - - -```res example -type universityStudent = {gpa: float} - -type response<'studentType> = { - status: int, - student: 'studentType, -} -``` - -```js -// Empty output -``` - - - -## Creating a JS Object - - - -```res example -let student1 = { - "name": "John", - "age": 30, -} -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -Or using [record](record.md): - - - -```res example -type payload = { - name: string, - age: int, -} - -let student1 = { - name: "John", - age: 30, -} -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -## Modeling a JS Module with Default Export - -See [here](import-from-export-to-js.md#import-a-javascript-module-itself-es6-module-format). - -## Checking for JS nullable types using the `option` type - -For a function whose argument is passed a JavaScript value that's potentially `null` or `undefined`, it's idiomatic to convert it to an `option`. The conversion is done through the helper functions in ReScript's [`Nullable`](api/core/nullable#value-toOption) module. In this case, `toOption`: - - - -```res example -let greetByName = (possiblyNullName) => { - let optionName = Nullable.toOption(possiblyNullName) - switch optionName { - | None => "Hi" - | Some(name) => "Hello " ++ name - } -} -``` - -```js -function greetByName(possiblyNullName) { - if (possiblyNullName == null) { - return "Hi"; - } else { - return "Hello " + possiblyNullName; - } -} -``` - - - -This check compiles to `possiblyNullName == null` in JS, so checks for the presence of `null` or `undefined`. diff --git a/pages/docs/manual/v11.0.0/null-undefined-option.mdx b/pages/docs/manual/v11.0.0/null-undefined-option.mdx deleted file mode 100644 index 82b4ecd98..000000000 --- a/pages/docs/manual/v11.0.0/null-undefined-option.mdx +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: "Null, Undefined and Option" -description: "JS interop with nullable and optional values in ReScript" -canonical: "/docs/manual/v11.0.0/null-undefined-option" ---- - -# Null, Undefined and Option - -ReScript itself doesn't have the notion of `null` or `undefined`. This is a _great_ thing, as it wipes out an entire category of bugs. No more `undefined is not a function`, and `cannot access someAttribute of undefined`! - -However, the **concept** of a potentially nonexistent value is still useful, and safely exists in our language. - -We represent the existence and nonexistence of a value by wrapping it with the `option` type. Here's its definition from the standard library: - - - -```res example -type option<'a> = None | Some('a) -``` - -```js -// Empty output -``` - - - -It means "a value of type option is either None (representing nothing) or that actual value wrapped in a Some". - -**Note** how the `option` type is just a regular [variant](variant.md). - -## Example - -Here's a normal value: - - - -```res example -let licenseNumber = 5 -``` - -```js -var licenseNumber = 5; -``` - - - -To represent the concept of "maybe null", you'd turn this into an `option` type by wrapping it. For the sake of a more illustrative example, we'll put a condition around it: - - - -```res -let licenseNumber = - if personHasACar { - Some(5) - } else { - None - } -``` - -```js -var licenseNumber = personHasACar ? 5 : undefined; -``` - - - -Later on, when another piece of code receives such value, it'd be forced to handle both cases through [pattern matching](pattern-matching-destructuring.md): - - - -```res -switch licenseNumber { -| None => - Console.log("The person doesn't have a car") -| Some(number) => - Console.log("The person's license number is " ++ Int.toString(number)) -} -``` - -```js -var number = licenseNumber; - -if (number !== undefined) { - console.log("The person's license number is " + number.toString()); -} else { - console.log("The person doesn't have a car"); -} -``` - - - -By turning your ordinary number into an `option` type, and by forcing you to handle the `None` case, the language effectively removed the possibility for you to mishandle, or forget to handle, a conceptual `null` value! **A pure ReScript program doesn't have null errors**. - -## Interoperate with JavaScript `undefined` and `null` - -The `option` type is common enough that we special-case it when compiling to JavaScript: - - - -```res example -let x = Some(5) -``` - -```js -var x = 5; -``` - - - -simply compiles down to `5`, and - - - -```res example -let x = None -``` - -```js -var x; -``` - - - -compiles to `undefined`! If you've got e.g. a string in JavaScript that you know might be `undefined`, type it as `option` and you're done! Likewise, you can send a `Some(5)` or `None` to the JS side and expect it to be interpreted correctly =) - -### Caveat 1 - -The option-to-undefined translation isn't perfect, because on our side, `option` values can be composed: - - - -```res example -let x = Some(Some(Some(5))) -``` - -```js -var x = 5; -``` - - - -This still compiles to `5`, but this gets troublesome: - - - -```res example -let x = Some(None) -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -var x = Caml_option.some(undefined); -``` - -(See output tab). - - - -What's this `Caml_option.some` thing? Why can't this compile to `undefined`? Long story short, when dealing with a polymorphic `option` type (aka `option<'a>`, for any `'a`), many operations become tricky if we don't mark the value with some special annotation. If this doesn't make sense, don't worry; just remember the following rule: - -- **Never, EVER, pass a nested `option` value (e.g. `Some(Some(Some(5)))`) into the JS side.** -- **Never, EVER, annotate a value coming from JS as `option<'a>`. Always give the concrete, non-polymorphic type.** - -### Caveat 2 - -Unfortunately, lots of times, your JavaScript value might be _both_ `null` or `undefined`. In that case, you unfortunately can't type such value as e.g. `option`, since our `option` type only checks for `undefined` and not `null` when dealing with a `None`. - -#### Solution: More Sophisticated `undefined` & `null` Interop - -To solve this, we provide access to more elaborate `null` and `undefined` helpers through the [`Nullable`](api/core/nullable) module. This somewhat works like an `option` type, but is different from it. - -#### Examples - -To create a JS `null`, use the value `Nullable.null`. To create a JS `undefined`, use `Nullable.undefined` (you can naturally use `None` too, but that's not the point here; the `Nullable.*` helpers wouldn't work with it). - -If you're receiving, for example, a JS string that can be `null` and `undefined`, type it as: - - - -```res example -@module("MyConstant") external myId: Nullable.t = "myId" -``` - -```js -// Empty output -``` - - - -To create such a nullable string from our side (presumably to pass it to the JS side, for interop purpose), do: - - - -```res example -@module("MyIdValidator") external validate: Nullable.t => bool = "validate" -let personId: Nullable.t = Nullable.make("abc123") - -let result = validate(personId) -``` - -```js -var MyIdValidator = require("MyIdValidator"); -var personId = "abc123"; -var result = MyIdValidator.validate(personId); -``` - - - -The `return` part "wraps" a string into a nullable string, to make the type system understand and track the fact that, as you pass this value around, it's not just a string, but a string that can be `null` or `undefined`. - -#### Convert to/from `option` - -`Nullable.fromOption` converts from a `option` to `Nullable.t`. `Nullable.toOption` does the opposite. diff --git a/pages/docs/manual/v11.0.0/object.mdx b/pages/docs/manual/v11.0.0/object.mdx deleted file mode 100644 index 0042d4aa2..000000000 --- a/pages/docs/manual/v11.0.0/object.mdx +++ /dev/null @@ -1,202 +0,0 @@ ---- -title: "Object" -description: "Interoping with JS objects in ReScript" -canonical: "/docs/manual/v11.0.0/object" ---- - -# Object - -ReScript objects are like [records](record.md), but: - -- No type declaration needed. -- Structural and more polymorphic, [unlike records](record.md#record-types-are-found-by-field-name). -- Doesn't support updates unless the object comes from the JS side. -- Doesn't support [pattern matching](pattern-matching-destructuring). - - - -Although ReScript records compile to clean JavaScript objects, ReScript objects are a better candidate for emulating/binding to JS objects, as you'll see. - -## Type Declaration - -**Optional**, unlike for records. The type of an object is inferred from the value, so you never really need to write down its type definition. Nevertheless, here's its type declaration syntax: - - - -```res prelude -type person = { - "age": int, - "name": string -}; -``` - -```js -// Empty output -``` - - - -Visually similar to record type's syntax, with the field names quoted. - - - -## Creation - -To create a new object: - - - -```res example -let me = { - "age": 5, - "name": "Big ReScript" -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -**Note**: as said above, unlike for record, this `me` value does **not** try to find a conforming type declaration with the field `"age"` and `"name"`; rather, the type of `me` is inferred as `{"age": int, "name": string}`. This is convenient, but also means this code passes type checking without errors: - - - -```res -type person = { - "age": int -}; - -let me = { - "age": "hello!" // age is a string. No error. -} -``` - -```js -var me = { - age: "hello!", -}; -``` - - - -Since the type checker doesn't try to match `me` with the type `person`. If you ever want to force an object value to be of a predeclared object type, just annotate the value: - -```res -let me: person = { - "age": "hello!" -} -``` - -Now the type system will error properly. - -## Access - - - -```res -let age = me["age"] -``` - -```js -var age = me["age"]; -``` - - - -## Update - -Disallowed unless the object is a binding that comes from the JavaScript side. In that case, use `=` - - - -```res example -type student = { - @set "age": int, - @set "name": string, -} -@module("MyJSFile") external student1: student = "student1" - -student1["name"] = "Mary" -``` - -```js -var MyJSFile = require("MyJSFile"); -MyJSFile.student1.name = "Mary"; -``` - - - -## Combine Types - -You can spread one object type definition into another using `...`: - - - -```res example -type point2d = { - "x": float, - "y": float, -} -type point3d = { - ...point2d, - "z": float, -} - -let myPoint: point3d = { - "x": 1.0, - "y": 2.0, - "z": 3.0, -} -``` - -```js -var myPoint = { - x: 1.0, - y: 2.0, - z: 3.0, -}; -``` - - - -This only works with object types, not object values! - -## Tips & Tricks - -Since objects don't require type declarations, and since ReScript infers all the types for you, you get to very quickly and easily (and dangerously) bind to any JavaScript API. Check the JS output tab: - - - -```res example -// The type of document is just some random type 'a -// that we won't bother to specify -@val external document: 'a = "document" - -// call a method -document["addEventListener"]("mouseup", _event => { - Console.log("clicked!") -}) - -// get a property -let loc = document["location"] - -// set a property -document["location"]["href"] = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); -var loc = document.location; -document.location.href = "rescript-lang.org"; -``` - - - -The `external` feature and the usage of this trick are also documented in the [external](external#tips--tricks) section later. It's an excellent way to start writing some ReScript code without worrying about whether bindings to a particular library exists. diff --git a/pages/docs/manual/v11.0.0/overview.mdx b/pages/docs/manual/v11.0.0/overview.mdx deleted file mode 100644 index 53f8a7cfa..000000000 --- a/pages/docs/manual/v11.0.0/overview.mdx +++ /dev/null @@ -1,255 +0,0 @@ ---- -title: "Overview" -metaTitle: "Language Features Overview" -description: "A quick overview on ReScript's syntax" -canonical: "/docs/manual/v11.0.0/overview" ---- - -# Overview - -## Comparison to JS - -### Semicolon - -| JavaScript | ReScript | -| ---------------------------------- | -------------------- | -| Rules enforced by linter/formatter | No semicolon needed! | - -### Comments - -| JavaScript | ReScript | -| -------------------- | -------------------------------- | -| `// Line comment` | Same | -| `/* Comment */` | Same | -| `/** Doc Comment */` | `/** Before Types/Values */` | -| | `/*** Standalone Doc Comment */` | - -### Variable - -| JavaScript | ReScript | -| ----------------------- | ------------------------------------- | -| `const x = 5;` | `let x = 5` | -| `var x = y;` | No equivalent (thankfully) | -| `let x = 5; x = x + 1;` | `let x = ref(5); x := x.contents + 1` | - -### String & Character - -| JavaScript | ReScript | -| ---------------------------- | --------------------- | -| `"Hello world!"` | Same | -| `'Hello world!'` | Strings must use `"` | -| `"hello " + "world"` | `"hello " ++ "world"` | -| `` `hello ${message}` `` | Same | -| `` sql`select ${fnName};` `` | Same | - -### Boolean - -| JavaScript | ReScript | -| ------------------------------------ | ---------------------------------------------- | -| `true`, `false` | Same | -| `!true` | Same | -| `\|\|`, `&&`, `<=`, `>=`, `<`, `>` | Same | -| `a === b`, `a !== b` | Same | -| No deep equality (recursive compare) | `a == b`, `a != b` | -| `a == b` | No equality with implicit casting (thankfully) | - -### Number - -| JavaScript | ReScript | -| ----------- | ------------ | -| `3` | Same \* | -| `3.1415` | Same | -| `3 + 4` | Same | -| `3.0 + 4.5` | `3.0 +. 4.5` | -| `5 % 3` | `mod(5, 3)` | - -\* JS has no distinction between integer and float. - -### Object/Record - -| JavaScript | ReScript | -| ------------------- | --------------------------------------- | -| no types | `type point = {x: int, mutable y: int}` | -| `{x: 30, y: 20}` | Same | -| `point.x` | Same | -| `point.y = 30;` | Same | -| `{...point, x: 30}` | Same | - -### Array - -| JavaScript | ReScript | -| ------------------ | --------------------- | -| `[1, 2, 3]` | Same | -| `myArray[1] = 10` | Same | -| `[1, "Bob", true]` | `(1, "Bob", true)` \* | - -\* ReScript does not have heterogenous arrays. Use tuples or [Untagged Variants](variant#untagged-variants) instead. - -### Null - -| JavaScript | ReScript | -| ------------------- | --------- | -| `null`, `undefined` | `None` \* | - -\* Again, only a spiritual equivalent; we don't have nulls, nor null bugs! But we do have an `option` type for when you actually need nullability. - -### Function - -| JavaScript | ReScript | -| ------------------------------- | ---------------------------- | -| `arg => retVal` | Same | -| `function named(arg) {...}` | `let named = (arg) => {...}` | -| `const f = function(arg) {...}` | `let f = (arg) => {...}` | -| `add(4, add(5, 6))` | Same | - -### Async Function / Await - -| JavaScript | ReScript | -| --------------------------------------- | ----------------------------------------------------- | -| `async (arg) => {...}` | Same | -| `async function named(arg) {...}` | `let named = async (arg) => {...}` | -| `await somePromise` | Same | -| `async (arg): Promise => {...}` | `async (arg): string => {...}` (note the return type) | - -### Blocks - - - - - - - - - - - - - - -
JavaScriptReScript
- ``` - const myFun = (x, y) => { - const doubleX = x + x; - const doubleY = y + y; - return doubleX + doubleY; - }; - ``` - - ``` - let myFun = (x, y) => { - let doubleX = x + x - let doubleY = y + y - doubleX + doubleY - } - ``` -
- -### If-else - -| JavaScript | ReScript | -| --------------------- | --------------------------------------------------------------------------------- | -| `if (a) {b} else {c}` | `if a {b} else {c}` \* | -| `a ? b : c` | Same | -| `switch` | `switch` but [super-powered pattern matching!](pattern-matching-destructuring.md) | - -\* Our conditionals are always expressions! You can write `let result = if a {"hello"} else {"bye"}` - -### Destructuring - -| JavaScript | ReScript | -| ----------------------------- | --------------------------- | -| `const {a, b} = data` | `let {a, b} = data` | -| `const [a, b] = data` | `let [a, b] = data` \* | -| `const {a: aa, b: bb} = data` | `let {a: aa, b: bb} = data` | - -\* Gives good compiler warning that `data` might not be of length 2. - -### Loop - -| JavaScript | ReScript | -| ------------------------------------- | ---------------------------- | -| `for (let i = 0; i <= 10; i++) {...}` | `for i in 0 to 10 {...}` | -| `for (let i = 10; i >= 0; i--) {...}` | `for i in 10 downto 0 {...}` | -| `while (true) {...}` | `while true {...}` | - -### JSX - -| JavaScript | ReScript | -| ----------------------------------------- | -------------------------- | -| `` | Same | -| `` | `` \* | -| `` | `` | -| No children spread | `...children` | - -\* Argument punning! - -### Exception - -| JavaScript | ReScript | -| ----------------------------------------- | -------------------------------------------- | -| `throw new SomeError(...)` | `raise(SomeError(...))` | -| `try {a} catch (err) {...} finally {...}` | `try a catch { \| SomeError(err) => ...}` \* | - -\* No finally. - -### Blocks - -The last expression of a block delimited by `{}` implicitly returns (including function body). In JavaScript, this can only be simulated via an immediately-invoked function expression (since function bodies have their own local scope). - - - - - - - - - - - - - - -
JavaScriptReScript
- ``` - let result = (function() { - const x = 23; - const y = 34; - return x + y; - })(); - ``` - - ``` - let result = { - let x = 23 - let y = 34 - x + y - } - ``` -
- -## Common Features' JS Output - -| Feature | Example | JavaScript Output | -| ------------------------------- | ------------------------------------ | ------------------------------------------ | -| String | `"Hello"` | `"Hello"` | -| String Interpolation | `` `Hello ${message}` `` | `"Hello " + message` | -| Character (disrecommended) | `'x'` | `120` (char code) | -| Integer | `23`, `-23` | `23`, `-23` | -| Float | `23.0`, `-23.0` | `23.0`, `-23.0` | -| Integer Addition | `23 + 1` | `23 + 1` | -| Float Addition | `23.0 +. 1.0` | `23.0 + 1.0` | -| Integer Division/Multiplication | `2 / 23 * 1` | `2 / 23 * 1` | -| Float Division/Multiplication | `2.0 /. 23.0 *. 1.0` | `2.0 / 23.0 * 1.0` | -| Float Exponentiation | `2.0 ** 3.0` | `Math.pow(2.0, 3.0)` | -| String Concatenation | `"Hello " ++ "World"` | `"Hello " + "World"` | -| Comparison | `>`, `<`, `>=`, `<=` | `>`, `<`, `>=`, `<=` | -| Boolean operation | `!`, `&&`, `\|\|` | `!`, `&&`, `\|\|` | -| Shallow and deep Equality | `===`, `==` | `===`, `==` | -| List (disrecommended) | `list{1, 2, 3}` | `{hd: 1, tl: {hd: 2, tl: {hd: 3, tl: 0}}}` | -| List Prepend | `list{a1, a2, ...oldList}` | `{hd: a1, tl: {hd: a2, tl: theRest}}` | -| Array | `[1, 2, 3]` | `[1, 2, 3]` | -| Record | `type t = {b: int}; let a = {b: 10}` | `var a = {b: 10}` | -| Multiline Comment | `/* Comment here */` | Not in output | -| Single line Comment | `// Comment here` | Not in output | - -_Note that this is a cleaned-up comparison table; a few examples' JavaScript output are slightly different in reality._ diff --git a/pages/docs/manual/v11.0.0/pattern-matching-destructuring.mdx b/pages/docs/manual/v11.0.0/pattern-matching-destructuring.mdx deleted file mode 100644 index c388dd2dd..000000000 --- a/pages/docs/manual/v11.0.0/pattern-matching-destructuring.mdx +++ /dev/null @@ -1,899 +0,0 @@ ---- -title: "Pattern Matching / Destructuring" -description: "Pattern matching and destructuring complex data structures in ReScript" -canonical: "/docs/manual/v11.0.0/pattern-matching-destructuring" ---- - -# Pattern Matching / Destructuring - -One of ReScript's **best** feature is our pattern matching. Pattern matching combines 3 brilliant features into one: - -- Destructuring. -- `switch` based on shape of data. -- Exhaustiveness check. - -We'll dive into each aspect below. - -## Destructuring - -Even JavaScript has destructuring, which is "opening up" a data structure to extract the parts we want and assign variable names to them: - - - -```res example -let coordinates = (10, 20, 30) -let (x, _, _) = coordinates -Console.log(x) // 10 -``` - -```js -var coordinates = [10, 20, 30]; -var x = 10; -console.log(10); -``` - - - -Destructuring works with most built-in data structures: - - - -```res -// Record -type student = {name: string, age: int} -let student1 = {name: "John", age: 10} -let {name} = student1 // "John" assigned to `name` - -// Variant -type result = - | Success(string) -let myResult = Success("You did it!") -let Success(message) = myResult // "You did it!" assigned to `message` -``` - -```js -var student1 = { - name: "John", - age: 10, -}; -var name = "John"; - -var myResult = /* Success */ { - _0: "You did it!", -}; -var message = "You did it!"; - -var myArray = [1, 2, 3]; -if (myArray.length !== 2) { - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 14, 4], - Error: new Error(), - }; -} -var item1 = myArray[0]; -var item2 = myArray[1]; - -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */ 0, - }, - }, -}; -// ... -``` - - - -You can also use destructuring anywhere you'd usually put a binding: - - - -```res example -type result = - | Success(string) -let displayMessage = (Success(m)) => { - // we've directly extracted the success message - // string by destructuring the parameter - Console.log(m) -} -displayMessage(Success("You did it!")) -``` - -```js -function displayMessage(m) { - console.log(m._0); -} - -displayMessage( - /* Success */ { - _0: "You did it!", - }, -); -``` - - - -For a record, you can rename the field while destructuring: - - - -```res -let {name: n} = student1 // "John" assigned to `n` -``` - -```js -var n = "John"; -``` - - - -You _can_ in theory destructure array and list at the top level too: - -```res -let myArray = [1, 2, 3] -let [item1, item2, _] = myArray -// 1 assigned to `item1`, 2 assigned to `item2`, 3rd item ignored - -let myList = list{1, 2, 3} -let list{head, ...tail} = myList -// 1 assigned to `head`, `list{2, 3}` assigned to tail -``` - -But the array example is **highly disrecommended** (use tuple instead) and the list example will error on you. They're only there for completeness' sake. As you'll see below, the proper way of using destructuring array and list is using `switch`. - -## `switch` Based on Shape of Data - -While the destructuring aspect of pattern matching is nice, it doesn't really change the way you think about structuring your code. One paradigm-changing way of thinking about your code is to execute some code based on the shape of the data. - -Consider a variant: - - - -```res prelude -type payload = - | BadResult(int) - | GoodResult(string) - | NoResult -``` - -```js -// Empty output -``` - - - -We'd like to handle each of the 3 cases differently. For example, print a success message if the value is `GoodResult(...)`, do something else when the value is `NoResult`, etc. - -In other languages, you'd end up with a series of if-elses that are hard to read and error-prone. In ReScript, you can instead use the supercharged `switch` pattern matching facility to destructure the value while calling the right code based on what you destructured: - - - -```res example -let data = GoodResult("Product shipped!") -switch data { -| GoodResult(theMessage) => - Console.log("Success! " ++ theMessage) -| BadResult(errorCode) => - Console.log("Something's wrong. The error code is: " ++ Int.toString(errorCode)) -| NoResult => - Console.log("Bah.") -} -``` - -```js -var data = { - TAG: "GoodResult", - _0: "Product shipped!", -}; - -if (typeof data !== "object") { - console.log("Bah."); -} else if (data.TAG === "BadResult") { - console.log( - "Something's wrong. The error code is: " + "Product shipped!".toString(), - ); -} else { - console.log("Success! Product shipped!"); -} -``` - - - -In this case, `message` will have the value `"Success! Product shipped!"`. - -Suddenly, your if-elses that messily checks some structure of the value got turned into a clean, compiler-verified, linear list of code to execute based on exactly the shape of the value. - -### Complex Examples - -Here's a real-world scenario that'd be a headache to code in other languages. Given this data structure: - - - -```res prelude -type status = Vacations(int) | Sabbatical(int) | Sick | Present -type reportCard = {passing: bool, gpa: float} -type student = {name: string, status: status, reportCard: reportCard} -type person = - | Teacher({name: string, age: int}) - | Student(student) -``` - -```js -// Empty output -``` - - - -Imagine this requirement: - -- Informally greet a person who's a teacher and if his name is Mary or Joe. -- Greet other teachers formally. -- If the person's a student, congratulate him/her score if they passed the semester. -- If the student has a gpa of 0 and is on vacations or sabbatical, display a different message. -- A catch-all message for a student. - -ReScript can do this easily! - - - -```res prelude -let person1 = Teacher({name: "Jane", age: 35}) - -let message = switch person1 { -| Teacher({name: "Mary" | "Joe"}) => - `Hey, still going to the party on Saturday?` -| Teacher({name}) => - // this is matched only if `name` isn't "Mary" or "Joe" - `Hello ${name}.` -| Student({name, reportCard: {passing: true, gpa}}) => - `Congrats ${name}, nice GPA of ${Float.toString(gpa)} you got there!` -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - `Come back in ${Int.toString(daysLeft)} days!` -| Student({status: Sick}) => - `How are you feeling?` -| Student({name}) => - `Good luck next semester ${name}!` -} -``` - -```js -var person1 = { - TAG: "Teacher", - name: "Jane", - age: 35, -}; - -var message; - -if (person1.TAG === "Teacher") { - message = "Hello Jane."; -} else { - var match = "Jane"; - var match$1 = match.status; - var name = match.name; - var match$2 = match.reportCard; - if (match$2.passing) { - message = - "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!"; - } else { - var exit = 0; - if (typeof match$1 !== "object") { - message = - match$1 === "Sick" - ? "How are you feeling?" - : "Good luck next semester " + name + "!"; - } else { - exit = 1; - } - if (exit === 1) { - message = - match.reportCard.gpa !== 0.0 - ? "Good luck next semester " + name + "!" - : "Come back in " + match$1._0.toString() + " days!"; - } - } -} -``` - - - -**Note** how we've: - -- drilled deep down into the value concisely -- using a **nested pattern check** `"Mary" | "Joe"` and `Vacations | Sabbatical` -- while extracting the `daysLeft` number from the latter case -- and assigned the greeting to the binding `message`. - -Here's another example of pattern matching, this time on an inline tuple. - - - -```res -type animal = Dog | Cat | Bird -let categoryId = switch (isBig, myAnimal) { -| (true, Dog) => 1 -| (true, Cat) => 2 -| (true, Bird) => 3 -| (false, Dog | Cat) => 4 -| (false, Bird) => 5 -} -``` - -```js -var categoryId = isBig ? (myAnimal + 1) | 0 : myAnimal >= 2 ? 5 : 4; -``` - - - -**Note** how pattern matching on a tuple is equivalent to a 2D table: - -| isBig \ myAnimal | Dog | Cat | Bird | -| ---------------- | --- | --- | ---- | -| true | 1 | 2 | 3 | -| false | 4 | 4 | 5 | - -### Fall-Through Patterns - -The nested pattern check, demonstrated in the earlier `person` example, also works at the top level of a `switch`: - - - -```res prelude -let myStatus = Vacations(10) - -switch myStatus { -| Vacations(days) -| Sabbatical(days) => Console.log(`Come back in ${Int.toString(days)} days!`) -| Sick -| Present => Console.log("Hey! How are you?") -} -``` - -```js -var myStatus = { - TAG: /* Vacations */ 0, - _0: 10, -}; - -if (typeof myStatus === "number") { - console.log("Hey! How are you?"); -} else { - console.log("Come back in " + (10).toString() + " days!"); -} -``` - - - -Having multiple cases fall into the same handling can clean up certain types of logic. - -### Ignore Part of a Value - -If you have a value like `Teacher(payload)` where you just want to pattern match on the `Teacher` part and ignore the `payload` completely, you can use the `_` wildcard like this: - - - -```res example -switch person1 { -| Teacher(_) => Console.log("Hi teacher") -| Student(_) => Console.log("Hey student") -} -``` - -```js -if (person1.TAG === "Teacher") { - console.log("Hi teacher"); -} else { - console.log("Hey student"); -} -``` - - - -`_` also works at the top level of the `switch`, serving as a catch-all condition: - - - -```res example -switch myStatus { -| Vacations(_) => Console.log("Have fun!") -| _ => Console.log("Ok.") -} -``` - -```js -if (typeof myStatus !== "object" || myStatus.TAG !== "Vacations") { - console.log("Ok."); -} else { - console.log("Have fun!"); -} -``` - - - -**Do not** abuse a top-level catch-all condition. Instead, prefer writing out all the cases: - - - -```res example -switch myStatus { -| Vacations(_) => Console.log("Have fun!") -| Sabbatical(_) | Sick | Present => Console.log("Ok.") -} -``` - -```js -if (typeof myStatus !== "object" || myStatus.TAG !== "Vacations") { - console.log("Ok."); -} else { - console.log("Have fun!"); -} -``` - - - -Slightly more verbose, but a one-time writing effort. This helps when you add a new variant case e.g. `Quarantined` to the `status` type and need to update the places that pattern match on it. A top-level wildcard here would have accidentally and silently continued working, potentially causing bugs. - -### If Clause - -Sometime, you want to check more than the shape of a value. You want to also run some arbitrary check on it. You might be tempted to write this: - - - -```res example -switch person1 { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) => - if gpa < 0.5 { - Console.log("What's happening") - } else { - Console.log("Heyo") - } -} -``` - -```js -if (person1.TAG !== "Teacher") { - if ("Jane".reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -`switch` patterns support a shortcut for the arbitrary `if` check, to keep your pattern linear-looking: - - - -```res example -switch person1 { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) if gpa < 0.5 => - Console.log("What's happening") -| Student(_) => - // fall-through, catch-all case - Console.log("Heyo") -} -``` - -```js -if (person1.TAG) { - if (person1.reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -**Note:** Rescript versions < 9.0 had a `when` clause, not an `if` clause.  Rescript 9.0 changed `when` to `if`.  (`when` may still work, but is deprecated.) - -### Match on Exceptions - -If the function throws an exception (covered later), you can also match on _that_, in addition to the function's normally returned values. - - - -```res -switch List.find(i => i === theItem, myItems) { -| item => Console.log(item) -| exception Not_found => Console.log("No such item found!") -} -``` - -```js -var exit = 0; - -var item; - -try { - item = List.find(function (i) { - return i === theItem; - }, myItems); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -### Match on Array - - - -```res example -let students = ["Jane", "Harvey", "Patrick"] -switch students { -| [] => Console.log("There are no students") -| [student1] => - Console.log("There's a single student here: " ++ student1) -| manyStudents => - // display the array of names - Console.log2("The students are: ", manyStudents) -} -``` - -```js -var students = ["Jane", "Harvey", "Patrick"]; - -var len = students.length; - -if (len !== 1) { - if (len !== 0) { - console.log("The students are: ", students); - } else { - console.log("There are no students"); - } -} else { - var student1 = students[0]; - console.log("There's a single student here: " + student1); -} -``` - - - -### Match on List - -Pattern matching on list is similar to array, but with the extra feature of extracting the tail of a list (all elements except the first one): - - - -```res example -let rec printStudents = (students) => { - switch students { - | list{} => () // done - | list{student} => Console.log("Last student: " ++ student) - | list{student1, ...otherStudents} => - Console.log(student1) - printStudents(otherStudents) - } -} -printStudents(list{"Jane", "Harvey", "Patrick"}) -``` - -```js -function printStudents(_students) { - while (true) { - var students = _students; - if (!students) { - return; - } - var otherStudents = students.tl; - var student = students.hd; - if (otherStudents) { - console.log(student); - _students = otherStudents; - continue; - } - console.log("Last student: " + student); - return; - } -} - -printStudents({ - hd: "Jane", - tl: { - hd: "Harvey", - tl: { - hd: "Patrick", - tl: /* [] */ 0, - }, - }, -}); -``` - - - -### Small Pitfall - -**Note**: you can only pass literals (i.e. concrete values) as a pattern, not let-binding names or other things. The following doesn't work as expected: - - - -```res example -let coordinates = (10, 20, 30) -let centerY = 20 -switch coordinates { -| (x, _centerY, _) => Console.log(x) -} -``` - -```js -var coordinates = [10, 20, 30]; -var centerY = 20; - -console.log(10); -``` - - - -A first time ReScript user might accidentally write that code, assuming that it's matching on `coordinates` when the second value is of the same value as `centerY`. In reality, this is interpreted as matching on coordinates and assigning the second value of the tuple to the name `centerY`, which isn't what's intended. - -## Exhaustiveness Check - -As if the above features aren't enough, ReScript also provides arguably the most important pattern matching feature: **compile-time check of missing patterns**. - -Let's revisit one of the above examples: - - - -```res -let message = switch person1 { -| Teacher({name: "Mary" | "Joe"}) => - `Hey, still going to the party on Saturday?` -| Student({name, reportCard: {passing: true, gpa}}) => - `Congrats ${name}, nice GPA of ${Float.toString(gpa)} you got there!` -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - `Come back in ${Int.toString(daysLeft)} days!` -| Student({status: Sick}) => - `How are you feeling?` -| Student({name}) => - `Good luck next semester ${name}!` -} -``` - -```js -if (person1.TAG) { - var match$1 = person1.status; - var name = person1.name; - var match$2 = person1.reportCard; - if (match$2.passing) { - "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!"; - } else if (typeof match$1 === "number") { - if (match$1 !== 0) { - "Good luck next semester " + name + "!"; - } else { - ("How are you feeling?"); - } - } else if (person1.reportCard.gpa !== 0.0) { - "Good luck next semester " + name + "!"; - } else { - "Come back in " + match$1._0.toString() + " days!"; - } -} else { - switch (person1.name) { - case "Joe": - case "Mary": - break; - default: - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 13, 0], - Error: new Error(), - }; - } -} -``` - - - -Did you see what we removed? This time, we've omitted the handling of the case where `person1` is `Teacher({name})` when `name` isn't Mary or Joe. - -Failing to handle every scenario of a value likely constitutes the majority of program bugs out there. This happens very often when you refactor a piece of code someone else wrote. Fortunately for ReScript, the compiler will tell you so: - -``` -Warning 8: this pattern-matching is not exhaustive. -Here is an example of a value that is not matched: -Some({name: ""}) -``` - -**BAM**! You've just erased an entire category of important bugs before you even ran the code. In fact, this is how most of nullable values is handled: - - - -```res example -let myNullableValue = Some(5) - -switch myNullableValue { -| Some(_v) => Console.log("value is present") -| None => Console.log("value is absent") -} -``` - -```js -var myNullableValue = 5; - -if (myNullableValue !== undefined) { - console.log("value is present"); -} else { - console.log("value is absent"); -} -``` - - - -If you don't handle the `None` case, the compiler warns. No more `undefined` bugs in your code! - -## Conclusion & Tips & Tricks - -Hopefully you can see how pattern matching is a game changer for writing correct code, through the concise destructuring syntax, the proper conditions handling of `switch`, and the static exhaustiveness check. - -Below is some advice: - -Avoid using the wildcard `_` unnecessarily. Using the wildcard `_` will bypass the compiler's exhaustiveness check. Consequently, the compiler will not be able to notify you of probable errors when you add a new case to a variant. Try only using `_` against infinite possibilities, e.g. string, int, etc. - -Use the `if` clause sparingly. - -**Flatten your pattern-match whenever you can**. This is a real bug remover. Here's a series of examples, from worst to best: - - - -```res example -let optionBoolToBool = opt => { - if opt == None { - false - } else if opt === Some(true) { - true - } else { - false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt === undefined) { - return false; - } else { - return opt === true; - } -} -``` - - - -Now that's just silly =). Let's turn it into pattern-matching: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | None => false - | Some(a) => a ? true : false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Slightly better, but still nested. Pattern-matching allows you to do this: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | None => false - | Some(true) => true - | Some(false) => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Much more linear-looking! Now, you might be tempted to do this: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | Some(true) => true - | _ => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Which is much more concise, but kills the exhaustiveness check mentioned above; refrain from using that. This is the best: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | Some(trueOrFalse) => trueOrFalse - | None => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined) { - return opt; - } else { - return false; - } -} -``` - - - -Pretty darn hard to make a mistake in this code at this point! Whenever you'd like to use an if-else with many branches, prefer pattern matching instead. It's more concise and [performant](variant#design-decisions) too. diff --git a/pages/docs/manual/v11.0.0/pipe.mdx b/pages/docs/manual/v11.0.0/pipe.mdx deleted file mode 100644 index 6fd71a7de..000000000 --- a/pages/docs/manual/v11.0.0/pipe.mdx +++ /dev/null @@ -1,258 +0,0 @@ ---- -title: "Pipe" -description: "The Pipe operator (->)" -canonical: "/docs/manual/v11.0.0/pipe" ---- - -# Pipe - -ReScript provides a tiny but surprisingly useful operator `->`, called the "pipe", that allows you to "flip" your code inside-out. `a(b)` becomes `b->a`. It's a simple piece of syntax that doesn't have any runtime cost. - -Why would you use it? Imagine you have the following: - - - -```res -validateAge(getAge(parseData(person))) -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -This is slightly hard to read, since you need to read the code from the innermost part, to the outer parts. Use pipe to streamline it: - - - -```res -person - ->parseData - ->getAge - ->validateAge -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -Basically, `parseData(person)` is transformed into `person->parseData`, and `getAge(person->parseData)` is transformed into `person->parseData->getAge`, etc. - -**This works when the function takes more than one argument too**. - - - -```res -a(one, two, three) -``` - -```js -a(one, two, three); -``` - - - -is the same as - - - -```res -one->a(two, three) -``` - -```js -a(one, two, three); -``` - - - -This also works with labeled arguments. - -Pipes are used to emulate object-oriented programming. For example, `myStudent.getName` in other languages like Java would be `myStudent->getName` in ReScript (equivalent to `getName(myStudent)`). This allows us to have the readability of OOP without the downside of dragging in a huge class system just to call a function on a piece of data. - -## Tips & Tricks - -Do **not** abuse pipes; they're a means to an end. Inexperienced engineers sometimes shape a library's API to take advantage of the pipe. This is backwards. - -## JS Method Chaining - -_This section requires understanding of [our binding API](bind-to-js-function.md#object-method)_. - -JavaScript's APIs are often attached to objects, and are often chainable, like so: - -```js -const result = [1, 2, 3].map((a) => a + 1).filter((a) => a % 2 === 0); - -asyncRequest().setWaitDuration(4000).send(); -``` - -Assuming we don't need the chaining behavior above, we'd bind to each case of this using [`@send`](/syntax-lookup#send-decorator) from the aforementioned binding API page: - - - -```res prelude -type request -@val external asyncRequest: unit => request = "asyncRequest" -@send external setWaitDuration: (request, int) => request = "setWaitDuration" -@send external send: request => unit = "send" -``` - -```js -// Empty output -``` - - - -You'd use them like this: - - - -```res example -let result = Array.filter( - Array.map([1, 2, 3], a => a + 1), - a => mod(a, 2) == 0 -) - -send(setWaitDuration(asyncRequest(), 4000)) -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -This looks much worse than the JS counterpart! Clean it up visually with pipe: - - - -```res example -let result = [1, 2, 3] - ->Array.map(a => a + 1) - ->Array.filter(a => mod(a, 2) == 0) - -asyncRequest()->setWaitDuration(4000)->send -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -## Pipe Into Variants - -You can pipe into a variant's constructor as if it was a function: - - - -```res -let result = name->preprocess->Some -``` - -```js -var result = preprocess(name); -``` - - - -We turn this into: - - - -```res -let result = Some(preprocess(name)) -``` - -```js -var result = preprocess(name); -``` - - - -**Note** that using a variant constructor as a function wouldn't work anywhere else beside here. - -## Pipe Placeholders - -A placeholder is written as an underscore and it tells ReScript that you want to fill in an argument of a function later. These two have equivalent meaning: - -```res -let addTo7 = (x) => add3(3, x, 4) -let addTo7 = add3(3, _, 4) -``` - -Sometimes you don't want to pipe the value you have into the first position. In these cases you can mark a placeholder value to show which argument you would like to pipe into. - -Let's say you have a function `namePerson`, which takes a `person` then a `name` argument. If you are transforming a person then pipe will work as-is: - - - -```res -makePerson(~age=47) - ->namePerson("Jane") -``` - -```js -namePerson(makePerson(47), "Jane"); -``` - - - -If you have a name that you want to apply to a person object, you can use a placeholder: - - - -```res -getName(input) - ->namePerson(personDetails, _) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -This allows you to pipe into any positional argument. It also works for named arguments: - - - -```res -getName(input) - ->namePerson(~person=personDetails, ~name=_) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -## Triangle Pipe (Deprecated) - -You might see usages of another pipe, `|>`, in some codebases. These are deprecated. - -Unlike `->` pipe, the `|>` pipe puts the subject as the last (not first) argument of the function. `a |> f(b)` turns into `f(b, a)`. - -For a more thorough discussion on the rationale and differences between the two operators, please refer to the [Data-first and Data-last comparison by Javier Chávarri](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/) diff --git a/pages/docs/manual/v11.0.0/polymorphic-variant.mdx b/pages/docs/manual/v11.0.0/polymorphic-variant.mdx deleted file mode 100644 index fd5569cce..000000000 --- a/pages/docs/manual/v11.0.0/polymorphic-variant.mdx +++ /dev/null @@ -1,433 +0,0 @@ ---- -title: "Polymorphic Variant" -description: "The Polymorphic Variant data structure in ReScript" -canonical: "/docs/manual/v11.0.0/polymorphic-variant" ---- - -# Polymorphic Variant - -Polymorphic variants (or poly variant) are a cousin of [variant](variant). With these differences: - -- They start with a `#` and the constructor name doesn't need to be capitalized. -- They don't require an explicit type definition. The type is inferred from usage. -- Values of different poly variant types can share the constructors they have in common (aka, poly variants are "structurally" typed, as opposed to ["nominally" typed](variant#variant-types-are-found-by-field-name)). - -They're a convenient and useful alternative to regular variants, but should **not** be abused. See the drawbacks at the end of this page. - -## Creation - -We provide 3 syntaxes for a poly variant's constructor: - - - -```res -let myColor = #red -let myLabel = #"aria-hidden" -let myNumber = #7 -``` - -```js -var myColor = "red"; -var myLabel = "aria-hidden"; -var myNumber = 7; -``` - - - -**Take a look at the output**. Poly variants are _great_ for JavaScript interop. For example, you can use it to model JavaScript string and number enums like TypeScript, but without confusing their accidental usage with regular strings and numbers. - -`myColor` uses the common syntax. The second and third syntaxes are to support expressing strings and numbers more conveniently. We allow the second one because otherwise it'd be invalid syntax since symbols like `-` and others are usually reserved. - -## Type Declaration - -Although **optional**, you can still pre-declare a poly variant type: - -```res -// Note the surrounding square brackets, and # for constructors -type color = [#red | #green | #blue] -``` - -These types can also be inlined, unlike for regular variant: - - - -```res -let render = (myColor: [#red | #green | #blue]) => { - switch myColor { - | #blue => Console.log("Hello blue!") - | #red - | #green => Console.log("Hello other colors") - } -} -``` - -```js -function render(myColor) { - if (myColor === "green" || myColor === "red") { - console.log("Hello other colors"); - } else { - console.log("Hello blue!"); - } -} -``` - - - -**Note**: because a poly variant value's type definition is **inferred** and not searched in the scope, the following snippet won't error: - - - -```res -type color = [#red | #green | #blue] - -let render = myColor => { - switch myColor { - | #blue => Console.log("Hello blue!") - | #green => Console.log("Hello green!") - // works! - | #yellow => Console.log("Hello yellow!") - } -} -``` - -```js -function render(myColor) { - if (myColor === "yellow") { - console.log("Hello yellow!"); - } else if (myColor === "green") { - console.log("Hello green!"); - } else { - console.log("Hello blue!"); - } -} -``` - - - -That `myColor` parameter's type is inferred to be `#red`, `#green` or `#yellow`, and is unrelated to the `color` type. If you intended `myColor` to be of type `color`, annotate it as `myColor: color` in any of the places. - -## Constructor Arguments - -This is similar to a regular variant's [constructor arguments](variant#constructor-arguments): - - - -```res -type account = [ - | #Anonymous - | #Instagram(string) - | #Facebook(string, int) -] - -let me: account = #Instagram("Jenny") -let him: account = #Facebook("Josh", 26) -``` - -```js -var me = { - NAME: "Instagram", - VAL: "Jenny", -}; - -var him = { - NAME: "Facebook", - VAL: ["Josh", 26], -}; -``` - - - -### Combine Types and Pattern Match - -You can use poly variant types within other poly variant types to create a sum of all constructors: - - - -```res -type red = [#Ruby | #Redwood | #Rust] -type blue = [#Sapphire | #Neon | #Navy] - -// Contains all constructors of red and blue. -// Also adds #Papayawhip -type color = [red | blue | #Papayawhip] - -let myColor: color = #Ruby -``` - -```js -var myColor = "Ruby"; -``` - - - -There's also some special [pattern matching](./pattern-matching-destructuring) syntax to match on constructors defined in a specific poly variant type: - - - -```res -// Continuing the previous example above... - -switch myColor { -| #...blue => Console.log("This blue-ish") -| #...red => Console.log("This red-ish") -| other => Console.log2("Other color than red and blue: ", other) -} -``` - -```js -var other = myColor; - -if (other === "Neon" || other === "Navy" || other === "Sapphire") { - console.log("This is blue-ish"); -} else if (other === "Rust" || other === "Ruby" || other === "Redwood") { - console.log("This is red-ish"); -} else { - console.log("Other color than red and blue: ", other); -} -``` - - - -This is a shorter version of: - -```res -switch myColor { -| #Sapphire | #Neon | #Navy => Console.log("This is blue-ish") -| #Ruby | #Redwood | #Rust => Console.log("This is red-ish") -| other => Console.log2("Other color than red and blue: ", other) -} -``` - -## Structural Sharing - -Since poly variants value don't have a source of truth for their type, you can write such code: - - - -```res -type preferredColors = [#white | #blue] - -let myColor: preferredColors = #blue - -let displayColor = v => { - switch v { - | #red => "Hello red" - | #green => "Hello green" - | #white => "Hey white!" - | #blue => "Hey blue!" - } -} - -Console.log(displayColor(myColor)) -``` - -```js -var myColor = "blue"; - -function displayColor(v) { - if (v === "white") { - return "Hey white!"; - } else if (v === "red") { - return "Hello red"; - } else if (v === "green") { - return "Hello green"; - } else { - return "Hey blue!"; - } -} - -console.log(displayColor("blue")); -``` - - - -With a regular variant, the line `displayColor(myColor)` would fail, since it'd complain that the type of `myColor` doesn't match the type of `v`. No problem with poly variant. - -## JavaScript Output - -Poly variants are great for JavaScript interop! You can share their values to JS code, or model incoming JS values as poly variants. - -- `#red` and `#"I am red 😃"` compile to JavaScipt `"red"` and `"I am red 😃"`. -- `#1` compiles to JavaScript `1`. -- Poly variant constructor with 1 argument, like `Instagram("Jenny")` compile to a straightforward `{NAME: "Instagram", VAL: "Jenny"}`. 2 or more arguments like `#Facebook("Josh", 26)` compile to a similar object, but with `VAL` being an array of the arguments. - -### Bind to Functions - -For example, let's assume we want to bind to `Intl.NumberFormat` and want to make sure that our users only pass valid locales, we could define an external binding like this: - - - -```res -type t - -@scope("Intl") @val -external makeNumberFormat: ([#"de-DE" | #"en-GB" | #"en-US"]) => t = "NumberFormat" - -let intl = makeNumberFormat(#"de-DE") -``` - -```js -var intl = Intl.NumberFormat("de-DE"); -``` - - - -The JS output is identical to handwritten JS, but we also get to enjoy type errors if we accidentally write `makeNumberFormat(#"de-DR")`. - -More advanced usage examples for poly variant interop can be found in [Bind to JS Function](bind-to-js-function#constrain-arguments-better). - -### Bind to String Enums - -Let's assume we have a TypeScript module that expresses following enum export: - -```js -// direction.js -enum Direction { - Up = "UP", - Down = "DOWN", - Left = "LEFT", - Right = "RIGHT", -} - -export const myDirection = Direction.Up -``` - -For this particular example, we can also inline poly variant type definitions to design the type for the imported `myDirection` value: - - - -```res -type direction = [ #UP | #DOWN | #LEFT | #RIGHT ] -@module("./direction.js") external myDirection: direction = "myDirection" -``` - -```js -var DirectionJs = require("./direction.js"); - -var myDirection = DirectionJs.myDirection; -``` - - - -Again: since we were using poly variants, the JS Output is practically zero-cost and doesn't add any extra code! - -## Extra Constraints on Types - -The previous poly variant type annotations we've looked at are the regular "closed" kind. However, there's a way to express "I want at least these constructors" (lower bound) and "I want at most these constructors" (upper bound): - -```res -// Only #Red allowed. Closed. -let basic: [#Red] = #Red - -// May contain #Red, or any other value. Open -// here, foreground will actually be inferred as [> #Red | #Green] -let foreground: [> #Red] = #Green - -// The value must be, at most, one of #Red or #Blue -// Only #Red and #Blue are valid values -let background: [< #Red | #Blue] = #Red -``` - -**Note:** We added this info for educational purposes. In most cases you will not want to use any of this stuff, since it makes your APIs pretty unreadable / hard to use. - -### Closed `[` - -This is the simplest poly variant definition, and also the most practical one. Like a common variant type, this one defines an exact set of constructors. - -```res -type rgb = [ #Red | #Green | #Blue ] - -let color: rgb = #Green -``` - -In the example above, `color` will only allow one of the three constructors that are defined in the `rgb` type. This is usually the way how poly variants should be defined. - -In case you want to define a type that is extensible, you'll need to use the lower / upper bound syntax. - -### Lower Bound `[>` - -A lower bound defines the minimum set of constructors a poly variant type is aware of. It is also considered an "open poly variant type", because it doesn't restrict any additional values. - -Here is an example on how to make a minimum set of `basicBlueTones` extensible for a new `color` type: - -```res -type basicBlueTone<'a> = [> #Blue | #DeepBlue | #LightBlue ] as 'a -type color = basicBlueTone<[#Blue | #DeepBlue | #LightBlue | #Purple]> - -let color: color = #Purple - -// This will fail due to missing minimum constructors: -type notWorking = basicBlueTone<[#Purple]> -``` - -Here, the compiler will enforce the user to define `#Blue | #DeepBlue | #LightBlue` as the minimum set of constructors when trying to extend `basicBlueTone<'a>`. - -**Note:** Since we want to define an extensible poly variant, we need to provide a type placeholder `<'a>`, and also add `as 'a` after the poly variant declaration, which essentially means: "Given type `'a` is constraint to the minimum set of constructors (`#Blue | #DeepBlue | #LightBlue`) defined in `basicBlueTone`". - -### Upper Bound `[<` - -The upper bound works in the opposite way than a lower bound: the extending type may only use constructors that are stated in the upper bound constraint. - -Here another example, but with red colors: - -```res -type validRed<'a> = [< #Fire | #Crimson | #Ash] as 'a -type myReds = validRed<[#Ash]> - -// This will fail due to unlisted constructor not defined by the lower bound -type notWorking = validRed<[#Purple]> -``` - -## Coercion - -You can convert a poly variant to a `string` or `int` at no cost: - - - -```res -type company = [#Apple | #Facebook] -let theCompany: company = #Apple - -let message = "Hello " ++ (theCompany :> string) -``` - -```js -var theCompany = "Apple"; -var message = "Hello " + theCompany; -``` - - - -**Note**: for the coercion to work, the poly variant type needs to be closed; you'd need to annotate it, since otherwise, `theCompany` would be inferred as `[> #Apple]`. - -## Tips & Tricks - -### Variant vs Polymorphic Variant - -One might think that polymorphic variants are superior to regular [variants](./variant). As always, there are trade-offs: - -- Due to their "structural" nature, poly variant's type errors might be more confusing. If you accidentally write `#blur` instead of `#blue`, ReScript will still error but can't indicate the correct source as easily. Regular variants' source of truth is the type definition, so the error can't go wrong. -- It's also harder to refactor poly variants. Consider this: - - ```res - let myFruit = #Apple - let mySecondFruit = #Apple - let myCompany = #Apple - ``` - - Refactoring the first one to `#Orange` doesn't mean we should refactor the third one. Therefore, the editor plugin can't touch the second one either. Regular variant doesn't have such problem, as these 2 values presumably come from different variant type definitions. - -- You might lose some nice pattern match checks from the compiler: - - ```res - let myColor = #red - - switch myColor { - | #red => Console.log("Hello red!") - | #blue => Console.log("Hello blue!") - } - ``` - - Because there's no poly variant definition, it's hard to know whether the `#blue` case can be safely removed. - -In most scenarios, we'd recommend to use regular variants over polymorphic variants, especially when you are writing plain ReScript code. In case you want to write zero-cost interop bindings or generate clean JS output, poly variants are oftentimes a better option. diff --git a/pages/docs/manual/v11.0.0/primitive-types.mdx b/pages/docs/manual/v11.0.0/primitive-types.mdx deleted file mode 100644 index a0c96a950..000000000 --- a/pages/docs/manual/v11.0.0/primitive-types.mdx +++ /dev/null @@ -1,280 +0,0 @@ ---- -title: "Primitive Types" -description: "Primitive Data Types in ReScript" -canonical: "/docs/manual/v11.0.0/primitive-types" ---- - -# Primitive Types - -ReScript comes with the familiar primitive types like `string`, `int`, `float`, etc. - - - -## String - -ReScript `string`s are delimited using **double** quotes (single quotes are reserved for the character type below). - - - -```res example -let greeting = "Hello world!" -let multilineGreeting = "Hello - world!" -``` - -```js -var greeting = "Hello world!"; -var multilineGreeting = "Hello\n world!"; -``` - - - -To concatenate strings, use `++`: - - - -```res example -let greetings = "Hello " ++ "world!" -``` - -```js -var greetings = "Hello world!"; -``` - - - -### String Interpolation - -There's a special syntax for string that allows - -- multiline string just like before -- no special character escaping -- Interpolation - - - -```res example -let name = "Joe" - -let greeting = `Hello -World -👋 -${name} -` -``` - -```js -var name = "Joe"; - -var greeting = "Hello\nWorld\n👋\n" + name + "\n"; -``` - - - -This is just like JavaScript's backtick string interpolation, except without needing to escape special characters. - -### Usage - -See the familiar `String` API in the [API docs](api/core/string). Since a ReScript string maps to a JavaScript string, you can mix & match the string operations in all standard libraries. - -### Tips & Tricks - -**You have a good type system now!** In an untyped language, you'd often overload the meaning of string by using it as: - -- a unique id: `var BLUE_COLOR = "blue"` -- an identifier into a data structure: `var BLUE = "blue" var RED = "red" var colors = [BLUE, RED]` -- the name of an object field: `person["age"] = 24` -- an enum: `if (audio.canPlayType() === 'probably') {...}` [(ಠ_ಠ)](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType#Return_value) -- other crazy patterns you'll soon find horrible, after getting used to ReScript's alternatives. - -The more you overload the poor string type, the less the type system (or a teammate) can help you! ReScript provides concise, fast and maintainable types & data structures alternatives to the use-cases above (e.g. variants, in a later section). - -## Char - -ReScript has a type for a string with a single letter: - - - -```res example -let firstLetterOfAlphabet = 'a' -``` - -```js -var firstLetterOfAlphabet = /* "a" */ 97; -``` - - - -**Note**: Char doesn't support Unicode or UTF-8 and is therefore not recommended. - -To convert a String to a Char, use `OCamlCompat.String.get("a", 0)`. To convert a Char to a String, use `OCamlCompat.String.make(0, 'a')` or `String.fromCharCode('a' :> int)`. - -## Regular Expression - -ReScript regular expressions compile cleanly to their JavaScript counterpart: - - - -```res example -let r = %re("/b/g") -``` - -```js -var r = /b/g; -``` - - - -A regular expression like the above has the type `Re.t`. The [RegExp](api/core/regexp) module contains the regular expression helpers you have seen in JS. - -## Boolean - -A ReScript boolean has the type `bool` and can be either `true` or `false`. Common operations: - -- `&&`: logical and. -- `||`: logical or. -- `!`: logical not. -- `<=`, `>=`, `<`, `>` -- `==`: structural equal, compares data structures deeply. `(1, 2) == (1, 2)` is `true`. Convenient, but use with caution. -- `===`: referential equal, compares shallowly. `(1, 2) === (1, 2)` is `false`. `let myTuple = (1, 2); myTuple === myTuple` is `true`. -- `!=`: structural unequal. -- `!==`: referential unequal. - -ReScript's `true/false` compiles into a JavaScript `true/false`. - -## Integers - -32-bits, truncated when necessary. We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [Int](api/core/int) for helper functions. - -**Be careful when you bind to JavaScript numbers!** Since ReScript integers have a much smaller range than JavaScript numbers, data might get lost when dealing with large numbers. In those cases it’s much safer to bind the numbers as **float**. Be extra mindful of this when binding to JavaScript Dates and their epoch time. - -To improve readability, you may place underscores in the middle of numeric literals such as `1_000_000`. Note that underscores can be placed anywhere within a number, not just every three digits. - -## Floats - -Float requires other operators: `+.`, `-.`, `*.`, `/.`, etc. Like `0.5 +. 0.6`. See [Float](api/core/float) for helper functions. - -As with integers, you may use underscores within literals to improve readability. - -### Int-to-Float Coercion - -`int` values can be coerced to `float` with the `:>` (type coercion) operator. - - - -```res example -let result = (1 :> float) +. 2. -``` - -```js -var result = 1 + 2; -``` - - - -## Big Integers (experimental) - -**Since 11.1** - -For values which are too large to be represented by Int or Float, there is the `bigint` primitive type. -We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [BigInt](api/core/bigint) for helper functions. - -A `bigint` number is denoted by a trailing `n` like so: `42n`. - -As `bigint` is a different data type than `int`, it's necessary to open the corresponding module to overload the operators. - - - -```res example -open! BigInt - -let a = 9007199254740991n + 9007199254740991n -let b = 2n ** 2n -``` - -```js -var a = 9007199254740991n + 9007199254740991n; - -var p = 2n ** 2n; -``` - - - -It also supports all the bitwise operations, except unsigned shift right (`>>>`), which is not supported by JS itself for `bigint`s. - - - -```res example -open! BigInt - -let a = land(1n, 1n) -let b = lor(1n, 1n) -let c = lxor(1n, 1n) -let d = lnot(1n) -let e = lsl(1n, 1n) -let f = asr(1n, 1n) -``` - -```js -var Js_bigint = require("./stdlib/js_bigint.js"); - -var a = 1n & 1n; - -var b = 1n | 1n; - -var c = 1n ^ 1n; - -var d = Js_bigint.lnot(1n); - -var e = 1n << 1n; - -var f = 1n >> 1n; -``` - - - -It can also be pattern-matched. - - - -```res example -let bigintValue = 1n - -switch bigintValue { -| 1n => Console.log("Small bigint") -| 100n => Console.log("Larger bigint") -| _ => Console.log("Other bigint") -} -``` - -```js -if (1n !== 1n) { - if (1n !== 100n) { - console.log("Other bigint"); - } else { - console.log("Larger bigint"); - } -} else { - console.log("Small bigint"); -} - -var bigintValue = 1n; -``` - - - -## Unit - -The `unit` type indicates the absence of a specific value. It has only a single value, `()`, which acts as a placeholder when no other value exists or is needed. It compiles to JavaScript's `undefined` and resembles the `void` type in languages such as C++. What's the point of such a type? - -Consider the `Math.random` function. Its type signature is `unit => float`, which means it receives a `unit` as input and calculates a random `float` as output. You use the function like this - `let x = Math.random()`. Notice `()` as the first and only function argument. - -Imagine a simplified `Console.log` function that prints a message. Its type signature is `string => unit` and you'd use it like this `Console.log("Hello!")`. It takes a string as input, prints it, and then returns nothing useful. When `unit` is the output of a function it means the function performs some kind of side-effect. - -## Unknown - -The `unknown` type represents values with contents that are a mystery or are not 100% guaranteed to be what you think they are. It provides type-safety when interacting with data received from an untrusted source. For example, suppose an external function is supposed to return a `string`. It might. But if the documentation is not accurate or the code has bugs, the function could return `null`, an `array`, or something else you weren't expecting. - -The ReScript type system helps you avoid run-time crashes and unpredicatable behavior by preventing you from using `unknown` in places that expect a `string` or `int` or some other type. The ReScript core libraries also provide utility functions to help you inspect `unknown` values and access their contents. In some cases you may need a JSON parsing library to convert `unknown` values to types you can safely use. - -Consider using `unknown` when receiving data from [external JavaScript functions](/docs/manual/latest/bind-to-js-function) diff --git a/pages/docs/manual/v11.0.0/project-structure.mdx b/pages/docs/manual/v11.0.0/project-structure.mdx deleted file mode 100644 index 0e1ee94c6..000000000 --- a/pages/docs/manual/v11.0.0/project-structure.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Project Structure" -description: "Notes on project structure and other rough ReScript guidelines" -canonical: "/docs/manual/v11.0.0/project-structure" ---- - -# Project Structure - -These are the existing, non-codified community practices that are currently propagated through informal agreement. We might remove some of them at one point, and enforce some others. Right now, they're just recommendations for ease of newcomers. - -## File Casing - -Capitalized file names (aka first letter upper-cased). - -**Justification**: Module names can only be capitalized. Newcomers often ask how a file maps to a module, and why `draw.res` maps to the module `Draw`, and sometimes try to refer to a module through uncapitalized identifiers. Using `Draw.res` makes this mapping more straightforward. It also helps certain file names that'd be awkward in uncapitalized form: `uRI.res`. - -## Ignore `.merlin` File - -This is generated by the build system and you should not have to manually edit it. Don't check it into the repo. - -**Justification**: `.merlin` is for editor tooling. The file contains absolute paths, which are also not cross-platform (e.g. Windows paths are different). - -## Folders - -Try not to have too many nested folders. Keep your project flat, and have fewer files (reminder: you can use nested modules). - -**Justification**: The file system is a _tree_, but your code's dependencies are a _graph_. Because of that, any file & folder organization is usually imperfect. While it's still valuable to group related files together in a folder, the time wasted debating & getting decision paralysis over these far outweight their benefits. We'll always recommend you to Get Work Done instead of debating about these issues. - -## Third-party Dependencies - -Keep them to a minimum. - -**Justification**: A compiled, statically typed language cannot model its dependencies easily by muddling along like in a dynamic language, especially when we're still piggy-backing on NPM/Yarn (to reduce learning overhead in the medium-term). Keeping dependencies simple & lean helps reduce possibility of conflicts (e.g. two diamond dependencies, or clashing interfaces). - -## Documentation - -Have them. Spend more effort making them great (examples, pitfalls) and professional rather than _just_ fancy-looking. Do use examples, and avoid using names such as `foo` and `bar`. There's always more concrete names (it's an example, no need to be abstract/generalized just yet. The API docs will do this plentily). For blog posts, don't repeat the docs themselves, describe the _transition_ from old to new, and why (e.g. "it was a component, now it's a function, because ..."). - -**Justification**: It's hard for newcomers to distinguish between a simple/decent library and one that's fancy-looking. For the sake of the community, don't try too hard to one-up each other's libraries. Do spread the words, but use your judgement too. - -## PPX & Other Meta-tools - -Keep them to a minimum. PPX, unless used in renown cases (printer, accessors and serializer/deserializer generation), can cause big learning churn for newcomers; on top of the syntax, semantics, types, build tool & FFI that they already have to learn, learning per-library custom transformations of the code is an extra step. More invasive macros makes the code itself less semantically meaningful too, since the essence would be hiding somewhere else. - -## Paradigm - -Don't abuse overly fancy features. Do leave some breathing room for future APIs but don't over-architect things. - -**Justification**: Simple code helps newcomers understand and potentially contribute to your code. Contributing is the best way for them to learn. The extra help you receive might also surpass the gain of using a slightly more clever language trick. But do try new language tricks in some of more casual projects! You might discover new ways of architecting code. - -## Publishing - -If it's a wrapper for a JS library, don't publish the JS artifacts. If it's a legit library, publish the artifacts in lib/js if you think JS consumers might use it. This is especially the case when you gradually convert a JS lib to ReScript while not breaking existing JS consumers. - -Do put the keywords `"rescript"` in your package.json `keywords` field. This allows us to find the library much more easily for future purposes. - -**Justification**: Be nice to JS consumers of your library. They're your future ReScripters. diff --git a/pages/docs/manual/v11.0.0/promise.mdx b/pages/docs/manual/v11.0.0/promise.mdx deleted file mode 100644 index daa5ab8db..000000000 --- a/pages/docs/manual/v11.0.0/promise.mdx +++ /dev/null @@ -1,179 +0,0 @@ ---- -title: "Promises" -description: "JS Promise handling in ReScript" -canonical: "/docs/manual/v11.0.0/promise" ---- - -# Promise - -> **Note:** Starting from ReScript 10.1 and above, we recommend using [async / await](./async-await) when interacting with Promises. - -## `promise` type - -**Since 10.1** - -In ReScript, every JS promise is represented with the globally available `promise<'a>` type. For ReScript versions < 10.1, use its original alias `Js.Promise.t<'a>` instead. - -Here's a usage example in a function signature: - -```resi -// User.resi file - -type user = {name: string} - -let fetchUser: string => promise -``` - -To work with promise values (instead of using `async` / `await`) you may want to use the built-in `Promise` module. - -## Promise - -A builtin module to create, chain and manipulate promises. - -### Creating a promise - -```res -let p1 = Promise.make((resolve, reject) => { - // We use uncurried functions for resolve / reject - // for cleaner JS output without unintended curry calls - resolve("hello world") -}) - -let p2 = Promise.resolve("some value") - -// You can only reject `exn` values for streamlined catch handling -exception MyOwnError(string) -let p3 = Promise.reject(MyOwnError("some rejection")) -``` - -### Access the contents and transform a promise - -```res -let logAsyncMessage = () => { - open Promise - Promise.resolve("hello world") - ->then(msg => { - // then callbacks require the result to be resolved explicitly - resolve("Message: " ++ msg) - }) - ->then(msg => { - Console.log(msg) - - // Even if there is no result, we need to use resolve() to return a promise - resolve() - }) - ->ignore // Requires ignoring due to unhandled return value -} -``` - -For comparison, the `async` / `await` version of the same code would look like this: - -```res -let logAsyncMessage = async () => { - let msg = await Promise.resolve("hello world") - Console.log(`Message: ${msg}`) -} -``` - -Needless to say, the async / await version offers better ergonomics and less opportunities to run into type issues. - -### Handling Rejected Promises - -You can handle a rejected promise using the [`Promise.catch()`](./api/core/promise#value-catch) method, which allows you to catch and manage errors effectively. - -### Run multiple promises in parallel - -In case you want to launch multiple promises in parallel, use `Promise.all`: - - - -```res -@val -external fetchMessage: string => promise = "global.fetchMessage" - -let logAsyncMessage = async () => { - let messages = await Promise.all([fetchMessage("message1"), fetchMessage("message2")]) - - Console.log(messages->Array.joinWith(", ")) -} -``` - -```js -async function logAsyncMessage(param) { - var messages = await Promise.all([ - global.fetchMessage("message1"), - global.fetchMessage("message2"), - ]); - console.log(messages.join(", ")); -} - -export { logAsyncMessage }; -``` - - - -## Js.Promise module (legacy - do not use) - -> **Note:** The `Js.Promise` bindings are following the outdated data-last convention from a few years ago. We kept those APIs for backwards compatibility. Either use [`Promise`](api/core/promise) or a third-party promise binding instead. - -ReScript has built-in support for [JavaScript promises](api/js/promise). The 3 functions you generally need are: - -- `Js.Promise.resolve: 'a => Js.Promise.t<'a>` -- `Js.Promise.then_: ('a => Js.Promise.t<'b>, Js.Promise.t<'a>) => Js.Promise.t<'b>` -- `Js.Promise.catch: (Js.Promise.error => Js.Promise.t<'a>, Js.Promise.t<'a>) => Js.Promise.t<'a>` - -Additionally, here's the type signature for creating a promise on the ReScript side: - -```res -Js.Promise.make: ( - ( - ~resolve: (. 'a) => unit, - ~reject: (. exn) => unit - ) => unit -) => Js.Promise.t<'a> -``` - -This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](function.md#uncurried-function) (with a dot). `make` returns the created promise. - -### Usage - -Using the [pipe operator](pipe.md): - - - -```res example -let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2)) - -myPromise->Js.Promise.then_(value => { - Console.log(value) - Js.Promise.resolve(value + 2) -}, _)->Js.Promise.then_(value => { - Console.log(value) - Js.Promise.resolve(value + 3) -}, _)->Js.Promise.catch(err => { - Console.log2("Failure!!", err) - Js.Promise.resolve(-2) -}, _) -``` - -```js -var myPromise = new Promise(function (resolve, reject) { - return resolve(2); -}); - -myPromise - .then(function (value) { - console.log(value); - return Promise.resolve((value + 2) | 0); - }) - .then(function (value) { - console.log(value); - return Promise.resolve((value + 3) | 0); - }) - .catch(function (err) { - console.log("Failure!!", err); - return Promise.resolve(-2); - }); -``` - - diff --git a/pages/docs/manual/v11.0.0/record.mdx b/pages/docs/manual/v11.0.0/record.mdx deleted file mode 100644 index d074d2cda..000000000 --- a/pages/docs/manual/v11.0.0/record.mdx +++ /dev/null @@ -1,576 +0,0 @@ ---- -title: "Record" -description: "Record types in ReScript" -canonical: "/docs/manual/v11.0.0/record" ---- - -# Record - -Records are like JavaScript objects but: - -- are immutable by default -- have fixed fields (not extensible) - -## Type Declaration - -A record needs a mandatory type declaration: - - - -```res prelude -type person = { - age: int, - name: string, -} -``` - -```js -// Empty output -``` - - - -## Creation - -To create a `person` record (declared above): - - - -```res prelude -let me = { - age: 5, - name: "Big ReScript" -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -When you create a new record value, ReScript tries to find a record type declaration that conforms to the shape of the value. So the `me` value here is inferred as of type `person`. - -The type is found by looking above the `me` value. **Note**: if the type instead resides in another file or module, you need to explicitly indicate which file or module it is: - - - -```res example -// School.res -type person = {age: int, name: string} -``` - -```js -// Empty output -``` - - - - - -```res -// Example.res - -let me: School.person = {age: 20, name: "Big ReScript"} -/* or */ -let me2 = {School.age: 20, name: "Big ReScript"} -``` - -```js -var me = { - age: 20, - name: "Big ReScript", -}; -var me2 = { - age: 20, - name: "Big ReScript", -}; -``` - - - -In both `me` and `me2` the record definition from `School` is found. The first one, `me` with the regular type annotation, is preferred. - -## Access - -Use the familiar dot notation: - - - -```res example -let name = me.name -``` - -```js -var name = "Big ReScript"; -``` - - - -## Immutable Update - -New records can be created from old records with the `...` spread operator. The original record isn't mutated. - - - -```res example -let meNextYear = {...me, age: me.age + 1} -``` - -```js -var meNextYear = { - age: 21, - name: "Big ReScript", -}; -``` - - - -**Note**: spread cannot add new fields to the record value, as a record's shape is fixed by its type. - -## Mutable Update - -Record fields can optionally be mutable. This allows you to efficiently update those fields in-place with the `=` operator. - - - -```res example -type person = { - name: string, - mutable age: int -} - -let baby = {name: "Baby ReScript", age: 5} -baby.age = baby.age + 1 // `baby.age` is now 6. Happy birthday! -``` - -```js -var baby = { - name: "Baby ReScript", - age: 5, -}; - -baby.age = (baby.age + 1) | 0; -``` - - - -Fields not marked with `mutable` in the type declaration cannot be mutated. - -## JavaScript Output - -ReScript records compile to straightforward JavaScript objects; see the various JS output tabs above. - -## Optional Record Fields - -ReScript [`v10`](/blog/release-10-0-0#experimental-optional-record-fields) introduced optional record fields. This means that you can define fields that can be omitted when creating the record. It looks like this: - - - -```res example -type person = { - age: int, - name?: string -} -``` - -```js -// Empty output -``` - - - -Notice how `name` has a suffixed `?`. That means that the field itself is _optional_. - -### Creation - -You can omit any optional fields when creating a record. Not setting an optional field will default the field's value to `None`: - - - -```res example -type person = { - age: int, - name?: string -} - -let me = { - age: 5, - name: "Big ReScript" -} - -let friend = { - age: 7 -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; - -var friend = { - age: 7, -}; -``` - - - -This has consequences for pattern matching, which we'll expand a bit on soon. - -## Immutable Update - -Updating an optional field via an immutable update above lets you set that field value without needing to care whether it's optional or not. - - - -```res example -type person = { - age: int, - name?: string -} - -let me = { - age: 123, - name: "Hello" -} - -let withoutName = { - ...me, - name: "New Name" -} -``` - -```js -import * as Caml_obj from "./stdlib/caml_obj.js"; - -var me = { - age: 123, - name: "Hello", -}; - -var newrecord = Caml_obj.obj_dup(me); - -newrecord.name = "New Name"; - -var withoutName = newrecord; -``` - - - -However, if you want to set the field to an optional value, you prefix that value with `?`: - - - -```res example -type person = { - age: int, - name?: string -} - -let me = { - age: 123, - name: "Hello" -} - -let maybeName = Some("My Name") - -let withoutName = { - ...me, - name: ?maybeName -} -``` - -```js -import * as Caml_obj from "./stdlib/caml_obj.js"; - -var me = { - age: 123, - name: "Hello", -}; - -var maybeName = "My Name"; - -var newrecord = Caml_obj.obj_dup(me); - -newrecord.name = maybeName; - -var withoutName = newrecord; -``` - - - -You can unset an optional field's value via that same mechanism by setting it to `?None`. - -### Pattern Matching on Optional Fields - -[Pattern matching](pattern-matching-destructuring), one of ReScript's most important features, has two caveats when you deal with optional fields. - -When matching on the value directly, it's an `option`. Example: - - - -```res -type person = { - age: int, - name?: string, -} - -let me = { - age: 123, - name: "Hello", -} - -let isRescript = switch me.name { -| Some("ReScript") => true -| Some(_) | None => false -} -``` - -```js -var isRescript; - -isRescript = "Hello" === "ReScript" ? true : false; - -var me = { - age: 123, - name: "Hello", -}; -``` - - - -But, when matching on the field as part of the general record structure, it's treated as the underlying, non-optional value: - - - -```res -type person = { - age: int, - name?: string, -} - -let me = { - age: 123, - name: "Hello", -} - -let isRescript = switch me { -| {name: "ReScript"} => true -| _ => false -} - -``` - -```js -var isRescript; - -isRescript = "Hello" === "ReScript" ? true : false; - -var me = { - age: 123, - name: "Hello", -}; -``` - - - -Sometimes you _do_ want to know whether the field was set or not. You can tell the pattern matching engine about that by prefixing your option match with `?`, like this: - - - -```res -type person = { - age: int, - name?: string, -} - -let me = { - age: 123, - name: "Hello", -} - -let nameWasSet = switch me { -| {name: ?None} => false -| {name: ?Some(_)} => true -} -``` - -```js -var nameWasSet = true; - -var me = { - age: 123, - name: "Hello", -}; -``` - - - -## Record Type Spread - -In ReScript v11, you can now spread one or more record types into a new record type. It looks like this: - -```rescript -type a = { - id: string, - name: string, -} - -type b = { - age: int -} - -type c = { - ...a, - ...b, - active: bool -} -``` - -`type c` will now be: - -```rescript -type c = { - id: string, - name: string, - age: int, - active: bool, -} -``` - -Record type spreads act as a 'copy-paste' mechanism for fields from one or more records into a new record. This operation inlines the fields from the spread records directly into the new record definition, while preserving their original properties, such as whether they are optional or mandatory. It's important to note that duplicate field names are not allowed across the records being spread, even if the fields have the same type. - -## Record Type Coercion - -Record type coercion gives us more flexibility when passing around records in our application code. In other words, we can now coerce a record `a` to be treated as a record `b` at the type level, as long as the original record `a` contains the same set of fields in `b`. Here's an example: - -```rescript -type a = { - name: string, - age: int, -} - -type b = { - name: string, - age: int, -} - -let nameFromB = (b: b) => b.name - -let a: a = { - name: "Name", - age: 35, -} - -let name = nameFromB(a :> b) -``` - -Notice how we _coerced_ the value `a` to type `b` using the coercion operator `:>`. This works because they have the same record fields. This is purely at the type level, and does not involve any runtime operations. - -Additionally, we can also coerce records from `a` to `b` whenever `a` is a super-set of `b` (i.e. `a` containing all the fields of `b`, and more). The same example as above, slightly altered: - -```rescript -type a = { - id: string, - name: string, - age: int, - active: bool, -} - -type b = { - name: string, - age: int, -} - -let nameFromB = (b: b) => b.name - -let a: a = { - id: "1", - name: "Name", - age: 35, - active: true, -} - -let name = nameFromB(a :> b) -``` - -Notice how `a` now has more fields than `b`, but we can still coerce `a` to `b` because `b` has a subset of the fields of `a`. - -In combination with [optional record fields](/docs/manual/latest/record#optional-record-fields), one may coerce a mandatory field of an `option` type to an optional field: - -```rescript -type a = { - name: string, - - // mandatory, but explicitly typed as option - age: option, -} - -type b = { - name: string, - // optional field - age?: int, -} - -let nameFromB = (b: b) => b.name - -let a: a = { - name: "Name", - age: Some(35), -} - -let name = nameFromB(a :> b) -``` - -## Tips & Tricks - -### Record Types Are Found By Field Name - -With records, you **cannot** say "I'd like this function to take any record type, as long as they have the field `age`". The following **won't work as intended**: - - - -```res -type person = {age: int, name: string} -type monster = {age: int, hasTentacles: bool} - -let getAge = (entity) => entity.age -``` - -```js -function getAge(entity) { - return entity.age; -} -``` - - - -Instead, `getAge` will infer that the parameter `entity` must be of type `monster`, the closest record type with the field `age`. The following code's last line fails: - -```res -let kraken = {age: 9999, hasTentacles: true} -let me = {age: 5, name: "Baby ReScript"} - -getAge(kraken) -getAge(me) // type error! -``` - -The type system will complain that `me` is a `person`, and that `getAge` only works on `monster`. If you need such capability, use ReScript objects, described [here](object.md). - -### Optional Fields in Records Can Be Useful for Bindings - -Many JavaScript APIs tend to have large configuration objects that can be a bit annoying to model as records, since you previously always needed to specify all record fields when creating a record. - -Optional record fields, introduced in [`v10`](/blog/release-10-0-0#experimental-optional-record-fields), is intended to help with this. Optional fields will let you avoid having to specify all fields, and let you just specify the one's you care about. A significant improvement in ergonomics for bindings and other APIs with for example large configuration objects. - -## Design Decisions - -After reading the constraints in the previous sections, and if you're coming from a dynamic language background, you might be wondering why one would bother with record in the first place instead of straight using object, since the former needs explicit typing and doesn't allow different records with the same field name to be passed to the same function, etc. - -1. The truth is that most of the times in your app, your data's shape is actually fixed, and if it's not, it can potentially be better represented as a combination of variant (introduced next) + record instead. -2. Since a record type is resolved through finding that single explicit type declaration (we call this "nominal typing"), the type error messages end up better than the counterpart ("structural typing", like for tuples). This makes refactoring easier; changing a record type's fields naturally allows the compiler to know that it's still the same record, just misused in some places. Otherwise, under structural typing, it might get hard to tell whether the definition site or the usage site is wrong. diff --git a/pages/docs/manual/v11.0.0/reserved-keywords.mdx b/pages/docs/manual/v11.0.0/reserved-keywords.mdx deleted file mode 100644 index 3426a8c32..000000000 --- a/pages/docs/manual/v11.0.0/reserved-keywords.mdx +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: "Reserved Keywords" -description: "All reserved keywords in ReScript" -canonical: "/docs/manual/v11.0.0/reserved-keywords" ---- - -# Reserved Keywords - -> **Note**: Some of these words are reserved purely for backward compatibility. -> -> If you _need_ to use one of these names as binding and/or field name, see [Use Illegal Identifier Names](use-illegal-identifier-names.md). - -- `and` -- `as` -- `assert` - - - - - -- `constraint` - - - - -- `else` - - -- `exception` -- `external` - -* `false` -* `for` - - - - -- `if` -- `in` -- `include` - - - -* `lazy` -* `let` - -- `module` -- `mutable` - - - - - - -- `of` -- `open` - - - - - -- `rec` - - - - -- `switch` - - - -- `true` -- `try` -- `type` - - - - -- `when` -- `while` -- `with` diff --git a/pages/docs/manual/v11.0.0/scoped-polymorphic-types.mdx b/pages/docs/manual/v11.0.0/scoped-polymorphic-types.mdx deleted file mode 100644 index bbf506469..000000000 --- a/pages/docs/manual/v11.0.0/scoped-polymorphic-types.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: "Scoped Polymorphic Types" -description: "Scoped Polymorphic Types in ReScript" -canonical: "/docs/manual/v11.0.0/scoped-polymorphic-types" ---- - -# Scoped Polymorphic Types - -Scoped Polymorphic Types in ReScript are functions with the capability to handle arguments of any type within a specific scope. This feature is particularly valuable when working with JavaScript APIs, as it allows your functions to accommodate diverse data types while preserving ReScript's strong type checking. - -## Definition and Usage - -Scoped polymorphic types in ReScript offer a flexible and type-safe way to handle diverse data types within specific scopes. This documentation provides an example to illustrate their usage in a JavaScript context. - -### Example: Logging API - -Consider a logging example within a JavaScript context that processes various data types: - -```js -const logger = { - log: (data) => { - if (typeof data === "string") { - /* handle string */ - } else if (typeof data === "number") { - /* handle number */ - } else { - /* handle other types */ - } - }, -}; -``` - -In ReScript, we can bind to this function as a record with a scoped polymorphic function type: - -```res prelude -type logger = { log: 'a. 'a => unit } - -@module("jsAPI") external getLogger: unit => logger = "getLogger" -``` - -The `logger` type represents a record with a single field `log`, which is a scoped polymorphic function type `'a. 'a => unit`. The `'a` indicates a type variable that can be any type within the scope of the `log` function. - -Now, we can utilize the function obtained from `getLogger`: - - - -```res example -let myLogger = getLogger() - -myLogger.log("Hello, ReScript!") -myLogger.log(42) -``` - -```js -var myLogger = JsAPI.getLogger(); - -myLogger.log("Hello, ReScript!"); -myLogger.log(42); -``` - - - -In this example, we create an instance of the logger by calling `getLogger()`, and then we can use the `log` function on the `myLogger` object to handle different data types. - -## Limitations of Normal Polymorphic Types - -Let's consider the same logging example in ReScript, but this time using normal polymorphic types: - -```res -type logger<'a> = { log: 'a => unit} - -@module("jsAPI") external getLogger: unit => logger<'a> = "getLogger" -``` - -In this case, the `logger` type is a simple polymorphic function type `'a => unit`. However, when we attempt to use this type in the same way as before, we encounter an issue: - -```res -let myLogger = getLogger() - -myLogger.log("Hello, ReScript!") -myLogger.log(42) // Type error! -``` - -The problem arises because the type inference in ReScript assigns a concrete type to the `logger` function based on the first usage. In this example, after the first call to `myLogger`, the compiler infers the type `logger` for `myLogger`. Consequently, when we attempt to pass an argument of type `number` in the next line, a type error occurs because it conflicts with the inferred type `logger`. - -In contrast, scoped polymorphic types, such as `'a. 'a => unit`, overcome this limitation by allowing type variables within the scope of the function. They ensure that the type of the argument is preserved consistently within that scope, regardless of the specific value used in the first invocation. - -## Limitations of Scoped Polymorphic Types - -Scoped polymorphic types work only when they are directly applied to let-bindings or record fields (as demonstrated in the logger example above). They can neither be applied to function bodies, nor to separate type definitions: - -```res -exception Abort - -let testExn: 'a. unit => 'a = () => raise(Abort) // Works! - -let testExn2 = (): 'a. 'a = raise(Abort) // Syntax error! -type fn = 'a. 'a => unit // Syntax error! -``` diff --git a/pages/docs/manual/v11.0.0/shared-data-types.mdx b/pages/docs/manual/v11.0.0/shared-data-types.mdx deleted file mode 100644 index 59e2919d3..000000000 --- a/pages/docs/manual/v11.0.0/shared-data-types.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Shared Data Types" -description: "Data types that share runtime presentation between JS and ReScript" -canonical: "/docs/manual/v11.0.0/shared-data-types" ---- - -# Shared Data Types - -ReScript's built-in values of type `string`, `float`, `array` and a few others have a rather interesting property: they compile to the exact same value in JavaScript! - -This means that if you're passing e.g. a ReScript string to the JavaScript side, the JS side can directly use it as a native JS string. It also means that you can import a JS string and pretend it's a native ReScript string. - -Unlike most compiled-to-js languages, in ReScript, **you don't need to write data converters back and forth for most of our values**! - -**Shared, bidirectionally usable types**: - -- String. ReScript strings are JavaScript strings, vice-versa. (Caveat: only our backtick string `` `hello 👋 ${personName}` `` supports unicode and interpolation). -- Float. ReScript floats are JS numbers, vice-versa. -- Array. In addition to the [Array API](api/core/array), we provide our own [Belt.Array](api/belt/array#set) API too. -- Tuple. Compiles to a JS array. You can treat a fixed-sized, heterogenous JS array as ReScript tuple too. -- Boolean. -- Record. Record compiles to JS object. Therefore you can also treat JS objects as records. If they're too dynamic, consider modeling them on the ReScript side as a hashmap/dictionary [`Dict`](api/core/dict) or a ReScript object. -- Object. ReScript objects are JavaScript objects, vice-versa. -- Function. They compile to clean JS functions. -- Module. ReScript files are considered top-level modules, and are compiled to JS files 1 to 1. Nested modules are compiled to JavaScript objects. -- Polymorphic variants. -- Unit. The `unit` type, which has a single value `()`, compiles to `undefined` too. Likewise, you can treat an incoming JS `undefined` as `()` if that's the only value it'll ever be. - -**Types that are slightly different than JS, but that you can still use from JS**: - -- Int. **Ints are 32-bits**! Be careful, you can potentially treat them as JS numbers and vice-versa, but if the number's large, then you better treat JS numbers as floats. For example, we bind to `Date` using `float`s. -- Option. The `option` type's `None` value compiles into JS `undefined`. The `Some` value, e.g. `Some(5)`, compiles to `5`. Likewise, you can treat an incoming JS `undefined` as `None`. **JS `null` isn't handled here**. If your JS value can be `null`, use [Nullable](api/core/nullable) helpers. -- Exception. -- Variant. Check the compiled JavaScript output of variant to see its shape. We don't recommend exporting a ReScript variant for pure JS usage, since they're harder to read as plain JS code, but you can do it. -- List, which is just a regular variant. - -**Non-shared types (aka internal types)**: - -- Character. -- Int64. -- Lazy values. -- Everything else. - -Many of these are stable, which means that you can still serialize/deserialize them as-is without manual conversions. But we discourage actively peeking into their structure otherwise. - -These types require manual conversions if you want to export them for JS consumption. For a seamless JS/TypeScript integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand. diff --git a/pages/docs/manual/v11.0.0/tagged-templates.mdx b/pages/docs/manual/v11.0.0/tagged-templates.mdx deleted file mode 100644 index 752e04111..000000000 --- a/pages/docs/manual/v11.0.0/tagged-templates.mdx +++ /dev/null @@ -1,135 +0,0 @@ ---- -title: "Tagged templates" -description: "Using tagged templates in ReScript" -canonical: "/docs/manual/v11.0.0/tagged-templates" ---- - -# Tagged templates - -**Since 11.1** - -Tagged templates provide a special form of string interpolation, enabling the creation of template literals -where placeholders aren't restricted to strings. Moreover, the resulting output isn't confined solely to -strings either. You can take a look at the [JS documentation -about tagged templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) -to learn more about them. - -## Define a tag function - -Tag functions in ReScript have the following signature: - -```res -let myTagFunction : (array, array<'param>) => 'output -``` - -As you can see, you can have any type you want both for the placeholder array and for the output. - -Given how string interpolation works, you'll always have the following invariant: - -```res -Array.length(strings) == Array.length(placeholder) + 1 -``` - -Let's say you want to interpolate strings with all kind of builtin types and make it work inside React components, -you can define the following tag function: - - - -```res prelude -type params = - | I(int) - | F(float) - | S(string) - | Bool(bool) - -let s = (strings, parameters) => { - let text = Array.reduceWithIndex(parameters, Array.getUnsafe(strings, 0), ( - acc, - param, - i, - ) => { - let s = Array.getUnsafe(strings, i + 1) - let p = switch param { - | I(i) => Int.toString(i) - | F(f) => Float.toString(f) - | S(s) => s - | Bool(true) => "true" - | Bool(false) => "false" - } - acc ++ p ++ s - }) - React.string(text) -} -``` - -```js -import * as Core__Array from "./stdlib/core__Array.js"; - -function s(strings, parameters) { - return Core__Array.reduceWithIndex( - parameters, - strings[0], - function (acc, param, i) { - var s = strings[(i + 1) | 0]; - var p; - switch (param.TAG) { - case "I": - case "F": - p = param._0.toString(); - break; - case "S": - p = param._0; - break; - case "Bool": - p = param._0 ? "true" : "false"; - break; - } - return acc + p + s; - }, - ); -} -``` - - - -## Write tagged template literals - -Now that you have defined your tag function, you can use it this way: - - - -```res example -module Greetings = { - @react.component - let make = (~name, ~age) => { -
{s`hello ${S(name)} you're ${I(age)} year old!`}
- } -} -``` - -```js -function Greetings(props) { - return React.createElement( - "div", - undefined, - s( - ["hello ", " you're ", " year old!"], - [ - { - TAG: "S", - _0: props.name, - }, - { - TAG: "I", - _0: props.age, - }, - ], - ), - ); -} -``` - -
- -Pretty neat, isn't it? As you can see, it looks like any regular template literal but it accepts placeholders that are not strings -and it outputs something that is not a string either, a `React.element` in this case. diff --git a/pages/docs/manual/v11.0.0/try.mdx b/pages/docs/manual/v11.0.0/try.mdx deleted file mode 100644 index 8969401a3..000000000 --- a/pages/docs/manual/v11.0.0/try.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: "Try" -description: "Try ReScript via Command Line" -canonical: "/docs/manual/v11.0.0/try" ---- - -## Try Online - -Our [Playground](/try) lets you try ReScript online, and comes with the [ReScript React bindings](/docs/react/latest/introduction) and the new [ReScript Core](https://github.com/rescript-lang/rescript-core) standard library preinstalled. diff --git a/pages/docs/manual/v11.0.0/tuple.mdx b/pages/docs/manual/v11.0.0/tuple.mdx deleted file mode 100644 index c1d50e593..000000000 --- a/pages/docs/manual/v11.0.0/tuple.mdx +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: "Tuple" -description: "Tuple types and values in ReScript" -canonical: "/docs/manual/v11.0.0/tuple" ---- - -# Tuple - -Tuples are a ReScript-specific data structure that don't exist in JavaScript. They are: - -- immutable -- ordered -- fix-sized at creation time -- heterogeneous (can contain different types of values) - - - -```res example -let ageAndName = (24, "Lil' ReScript") -let my3dCoordinates = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -Tuples' types can be used in type annotations as well. Tuple types visually resemble tuples values. - - - -```res prelude -let ageAndName: (int, string) = (24, "Lil' ReScript") -// a tuple type alias -type coord3d = (float, float, float) -let my3dCoordinates: coord3d = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -**Note**: there's no tuple of size 1. You'd just use the value itself. - -## Usage - -To get a specific member of a tuple, destructure it: - - - -```res example -let (_, y, _) = my3dCoordinates // now you've retrieved y -``` - -```js -var y = 30.5; -``` - - - -The `_` means you're ignoring the indicated members of the tuple. - -Tuples aren't meant to be updated mutatively. You'd create new ones by destructuring the old ones: - - - -```res example -let coordinates1 = (10, 20, 30) -let (c1x, _, _) = coordinates1 -let coordinates2 = (c1x + 50, 20, 30) -``` - -```js -var coordinates1 = [10, 20, 30]; -var c1x = 10; -var coordinates2 = [60, 20, 30]; -``` - - - -## Tips & Tricks - -You'd use tuples in handy situations that pass around multiple values without too much ceremony. For example, to return many values: - - - -```res -let getCenterCoordinates = () => { - let x = doSomeOperationsHere() - let y = doSomeMoreOperationsHere() - (x, y) -} -``` - -```js -function getCenterCoordinates(param) { - var x = doSomeOperationsHere(undefined); - var y = doSomeMoreOperationsHere(undefined); - return [x, y]; -} -``` - - - -Try to keep the usage of tuple **local**. For data structures that are long-living and passed around often, prefer a **record**, which has named fields. diff --git a/pages/docs/manual/v11.0.0/type.mdx b/pages/docs/manual/v11.0.0/type.mdx deleted file mode 100644 index fb5e50754..000000000 --- a/pages/docs/manual/v11.0.0/type.mdx +++ /dev/null @@ -1,292 +0,0 @@ ---- -title: "Type" -description: "Types and type definitions in ReScript" -canonical: "/docs/manual/v11.0.0/type" ---- - -# Type - -Types are the highlight of ReScript! They are: - -- **Strong**. A type can't change into another type. In JavaScript, your variable's type might change when the code runs (aka at runtime). E.g. a `number` variable might change into a `string` sometimes. This is an anti-feature; it makes the code much harder to understand when reading or debugging. -- **Static**. ReScript types are erased after compilation and don't exist at runtime. Never worry about your types dragging down performance. You don't need type info during runtime; we report all the information (especially all the type errors) during compile time. Catch the bugs earlier! -- **Sound**. This is our biggest differentiator versus many other typed languages that compile to JavaScript. Our type system is guaranteed to **never** be wrong. Most type systems make a guess at the type of a value and show you a type in your editor that's sometime incorrect. We don't do that. We believe that a type system that is sometime incorrect can end up being dangerous due to expectation mismatches. -- **Fast**. Many developers underestimate how much of their project's build time goes into type checking. Our type checker is one of the fastest around. -- **Inferred**. You don't have to write down the types! ReScript can deduce them from their values. Yes, it might seem magical that we can deduce all of your program's types, without incorrectness, without your manual annotation, and do so quickly. Welcome to ReScript =). - -The following sections explore more of our type system. - -## Inference - -This let-binding doesn't contain any written type: - - - -```res example -let score = 10 -let add = (a, b) => a + b -``` - -```js -var score = 10; -function add(a, b) { - return (a + b) | 0; -} -``` - - - -ReScript knows that `score` is an `int`, judging by the value `10`. This is called **inference**. Likewise, it also knows that the `add` function takes 2 `int`s and returns an `int`, judging from the `+` operator, which works on ints. - -## Type Annotation - -But you can also optionally write down the type, aka annotate your value: - - - -```res example -let score: int = 10 -``` - -```js -var score = 10; -``` - - - -If the type annotation for `score` doesn't correspond to our inferred type for it, we'll show you an error during compilation time. We **won't** silently assume your type annotation is correct, unlike many other languages. - -You can also wrap any expression in parentheses and annotate it: - - - -```res -let myInt = 5 -let myInt: int = 5 -let myInt = (5: int) + (4: int) -let add = (x: int, y: int) : int => x + y -let drawCircle = (~radius as r: int): circleType => /* code here */ -``` - -```js -var myInt = 9; -function add(x, y) { - return (x + y) | 0; -} -function drawCircle(r) { - /* code here */ -} -``` - - - -Note: in the last line, `(~radius as r: int)` is a labeled argument. More on this in the [function](function.md) page. - -## Type Alias - -You can refer to a type by a different name. They'll be equivalent: - - - -```res example -type scoreType = int -let x: scoreType = 10 -``` - -```js -var x = 10; -``` - - - -## Type Parameter (Aka Generic) - -Types can accept parameters, akin to generics in other languages. The parameters' names **need** to start with `'`. - -The use-case of a parameterized type is to kill duplications. Before: - - - -```res example -// this is a tuple of 3 items, explained next -type intCoordinates = (int, int, int) -type floatCoordinates = (float, float, float) - -let a: intCoordinates = (10, 20, 20) -let b: floatCoordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -After: - - - -```res example -type coordinates<'a> = ('a, 'a, 'a) - -let a: coordinates = (10, 20, 20) -let b: coordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -Note that the above codes are just contrived examples for illustration purposes. Since the types are inferred, you could have just written: - - - -```res example -let buddy = (10, 20, 20) -``` - -```js -var buddy = [10, 20, 20]; -``` - - - -The type system infers that it's a `(int, int, int)`. Nothing else needed to be written down. - -Type arguments appear in many places. Our `array<'a>` type is such a type that requires a type parameter. - - - -```res example -// inferred as `array` -let greetings = ["hello", "world", "how are you"] -``` - -```js -// inferred as `array` -var greetings = ["hello", "world", "how are you"]; -``` - - - -If types didn't accept parameters, the standard library would need to define the types `arrayOfString`, `arrayOfInt`, `arrayOfTuplesOfInt`, etc. That'd be tedious. - -Types can receive many arguments, and be composable. - - - - - -```res example -type result<'a, 'b> = - | Ok('a) - | Error('b) - -type myPayload = {data: string} - -type myPayloadResults<'errorType> = array> - -let payloadResults: myPayloadResults = [ - Ok({data: "hi"}), - Ok({data: "bye"}), - Error("Something wrong happened!") -] -``` - -```js -var payloadResults = [ - { - TAG: /* Ok */ 0, - _0: { data: "hi" }, - }, - { - TAG: /* Ok */ 0, - _0: { data: "bye" }, - }, - { - TAG: /* Error */ 1, - _0: "Something wrong happened!", - }, -]; -``` - - - -## Recursive Types - -Just like a function, a type can reference itself within itself using `rec`: - - - -```res example -type rec person = { - name: string, - friends: array -} -``` - -```js -// Empty output -``` - - - -## Mutually Recursive Types - -Types can also be _mutually_ recursive through `and`: - - - -```res example -type rec student = {taughtBy: teacher} -and teacher = {students: array} -``` - -```js -// Empty output -``` - - - -## Type Escape Hatch - -ReScript's type system is robust and does not allow dangerous, unsafe stuff like implicit type casting, randomly guessing a value's type, etc. However, out of pragmatism, we expose a single escape hatch for you to "lie" to the type system: - - - -```res -external myShadyConversion: myType1 => myType2 = "%identity" -``` - -```js -// Empty output -``` - - - -This declaration converts a `myType1` of your choice to `myType2` of your choice. You can use it like so: - - - -```res example -external convertToFloat : int => float = "%identity" -let age = 10 -let gpa = 2.1 +. convertToFloat(age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - - -Obviously, do **not** abuse this feature. Use it tastefully when you're working with existing, overly dynamic JS code, for example. - -More on externals [here](external.md). - -**Note**: this particular `external` is the only one that isn't preceded by a `@` [attribute](attribute.md). diff --git a/pages/docs/manual/v11.0.0/typescript-integration.mdx b/pages/docs/manual/v11.0.0/typescript-integration.mdx deleted file mode 100644 index 0ec824217..000000000 --- a/pages/docs/manual/v11.0.0/typescript-integration.mdx +++ /dev/null @@ -1,282 +0,0 @@ ---- -title: "TypeScript" -description: "GenType - Interoperability between ReScript and TypeScript" -canonical: "/docs/manual/v11.0.0/typescript-integration" ---- - -# ReScript & TypeScript - -The ReScript compiler includes a code generation tool that lets you export ReScript values and types to use in TypeScript, and import TypeScript values and types into ReScript. It is called "genType". - -The implementation of genType performs a type-directed transformation of ReScript programs after compilation. The transformed programs operate on data types idiomatic to TypeScript. - -For example, a ReScript variant (which is represented as custom objects with tags at runtime): - -```res -@genType -type t = | A(int) | B(string) -``` - -is exported to a TypeScript type: - -```ts -type t = { TAG: "A"; _0: number } | { TAG: "B"; _0: string }; -``` - -## A Quick Example - -Let's assume we are working on a TypeScript codebase and we want to integrate a single ReScript function. - -We want to be able to import the function like any other one in our existing TypeScript code, but we also want to preserve all the ReScript types in the TypeScript type system. - -**That's exactly what genType was made for!** - -First we'll set up a function: - -```res -// src/Color.res - -@genType -type color = - | Red - | Blue - -@genType -let printColorMessage = (~color, ~message) => { - let prefix = switch color { - | Red => "\x1b[91m" - | Blue => "\x1b[94m" - } - let reset = "\x1b[0m" - - Console.log(prefix ++ message ++ reset) -} - -``` - -On a successful compile, `genType` will convert `src/Color.res` to a TypeScript file called `src/Color.gen.tsx` which will look something like this: - -```ts -// src/Color.gen.tsx - -/* TypeScript file generated from Color.res by genType. */ - -/* eslint-disable */ -/* tslint:disable */ - -import * as ColorJS from "./Color.res.js"; - -export type color = "Red" | "Blue"; - -export const printColorMessage: (color: color) => void = - ColorJS.printColorMessage as any; -``` - -genType automatically maps the `color` variant to TS via a string union type `"Red" | "Blue"`. - -Within our TypeScript application, we can now import and use the function in the following manner: - -```ts -// src/app.ts - -import { printColorMessage } from "./Color.gen.tsx"; - -printColorMessage("Red", "Hello, genType!"); -``` - -## Exporting an entire module - -_Since ReScript `11.0.0`_ modules can be annotated with `@genType` as well. In that case, all types and values of the module will be converted to TS types. Example: - - - -```res example -@genType -module Size = { - type t = - | Small - | Medium - | Large - - let getNum = (size: t) => - switch size { - | Small => 1. - | Medium => 5. - | Large => 10. - } -} -``` - -```ts -import * as MyCompBS__Es6Import from "./MyComp.res"; -const MyCompBS: any = MyCompBS__Es6Import; - -export type Size_t = "Small" | "Medium" | "Large"; - -export const Size_getNum: (size: Size_t) => number = MyCompBS.Size.getNum; - -export const Size: { getNum: (size: Size_t) => number } = MyCompBS.Size; -``` - - - -## Setup - -Add a `gentypeconfig` section to your `rescript.json` (See [Configuration](/docs/manual/latest/build-configuration#gentypeconfig) for details). - -Every `genType` powered project requires a configuration item `"gentypeconfig"` at top level in the project's `rescript.json`. - -The minimal configuration of genType is following: - -```json -{ - "gentypeconfig": { - "module": "esmodule", - "moduleResolution": "node", - "generatedFileExtension": ".gen.tsx" - } -} -``` - -And don't forget to make sure `allowJs` is set to `true` in the project's `tsconfig.json`: - -```json -{ - "compilerOptions": { - "allowJs": true - } -} -``` - -### TypeScript Module Resolutions - -Make sure to set the same `moduleResolution` value in both `rescript.json` and `tsconfig.json`, so that the output of genType is done with the preferred module resolution. - -For example if the TypeScript project uses JavaScript modules with `Node16` / `NodeNext` module resolution: - -```json -// tsconfig.json -{ - "compilerOptions": { - "moduleResolution": "node16" - } -} -``` - -Then `moduleResolution` in `gentypeconfig` should be same value: - -```json -// rescript.json -{ - "gentypeconfig": { - "moduleResolution": "node16" - } -} -``` - -In case of the TypeScript project using `Bundler` module resolution, `allowImportingTsExtensions` should also be `true`: - -```json -// tsconfig.json -{ - "compilerOptions": { - "moduleResolution": "bundler", - "allowImportingTsExtensions": true - } -} -``` - -```json -// rescript.json -{ - "gentypeconfig": { - "moduleResolution": "bundler" - } -} -``` - -## Testing the Whole Setup - -Open any relevant `*.res` file and add `@genType` annotations to any bindings / values / functions to be used from JavaScript. If an annotated value uses a type, the type must be annotated too. See e.g. [Hooks.res](https://github.com/rescript-lang/rescript/blob/master/tests/gentype_tests/typescript-react-example/src/Hooks.res). - -Save the file and rebuild the project via `npm run res:build` or similar. You should now see a `*.gen.tsx` file with the same name (e.g. `MyComponent.res` -> `MyComponent.gen.tsx`). - -Any values exported from `MyComponent.res` can then be imported from TypeScript. For example: - -```js -import MyComponent from "./components/MyComponent.gen.tsx"; -``` - -## Experimental features - -These features are for experimentation only. They could be changed/removed any time, and not be considered breaking changes. - -- Export object and record types as interfaces. To activate, add `"exportInterfaces": true` to the configuration. The types are also renamed from `name` to `Iname`. - -## Shims - -A shim is a TS file that provides user-provided definitions for library types. - -Required only if one needs to export certain basic ReScript data types to JS when one cannot modify the sources to add annotations (e.g. exporting ReScript lists), and if the types are not first-classed in genType. - -- Example: `Array` with format: `"RescriptModule=JavaScriptModule"` - -Configure your shim files within `"gentypeconfig"` in your [`rescript.json`]: - -```json -{ - "gentypeconfig": { - "shims": { - "Js": "Js", - "ReactEvent": "ReactEvent", - "RescriptPervasives": "RescriptPervasives", - "ReasonReact": "ReactShim" - } - } -} -``` - -and add relevant `.shim.ts` files in a directory which is visible by ReScript e.g. - -``` -├── rescript.json -├── src -│ ├── shims -│ │ ├── Js.shim.ts -│ │ ├── ReactEvent.shim.ts -│ │ └── RescriptPervasives.shim.ts -``` - -Here are some examples: - -```ts -// Excerpt from https://github.com/rescript-lang/rescript/blob/master/tests/gentype_tests/typescript-react-example/src/shims/Js.shim.ts -export type Json_t = unknown; -export type t = unknown; -``` - -```ts -// Excerpt from https://github.com/rescript-lang/rescript/tree/master/tests/gentype_tests/typescript-react-example/src/shims/JsxEvent.shim.ts -export type inputFocusEvent = React.FocusEvent; -``` - -More complete example shims can be found [here](https://github.com/rescript-lang/rescript/blob/master/tests/gentype_tests/typescript-react-example/src/shims/). - -## Deprecated features - -Features related to generating runtimes were deprecated since v11 and should no longer be used. - -- **`@genType("alias")`** and **`@genType.as("alias")`** -- **`@genType.opaque`** -- **`@genType.import`** -- TypeScript Shims - -genType does not generate anything runtime-related, and in the near future it generates definition files (`*.d.ts`) directly (See the [roadmap](https://github.com/rescript-lang/rescript/issues/6196)). - -If any runtime code is required for interoperability with JavaScript / TypeScript projects, it can be written by hand, or request a relevant features (e.g. `@deriving`) to the compiler. - -## Limitations - -- **in-source = true**. Currently only supports ReScript projects with [in-source generation](/docs/manual/latest/build-configuration#package-specs) and file suffixes that end on `.js`, like `.res.js` or `.bs.js`. - -- **Limited namespace support**. Currently there's limited [namespace](/docs/manual/latest/build-configuration#name-namespace) support, and only `namespace:true` is possible, not e.g. `namespace:"custom"`. diff --git a/pages/docs/manual/v11.0.0/use-illegal-identifier-names.mdx b/pages/docs/manual/v11.0.0/use-illegal-identifier-names.mdx deleted file mode 100644 index 3d0179f94..000000000 --- a/pages/docs/manual/v11.0.0/use-illegal-identifier-names.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: "Use Illegal Identifier Names" -description: "Handling (JS) naming collisions in ReScript" -canonical: "/docs/manual/v11.0.0/use-illegal-identifier-names" ---- - -# Use Illegal Identifier Names - -Sometime, for e.g. a let binding or a record field, you might want to use: - -- A capitalized name. -- A name that contains illegal characters (e.g. emojis, hyphen, space). -- A name that's one of ReScript's reserved keywords. - -We provide an escape hatch syntax for these cases: - - - -```res example -let \"my-🍎" = 10 - -type element = { - \"aria-label": string -} - -let myElement = { - \"aria-label": "close" -} - -let label = myElement.\"aria-label" - -let calculate = (~\"Props") => { - \"Props" + 1 -} -``` - -```js -var my$$unknown$unknown$unknown$unknown = 10; - -var myElement = { - "aria-label": "close", -}; - -var label = myElement["aria-label"]; - -function calculate(Props) { - return (Props + 1) | 0; -} -``` - - - -See the output. **Use them only when necessary**, for interop with JavaScript. This is a last-resort feature. If you abuse this, many of the compiler guarantees will go away. diff --git a/pages/docs/manual/v11.0.0/variant.mdx b/pages/docs/manual/v11.0.0/variant.mdx deleted file mode 100644 index ac20c36d8..000000000 --- a/pages/docs/manual/v11.0.0/variant.mdx +++ /dev/null @@ -1,837 +0,0 @@ ---- -title: "Variant" -description: "Variant data structures in ReScript" -canonical: "/docs/manual/v11.0.0/variant" ---- - -# Variant - -So far, most of ReScript's data structures might look familiar to you. This section introduces an extremely important, and perhaps unfamiliar, data structure: variant. - -Most data structures in most languages are about "this **and** that". A variant allows us to express "this **or** that". - - - -```res example -type myResponse = - | Yes - | No - | PrettyMuch - -let areYouCrushingIt = Yes -``` - -```js -var areYouCrushingIt = "Yes"; -``` - - - -`myResponse` is a variant type with the cases `Yes`, `No` and `PrettyMuch`, which are called "variant constructors" (or "variant tag"). The `|` bar separates each constructor. - -**Note**: a variant's constructors need to be capitalized. - -## Variant Needs an Explicit Definition - -If the variant you're using is in a different file, bring it into scope like you'd do [for a record](record.md#record-needs-an-explicit-definition): - - - -```res example -// Zoo.res -type animal = Dog | Cat | Bird -``` - -```js -// Empty output -``` - - - - - -```res -// Example.res -let pet: Zoo.animal = Dog // preferred -// or -let pet2 = Zoo.Dog -``` - -```js -var pet = "Dog"; -var pet2 = "Dog"; -``` - - - -## Constructor Arguments - -A variant's constructors can hold extra data separated by comma. - - - -```res prelude -type account = - | None - | Instagram(string) - | Facebook(string, int) -``` - -```js -// Empty output -``` - - - -Here, `Instagram` holds a `string`, and `Facebook` holds a `string` and an `int`. Usage: - - - -```res example -let myAccount = Facebook("Josh", 26) -let friendAccount = Instagram("Jenny") -``` - -```js -var myAccount = { - TAG: "Facebook", - _0: "Josh", - _1: 26, -}; -var friendAccount = { - TAG: "Instagram", - _0: "Jenny", -}; -``` - - - -### Labeled Variant Payloads (Inline Record) - -If a variant payload has multiple fields, you can use a record-like syntax to label them for better readability: - - - -```res example -type user = - | Number(int) - | Id({name: string, password: string}) - -let me = Id({name: "Joe", password: "123"}) -``` - -```js -var me = { - TAG: "Id", - name: "Joe", - password: "123", -}; -``` - - - -This is technically called an "inline record", and only allowed within a variant constructor. You cannot inline a record type declaration anywhere else in ReScript. - -Of course, you can just put a regular record type in a variant too: - - - -```res example -type u = {name: string, password: string} -type user = - | Number(int) - | Id(u) - -let me = Id({name: "Joe", password: "123"}) -``` - -```js -var me = { - TAG: "Id", - _0: { - name: "Joe", - password: "123", - }, -}; -``` - - - -The output is slightly uglier and less performant than the former. - -## Variant Type Spreads - -Just like [with records](record#record-type-spread), it's possible to use type spreads to create new variants from other variants: - -```rescript -type a = One | Two | Three -type b = | ...a | Four | Five -``` - -Type `b` is now: - -```rescript -type b = One | Two | Three | Four | Five -``` - -Type spreads act as a 'copy-paste', meaning all constructors are copied as-is from `a` to `b`. Here are the rules for spreads to work: - -- You can't overwrite constructors, so the same constructor name can exist in only one place as you spread. This is true even if the constructors are identical. -- All variants and constructors must share the same runtime configuration - `@unboxed`, `@tag`, `@as` and so on. -- You can't spread types in recursive definitions. - -Note that you need a leading `|` if you want to use a spread in the first position of a variant definition. - -### Pattern Matching On Variant - -See the [Pattern Matching/Destructuring](pattern-matching-destructuring) section later. - -## JavaScript Output - -A variant value compiles to 3 possible JavaScript outputs depending on its type declaration: - -- If the variant value is a constructor with no payload, it compiles to a string of the constructor name. Example: `Yes` compiles to `"Yes"`. -- If it's a constructor with a payload, it compiles to an object with the field `TAG` and the field `_0` for the first payload, `_1` for the second payload, etc. The value of `TAG` is the constructor name as string by default, but note that the name of the `TAG` field as well as the string value used for each constructor name [can be customized](#tagged-variants). -- Labeled variant payloads (the inline record trick earlier) compile to an object with the label names instead of `_0`, `_1`, etc. The object will have the `TAG` field as per the previous rule. - -Check the output in these examples: - - - -```res example -type greeting = Hello | Goodbye -let g1 = Hello -let g2 = Goodbye - -type outcome = Good | Error(string) -let o1 = Good -let o2 = Error("oops!") - -type family = Child | Mom(int, string) | Dad (int) -let f1 = Child -let f2 = Mom(30, "Jane") -let f3 = Dad(32) - -type person = Teacher | Student({gpa: float}) -let p1 = Teacher -let p2 = Student({gpa: 99.5}) - -type s = {score: float} -type adventurer = Warrior(s) | Wizard(string) -let a1 = Warrior({score: 10.5}) -let a2 = Wizard("Joe") -``` - -```js -var g1 = "Hello"; - -var g2 = "Goodbye"; - -var o1 = "Good"; - -var o2 = { - TAG: "Error", - _0: "oops!", -}; - -var f1 = "Child"; - -var f2 = { - TAG: "Mom", - _0: 30, - _1: "Jane", -}; - -var f3 = { - TAG: "Dad", - _0: 32, -}; - -var p1 = "Teacher"; - -var p2 = { - TAG: "Student", - gpa: 99.5, -}; - -var a1 = { - TAG: "Warrior", - _0: { - score: 10.5, - }, -}; - -var a2 = { - TAG: "Wizard", - _0: "Joe", -}; -``` - - - -## Tagged variants - -- The `@tag` attribute lets you customize the discriminator (default: `TAG`). -- `@as` attributes control what each variant case is discriminated on (default: the variant case name as string). - -### Example: Binding to TypeScript enums - -```typescript -// direction.ts -/** Direction of the action. */ -enum Direction { - /** The direction is up. */ - Up = "UP", - - /** The direction is down. */ - Down = "DOWN", - - /** The direction is left. */ - Left = "LEFT", - - /** The direction is right. */ - Right = "RIGHT", -} - -export const myDirection = Direction.Up; -``` - -You can bind to the above enums like so: - -```rescript -/** Direction of the action. */ -type direction = - | /** The direction is up. */ - @as("UP") - Up - - | /** The direction is down. */ - @as("DOWN") - Down - - | /** The direction is left. */ - @as("LEFT") - Left - - | /** The direction is right. */ - @as("RIGHT") - Right - -@module("./direction.js") external myDirection: direction = "myDirection" -``` - -Now, this maps 100% to the TypeScript code, including letting us bring over the documentation strings so we get a nice editor experience. - -### String literals - -The same logic is easily applied to string literals from TypeScript, only here the benefit is even larger, because string literals have the same limitations in TypeScript that polymorphic variants have in ReScript: - -```typescript -// direction.ts -type direction = "UP" | "DOWN" | "LEFT" | "RIGHT"; -``` - -There's no way to attach documentation strings to string literals in TypeScript, and you only get the actual value to interact with. - -### Valid `@as` payloads - -Here's a list of everything you can put in the `@as` tag of a variant constructor: - -- A string literal: `@as("success")` -- An int: `@as(5)` -- A float: `@as(1.5)` -- True/false: `@as(true)` and `@as(false)` -- Null: `@as(null)` -- Undefined: `@as(undefined)` - -## Untagged variants - -With _untagged variants_ it is possible to mix types together that normally can't be mixed in the ReScript type system, as long as there's a way to discriminate them at runtime. For example, with untagged variants you can represent a heterogenous array: - -```rescript -@unboxed type listItemValue = String(string) | Boolean(bool) | Number(float) - -let myArray = [String("Hello"), Boolean(true), Boolean(false), Number(13.37)] -``` - -Here, each value will be _unboxed_ at runtime. That means that the variant payload will be all that's left, the variant case name wrapping the payload itself will be stripped out and the payload will be all that remains. - -It, therefore, compiles to this JS: - -```javascript -var myArray = ["hello", true, false, 13.37]; -``` - -In the above example, reaching back into the values is as simple as pattern matching on them. - -### Advanced: Unboxing rules - -#### No overlap in constructors - -A variant can be unboxed if no constructors have overlap in their runtime representation. - -For example, you can't have `String1(string) | String2(string)` in the same unboxed variant, because there's no way for ReScript to know at runtime which of `String1` or `String2` that `string` belongs to, as it could belong to both. -The same goes for two records - even if they have fully different shapes, they're still JavaScript `object` at runtime. - -Don't worry - the compiler will guide you and ensure there's no overlap. - -#### What you can unbox - -Here's a list of all possible things you can unbox: - -- `string`: `String(string)` -- `float`: `Float(float)`. Note you can only have one of `float` or `int` because JavaScript only has `number` (not actually `int` and `float` like in ReScript) so we can't disambiguate between `float` and `int` at runtime. -- `int`: `Int(int)`. See note above on `float`. -- `bigint`: `BigInt(int)`. **Since 11.1** This is a distinct type from JavaScript's `number` type so you can use it beside either `float` or `int`. -- `bool`: `Boolean(bool)` -- `array<'value>`: `List(array)` -- `('a, 'b, 'c)`: `Tuple((string, int, bool))`. Any size of tuples works, but you can have only one case of array or tuple in a variant. -- `promise<'value>`: `Promise(promise)` -- `Dict.t`: `Object(Dict.t)` -- `Date.t`: `Date(Date.t)`. A JavaScript date. -- `Blob.t`: `Blob(Blob.t)`. A JavaScript blob. -- `File.t`: `File(File.t)`. A JavaScript file. -- `RegExp.t`: `RegExp(RegExp.t)`. A JavaScript regexp instance. - -Again notice that the constructor names can be anything, what matters is what's in the payload. - -> **Under the hood**: Untagged variants uses a combination of JavaScript `typeof` and `instanceof` checks to discern between unboxed constructors at runtime. This means that we could add more things to the list above detailing what can be unboxed, if there are useful enough use cases. - -### Pattern matching on unboxed variants - -Pattern matching works the same on unboxed variants as it does on regular variants. In fact, in the perspective of ReScript's type system there's no difference between untagged and tagged variants. You can do virtually the same things with both. That's the beauty of untagged variants - they're just variants to you as a developer. - -Here's an example of pattern matching on an unboxed nullable value that illustrates the above: - -```rescript -module Null = { - @unboxed type t<'a> = Present('a) | @as(null) Null -} - -type userAge = {ageNum: Null.t} - -type rec user = { - name: string, - age: Null.t, - bestFriend: Null.t, -} - -let getBestFriendsAge = user => - switch user.bestFriend { - | Present({age: Present({ageNum: Present(ageNum)})}) => Some(ageNum) - | _ => None - } -``` - -No difference to how you'd do with a regular variant. But, the runtime representation is different to a regular variant. - -> Notice how `@as` allows us to say that an untagged variant case should map to a specific underlying _primitive_. `Present` has a type variable, so it can hold any type. And since it's an unboxed type, only the payloads `'a` or `null` will be kept at runtime. That's where the magic comes from. - -### Decoding and encoding JSON idiomatically - -With untagged variants, we have everything we need to define a native JSON type: - -```rescript -@unboxed -type rec json = - | @as(null) Null - | Boolean(bool) - | String(string) - | Number(float) - | Object(Dict.t) - | Array(array) - -let myValidJsonValue = Array([String("Hi"), Number(123.)]) -``` - -Here's an example of how you could write your own JSON decoders easily using the above, leveraging pattern matching: - -```rescript -@unboxed -type rec json = - | @as(null) Null - | Boolean(bool) - | String(string) - | Number(float) - | Object(Dict.t) - | Array(array) - -type rec user = { - name: string, - age: int, - bestFriend: option, -} - -let rec decodeUser = json => - switch json { - | Object(userDict) => - switch ( - userDict->Dict.get("name"), - userDict->Dict.get("age"), - userDict->Dict.get("bestFriend"), - ) { - | (Some(String(name)), Some(Number(age)), Some(maybeBestFriend)) => - Some({ - name, - age: age->Float.toInt, - bestFriend: maybeBestFriend->decodeUser, - }) - | _ => None - } - | _ => None - } - -let decodeUsers = json => - switch json { - | Array(array) => array->Array.map(decodeUser)->Array.keepSome - | _ => [] - } -``` - -Encoding that same structure back into JSON is also easy: - -```rescript -let rec userToJson = user => Object( - Dict.fromArray([ - ("name", String(user.name)), - ("age", Number(user.age->Int.toFloat)), - ( - "bestFriend", - switch user.bestFriend { - | None => Null - | Some(friend) => userToJson(friend) - }, - ), - ]), -) - -let usersToJson = users => Array(users->Array.map(userToJson)) -``` - -This can be extrapolated to many more cases. - -### Advanced: Catch-all Constructors - -With untagged variants comes a rather interesting capability - catch-all cases are now possible to encode directly into a variant. - -Let's look at how it works. Imagine you're using a third party API that returns a list of available animals. You could of course model it as a regular `string`, but given that variants can be used as "typed strings", using a variant would give you much more benefit: - - -```rescript -type animal = Dog | Cat | Bird - -type apiResponse = { -animal: animal -} - -let greetAnimal = (animal: animal) => -switch animal { -| Dog => "Wof" -| Cat => "Meow" -| Bird => "Kashiiin" -} - -```` -```javascript -```` - - - -This is all fine and good as long as the API returns `"Dog"`, `"Cat"` or `"Bird"` for `animal`. -However, what if the API changes before you have a chance to deploy new code, and can now return `"Turtle"` as well? Your code would break down because the variant `animal` doesn't cover `"Turtle"`. - -So, we'll need to go back to `string`, loosing all of the goodies of using a variant, and then do manual conversion into the `animal` variant from `string`, right? -Well, this used to be the case before, but not anymore! We can leverage untagged variants to bake in handling of unknown values into the variant itself. - -Let's update our type definition first: - -```rescript -@unboxed -type animal = Dog | Cat | Bird | UnknownAnimal(string) -``` - -Notice we've added `@unboxed` and the constructor `UnknownAnimal(string)`. Remember how untagged variants work? You remove the constructors and just leave the payloads. This means that the variant above at runtime translates to this (made up) JavaScript type: - -``` -type animal = "Dog" | "Cat" | "Bird" | string -``` - -So, any string not mapping directly to one of the payloadless constructors will now map to the general `string` case. - -As soon as we've added this, the compiler complains that we now need to handle this additional case in our pattern match as well. Let's fix that: - - -```rescript -@unboxed -type animal = Dog | Cat | Bird | UnknownAnimal(string) - -type apiResponse = { -animal: animal -} - -let greetAnimal = (animal: animal) => -switch animal { -| Dog => "Wof" -| Cat => "Meow" -| Bird => "Kashiiin" -| UnknownAnimal(otherAnimal) => -`I don't know how to greet animal ${otherAnimal}` -} - -```` -```javascript -function greetAnimal(animal) { - if (!(animal === "Cat" || animal === "Dog" || animal === "Bird")) { - return "I don't know how to greet animal " + animal; - } - switch (animal) { - case "Dog" : - return "Wof"; - case "Cat" : - return "Meow"; - case "Bird" : - return "Kashiiin"; - - } -} -```` - - - -There! Now the external API can change as much as it wants, we'll be forced to write all code that interfaces with `animal` in a safe way that handles all possible cases. All of this baked into the variant definition itself, so no need for labor intensive manual conversion. - -This is useful in any scenario when you use something enum-style that's external and might change. Additionally, it's also useful when something external has a large number of possible values that are known, but where you only care about a subset of them. With a catch-all case you don't need to bind to all of them just because they can happen, you can safely just bind to the ones you care about and let the catch-all case handle the rest. - -## Coercion - -In certain situations, variants can be coerced to other variants, or to and from primitives. Coercion is always zero cost. - -### Coercing Variants to Other Variants - -You can coerce a variant to another variant if they're identical in runtime representation, and additionally if the variant you're coercing can be represented as the variant you're coercing to. - -Here's an example using [variant type spreads](#variant-type-spreads): - -```rescript -type a = One | Two | Three -type b = | ...a | Four | Five - -let one: a = One -let four: b = Four - -// This works because type `b` can always represent type `a` since all of type `a`'s constructors are spread into type `b` -let oneAsTypeB = (one :> b) -``` - -### Coercing Variants to Primitives - -Variants that are guaranteed to always be represented by a single primitive at runtime can be coerced to that primitive. - -It works with strings, the default runtime representation of payloadless constructors: - -```rescript -// Constructors without payloads are represented as `string` by default -type a = One | Two | Three - -let one: a = One - -// All constructors are strings at runtime, so you can safely coerce it to a string -let oneAsString = (one :> string) -``` - -If you were to configure all of your construtors to be represented as `int` or `float`, you could coerce to those too: - -```rescript -type asInt = | @as(1) One | @as(2) Two | @as(3) Three - -let oneInt: asInt = One -let toInt = (oneInt :> int) -``` - -### Advanced: Coercing `string` to Variant - -In certain situtations it's possible to coerce a `string` to a variant. This is an advanced technique that you're unlikely to need much, but when you do it's really useful. - -You can coerce a `string` to a variant when: - -- Your variant is `@unboxed` -- Your variant has a "catch-all" `string` case - -Let's look at an example: - -```rescript -@unboxed -type myEnum = One | Two | Other(string) - -// Other("Other thing") -let asMyEnum = ("Other thing" :> myEnum) - -// One -let asMyEnum = ("One" :> myEnum) -``` - -This works because the variant is unboxed **and** has a catch-all case. So, if you throw a string at this variant that's not representable by the payloadless constructors, like `"One"` or `"Two"`, it'll _always_ end up in `Other(string)`, since that case can represent any `string`. - -## Tips & Tricks - -**Be careful** not to confuse a constructor carrying 2 arguments with a constructor carrying a single tuple argument: - - - -```res example -type account = - | Facebook(string, int) // 2 arguments -type account2 = - | Instagram((string, int)) // 1 argument - happens to be a 2-tuple -``` - -```js -// Empty output -``` - - - -### Variants Must Have Constructors - -If you come from an untyped language, you might be tempted to try `type myType = int | string`. This isn't possible in ReScript; you'd have to give each branch a constructor: `type myType = Int(int) | String(string)`. The former looks nice, but causes lots of trouble down the line. - -### Interop with JavaScript - -_This section assumes knowledge about our JavaScript interop. Skip this if you haven't felt the itch to use variants for wrapping JS functions yet_. - -Quite a few JS libraries use functions that can accept many types of arguments. In these cases, it's very tempting to model them as variants. For example, suppose there's a `myLibrary.draw` JS function that takes in either a `number` or a `string`. You might be tempted to bind it like so: - - - -```res example -// reserved for internal usage -@module("myLibrary") external draw : 'a => unit = "draw" - -type animal = - | MyFloat(float) - | MyString(string) - -let betterDraw = (animal) => - switch animal { - | MyFloat(f) => draw(f) - | MyString(s) => draw(s) - } - -betterDraw(MyFloat(1.5)) -``` - -```js -var MyLibrary = require("myLibrary"); - -function betterDraw(animal) { - MyLibrary.draw(animal._0); -} - -betterDraw({ - TAG: "MyFloat", - _0: 1.5, -}); -``` - - - -**Try not to do that**, as this generates extra noisy output. Instead, use the `@unboxed` attribute to guide ReScript to generate more efficient code: - - - -```res example -// reserved for internal usage -@module("myLibrary") external draw : 'a => unit = "draw" - -@unboxed -type animal = - | MyFloat(float) - | MyString(string) - -let betterDraw = (animal) => - switch animal { - | MyFloat(f) => draw(f) - | MyString(s) => draw(s) - } - -betterDraw(MyFloat(1.5)) -``` - -```js -var MyLibrary = require("myLibrary"); - -function betterDraw(animal) { - MyLibrary.draw(animal); -} - -MyLibrary.draw(1.5); -``` - - - -Alternatively, define two `external`s that both compile to the same JS call: - - - -```res example -@module("myLibrary") external drawFloat: float => unit = "draw" -@module("myLibrary") external drawString: string => unit = "draw" -``` - -```js -// Empty output -``` - - - -ReScript also provides [a few other ways](bind-to-js-function.md#modeling-polymorphic-function) to do this. - -### Variant Types Are Found By Field Name - -Please refer to this [record section](record#tips--tricks). Variants are the same: a function can't accept an arbitrary constructor shared by two different variants. Again, such feature exists; it's called a polymorphic variant. We'll talk about this in the future =). - -## Design Decisions - -Variants, in their many forms (polymorphic variant, open variant, GADT, etc.), are likely _the_ feature of a type system such as ReScript's. The aforementioned `option` variant, for example, obliterates the need for nullable types, a major source of bugs in other languages. Philosophically speaking, a problem is composed of many possible branches/conditions. Mishandling these conditions is the majority of what we call bugs. **A type system doesn't magically eliminate bugs; it points out the unhandled conditions and asks you to cover them**\*. The ability to model "this or that" correctly is crucial. - -For example, some folks wonder how the type system can safely eliminate badly formatted JSON data from propagating into their program. They don't, not by themselves! But if the parser returns the `option` type `None | Some(actualData)`, then you'd have to handle the `None` case explicitly in later call sites. That's all there is. - -Performance-wise, a variant can potentially tremendously speed up your program's logic. Here's a piece of JavaScript: - -```js -let data = 'dog' -if (data === 'dog') { - ... -} else if (data === 'cat') { - ... -} else if (data === 'bird') { - ... -} -``` - -There's a linear amount of branch checking here (`O(n)`). Compare this to using a ReScript variant: - - - -```res example -type animal = Dog | Cat | Bird -let data = Dog -switch data { -| Dog => Console.log("Wof") -| Cat => Console.log("Meow") -| Bird => Console.log("Kashiiin") -} -``` - -```js -console.log("Wof"); - -var data = "Dog"; -``` - - - -The compiler sees the variant, then - -1. conceptually turns them into `type animal = "Dog" | "Cat" | "Bird"` -2. compiles `switch` to a constant-time jump table (`O(1)`). diff --git a/pages/docs/manual/v11.0.0/warning-numbers.mdx b/pages/docs/manual/v11.0.0/warning-numbers.mdx deleted file mode 100644 index 55eb1f04b..000000000 --- a/pages/docs/manual/v11.0.0/warning-numbers.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: "Warning Numbers" -description: "Available compiler warning numbers in ReScript" -canonical: "/docs/manual/v11.0.0/warning-numbers" ---- - -import { make as WarningTable } from "src/components/WarningTable.mjs"; - -# Warning Numbers - -You can configure which warnings the ReScript compiler generates -[in the build configuration](/docs/manual/latest/build-configuration#warnings) or -using the [`@warning()`](/syntax-lookup#expression-warning-decorator) or the [`@@warning()`](/syntax-lookup#module-warning-decorator) decorator. - - diff --git a/pages/docs/manual/v8.0.0/api.mdx b/pages/docs/manual/v8.0.0/api.mdx deleted file mode 100644 index 14dbdfb09..000000000 --- a/pages/docs/manual/v8.0.0/api.mdx +++ /dev/null @@ -1,15 +0,0 @@ -# Introduction - -We ship 3 modules in our standard library. - -- [Js](api/js): bindings for all your familiar JavaScript APIs. -- [Belt](api/belt): extra collections and helpers not available in JavaScript. -- [Dom](api/dom): Dom related types and modules. - -Usage heuristics: - -- Default to using the `Js` module. Most of the APIs in it are runtime-free and compile down to clean, readable JavaScript, which is our priority. -- For other APIs that aren't available in regular JavaScript (and thus don't exist in our `Js` bindings), use Belt. For example, prefer `Js.Array2` over `Belt.Array`. -- The `Dom` module contains our standardized types used by various userland DOM bindings. Due to the complexity of DOM, we don't mind that you ignore this module and build your application-specific DOM bindings. - -**Note**: we do not recommend other userland standard library alternatives (unless it's DOM bindings). These cause confusion and split points for the community. diff --git a/pages/docs/manual/v8.0.0/api/belt.mdx b/pages/docs/manual/v8.0.0/api/belt.mdx deleted file mode 100644 index 69a58a6fc..000000000 --- a/pages/docs/manual/v8.0.0/api/belt.mdx +++ /dev/null @@ -1,225 +0,0 @@ -# Belt - -The preferred standard library for Reason when targeting JavaScript -(browser, node, React Native). - -It is recommended to use the modules from Belt rather than from the -OCaml standard library or from the [Js](./js) namespace, e.g. use -[Belt.List](./belt/list) instead of `List` or [Js.List](./js/list) -and [Belt.Array](./belt/array) instead of `Array` or [Js.Array](./js/array). - -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.) - -## Motivation - -Belt aims to improve the user experience for Reason developers targeting -JavaScript as well as for JavaScript developers learning Reason, -since the original OCaml standard library was not written with JS in mind. - -To achieve this, Belt provides: - -- A consistent naming convention familiar to JS developers ([camelCase](https://en.wikipedia.org/wiki/Camel_case)) -- A consistent argument order familiar to JS Developers (see [Pipe First](#Pipe%20First)) -- Safety by default: A Belt function will never throw exceptions, unless it is - indicated explicitly in the function name (suffix "Exn"). -- Better performance and smaller code size running on the JS platform -- Ready for [Tree Shaking](https://webpack.js.org/guides/tree-shaking/) - -## Usage - -To use modules from Belt, either refer to them by their fully qualified name -(`Belt.List`, `Belt.Array` etc.) or open the `Belt` module by putting - -``` -open Belt; -``` - -at the top of your source files. After opening Belt this way, -`Array` will refer to `Belt.Array`, `List` will refer to `Belt.List` etc. -in the source code below. - -If you want to open Belt globally for all files in your project instead, -you can put - -``` - "bsc-flags": [ "-open Belt" ], -``` - -into your `bsconfig.json`. - -## Pipe First - -The argument order of Belt functions follows the "Data-First" convention. -I.e. the object they act on (e.g. a list or an array) will always be -the first argument. - -This way, the _pipe first operator_ `->` can be used nicely with the Belt APIs, -giving a similar feel to method invocations in OOP languages and allowing -easy chaining of Belt API calls. - -For more information about the data-first argument order and the -trade-offs compared to data-last, see -[this blog post](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/). - -Example: - -``` -let someNumbers = [|1, 1, 4, 2, 3, 6, 3, 4, 2|]; - -let greaterThan2UniqueAndSorted = - someNumbers - ->Belt.Array.keep(x => x > 2) - /* convert to and from set to make values unique */ - ->Belt.Set.Int.fromArray - ->Belt.Set.Int.toArray; /* output is already sorted */ - -Js.log2("result", greaterThan2UniqueAndSorted); -``` - -## Curried vs. Uncurried Callbacks - -For functions taking a callback parameter, there are usually two versions -available: - -- curried (no suffix) -- uncurried (suffixed with `U`) - -E.g.: - -``` -let forEach: (t('a), 'a => unit) => unit; - -let forEachU: (t('a), (. 'a) => unit) => unit; -``` - -The uncurried version will be faster in some cases, but for simplicity we -recommend to stick with the curried version unless you know -what you are doing and really need the optimization. - -The two versions can be invoked as follows: - -``` -["a", "b", "c"]->Belt.List.forEach(x => Js.log(x)); - -["a", "b", "c"]->Belt.List.forEachU((. x) => Js.log(x)); -``` - -## Specialized Collections - -For collections types like set or map, Belt provides both a generic module -as well as specialized, more efficient implementations for string and int keys. - -For example, Belt has the following set modules: - -- [Belt.Set](./belt/set) -- [Belt.Set.Int](./belt/set-int) -- [Belt.Set.String](./belt/set-string) - -## Implementation Details - -### Array access runtime safety - -One common confusion comes from the way Belt handles array access. It differs from than the default standard library's. - -```reason -let letters = [|"a", "b", "c"|]; -let a = letters[0]; /* a == "a" */ -let capitalA = Js.String.toUpperCase(a); -let k = letters[10]; /* Raises an exception! The 10th index doesn't exist. */ -``` - -Because Belt avoids exceptions and returns `options` instead, this code behaves differently: - -```reason -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 k = letters[10]; /* k == None */ -``` - -Although we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here: - -- Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`. -- The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`. -- `Belt.Array.get` returns values wrapped in options, so `letters[0] == Some("a")`. - -Fortunately, this is easy to fix: - -```reason example -open Belt; -let letters = [|"a", "b", "c"|]; -let a = letters[0]; - -/* Use a switch statement: */ -let capitalA = - switch(a) { - | Some(a) => Some(Js.String.toUpperCase(a)) - | None => None - }; - -/* Alternatively, use the Option module: */ -let capitalA = a->Option.map(Js.String.toUpperCase); - -let k = letters[10]; /* k == None */ -``` - -With that little bit of tweaking, our code now compiles successfully and is 100% free of runtime errors! - -### A special encoding for collection safety - -When we create a collection library for a custom data type we need a way to -provide a comparator function. Take Set for example, suppose its element type -is a pair of ints, it needs a custom compare function that takes two tuples and -returns their order. The Set could not just be typed as Set.t (int \* int) , its -customized compare function needs to manifest itself in the signature, -otherwise, if the user creates another customized compare function, the two -collection could mix which would result in runtime error. - -The original OCaml stdlib solved the problem using functor which creates a big -closure at runtime and makes dead code elimination much harder. We use a -phantom type to solve the problem: - -``` -module Comparable1 = - Belt.Id.MakeComparable( - { - type t = (int, int); - let cmp = ((a0, a1), (b0, b1)) => - switch (Pervasives.compare(a0, b0)) { - | 0 => Pervasives.compare(a1, b1) - | c => c - }; - } - ); - -let mySet1 = Belt.Set.make(~id=(module Comparable1)); - -module Comparable2 = - Belt.Id.MakeComparable( - { - type t = (int, int); - let cmp = ((a0, a1), (b0, b1)) => - switch (Pervasives.compare(a0, b0)) { - | 0 => Pervasives.compare(a1, b1) - | c => c - }; - } - ); - -let mySet2 = Belt.Set.make(~id=(module Comparable2)); -``` - -Here, the compiler would infer mySet1 and mySet2 having different type, so e.g. -a `merge` operation that tries to merge these two sets will correctly fail. - -``` -let mySet1: t((int, int), Comparable1.identity); -let mySet2: t((int, int), Comparable2.identity); -``` - -`Comparable1.identity` and `Comparable2.identity` are not the same using our -encoding scheme. diff --git a/pages/docs/manual/v8.0.0/api/belt/array.mdx b/pages/docs/manual/v8.0.0/api/belt/array.mdx deleted file mode 100644 index 4b04fc6df..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/array.mdx +++ /dev/null @@ -1,934 +0,0 @@ -# Array - - - -Utililites for `Array` functions. - - - -### Note about index syntax - -Code like `arr[0]` does _not_ compile to JavaScript `arr[0]`. ReScript transforms the `[]` index syntax into a function: `Array.get(arr, 0)`. By default, this uses the default standard library's `Array.get` function, which may raise an exception if the index isn't found. If you `open Belt`, it will use the `Belt.Array.get` function which returns options instead of raising exceptions. [See this for more information](../belt.mdx#array-access-runtime-safety). - -## length - -```re sig -let length: array('a) => int; -``` - -return the size of the array - -```re example -/* Returns 1 */ -Belt.Array.length([|"test"|]); -``` - -## size - -```re sig -let size: array('a) => int; -``` - -See Belt_Array.length - -## get - -```re sig -let get: (array('a), int) => option('a); -``` - -If `i <= 0 <= length(arr)` returns `Some(value)` where `value` is the item at index `i`. -If `i` is out of range returns `None` - -## getExn - -```re sig -let getExn: (array('a), int) => 'a; -``` - -Raise an exception if `i` is out of range. -Otherwise return the value at index `i` in `arr`. - -## getUnsafe - -```re sig -let getUnsafe: (array('a), int) => 'a; -``` - -Unsafe - -no bounds checking; this would cause type error if `i` does not stay within range - -## getUndefined - -```re sig -let getUndefined: (array('a), int) => Js.undefined('a); -``` - -It does the samething in the runtime as `Belt_Array.getUnsafe` it is type safe since the return type still track whether it is in range or not - -## set - -```re sig -let set: (array('a), int, 'a) => bool; -``` - -`set(arr, n, x);` modifies `arr` in place; it replaces the nth element of `arr` with `x`. - -Returns false means not updated due to out of range. - -## setExn - -```re sig -let setExn: (array('a), int, 'a) => unit; -``` - -`setExn(arr, i, x);` raise an exception if `i` is out of range. - -## setUnsafe - -```re sig -let setUnsafe: (array('a), int, 'a) => unit; -``` - -## shuffleInPlace - -```re sig -let shuffleInPlace: array('a) => unit; -``` - -`shuffleInPlace(arr)` randomly re-orders the items in `arr` - -## shuffle - -```re sig -let shuffle: array('a) => array('a); -``` - -Returns a fresh array with items in original array randomly shuffled. - -## reverseInPlace - -```re sig -let reverseInPlace: array('a) => unit; -``` - -`reverseInPlace(arr)` reverses items in `arr` in place. - -```re example -let arr = [|10, 11, 12, 13, 14|]; - -let () = Belt.Array.reverseInPlace(arr); - -arr == [|14, 13, 12, 11, 10|]; -``` - -## reverse - -```re sig -let reverse: array('a) => array('a); -``` - -`reverse(arr)` returns a fresh array with items in arr in reverse order. - -```re example -Belt.Array.reverse([|10, 11, 12, 13, 14|]) == [|14, 13, 12, 11, 10|]; -``` - -## makeUninitialized - -```re sig -let makeUninitialized: int => array(Js.undefined('a)); -``` - -`makeUninitialized(n)` creates an array of length `n` filled with the undefined value. You must specify the type of data that will eventually fill the array. - -```re example -let arr: array(Js.undefined(string)) = Belt.Array.makeUninitialized(5); - -Belt.Array.getExn(arr, 0) == Js.undefined; -``` - -## makeUninitializedUnsafe - -```re sig -let makeUninitializedUnsafe: int => array('a); -``` - -Unsafe - -```re example -let arr = Belt.Array.makeUninitializedUnsafe(5); - -let () = Js.log(Belt.Array.getExn(arr, 0)); /* undefined */ - -Belt.Array.setExn(arr, 0, "example"); - -let () = Js.log(Belt.Array.getExn(arr, 0) == "example"); -``` - -## make - -```re sig -let make: (int, 'a) => array('a); -``` - -`make(n, e)` return an array of size `n` filled with value `e`. -Returns an empty array when `n` is negative. - -## range - -```re sig -let range: (int, int) => array(int); -``` - -`range(start, finish);` create an inclusive array. - -```re example -Belt.Array.range(0, 3) == [|0, 1, 2, 3|]; - -Belt.Array.range(3, 0) == [||]; - -Belt.Array.range(3, 3) == [|3|]; -``` - -## rangeBy - -```re sig -let rangeBy: (int, int, ~step: int) => array(int); -``` - -`rangeBy(start, finish, ~step);` - -Returns empty array when step is 0 or negative. It also return an empty array when `start > finish`. - -```re example -Belt.Array.rangeBy(0, 10, ~step=3) == [|0, 3, 6, 9|]; - -Belt.Array.rangeBy(0, 12, ~step=3) == [|0, 3, 6, 9, 12|]; - -Belt.Array.rangeBy(33, 0, ~step=1) == [||]; - -Belt.Array.rangeBy(33, 0, ~step=-1) == [||]; - -Belt.Array.rangeBy(3, 12, ~step=-1) == [||]; - -Belt.Array.rangeBy(3, 3, ~step=0) == [||]; - -Belt.Array.rangeBy(3, 3, ~step=1) == [|3|]; -``` - -## makeByU - -```re sig -let makeByU: (int, [@bs] (int => 'a)) => array('a); -``` - -## makeBy - -```re sig -let makeBy: (int, int => 'a) => array('a); -``` - -`makeBy(n, f);` - -Return an empty array when n is negative return an array of size n populated by `f(i)` start from `0` to `n - 1`. - -```re example -Belt.Array.makeBy(5, (i) => i) == [|0, 1, 2, 3, 4|]; - -Belt.Array.makeBy(5, (i) => i * i) == [|0, 1, 4, 9, 16|]; -``` - -## makeByAndShuffleU - -```re sig -let makeByAndShuffleU: (int, [@bs] (int => 'a)) => array('a); -``` - -## makeByAndShuffle - -```re sig -let makeByAndShuffle: (int, int => 'a) => array('a); -``` - -`makeByAndShuffle(n, f);` - -Equivalent to `shuffle(makeBy(n, f));` - -## zip - -```re sig -let zip: (array('a), array('b)) => array(('a, 'b)); -``` - -`zip(a, b);` - -Create an array of pairs from corresponding elements of a and b. Stop with the shorter array. - -```re example -Belt.Array.zip([|1, 2|], [|3, 4, 5|]) == [|(1, 3), (2, 4)|] -``` - -## zipByU - -```re sig -let zipByU: (array('a), array('b), [@bs] (('a, 'b) => 'c)) => array('c); -``` - -## zipBy - -```re sig -let zipBy: (array('a), array('b), ('a, 'b) => 'c) => array('c); -``` - -`zipBy(xs, ys, f);` - -Create an array by applying `f` to corresponding elements of `xs` and `ys`. Stops with shorter array. - -Equivalent to `map(zip(xs, ys), ((a, b)) => f(a, b));` - -```re example -Belt.Array.zipBy([|1, 2, 3|], [|4, 5|], (a, b) => 2 * a + b) == [|6, 9|]; -``` - -## unzip - -```re sig -let unzip: array(('a, 'b)) => (array('a), array('b)); -``` - -`unzip(a);` takes an array of pairs and creates a pair of arrays. The first array contains all the first items of the pairs; the second array contains all the second items. - -```re example -Belt.Array.unzip([|(1, 2), (3, 4)|]) == ([|1, 3|], [|2, 4|]); - -Belt.Array.unzip([|(1, 2), (3, 4), (5, 6), (7, 8)|]) == ([|1, 3, 5, 7|], [|2, 4, 6, 8|]); -``` - -## concat - -```re sig -let concat: (array('a), array('a)) => array('a); -``` - -`concat(xs, ys);` - -Returns a fresh array containing the concatenation of the arrays `v1` and `v2`;so even if `v1` or `v2` is empty; it can not be shared - -```re example -Belt.Array.concat([|1, 2, 3|], [|4, 5|]) == [|1, 2, 3, 4, 5|]; - -Belt.Array.concat([||], [|"a", "b", "c"|]) == [|"a", "b", "c"|]; -``` - -## concatMany - -```re sig -let concatMany: array(array('a)) => array('a); -``` - -`concatMany(xss);` - -Returns a fresh array as the concatenation of `xss` (an array of arrays) - -```re example -Belt.Array.concatMany([|[|1, 2, 3|], [|4, 5, 6|], [|7, 8|]|]) == [|1, 2, 3, 4, 5, 6, 7, 8|]; -``` - -## slice - -```re sig -let slice: (array('a), ~offset: int, ~len: int) => array('a); -``` - -`slice(xs, offset, len);` creates a new array with the len elements of `xs` -starting at `offset` for `offset` can be negative;and is evaluated as -`length(xs) - offset(slice, xs) - 1(1);` means get the last element as a -singleton array `slice(xs, ~-len, len);` will return a copy of the array if the -array does not have enough data; `slice` extracts through the end of sequence. - -if `len` is negative; returns the empty array. - -```re example -Belt.Array.slice([|10, 11, 12, 13, 14, 15, 16|], ~offset=2, ~len=3) == [|12, 13, 14|]; - -Belt.Array.slice([|10, 11, 12, 13, 14, 15, 16|], ~offset=-4, ~len=3) == [|13, 14, 15|]; - -Belt.Array.slice([|10, 11, 12, 13, 14, 15, 16|], ~offset=4, ~len=9) == [|14, 15, 16|]; -``` - -## sliceToEnd - -```re sig -let sliceToEnd: (array('a), int) => array('a); -``` - -`sliceToEnd(xs, offset);` creates a new array with the elements of `xs` starting at `offset` - -`offset` can be negative; and is evaluated as `length(xs) - offset(sliceToEnd, xs) - 1;` means get the last element as a singleton array - -`sliceToEnd(xs, 0);` will return a copy of the array - -```re example -Belt.Array.sliceToEnd([|10, 11, 12, 13, 14, 15, 16|], 2) == [|12, 13, 14, 15, 16|]; - -Belt.Array.sliceToEnd([|10, 11, 12, 13, 14, 15, 16|], -4) == [|13, 14, 15, 16|]; -``` - -## copy - -```re sig -let copy: array('a) => array('a); -``` - -`copy(a);` - -Returns a copy of a; that is; a fresh array containing the same elements as a. - -## fill - -```re sig -let fill: (array('a), ~offset: int, ~len: int, 'a) => unit; -``` - -`fill(arr, ~offset, ~len, x);` - -Modifies `arr` in place, storing `x` in elements number `offset` to `offset + len - 1`. -`offset` can be negative; and is evaluated as `length(arr - offset);` - -`fill(arr, ~offset=-1, ~len=1);` means fill the last element, if the array does not have enough data; `fill` will ignore it - -```re example -let arr = Belt.Array.makeBy(5, (i) => i); - -Belt.Array.fill(arr, ~offset=2, ~len=2, 9); - -arr == [|0, 1, 9, 9, 4|]; - -Belt.Array.fill(arr, ~offset=7, ~len=2, 8); - -arr == [|0, 1, 9, 9, 4|]; -``` - -## blit - -```re sig -let blit: - ( - ~src: array('a), - ~srcOffset: int, - ~dst: array('a), - ~dstOffset: int, - ~len: int - ) => - unit; -``` - -`blit(~src=v1, ~srcOffset=o1, ~dst=v2, ~dstOffset=o2, ~len);` - -copies `len` elements from array `v1`;starting at element number `o1`;to array `v2`, starting at element number `o2`. - -It works correctly even if `v1` and `v2` are the same array;and the source and destination chunks overlap. - -`offset` can be negative; `-1` means `len - 1`; if `len + offset` is still negative;it will be set as 0 - -For each of the examples;presume that `v1 == [|10, 11, 12, 13, 14, 15, 16, 17|];` and `v2 == [|20, 21, 22, 23, 24, 25, 26, 27|];`. The result shown is the content of the destination array. - -```re example -let v1 = [|10, 11, 12, 13, 14, 15, 16, 17|]; -let v2 = [|20, 21, 22, 23, 24, 25, 26, 27|]; - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v2, ~dstOffset=2, ~len=3); -v2 == [|20, 21, 14, 15, 16, 25, 26, 27|]; - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v1, ~dstOffset=2, ~len=3); -v1 == [|10, 11, 14, 15, 16, 15, 16, 17|]; -``` - -## blitUnsafe - -```re sig -let blitUnsafe: (~src: array('a), ~srcOffset: int, ~dst: array('a), ~dstOffset: int, ~len: int) => unit; -``` - -Unsafe blit without bounds checking. - -## forEachU - -```re sig -let forEachU: (array('a), [@bs] ('a => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (array('a), 'a => unit) => unit; -``` - -`forEach(xs, f);` - -Call `f` on each element of `xs` from the beginning to end. `f` returns `unit`;so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects. - -```re example -Belt.Array.forEach([|"a", "b", "c"|], x => Js.log("Item: " ++ x)); - -/* prints: - Item: a - Item: b - Item: c - */ -let total = ref(0); - -Belt.Array.forEach([|1, 2, 3, 4|], x => total := total^ + x); - -total^ == 1 + 2 + 3 + 4; -``` - -## mapU - -```re sig -let mapU: (array('a), [@bs] ('a => 'b)) => array('b); -``` - -## map - -```re sig -let map: (array('a), 'a => 'b) => array('b); -``` - -`map(xs, f);` - -Returns a new array by calling `f` for each element of `xs` from the beginning to end. - -```re example -Belt.Array.map([|1, 2|], (x) => x + 1) == [|3, 4|]; -``` - -## getByU - -```re sig -let getByU: (array('a), [@bs] ('a => bool)) => option('a); -``` - -## getBy - -```re sig -let getBy: (array('a), 'a => bool) => option('a); -``` - -`getBy(xs, p);` - -Returns `Some(value)` for the first value in `xs` that satisifies the predicate function `p`; returns `None` if no element satisifies the function. - -```re example -Belt.Array.getBy([|1, 4, 3, 2|], (x) => x mod 2 == 0) == Some(4); -Belt.Array.getBy([|15, 13, 11|], (x) => x mod 2 == 0) == None; -``` - -## getIndexByU - -```re sig -let getIndexByU: (array('a), [@bs] ('a => bool)) => option(int); -``` - -## getIndexBy - -```re sig -let getIndexBy: (array('a), 'a => bool) => option(int); -``` - -`getIndexBy(xs, p);` - -returns `Some(index)` for the first value in `xs` that satisifies the predicate function `p`; -returns `None` if no element satisifies the function. - -```re example -Belt.Array.getIndexBy([|1, 4, 3, 2|], (x) => x mod 2 == 0) == Some(1); -Belt.Array.getIndexBy([|15, 13, 11|], (x) => x mod 2 == 0) == None; -``` - -## keepU - -```re sig -let keepU: (array('a), [@bs] ('a => bool)) => array('a); -``` - -## keep - -```re sig -let keep: (array('a), 'a => bool) => array('a); -``` - -`keep(xs, p);` - -Returns a new array that keep all elements satisfy `p`. - -```re example -Belt.Array.keep([|1, 2, 3|], (x) => x mod 2 == 0) == [|2|]; -``` - -## keepWithIndexU - -```re sig -let keepWithIndexU: (array('a), [@bs] (('a, int) => bool)) => array('a); -``` - -## keepWithIndex - -```re sig -let keepWithIndex: (array('a), ('a, int) => bool) => array('a); -``` - -`keepWithIndex(xs, p);` - -Returns a new array that keep all elements satisfy `p`. - -```re example -Belt.Array.keepWithIndex([|1, 2, 3|], (_x, i) => i == 1) == [|2|]; -``` - -## keepMapU - -```re sig -let keepMapU: (array('a), [@bs] ('a => option('b))) => array('b); -``` - -## keepMap - -```re sig -let keepMap: (array('a), 'a => option('b)) => array('b); -``` - -`keepMap(xs, p);` - -Returns a new array that keep all elements that return a non-None applied `p`. - -```re example -Belt.Array.keepMap([|1, 2, 3|], x => - if (x mod 2 == 0) { - Some(x); - } else { - None; - } -) -== [|2|]; -``` - -## forEachWithIndexU - -```re sig -let forEachWithIndexU: (array('a), [@bs] ((int, 'a) => unit)) => unit; -``` - -## forEachWithIndex - -```re sig -let forEachWithIndex: (array('a), (int, 'a) => unit) => unit; -``` - -`forEachWithIndex(xs, f);` - -The same as `Belt_Array.forEach`; -except that `f` is supplied two arguments: the index starting from 0 and the element from `xs`. - -```re example -Belt.Array.forEachWithIndex([|"a", "b", "c"|], (i, x) => Js.log("Item " ++ Belt.Int.toString(i) ++ " is " ++ x)); - -/* prints: - Item 0 is a - Item 1 is b - Item 2 is cc - */ -let total = ref(0); - -Belt.Array.forEachWithIndex([|10, 11, 12, 13|], (i, x) => total := total^ + x + i); - -total^ == 0 + 10 + 1 + 11 + 2 + 12 + 3 + 13; -``` - -## mapWithIndexU - -```re sig -let mapWithIndexU: (array('a), [@bs] ((int, 'a) => 'b)) => array('b); -``` - -## mapWithIndex - -```re sig -let mapWithIndex: (array('a), (int, 'a) => 'b) => array('b); -``` - -`mapWithIndex(xs, f);` - -`mapWithIndex(xs, f)` applies `f` to each element of `xs`. Function `f` takes two arguments: the index starting from 0 and the element from `xs`. - -```re example -Belt.Array.mapWithIndex([|1, 2, 3|], (i, x) => i + x) == [|0 + 1, 1 + 2, 2 + 3|]; -``` - -## partitionU - -```re sig -let partitionU: (array('a), [@bs] ('a => bool)) => (array('a), array('a)); -``` - -## partition - -```re sig -let partition: (array('a), 'a => bool) => (array('a), array('a)); -``` - -`partition(f, a)` split array into tuple of two arrays based on predicate `f`; first of tuple where predicate cause true, second where predicate cause false - -```re example -Belt.Array.partition([|1, 2, 3, 4, 5|], (x) => x mod 2 == 0) == ([|2, 4|], [|1, 2, 3|]); - -Belt.Array.partition([|1, 2, 3, 4, 5|], (x) => x mod 2 != 0) == ([|1, 2, 3|], [|2, 4|]); -``` - -## reduceU - -```re sig -let reduceU: (array('b), 'a, [@bs] (('a, 'b) => 'a)) => 'a; -``` - -## reduce - -```re sig -let reduce: (array('b), 'a, ('a, 'b) => 'a) => 'a; -``` - -`reduce(xs, init, f);` - -Applies `f` to each element of `xs` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”; which starts with a value of `init`. `reduce` returns the final value of the accumulator. - -```re example -Belt.Array.reduce([|2, 3, 4|], 1, (+)) == 10; - -Belt.Array.reduce([|"a", "b", "c", "d"|], "", (++)) == "abcd"; -``` - -## reduceReverseU - -```re sig -let reduceReverseU: (array('b), 'a, [@bs] (('a, 'b) => 'a)) => 'a; -``` - -## reduceReverse - -```re sig -let reduceReverse: (array('b), 'a, ('a, 'b) => 'a) => 'a; -``` - -`reduceReverse(xs, init, f);` - -Works like `Belt_Array.reduce`; except that function `f` is applied to each item of `xs` from the last back to the first. - -```re example -Belt.Array.reduceReverse([|"a", "b", "c", "d"|], "", (++)) == "dcba"; -``` - -## reduceReverse2U - -```re sig -let reduceReverse2U: (array('a), array('b), 'c, [@bs] (('c, 'a, 'b) => 'c)) => 'c; -``` - -## reduceReverse2 - -```re sig -let reduceReverse2: (array('a), array('b), 'c, ('c, 'a, 'b) => 'c) => 'c; -``` - -`reduceReverse2(xs, ys, init, f);` - -Reduces two arrays xs and ys;taking items starting at `min(length(xs), length(ys))` down to and including zero. - -```re example -Belt.Array.reduceReverse2([|1, 2, 3|], [|1, 2|], 0, (acc, x, y) => acc + x + y) == 6; -``` - -## reduceWithIndexU - -```re sig -let reduceWithIndexU: (array('a), 'b, [@bs] (('b, 'a, int) => 'b)) => 'b; -``` - -## reduceWithIndex - -```re sig -let reduceWithIndex: (array('a), 'b, ('b, 'a, int) => 'b) => 'b; -``` - -`reduceWithIndex(xs, f);` - -Applies `f` to each element of `xs` from beginning to end. Function `f` has three parameters: the item from the array and an “accumulator”, which starts with a value of `init` and the index of each element. `reduceWithIndex` returns the final value of the accumulator. - -```re example -Belt.Array.reduceWithIndex([|1, 2, 3, 4|], 0, (acc, x, i) => acc + x + i) == 16; -``` - -## someU - -```re sig -let someU: (array('a), [@bs] ('a => bool)) => bool; -``` - -## some - -```re sig -let some: (array('a), 'a => bool) => bool; -``` - -`some(xs, p);` - -Returns true if at least one of the elements in `xs` satifies `p`; where `p` is a predicate: a function taking an element and returning a `bool`. - -```re example -Belt.Array.some([|2, 3, 4|], (x) => x mod 2 == 1) == true; - -Belt.Array.some([|(-1), (-3), (-5)|], (x) => x > 0) == false; -``` - -## everyU - -```re sig -let everyU: (array('a), [@bs] ('a => bool)) => bool; -``` - -## every - -```re sig -let every: (array('a), 'a => bool) => bool; -``` - -`every(xs, p);` - -Returns `true` if all elements satisfy `p`; where `p` is a predicate: a function taking an element and returning a `bool`. - -```re example -Belt.Array.every([|1, 3, 5|], (x) => x mod 2 == 1) == true; - -Belt.Array.every([|1, (-3), 5|], (x) => x > 0) == false; -``` - -## every2U - -```re sig -let every2U: (array('a), array('b), [@bs] (('a, 'b) => bool)) => bool; -``` - -## every2 - -```re sig -let every2: (array('a), array('b), ('a, 'b) => bool) => bool; -``` - -`every2(xs, ys, p);` - -returns true if `p(xi, yi);` is true for all pairs of elements up to the shorter length (i.e. `min(length(xs), length(ys));`) - -```re example -Belt.Array.every2([|1, 2, 3|], [|0, 1|], (>)) == true; - -Belt.Array.every2([||], [|1|], (x, y) => x > y) == true; - -Belt.Array.every2([|2, 3|], [|1|], (x, y) => x > y) == true; - -Belt.Array.every2([|0, 1|], [|5, 0|], (x, y) => x > y) == false; -``` - -## some2U - -```re sig -let some2U: (array('a), array('b), [@bs] (('a, 'b) => bool)) => bool; -``` - -## some2 - -```re sig -let some2: (array('a), array('b), ('a, 'b) => bool) => bool; -``` - -`some2(xs, ys, p);` - -returns true if `p(xi, yi);` is true for any pair of elements up to the shorter length (i.e. `min(length(xs), length(ys));`) - -```re example -Belt.Array.some2([|0, 2|], [|1, 0, 3|], (>)) == true; - -Belt.Array.some2([||], [|1|], (x, y) => x > y) == false; - -Belt.Array.some2([|2, 3|], [|1, 4|], (x, y) => x > y) == true; -``` - -## cmpU - -```re sig -let cmpU: (array('a), array('a), [@bs] (('a, 'a) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (array('a), array('a), ('a, 'a) => int) => int; -``` - -`cmp(xs, ys, f);` - -Compared by length if `length(xs) != length(ys)`; returning -1 if `length(xs) < length(ys)` or 1 if `length(xs) > length(ys)` -Otherwise compare one by one `f(x, y);`. `f` returns -a negative number if `x` is “less than” `y` -zero if `x` is “equal to” `y` -a positive number if `x` is “greater than” `y` -The comparison returns the first non-zero result of `f`;or zero if `f` returns zero for all `x` and `y`. - -```re example -Belt.Array.cmp([|1, 3, 5|], [|1, 4, 2|], (a, b) => compare(a, b)) == (-1); - -Belt.Array.cmp([|1, 3, 5|], [|1, 2, 3|], (a, b) => compare(a, b)) == 1; - -Belt.Array.cmp([|1, 3, 5|], [|1, 3, 5|], (a, b) => compare(a, b)) == 0; -``` - -## eqU - -```re sig -let eqU: (array('a), array('a), [@bs] (('a, 'a) => bool)) => bool; -``` - -## eq - -```re sig -let eq: (array('a), array('a), ('a, 'a) => bool) => bool; -``` - -`eq(xs, ys);` - -return false if length is not the same -otherwise compare items one by one using `f(xi, yi);`; and return true if all results are true;false otherwise - -```re example -Belt.Array.eq([|1, 2, 3|], [|(-1), (-2), (-3)|], (a, b) => abs(a) == abs(b)) == true; -``` - -## truncateToLengthUnsafe - -```re sig -let truncateToLengthUnsafe: (array('a), int) => unit; -``` - -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`. - -If `n` is less than zero; raises a `RangeError`. - -```re example -let arr = [|"ant", "bee", "cat", "dog", "elk"|]; - -Belt.Array.truncateToLengthUnsafe(arr, 3); - -arr == [|"ant", "bee", "cat"|]; -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/debug.mdx b/pages/docs/manual/v8.0.0/api/belt/debug.mdx deleted file mode 100644 index 31a620b81..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/debug.mdx +++ /dev/null @@ -1,7 +0,0 @@ -# Debug - -## setupChromeDebugger - -``` -let setupChromeDebugger: unit => unit; -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/float.mdx b/pages/docs/manual/v8.0.0/api/belt/float.mdx deleted file mode 100644 index 7ea4f5aaf..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/float.mdx +++ /dev/null @@ -1,107 +0,0 @@ -# Float - -This module includes convenience methods for handling `float` types. - -## toInt - -```re sig -let toInt: float => int; -``` - -Converts a given `float` to an `int`. - -```re example -Js.log(Belt.Float.toInt(1.0) === 1); /* true */ -``` - -## fromInt - -```re sig -let fromInt: int => float; -``` - -Converts a given `int` to a `float`. - -```re example -Js.log(Belt.Float.fromInt(1) === 1.0); /* true */ -``` - -## fromString - -```re sig -let fromString: string => option(float); -``` - -Converts a given `string` to a `float`. Returns `Some(float)` when the input is a number, `None` otherwise. - -```re example -Js.log(Belt.Float.fromString("1.0") === Some(1.0)); /* true */ -``` - -## toString - -```re sig -let toString: float => string; -``` - -Converts a given `float` to a `string`. Uses the JavaScript `String` constructor under the hood. - -```re example -Js.log(Belt.Float.toString(1.0) === "1.0"); /* true */ -``` - -## + - -```re sig -let (+): (float, float) => float; -``` - -Addition of two `float` values. -Can be opened in a module to avoid dot-notation (`+.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```re example -open Belt.Float; -Js.log(2.0 + 2.0 === 4.0); /* true */ -``` - -## - - -```re sig -let (-): (float, float) => float; -``` - -Subtraction of two `float` values. -Can be opened in a module to avoid dot-notation (`-.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```re example -open Belt.Float; -Js.log(2.0 - 1.0 === 1.0); /* true */ -``` - -## \* - -```re sig -let ( * ): (float, float) => float; -``` - -Multiplication of two `float` values. -Can be opened in a module to avoid dot-notation (`*.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```re example -open Belt.Float; -Js.log(2.0 * 2.0 === 4.0); /* true */ -``` - -## / - -```re sig -let (/): (float, float) => float; -``` - -Division of two `float` values. -Can be opened in a module to avoid dot-notation (`/.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```re example -open Belt.Float; -Js.log(4.0 / 2.0 === 2.0); /* true */ -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/hash-map-int.mdx b/pages/docs/manual/v8.0.0/api/belt/hash-map-int.mdx deleted file mode 100644 index 335e83c10..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/hash-map-int.mdx +++ /dev/null @@ -1,331 +0,0 @@ -# HashMapInt - - - -Specalized when key type is `int`, more efficient than the generic type - - - -## key - -```re sig -type key = int; -``` - -Type of the `Belt.HashMap.Int` key. - -## t - -```re sig -type t('b); -``` - -Type of the `Belt.HashMap.Int` - -## make - -```re sig -let make: (~hintSize: int) => t('b); -``` - -`make(~hintSize=10)` creates a new hash map by taking the `hintSize`. - -```re example - -let hMap = Belt.HashMap.Int.make(~hintSize=10); - -Belt.HashMap.Int.set(hMap, 1, "a"); -``` - -## clear - -```re sig -let clear: t('b) => unit; -``` - -Clears a hash table. - -```re example -let hMap = Belt.HashMap.Int.fromArray([|(1, "1")|]) -Belt.HashMap.Int.clear(hMap) -Belt.HashMap.Int.isEmpty(hMap) == true; -``` - -## isEmpty - -```re sig -let isEmpty: t('a) => bool; -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```re example -let hMap = Belt.HashMap.Int.fromArray([|(1, "1")|]) -Belt.HashMap.Int.isEmpty(hMap) == false; -``` - -## set - -```re sig -let set: (t('a), key, 'a) => unit; -``` - -`set(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```re example - -let hMap = Belt.HashMap.Int.fromArray([|(2, "2")|]); - -Belt.HashMap.Int.set(hMap, 1, "1"); - -Belt.HashMap.Int.valuesToArray(hMap) == [|"1", "2"|]; -``` - -## copy - -```re sig -let copy: t('a) => t('a); -``` - -Creates copy of a hash map. - -```re example -let hMap1 = Belt.HashMap.Int.fromArray([|(1, "1"), (2, "2")|]); -let hMap2 = Belt.HashMap.Int.copy(hMap1) - -Belt.HashMap.Int.set(hMap2, 2, "3"); - -Belt.HashMap.Int.get(hMap1, 2) != Belt.HashMap.Int.get(hMap2, 2) -``` - -## get - -```re sig -let get: (t('a), key) => option('a); -``` - -## has - -```re sig -let has: (t('b), key) => bool; -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); - -Belt.HashMap.Int.get(hMap, 1) == Some("value1"); -Belt.HashMap.Int.get(hMap, 2) == None; -``` - -## remove - -```re sig -let remove: (t('a), key) => unit; -``` - -If bound exists, removes it from the hash map. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.remove(hMap, 1); -Belt.HashMap.Int.has(hMap, 1) == false; -``` - -## forEachU - -```re sig -let forEachU: (t('b), [@bs] ((key, 'b) => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t('b), (key, 'b) => unit) => unit; -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.forEach(hMap, (key, value) => Js.log2(key, value)); -// prints ("1", "value1") -``` - -## reduceU - -```re sig -let reduceU: (t('b), 'c, [@bs] (('c, key, 'b) => 'c)) => 'c; -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```re sig -let reduce: (t('b), 'c, ('c, key, 'b) => 'c) => 'c; -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.set(hMap, 2, "value2"); - -Belt.HashMap.Int.reduce(hMap, "", (acc, key, value) => { - acc ++ ", " ++ value -}) == "value1, value2"; -``` - -## keepMapInPlaceU - -```re sig -let keepMapInPlaceU: (t('a), [@bs] ((key, 'a) => option('a))) => unit; -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```re sig -let keepMapInPlace: (t('a), (key, 'a) => option('a)) => unit; -``` - -Filters out values for which function `f` returned `None`. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.set(hMap, 2, "value2"); - -Belt.HashMap.Int.keepMapInPlace(hMap, (key, value) => { - key mod 1 == 0 ? None : Some(value) -}); -``` - -## size - -```re sig -let size: t('a) => int; -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.set(hMap, 2, "value2"); - -Belt.HashMap.Int.size(hMap) == 2; -``` - -## toArray - -```re sig -let toArray: t('a) => array((key, 'a)); -``` - -Returns array of key value pairs. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.set(hMap, 2, "value2"); - -Belt.HashMap.Int.toArray(hMap) == [|(1, "value1"), (2, "value2")|]; -``` - -## keysToArray - -```re sig -let keysToArray: t('a) => array(key); -``` - -Returns array of keys. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.set(hMap, 2, "value2"); - -Belt.HashMap.Int.keysToArray(hMap) == [|1, 2|]; -``` - -## valuesToArray - -```re sig -let valuesToArray: t('a) => array('a); -``` - -Returns array of values. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "value1"); -Belt.HashMap.Int.set(hMap, 2, "value2"); - -Belt.HashMap.Int.valuesToArray(hMap) == [|"value1", "value2"|]; -``` - -## fromArray - -```re sig -let fromArray: array((key, 'a)) => t('a); -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```re example -let hMap = Belt.HashMap.Int.fromArray([|(1, "value1"), (1, "value2")|]); -Belt.HashMap.Int.toArray(hMap) == [|(1, "value1"), (2, "value2")|]; -``` - -## mergeMany - -```re sig -let mergeMany: (t('a), array((key, 'a))) => unit; -``` - -Merges many key value pairs into hash map. - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.mergeMany(hMap, [|(1, "value1"), (2, "value2")|]); -``` - -## getBucketHistogram - -```re sig -let getBucketHistogram: t('a) => array(int); -``` - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "1"); - -Belt.HashMap.Int.getBucketHistogram(hMap); -``` - -## logStats - -```re sig -let logStats: t('a) => unit; -``` - -```re example -let hMap = Belt.HashMap.Int.make(~hintSize=10); -Belt.HashMap.Int.set(hMap, 1, "1"); - -Belt.HashMap.Int.logStats(hMap); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/hash-map-string.mdx b/pages/docs/manual/v8.0.0/api/belt/hash-map-string.mdx deleted file mode 100644 index e496b6852..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/hash-map-string.mdx +++ /dev/null @@ -1,341 +0,0 @@ -# HashMapString - - - -Specalized when key type is `string`, more efficient than the generic type - - - -## key - -```re sig -type key = string; -``` - -Type of the `Belt.HashMap.String` key. - -## t - -```re sig -type t('b); -``` - -Type of the `Belt.HashMap.String`. - -## make - -```re sig -let make: (~hintSize: int) => t('b); -``` - -`make(~hintSize=10)` creates a new hash map by taking the `hintSize`. - -```re example - -let hMap = Belt.HashMap.String.make(~hintSize=10); - -Belt.HashMap.String.set(hMap, "key1", "a"); -``` - -## clear - -```re sig -let clear: t('b) => unit; -``` - -Clears a hash table. - -```re example -let hMap = Belt.HashMap.String.fromArray([|("1", "1")|]) -Belt.HashMap.String.clear(hMap) -Belt.HashMap.String.isEmpty(hMap) == true; -``` - -## isEmpty - -```re sig -let isEmpty: t('a) => bool; -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```re example -let hMap = Belt.HashMap.String.fromArray([|("1", "1")|]) -Belt.HashMap.String.isEmpty(hMap) == false; -``` - -## set - -```re sig -let set: (t('a), key, 'a) => unit; -``` - -`set(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```re example - -let hMap = Belt.HashMap.String.fromArray([|("2", "2")|]); - -Belt.HashMap.String.set(hMap, "1", "1"); - -Belt.HashMap.String.valuesToArray(hMap) == [|"1", "2"|]; -``` - -## copy - -```re sig -let copy: t('a) => t('a); -``` - -Creates copy of a hash map. - -```re example -let hMap1 = Belt.HashMap.String.fromArray([|("1", "1"), ("2", "2")|]); -let hMap2 = Belt.HashMap.String.copy(hMap1) - -Belt.HashMap.String.set(hMap2, "2", "3"); - -Belt.HashMap.String.get(hMap1, "2") != Belt.HashMap.String.get(hMap2, "2") -``` - -## get - -```re sig -let get: (t('a), key) => option('a); -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); - -Belt.HashMap.String.get(hMap, "1") == Some("value1"); -Belt.HashMap.String.get(hMap, "2") == None; -``` - -## has - -```re sig -let has: (t('b), key) => bool; -``` - -Checks if `x` is bound in `tbl`. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); - -Belt.HashMap.String.has(hMap, "1") == true; -Belt.HashMap.String.has(hMap, "2") == false; -``` - -## remove - -```re sig -let remove: (t('a), key) => unit; -``` - -If bound exists, removes it from the hash map. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.remove(hMap, "1"); -Belt.HashMap.String.has(hMap, "1") == false; -``` - -## forEachU - -```re sig -let forEachU: (t('b), [@bs] ((key, 'b) => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t('b), (key, 'b) => unit) => unit; -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.forEach(hMap, (key, value) => Js.log2(key, value)); -// prints ("1", "value1") -``` - -## reduceU - -```re sig -let reduceU: (t('b), 'c, [@bs] (('c, key, 'b) => 'c)) => 'c; -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```re sig -let reduce: (t('b), 'c, ('c, key, 'b) => 'c) => 'c; -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.set(hMap, "2", "value2"); - -Belt.HashMap.String.reduce(hMap, "", (acc, key, value) => { - acc ++ ", " ++ value -}) == "value1, value2"; -``` - -## keepMapInPlaceU - -```re sig -let keepMapInPlaceU: (t('a), [@bs] ((key, 'a) => option('a))) => unit; -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```re sig -let keepMapInPlace: (t('a), (key, 'a) => option('a)) => unit; -``` - -Filters out values for which function `f` returned `None`. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.set(hMap, "2", "value2"); - -Belt.HashMap.String.keepMapInPlace(hMap, (key, value) => { - key == "1" ? None : Some(value) -}); -``` - -## size - -```re sig -let size: t('a) => int; -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.set(hMap, "2", "value2"); - -Belt.HashMap.String.size(hMap) == 2; -``` - -## toArray - -```re sig -let toArray: t('a) => array((key, 'a)); -``` - -Returns array of key value pairs. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.set(hMap, "2", "value2"); - -Belt.HashMap.String.toArray(hMap) == [|("1", "value1"), ("2", "value2")|]; -``` - -## keysToArray - -```re sig -let keysToArray: t('a) => array(key); -``` - -Returns array of keys. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.set(hMap, "2", "value2"); - -Belt.HashMap.String.keysToArray(hMap) == [|"1", "2"|]; -``` - -## valuesToArray - -```re sig -let valuesToArray: t('a) => array('a); -``` - -Returns array of values. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "value1"); -Belt.HashMap.String.set(hMap, "2", "value2"); - -Belt.HashMap.String.valuesToArray(hMap) == [|"value1", "value2"|]; -``` - -## fromArray - -```re sig -let fromArray: array((key, 'a)) => t('a); -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```re example -let hMap = Belt.HashMap.String.fromArray([|("1", "value1"), ("2", "value2")|]); -Belt.HashMap.String.toArray(hMap) == [|("1", "value1"), ("2", "value2")|]; -``` - -## mergeMany - -```re sig -let mergeMany: (t('a), array((key, 'a))) => unit; -``` - -Merges many key value pairs into hash map. - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.mergeMany(hMap, [|("1", "value1"), ("2", "value2")|]); -``` - -## getBucketHistogram - -```re sig -let getBucketHistogram: t('a) => array(int); -``` - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "1"); - -Belt.HashMap.String.getBucketHistogram(hMap); -``` - -## logStats - -```re sig -let logStats: t('a) => unit; -``` - -```re example -let hMap = Belt.HashMap.String.make(~hintSize=10); -Belt.HashMap.String.set(hMap, "1", "1"); - -Belt.HashMap.String.logStats(hMap); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/hash-map.mdx b/pages/docs/manual/v8.0.0/api/belt/hash-map.mdx deleted file mode 100644 index bc7a7bc19..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/hash-map.mdx +++ /dev/null @@ -1,467 +0,0 @@ -# HashMap - - - -The top level provides generic mutable hash map operations. - - - -## t - -```re sig -type t('key, 'value, 'id); -``` - -The type of hash tables from type `'key` to type `'value`. - -## id - -```re sig -type id('a, 'id) = BeltId.hashable('a, 'id); -``` - -The identity needed for making an empty hash map. - -## make - -```re sig -let make: (~hintSize: int, ~id: id('key, 'id)) => t('key, 'value, 'id); -``` - -`make(~hintSize=10, ~id)` creates a new map by taking in the comparator and `hintSize`. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); - -Belt.HashMap.set(hMap, 0, "a"); -``` - -## clear - -```re sig -let clear: t('key, 'value, 'id) => unit; -``` - -Clears a hash table. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let hMap = Belt.HashMap.fromArray([|(1, "1")|], ~id=(module IntHash)) -Belt.HashMap.clear(hMap) -Belt.HashMap.isEmpty(hMap) == true; -``` - -## isEmpty - -```re sig -let isEmpty: t('a, 'b, 'c) => bool; -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -Belt.HashMap.isEmpty(Belt.HashMap.fromArray([|(1, "1")|], ~id=(module IntHash))) == false; -``` - -## set - -```re sig -let set: (t('key, 'value, 'id), 'key, 'value) => unit; -``` - -`set(hMap, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntHash)); - -Belt.HashMap.set(s0, 2, "3"); - -Belt.HashMap.valuesToArray(s0) == [|"1", "3", "3"|]; -``` - -## copy - -```re sig -let copy: t('key, 'value, 'id) => t('key, 'value, 'id); -``` - -Creates copy of a hash map. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntHash)); -let s1 = Belt.HashMap.copy(s0) - -Belt.HashMap.set(s0, 2, "3"); - -Belt.HashMap.get(s0, 2) != Belt.HashMap.get(s1, 2) -``` - -## get - -```re sig -let get: (t('key, 'value, 'id), 'key) => option('value); -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); - -Belt.HashMap.get(s0, 1) == Some("value1"); -Belt.HashMap.get(s0, 2) == None; -``` - -## has - -```re sig -let has: (t('key, 'value, 'id), 'key) => bool; -``` - -Checks if `x` is bound in `tbl`. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); - -Belt.HashMap.has(s0, 1) == true; -Belt.HashMap.has(s0, 2) == false; -``` - -## remove - -```re sig -let remove: (t('key, 'value, 'id), 'key) => unit; -``` - -If bound exists, removes it from the hash map. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); -Belt.HashMap.remove(s0, 1); -Belt.HashMap.has(s0, 1) == false; -``` - -## forEachU - -```re sig -let forEachU: (t('key, 'value, 'id), [@bs] (('key, 'value) => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t('key, 'value, 'id), ('key, 'value) => unit) => unit; -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -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)); -// prints (1, "value1") -``` - -## reduceU - -```re sig -let reduceU: (t('key, 'value, 'id), 'c, [@bs] (('c, 'key, 'value) => 'c)) => 'c; -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```re sig -let reduce: (t('key, 'value, 'id), 'c, ('c, 'key, 'value) => 'c) => 'c; -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); -Belt.HashMap.set(s0, 2, "value2"); - -Belt.HashMap.reduce(s0, "", (acc, key, value) => { - acc ++ ", " ++ value -}) == "value1, value2"; -``` - -## keepMapInPlaceU - -```re sig -let keepMapInPlaceU: (t('key, 'value, 'id), [@bs] (('key, 'value) => option('value))) => unit; -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```re sig -let keepMapInPlace: (t('key, 'value, 'id), ('key, 'value) => option('value)) => unit; -``` - -Filters out values for which function `f` returned `None`. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); -Belt.HashMap.set(s0, 2, "value2"); - -Belt.HashMap.keepMapInPlace(s0, (key, value) => { - key == 1 ? None : Some(value) -}); -``` - -## size - -```re sig -let size: t('a, 'b, 'c) => int; -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); -Belt.HashMap.set(s0, 2, "value2"); - -Belt.HashMap.size(s0) == 2; -``` - -## toArray - -```re sig -let toArray: t('key, 'value, 'id) => array(('key, 'value)); -``` - -Returns array of key value pairs. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); -Belt.HashMap.set(s0, 2, "value2"); - -Belt.HashMap.toArray(s0) == [|(1, "value1"), (2, "value2")|]; -``` - -## keysToArray - -```re sig -let keysToArray: t('key, 'a, 'b) => array('key); -``` - -Returns array of keys. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); -Belt.HashMap.set(s0, 2, "value2"); - -Belt.HashMap.keysToArray(s0) == [|1, 2|]; -``` - -## valuesToArray - -```re sig -let valuesToArray: t('a, 'value, 'b) => array('value); -``` - -Returns array of values. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(s0, 1, "value1"); -Belt.HashMap.set(s0, 2, "value2"); - -Belt.HashMap.valuesToArray(s0) == [|"value1", "value2"|]; -``` - -## fromArray - -```re sig -let fromArray: (array(('key, 'value)), ~id: id('key, 'id)) => t('key, 'value, 'id); -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let s0 = Belt.HashMap.fromArray([|(1, "value1"), (2, "value2")|], ~id=(module IntHash)); -Belt.HashMap.toArray(s0) == [|(1, "value1"), (2, "value2")|]; -``` - -## mergeMany - -```re sig -let mergeMany: (t('key, 'value, 'id), array(('key, 'value))) => unit; -``` - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.mergeMany(hMap, [|(1, "1"), (2, "2")|]) -``` - -## getBucketHistogram - -```re sig -let getBucketHistogram: t('a, 'b, 'c) => array(int); -``` - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); -let hMap = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(hMap, 1, "1"); - -Belt.HashMap.getBucketHistogram(hMap); -``` - -## logStats - -```re sig -let logStats: t('a, 'b, 'c) => unit; -``` - -```re example -module IntHash = - Belt.Id.MakeHashable({ - type t = int; - let hash = a => a; - let eq = (a, b) => a == b; - }); -let hMap = Belt.HashMap.make(~hintSize=10, ~id=(module IntHash)); -Belt.HashMap.set(hMap, 1, "1"); - -Belt.HashMap.logStats(hMap); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/hash-set-int.mdx b/pages/docs/manual/v8.0.0/api/belt/hash-set-int.mdx deleted file mode 100644 index b1812d954..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/hash-set-int.mdx +++ /dev/null @@ -1,123 +0,0 @@ -# HashSetInt - - - -This module is `Belt.HashSet` specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with `Belt.HashSet` except its key type is fixed, and identity is not needed(using the built-in one). - - - -## key - -```re sig -type key = int; -``` - -## t - -```re sig -type t; -``` - -## make - -```re sig -let make: (~hintSize: int) => t; -``` - -## clear - -```re sig -let clear: t => unit; -``` - -## isEmpty - -```re sig -let isEmpty: t => bool; -``` - -## add - -```re sig -let add: (t, key) => unit; -``` - -## copy - -```re sig -let copy: t => t; -``` - -## has - -```re sig -let has: (t, key) => bool; -``` - -## remove - -```re sig -let remove: (t, key) => unit; -``` - -## forEachU - -```re sig -let forEachU: (t, [@bs] (key => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t, key => unit) => unit; -``` - -## reduceU - -```re sig -let reduceU: (t, 'c, [@bs] (('c, key) => 'c)) => 'c; -``` - -## reduce - -```re sig -let reduce: (t, 'c, ('c, key) => 'c) => 'c; -``` - -## size - -```re sig -let size: t => int; -``` - -## logStats - -```re sig -let logStats: t => unit; -``` - -## toArray - -```re sig -let toArray: t => array(key); -``` - -## fromArray - -```re sig -let fromArray: array(key) => t; -``` - -## mergeMany - -```re sig -let mergeMany: (t, array(key)) => unit; -``` - -## getBucketHistogram - -```re sig -let getBucketHistogram: t => array(int); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/hash-set-string.mdx b/pages/docs/manual/v8.0.0/api/belt/hash-set-string.mdx deleted file mode 100644 index 053c9600d..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/hash-set-string.mdx +++ /dev/null @@ -1,123 +0,0 @@ -# HashSetString - - - -This module is `Belt.HashSet` specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with `Belt.HashSet` except its key type is fixed, and identity is not needed(using the built-in one). - - - -## key - -```re sig -type key = string; -``` - -## t - -```re sig -type t; -``` - -## make - -```re sig -let make: (~hintSize: int) => t; -``` - -## clear - -```re sig -let clear: t => unit; -``` - -## isEmpty - -```re sig -let isEmpty: t => bool; -``` - -## add - -```re sig -let add: (t, key) => unit; -``` - -## copy - -```re sig -let copy: t => t; -``` - -## has - -```re sig -let has: (t, key) => bool; -``` - -## remove - -```re sig -let remove: (t, key) => unit; -``` - -## forEachU - -```re sig -let forEachU: (t, [@bs] (key => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t, key => unit) => unit; -``` - -## reduceU - -```re sig -let reduceU: (t, 'c, [@bs] (('c, key) => 'c)) => 'c; -``` - -## reduce - -```re sig -let reduce: (t, 'c, ('c, key) => 'c) => 'c; -``` - -## size - -```re sig -let size: t => int; -``` - -## logStats - -```re sig -let logStats: t => unit; -``` - -## toArray - -```re sig -let toArray: t => array(key); -``` - -## fromArray - -```re sig -let fromArray: array(key) => t; -``` - -## mergeMany - -```re sig -let mergeMany: (t, array(key)) => unit; -``` - -## getBucketHistogram - -```re sig -let getBucketHistogram: t => array(int); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/hash-set.mdx b/pages/docs/manual/v8.0.0/api/belt/hash-set.mdx deleted file mode 100644 index 2a5a035a8..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/hash-set.mdx +++ /dev/null @@ -1,162 +0,0 @@ -# HashSet - - - -A mutable Hash set which allows customized `hash` behavior. -All data are parameterized by not its only type but also a unique identity in the time of initialization, so that two HashSets of ints initialized with different hash functions will have different type. - - - -```re example -type t = int; - -module I0 = ( - val Belt.Id.hashableU( - ~hash=(. a: t) => a land 65535, - ~eq=(. a, b) => a == b, - ) -); - -let s0 = Belt.HashSet.make(~id=(module I0), ~hintSize=40); - -module I1 = ( - val Belt.Id.hashableU( - ~hash=(. a: t) => a land 255, - ~eq=(. a, b) => a == b, - ) -); - -let s1 = Belt.HashSet.make(~id=(module I1), ~hintSize=40); - -Belt.HashSet.add(s1, 0); -Belt.HashSet.add(s1, 1); -``` - -The invariant must be held: for two elements who are equal, their hashed value should be the same. - -Here the compiler would infer `s0` and `s1` having different type so that it would not mix. - -```re sig -let s0: t(int, I0.identity); -let s1: t(int, I1.identity); -``` - -We can add elements to the collection (see last two lines in the example above). Since this is an mutable data structure, `s1` will contain two pairs. - -## t - -```re sig -type t('a, 'id); -``` - -## id - -```re sig -type id('a, 'id) = BeltId.hashable('a, 'id); -``` - -## make - -```re sig -let make: (~hintSize: int, ~id: id('a, 'id)) => t('a, 'id); -``` - -## clear - -```re sig -let clear: t('a, 'id) => unit; -``` - -## isEmpty - -```re sig -let isEmpty: t('a, 'b) => bool; -``` - -## add - -```re sig -let add: (t('a, 'id), 'a) => unit; -``` - -## copy - -```re sig -let copy: t('a, 'id) => t('a, 'id); -``` - -## has - -```re sig -let has: (t('a, 'id), 'a) => bool; -``` - -## remove - -```re sig -let remove: (t('a, 'id), 'a) => unit; -``` - -## forEachU - -```re sig -let forEachU: (t('a, 'id), [@bs] ('a => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('a, 'id), 'a => unit) => unit; -``` - -Order unspecified. - -## reduceU - -```re sig -let reduceU: (t('a, 'id), 'c, [@bs] (('c, 'a) => 'c)) => 'c; -``` - -## reduce - -```re sig -let reduce: (t('a, 'id), 'c, ('c, 'a) => 'c) => 'c; -``` - -Order unspecified. - -## size - -```re sig -let size: t('a, 'id) => int; -``` - -## logStats - -```re sig -let logStats: t('a, 'b) => unit; -``` - -## toArray - -```re sig -let toArray: t('a, 'id) => array('a); -``` - -## fromArray - -```re sig -let fromArray: (array('a), ~id: id('a, 'id)) => t('a, 'id); -``` - -## mergeMany - -```re sig -let mergeMany: (t('a, 'id), array('a)) => unit; -``` - -## getBucketHistogram - -```re sig -let getBucketHistogram: t('a, 'b) => array(int); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/id.mdx b/pages/docs/manual/v8.0.0/api/belt/id.mdx deleted file mode 100644 index 0da25077e..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/id.mdx +++ /dev/null @@ -1,137 +0,0 @@ -# Id - - - -Provide utilities to create identified comparators or hashes for data -structures used below. - -It creates a unique identifier per module of functions so that different data -structures with slightly different comparison functions won't mix. - - - -## hash - -```re sig -type hash('a, 'id); -``` - -Its runtime represenation is a hash function, but signed with a type parameter, so that different hash functions type mismatch. - -## eq - -```re sig -type eq('a, 'id); -``` - -Its runtime represenation is an eq function, but signed with a type parameter, so that different hash functions type mismatch. - -## cmp - -```re sig -type cmp('a, 'id); -``` - -Its runtime representation is a cmp function, but signed with a type parameter, so that different hash functions type mismatch. - -## Comparable - -```re sig -module type Comparable { - type identity; - - type t; - - let cmp: BeltId.cmp(t, identity); -} -``` - -## comparable - -```re sig -type ('key,'id) comparable = (module BeltId.Comparable with type identity = 'id and type t = 'key) -``` - -is a module of functions, here it only includes cmp. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed by the type system). - -It can be created using function `Belt_Id.comparableU` or `Belt_Id.comparable`. - -The idea of a unique identity when created is that it makes sure two sets would type mismatch if they use different comparison function - -## MakeComparableU - -```re sig -module MakeComparableU: (M: {type t; let cmp: [@bs] ((t, t) => int);}) => Comparable with type t = M.t; -``` - -## MakeComparable - -```re sig -module MakeComparable: (M: {type t; let cmp: (t, t) => int;}) => Comparable with type t = M.t; -``` - -## comparableU - -```re sig -let comparableU: (~cmp: [@bs] (('a, 'a) => int)) => (module BeltId.Comparable with type t = 'a); -``` - -## comparable - -```re sig -type ('key, 'id) comparable = (module BeltId.Comparable with type identity = 'id and type t = 'key) -``` - -## Hashable - -```re sig -module type Hashable = { - type identity; - - type t; - - let hash: BeltId.hash(t, identity); - - let eq: BeltId.eq(t, identity); -} -``` - -## hashable - -```re sig -type hashable('key, 'id) = (module BeltId.Hashable with type identity = 'id and type t = 'key); -``` - -is a module of functions, here it only includes hash, eq. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed by the type system). - -It can be created using function `Belt_Id.hashableU` or `Belt_Id.hashable`. - -The idea of a unique identity when created is that it makes sure two hash sets would type mismatch if they use different comparison function. - -## MakeHashableU - -```re sig -module MakeHashableU: (M: {type t; let hash: [@bs] (t => int); let eq: [@bs] ((t, t) => bool);}) => Hashable with type t = M.t; -``` - -## MakeHashable - -```re sig -module MakeHashable: (M: {type t; let hash: t => int; let eq: (t, t) => bool;}) => Hashable with type t = M.t; -``` - -## hashableU - -```re sig -let hashableU: (~hash: [@bs] ('a => int), ~eq: [@bs] (('a, 'a) => bool)) => (module BeltId.Hashable with type t = 'a); -``` - -## hashable - -```re sig -let hashable: (~hash: 'a => int, ~eq: ('a, 'a) => bool) => (module BeltId.Hashable with type t = 'a); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/int.mdx b/pages/docs/manual/v8.0.0/api/belt/int.mdx deleted file mode 100644 index 6a91b9b62..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/int.mdx +++ /dev/null @@ -1,103 +0,0 @@ -# Int - -This module includes convenience methods for handling `int` types. - -## toFloat - -```re sig -let toFloat: int => float; -``` - -Converts a given `int` to a `float`. - -```re example -Js.log(Belt.Int.toFloat(1) === 1.0); /* true */ -``` - -## fromFloat - -```re sig -let fromFloat: float => int; -``` - -Converts a given `float` to an `int`. - -```re example -Js.log(Belt.Int.fromFloat(1.0) === 1); /* true */ -``` - -## fromString - -```re sig -let fromString: string => option(int); -``` - -Converts a given `string` to an `int`. Returns `Some(int)` when the input is a number, `None` otherwise. - -```re example -Js.log(Belt.Int.fromString("1") === Some(1)); /* true */ -``` - -## toString - -```re sig -let toString: int => string; -``` - -Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood. - -```re example -Js.log(Belt.Int.toString(1) === "1"); /* true */ -``` - -## + - -```re sig -let (+): (int, int) => int; -``` - -Addition of two `int` values. Same as the addition from `Pervasives`. - -```re example -open Belt.Int; -Js.log(2 + 2 === 4); /* true */ -``` - -## - - -```re sig -let (-): (int, int) => int; -``` - -Subtraction of two `int` values. Same as the subtraction from `Pervasives`. - -```re example -open Belt.Int; -Js.log(2 - 1 === 1); /* true */ -``` - -## \* - -```re sig -let ( * ): (int, int) => int; -``` - -Multiplication of two `int` values. Same as the multiplication from `Pervasives`. - -```re example -open Belt.Int; -Js.log(2 * 2 === 4); /* true */ -``` - -## / - -```re sig -let (/): (int, int) => int; -``` - -Division of two `int` values. Same as the division from `Pervasives`. - -```re example -open Belt.Int; -Js.log(4 / 2 === 2); /* true */ -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/list.mdx b/pages/docs/manual/v8.0.0/api/belt/list.mdx deleted file mode 100644 index 58aaf643b..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/list.mdx +++ /dev/null @@ -1,1121 +0,0 @@ -# List - - - -Collection functions for manipulating `list` data structures. - - - -## t('a) - -```re sig -type t('a) = list('a); -``` - -## length - -```re sig -let length: t('a) => int; -``` - -Returns the length of a list. - -```re example -Belt.List.length([1, 2, 3]); /* 3 */ -``` - -## size - -```re sig -let size: t('a) => int; -``` - -**See:** [length](#length) - -## head - -```re sig -let head: t('a) => option('a); -``` - -Returns `Some(value)` where `value` is the first element in the list, or `None` if `someList` is an empty list. - -```re example -Belt.List.head([]); /* None */ - -Belt.List.head([1, 2, 3]); /* Some(1) */ -``` - -## headExn - -```re sig -let headExn: t('a) => 'a; -``` - -Same as [head](#head), but raises an exception if `someList` is empty. Use with care. - -```re example -Belt.List.headExn([1, 2, 3]); /* 1 */ - -Belt.List.headExn([]); /* Raises an Error */ -``` - -## tail - -```re sig -let tail: t('a) => option(t('a)); -``` - -Returns `None` if `someList` is empty, otherwise it returns `Some(tail)` where `tail` is everything except the first element of `someList`. - -```re example -Belt.List.tail([1, 2, 3]); /* Some([2, 3]) */ - -Belt.List.tail([]); /* None */ -``` - -## tailExn - -```re sig -let tailExn: t('a) => t('a); -``` - -Same as [tail](#tail), but raises an exception if `someList` is empty. Use with care. - -```re example -Belt.List.tailExn([1, 2, 3]); /* [2, 3] */ - -Belt.List.tailExn([]); /* Raises an Error */ -``` - -## add - -```re sig -let add: (t('a), 'a) => t('a); -``` - -Adds `value` to the beginning of `someList`. - -```re example -Belt.List.add([2, 3], 1); /* [1, 2, 3] */ - -Belt.List.add(["World", "!"], "Hello"); /* ["Hello", "World", "!"] */ -``` - -## get - -```re sig -let get: (t('a), int) => option('a); -``` - -Return the nth element in `someList`, or `None` if `index` is larger than the length. - -```re example -let abc = ["A", "B", "C"]; - -abc->Belt.List.get(1); /* Some("B") */ - -abc->Belt.List.get(4); /* None */ -``` - -## getExn - -```re sig -let getExn: (t('a), int) => 'a; -``` - -Same as [get](#get), but raises an exception if `index` is larger than the length. Use with care. - -```re example -let abc = ["A", "B", "C"]; - -abc->Belt.List.getExn(1); /* "B" */ - -abc->Belt.List.getExn(4); /* Raises an Error */ -``` - -## make - -``` -let make: (int, 'a) => t('a); -``` - -Returns a list of length `numItems` with each element filled with value `v`. Returns an empty list if `numItems` is negative. - -```re example -Belt.List.make(3, 1); /* [1, 1, 1] */ -``` - -## makeBy - -```re sig -let makeBy: (int, int => 'a) => t('a); -``` - -Return a list of length `numItems` with element `i` initialized with `f(i)`. -Returns an empty list if `numItems` is negative. - -```re example -Belt.List.makeBy(5, i => i); /* [0, 1, 2, 3, 4] */ - -Belt.List.makeBy(5, i => i * i); /* [0, 1, 4, 9, 16] */ -``` - -## makeByU - -```re sig -let makeByU: (int, [@bs] (int => 'a)) => t('a); -``` - -Uncurried version of [makeBy](#makeBy) - -## shuffle - -```re sig -let shuffle: t('a) => t('a); -``` - -Returns a new list in random order. - -```re example -Belt.List.shuffle([1, 2, 3]); /* [2, 1, 3] */ -``` - -## drop - -```re sig -let drop: (t('a), int) => option(t('a)); -``` - -Return a new list, dropping the first `n` elements. Returns `None` if `someList` has fewer than `n` elements. - -```re example -[1, 2, 3]->Belt.List.drop(2); /* Some([3]) */ - -[1, 2, 3]->Belt.List.drop(3); /* Some([]) */ - -[1, 2, 3]->Belt.List.drop(4); /* None */ -``` - -## take - -```re sig -let take: (t('a), int) => option(t('a)); -``` - -Returns a list with the first `n` elements from `someList`, or `None` if `someList` has fewer than `n` elements. - -```re example -[1, 2, 3]->Belt.List.take(1); /* Some([1]) */ - -[1, 2, 3]->Belt.List.take(2); /* Some([1, 2]) */ - -[1, 2, 3]->Belt.List.take(4); /* None */ -``` - -## splitAt - -```re sig -let splitAt: (t('a), int) => option((list('a), list('a))); -``` - -Split the list `someList` at `index`. Returns `None` when the length of `someList` is less than `index`. - -```re example -["Hello", "World"]->Belt.List.splitAt(1); /* Some((["Hello"], ["World"])) */ - -[0, 1, 2, 3, 4]->Belt.List.splitAt(2); /* Some(([0, 1], [2, 3, 4])) */ -``` - -## concat - -```re sig -let concat: (t('a), t('a)) => t('a); -``` - -Returns the list obtained by adding `secondList` after `firstList`. - -```re example -Belt.List.concat([1, 2, 3], [4, 5]); /* [1, 2, 3, 4, 5] */ -``` - -## concatMany - -```re sig -let concatMany: array(t('a)) => t('a); -``` - -Returns the list obtained by concatenating all the lists in array `a`, in order. - -```re example -Belt.List.concatMany([|[1, 2, 3], [], [3], [4]|]); /* [1, 2, 3, 3, 4] */ -``` - -## reverseConcat - -```re sig -let reverseConcat: (t('a), t('a)) => t('a); -``` - -Equivalent to writing: `concat(reverse(firstList), secondList)` - -```re example -Belt.List.reverseConcat([1, 2], [3, 4]); /* [2, 1, 3, 4] */ -``` - -## flatten - -```re sig -let flatten: t(t('a)) => t('a); -``` - -Return the list obtained by concatenating all the lists in list `ls`, in order. - -```re example -Belt.List.flatten([[1, 2, 3], [], [3], [4]]); /* [1, 2, 3, 3, 4] */ -``` - -## map - -```re sig -let map: (t('a), 'a => 'b) => t('b); -``` - -Returns a new list with `f` applied to each element of `someList`. - -```re example -[1, 2]->Belt.List.map(x => x + 1); /* [3, 4] */ -``` - -## mapU - -```re sig -let mapU: (t('a), [@bs] ('a => 'b)) => t('b); -``` - -Uncurried version of [map](#map). - -## zip - -```re sig -let zip: (t('a), t('b)) => t(('a, 'b)); -``` - -Returns a list of pairs from the two lists with the length of the shorter list. - -```re example -Belt.List.zip([1, 2], [3, 4, 5]); /* [(1, 3), (2, 4)] */ -``` - -## zipBy - -```re sig -let zipBy: (t('a), t('b), ('a, 'b) => 'c) => t('c); -``` - -**See:** [zip](#zip) - -Equivalent to: - -```re sig -zip(firstList, secondList) |> List.map(((x, y)) => f(x, y)); -``` - -```re example -Belt.List.zipBy([1, 2, 3], [4, 5], (a, b) => 2 * a + b); /* [6, 9] */ -``` - -## zipByU - -```re sig -let zipByU: (t('a), t('b), [@bs] (('a, 'b) => 'c)) => t('c); -``` - -Uncurried version of [zipBy](#zipBy). - -## mapWithIndex - -```re sig -let mapWithIndex: (t('a), (int, 'a) => 'b) => t('b); -``` - -Applies `f` to each element of `someList`. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`, in that order. - -```re example -[1, 2, 3]->Belt.List.mapWithIndex((index, x) => index + x); /* [1, 3, 5] */ -``` - -## mapWithIndexU - -```re sig -let mapWithIndexU: (t('a), [@bs] ((int, 'a) => 'b)) => t('b); -``` - -Uncurried version of [mapWithIndex](#mapWithIndex). - -## fromArray - -```re sig -let fromArray: array('a) => t('a); -``` - -Converts the given array to a list. - -```re example -Belt.List.fromArray([|1, 2, 3|]); /* [1, 2, 3] */ -``` - -## toArray - -```re sig -let toArray: t('a) => array('a); -``` - -Converts the given list to an array. - -```re example -Belt.List.toArray([1, 2, 3]); /* [|1, 2, 3|] */ -``` - -## reverse - -```re sig -let reverse: t('a) => t('a); -``` - -Returns a new list whose elements are those of `someList` in reversed order. - -```re example -Belt.List.reverse([1, 2, 3]); /* [3, 2, 1] */ -``` - -## mapReverse - -```re sig -let mapReverse: (t('a), 'a => 'b) => t('b); -``` - -Equivalent to: - -```re sig -map(someList, f)->reverse; -``` - -```re example -[3, 4, 5]->Belt.List.mapReverse(x => x * x); /* [25, 16, 9] */ -``` - -## mapReverseU - -```re sig -let mapReverseU: (t('a), [@bs] ('a => 'b)) => t('b); -``` - -Uncurried version of [mapReverse](#mapReverse). - -## forEach - -```re sig -let forEach: (t('a), 'a => 'b) => unit; -``` - -Call `f` on each element of `someList` from the beginning to end. -`f` returns `unit`, so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects. - -```re example -Belt.List.forEach(["a", "b", "c"], x => Js.log("Item: " ++ x)); -/* - prints: - Item: a - Item: b - Item: c -*/ -``` - -## forEachU - -```re sig -let forEachU: (t('a), [@bs] ('a => 'b)) => unit; -``` - -Uncurried version of [forEach](#forEach). - -## forEachWithIndex - -```re sig -let forEachWithIndex: (t('a), (int, 'a) => 'b) => unit; -``` - -Call `f` on each element of `someList` from beginning to end. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`. `f` returns `unit`. - -```re example -Belt.List.forEachWithIndex(["a", "b", "c"], (index, x) => Js.log("Item " ++ string_of_int(index) ++ " is " ++ x)); -/* prints: - Item 0 is a - Item 1 is b - Item 2 is cc - */ -``` - -## forEachWithIndexU - -```re sig -let forEachWithIndexU: (t('a), [@bs] ((int, 'a) => 'b)) => unit; -``` - -Uncurried version of [forEachWithIndex](#forEachWithIndex). - -## reduce - -```re sig -let reduce: (t('a), 'b, ('b, 'a) => 'b) => 'b; -``` - -Applies `f` to each element of `someList` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue`. reduce returns the final value of the accumulator. - -```re example -[1, 2, 3, 4]->Belt.List.reduce(0, (+)); /* 10 */ - -/* same as */ - -[1, 2, 3, 4]->Belt.List.reduce(0, (acc, item) => acc + item); /* 10 */ -``` - -## reduceU - -```re sig -let reduceU: (t('a), 'b, [@bs] (('b, 'a) => 'b)) => 'b; -``` - -Uncurried version of [reduce](#reduce). - -## reduceWithIndex - -```re sig -let reduceWithIndex: (t('a), 'b, ('b, 'a, int) => 'b) => 'b; -``` - -Applies `f` to each element of `someList` from beginning to end. Function `f` has three parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue` and the index of each element. `reduceWithIndex` returns the final value of the accumulator. - -```re example -[1, 2, 3, 4]->Belt.List.reduceWithIndex(0, (acc, item, index) => acc + item + index); /* 16 */ -``` - -## reduceWithIndexU - -```re sig -let reduceWithIndexU: (t('a), 'b, [@bs] (('b, 'a, int) => 'b)) => 'b; -``` - -Uncurried version of [reduceWithIndex](#reduceWithIndex). - -## reduceReverse - -```re sig -let reduceReverse: (t('a), 'b, ('b, 'a) => 'b) => 'b; -``` - -Works like [reduce](#reduce), except that function `f` is applied to each item of `someList` from the last back to the first. - -```re example -[1, 2, 3, 4]->Belt.List.reduceReverse(0, (+)); /* 10 */ - -[1, 2, 3, 4]->Belt.List.reduceReverse(10, (-)); /* 0 */ - -[1, 2, 3, 4]->Belt.List.reduceReverse([], Belt.List.add); /* [1, 2, 3, 4] */ -``` - -## reduceReverseU - -```re sig -let reduceReverseU: (t('a), 'b, [@bs] (('b, 'a) => 'b)) => 'b; -``` - -Uncurried version of [reduceReverse](#reduceReverse). - -## mapReverse2 - -```re sig -let mapReverse2: (t('a), t('b), ('a, 'b) => 'c) => t('c); -``` - -Equivalent to: `zipBy(xs, ys, f)->reverse` - -```re example - -Belt.List.mapReverse2([1, 2, 3], [1, 2], (+)); /* [4, 2] */ -``` - -## mapReverse2U - -```re sig -let mapReverse2U: (t('a), t('b), [@bs] (('a, 'b) => 'c)) => t('c); -``` - -Uncurried version of [mapReverse2](#mapReverse2). - -## forEach2 - -```re sig -let forEach2: (t('a), t('b), ('a, 'b) => 'c) => unit; -``` - -Stops at the length of the shorter list. - -```re example -Belt.List.forEach2(["Z", "Y"], ["A", "B", "C"], (x, y) => Js.log2(x, y)); - -/* prints: -"Z" "A" -"Y" "B" -*/ -``` - -## forEach2U - -```re sig -let forEach2U: (t('a), t('b), (.'a, 'b) => 'c) => unit; -``` - -Uncurried version of [forEach2](#forEach2). - -## reduce2 - -```re sig -let reduce2: (t('b), t('c), 'a, ('a, 'b, 'c) => 'a) => 'a; -``` - -Applies `f` to each element of `firstList` and `secondList` from beginning to end. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of `initialValue`, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator. - -```re example -Belt.List.reduce2([1, 2, 3], [4, 5], 0, (acc, x, y) => acc + x * x + y); /* 0 + (1 * 1 + 4) + (2 * 2 + 5) */ -``` - -## reduce2U - -```re sig -let reduce2U: (t('b), t('c), 'a, (.'a, 'b, 'c) => 'a) => 'a; -``` - -Uncurried version of [reduce2](#reduce2). - -## reduceReverse2 - -```re sig -let reduceReverse2: (t('a), t('b), 'c, ('c, 'a, 'b) => 'c) => 'c; -``` - -Applies `f` to each element of `firstList` and `secondList` from end to beginning. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of init, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator. - -```re example -Belt.List.reduceReverse2([1, 2, 3], [4, 5], 0, (acc, x, y) => acc + x * x + y); /* + (1 * 1 + 4) + (2 * 2 + 5) */ -``` - -## reduceReverse2U - -```re sig -let reduceReverse2U: (t('a), t('b), 'c, (.'c, 'a, 'b) => 'c) => 'c; -``` - -Uncurried version of [reduceReverse2](#reduceReverse2). - -## every - -```re sig -let every: (t('a), 'a => bool) => bool; -``` - -Returns `true` if all elements satisfy `pred`, where `pred` is a predicate: a function taking an element and returning a bool. - -```re example -let isBelow10 = value => value < 10; - -[1, 9, 8, 2]->Belt.List.every(isBelow10); /* true */ - -[1, 99, 8, 2]->Belt.List.every(isBelow10); /* false */ -``` - -## everyU - -```re sig -let everyU: (t('a), (.'a) => bool) => bool; -``` - -Uncurried version of [every](#every). - -## some - -```re sig -let some: (t('a), 'a => bool) => bool; -``` - -Returns `true` if at least _one_ of the elements in `someList` satisfies `pred`, where `pred` is a predicate: a function taking an element and returning a bool. - -```re example -let isAbove100 = value => value > 100; - -[101, 1, 2, 3]->Belt.List.some(isAbove100); /* true */ - -[1, 2, 3, 4]->Belt.List.some(isAbove100); /* false */ -``` - -## someU - -```re sig -let someU: (t('a), (.'a => bool)) => bool; -``` - -Uncurried version of [some](#some). - -## every2 - -```re sig -let every2: (t('a), t('b), ('a, 'b) => bool) => bool; -``` - -Returns `true` if predicate `pred(a, b)` is `true` for all pairs of elements up to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -```re example -Belt.List.every2([1, 2, 3], [0, 1], (>)); /* true */ - -Belt.List.every2([], [1], (a, b) => a > b); /* true */ - -Belt.List.every2([2, 3], [1], (a, b) => a > b); /* true */ - -Belt.List.every2([0, 1], [5, 0], (a, b) => a > b); /* false */ -``` - -## every2U - -```re sig -let every2U: (t('a), t('b), [@bs] (('a, 'b) => bool)) => bool; -``` - -Uncurried version of [every2](#every2). - -## some2 - -```re sig -let some2: (t('a), t('b), ('a, 'b) => bool) => bool; -``` - -Returns `true` if predicate `pred(a, b)` is true for any pair of elements up to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -```re example -Belt.List.some2([1, 2, 3], [0, 1], (>)); /* true */ - -Belt.List.some2([], [1], (a, b) => a > b); /* false */ - -Belt.List.some2([2, 3], [1], (a, b) => a > b); /* true */ - -Belt.List.some2([0, 1], [5, 0], (a, b) => a > b); /* true */ -``` - -## some2U - -```re sig -let some2U: (t('a), t('b), [@bs] (('a, 'b) => bool)) => bool; -``` - -Uncurried version of [some2](#some2). - -## cmpByLength - -```re sig -let cmpByLength: (t('a), t('a)) => int; -``` - -```re sig -cmpByLength(firstList, secondList); -``` - -Compare two lists solely by length. Returns `-1` if `length(firstList)` is less than `length(secondList)`, `0` if `length(firstList)` equals `length(secondList)`, and `1` if `length(firstList)` is greater than `length(secondList)`. - -```re example -Belt.List.cmpByLength([1, 2], [3, 4, 5, 6]); /* (-1) */ - -Belt.List.cmpByLength([1, 2, 3], [4, 5, 6]); /* = 0 */ - -Belt.List.cmpByLength([1, 2, 3, 4], [5, 6]); /* = 1 */ -``` - -## cmp - -```re sig -let cmp: (t('a), t('a), ('a, 'a) => int) => int; -``` - -Compare elements one by one `compareFn(a, b)`. `compareFn` returns a negative number if `a` is "less than" `b`, zero if `a` is "equal to" `b`, a positive number if `a` is "greater than" `b`. - -The comparison returns the first non-zero result of `compareFn`, or zero if `compareFn` returns zero for all `a` and `b`. - -If all items have compared equal, but `firstList` is exhausted first, return `-1`. (`firstList` is shorter). -If all items have compared equal, but `secondList` is exhausted first, return `1` (`firstList` is longer). - -```re example -Belt.List.cmp([3], [3, 7], (a, b) => compare(a, b)); /* (-1) */ - -Belt.List.cmp([5, 3], [5], (a, b) => compare(a, b)); /* 1 */ - -Belt.List.cmp([1, 3, 5], [1, 4, 2], (a, b) => compare(a, b)); /* (-1) */ - -Belt.List.cmp([1, 3, 5], [1, 2, 3], (a, b) => compare(a, b)); /* 1 */ - -Belt.List.cmp([1, 3, 5], [1, 3, 5], (a, b) => compare(a, b)); /* 0 */ -``` - -**Please note:** The total ordering of List is different from Array, -for Array, we compare the length first and, only if the lengths are equal, elements one by one. -For lists, we just compare elements one by one. - -## cmpU - -```re sig -let cmpU: (t('a), t('a), [@bs] (('a, 'a) => int)) => int; -``` - -Uncurried version of [cmp](#cmp). - -## eq - -```re sig -let eq: (t('a), t('a), ('a, 'a) => bool) => bool; -``` - -Check equality of `firstList` and `secondList` using `eqElem` for equality on elements, where `eqElem` is a function that returns `true` if items `x` and `y` meet some criterion for equality, `false` otherwise. eq `false` if length of `firstList` and `secondList` are not the same. - -```re example -Belt.List.eq([1, 2, 3], [1, 2], (==)); /* false */ - -Belt.List.eq([1, 2], [1, 2], (==)); /* true */ - -Belt.List.eq([1, 2, 3], [(-1), (-2), (-3)], (a, b) => abs(a) == abs(b)); /* true */ -``` - -## eqU - -```re sig -let eqU: (t('a), t('a), [@bs] (('a, 'a) => bool)) => bool; -``` - -Uncurried version of [eqU](#eqU). - -## has - -```re sig -let has: (t('a), 'b, ('a, 'b) => bool) => bool; -``` - -Returns `true` if the list contains at least one element for which `eqFunction(x)` returns true. - -```re example -[1, 2, 3]->Belt.List.has(2, (==)); /* true */ - -[1, 2, 3]->Belt.List.has(4, (==)); /* false */ - -[(-1), (-2), (-3)]->Belt.List.has(2, (a, b) => abs(a) == abs(b)); /* true */ -``` - -## hasU - -```re sig -let hasU: (t('a), 'b, [@bs] (('a, 'b) => bool)) => bool; -``` - -Uncurried version of [has](#has). - -## getBy - -```re sig -let getBy: (t('a), 'a => bool) => option('a); -``` - -Returns `Some(value)` for the first value in `someList` that satisfies the predicate function `pred`. Returns `None` if no element satisfies the function. - -```re example -Belt.List.getBy([1, 4, 3, 2], x => x > 3); /* Some(4) */ - -Belt.List.getBy([1, 4, 3, 2], x => x > 4); /* None */ -``` - -## getByU - -```re sig -let getByU: (t('a), [@bs] ('a => bool)) => option('a); -``` - -Uncurried version of [getBy](#getBy). - -## keep - -```re sig -let keep: (t('a), 'a => bool) => t('a); -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```re example -let isEven = x => x mod 2 == 0; - -Belt.List.keep([1, 2, 3, 4], isEven); /* [2, 4] */ - -Belt.List.keep([None, Some(2), Some(3), None], Belt.Option.isSome); /* [Some(2), Some(3)] */ -``` - -## keepU - -```re sig -let keepU: (t('a), [@bs] ('a => bool)) => t('a); -``` - -Uncurried version of [keep](#keep). - -## filter - -```re sig -let filter: (t('a), 'a => bool) => t('a); -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```re example -let isEven = x => x mod 2 == 0; - -Belt.List.filter([1, 2, 3, 4], isEven); /* [2, 4] */ - -Belt.List.filter([None, Some(2), Some(3), None], Belt.Option.isSome); /* [Some(2), Some(3)] */ -``` - -## keepWithIndex - -```re sig -let keepWithIndex: (t('a), ('a, int) => bool) => t('a); -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```re example -let isEven = x => x mod 2 == 0; - -Belt.List.keepWithIndex([1, 2, 3, 4], (_x, index) => isEven(index)); /* [1, 3] */ -``` - -## keepWithIndexU - -```re sig -let keepWithIndexU: (t('a), [@bs] (('a, int) => bool)) => t('a); -``` - -Uncurried version of [keepWithIndex](#keepWithIndex). - -## filterWithIndex - -```re sig -let filterWithIndex: (t('a), ('a, int) => bool) => t('a); -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```re example -let isEven = x => x mod 2 == 0; - -Belt.List.filterWithIndex([1, 2, 3, 4], (_x, index) => isEven(index)); /* [1, 3] */ -``` - -## keepMap - -```re sig -let keepMap: (t('a), 'a => option('b)) => t('b); -``` - -Applies `f` to each element of `someList`. If `f(x)` returns `Some(value)`, then `value` is _kept_ in the resulting list. -If `f(x)` returns `None`, the element is _not_ retained in the result. - -```re example -let isEven = x => x mod 2 == 0; - -[1, 2, 3, 4] -->Belt.List.keepMap(x => - if (isEven(x)) { - Some(x); - } else { - None; - } - ); /* [2, 4] */ - -[Some(1), Some(2), None]->Belt.List.keepMap(x => x); /* [1, 2] */ -``` - -## keepMapU - -```re sig -let keepMapU: (t('a), [@bs] ('a => option('b))) => t('b); -``` - -Uncurried version of [keepMap](#keepMap). - -## partition - -```re sig -let partition: (t('a), 'a => bool) => (t('a), t('a)); -``` - -Creates a pair of lists; the first list consists of all elements of `someList` that satisfy the predicate function `pred`; the second list consists of all elements of `someList` that _do not_ satisfy `pred. - -In other words: - -``` -([elementsThatSatisfies], [elementsThatDoesNotSatisfy]); -``` - -```re example -Belt.List.partition([1, 2, 3, 4], x => x > 2); /* ([3, 4], [1, 2]) */ -``` - -## partitionU - -```re sig -let partitionU: (t('a), [@bs] ('a => bool)) => (t('a), t('a)); -``` - -Uncurried version of [partition](#partition). - -## unzip - -```re sig -let unzip: t(('a, 'b)) => (t('a), t('b)); -``` - -Takes a list of pairs and creates a pair of lists. The first list contains all the first items of the pairs; the second list contains all the second items. - -```re example -Belt.List.unzip([(1, 2), (3, 4)]); /* ([1, 3], [2, 4]) */ - -Belt.List.unzip([("H", "W"), ("e", "o"), ("l", "r"), ("l", "l"), ("o", "d"), (" ", "!")]); -/* (["H", "e", "l", "l", "o", " "], ["W", "o", "r", "l", "d", "!"]); */ -``` - -## getAssoc - -```re sig -let getAssoc: (t(('a, 'c)), 'b, ('a, 'b) => bool) => option('c); -``` - -Return the second element of a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`, or `None` if not found. - -```re example -[(1, "a"), (2, "b"), (3, "c")]->Belt.List.getAssoc(3, (==)); /* Some("c") */ - -[(9, "morning"), (15, "afternoon"), (22, "night")] -->Belt.List.getAssoc(15, (k, item) => k /* 15 */ == item /* 9, 5, 22 */); -/* Some("afternoon"); */ -``` - -## getAssocU - -```re sig -let getAssocU: (t(('a, 'c)), 'b, [@bs] (('a, 'b) => bool)) => option('c); -``` - -Uncurried version of [getAssoc](#getAssoc). - -## hasAssoc - -```re sig -let hasAssoc: (t(('a, 'c)), 'b, ('a, 'b) => bool) => bool; -``` - -Returns `true` if there is a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`. - -```re example -[(1, "a"), (2, "b"), (3, "c")]->Belt.List.hasAssoc(1, (==)); /* true */ - -[(9, "morning"), (15, "afternoon"), (22, "night")] -->Belt.List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */); /* false */ -``` - -## hasAssocU - -```re sig -let hasAssocU: (t(('a, 'c)), 'b, [@bs] (('a, 'b) => bool)) => bool; -``` - -Uncurried version of [hasAssoc](#hasAssoc). - -## removeAssoc - -```re sig -let removeAssoc: (t(('a, 'c)), 'b, ('a, 'b) => bool) => t(('a, 'c)); -``` - -Return a list after removing the first pair whose first value is `k` per the equality predicate `eqFunction`; if not found, return a new list identical to `someList`. - -```re example -[(1, "a"), (2, "b"), (3, "c")]->Belt.List.removeAssoc(1, (==)); /* [(2, "b"), (3, "c")] */ - -[(9, "morning"), (15, "afternoon"), (22, "night")] -->Belt.List.removeAssoc(9, (k, item) => k /* 9 */ == item /* 9, 5, 22 */); -/* [(15, "afternoon"), (22, "night")] */ -``` - -## removeAssocU - -```re sig -let removeAssocU: (t(('a, 'c)), 'b, [@bs] (('a, 'b) => bool)) => t(('a, 'c)); -``` - -Uncurried version of [removeAssoc](#removeAssoc). - -## setAssoc - -```re sig -let setAssoc: (t(('a, 'c)), 'a, 'c, ('a, 'a) => bool) => t(('a, 'c)); -``` - -If `k` exists in `someList` by satisfying the `eqFunction` predicate, return a new list with the key and value replaced by the new `k` and `v`; otherwise, return a new list with the pair `k`, `v` added to the head of `someList`. - -```re example -[(1, "a"), (2, "b"), (3, "c")]->Belt.List.setAssoc(2, "x", (==)); /* [(1, "a"), (2, "x"), (3, "c")]; */ - -[(1, "a"), (3, "c")]->Belt.List.setAssoc(2, "b", (==)); /* [(2, "b"), (1, "a"), (3, "c")] */ - -[(9, "morning"), (3, "morning?!"), (22, "night")] -->Belt.List.setAssoc(15, "afternoon", (a, b) => a mod 12 == b mod 12); -/* [(9, "morning"), (15, "afternoon"), (22, "night")] */ -``` - -**Please note** - -In the last example, since: `15 mod 12` equals `3 mod 12` - -Both the key _and_ the value are replaced in the list. - -## setAssocU - -```re sig -let setAssocU: (t(('a, 'c)), 'a, 'c, [@bs] (('a, 'a) => bool)) => t(('a, 'c)); -``` - -Uncurried version of [setAssoc](#setAssoc). - -## sort - -```re sig -let sort: (t('a), ('a, 'a) => int) => t('a); -``` - -Returns a sorted list. - -```re example -Belt.List.sort([5, 4, 9, 3, 7], (a, b) => a - b); /* [3, 4, 5, 7, 9] */ -``` - -## sortU - -```re sig -let sortU: (t('a), [@bs] (('a, 'a) => int)) => t('a); -``` - -Uncurried version of [sort](#sort). diff --git a/pages/docs/manual/v8.0.0/api/belt/map-dict.mdx b/pages/docs/manual/v8.0.0/api/belt/map-dict.mdx deleted file mode 100644 index 030c04f94..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/map-dict.mdx +++ /dev/null @@ -1,397 +0,0 @@ -# MapDict - - - -This module seprate identity from data, it is a bit more verboe but slightly more efficient due to the fact that there is no need to pack identity and data back after each operation - -**_Advanced usage only_** - - - -## t - -```re sig -type t('key, 'value, 'id); -``` - -## cmp - -```re sig -type cmp('key, 'id) = Belt_Id.cmp('key, 'id); -``` - -## empty - -```re sig -let empty: t('k, 'v, 'id); -``` - -## isEmpty - -```re sig -let isEmpty: t('k, 'v, 'id) => bool; -``` - -## has - -```re sig -let has: (t('k, 'a, 'id), 'k, ~cmp: cmp('k, 'id)) => bool; -``` - -## cmpU - -```re sig -let cmpU: - (t('k, 'v, 'id), t('k, 'v, 'id), ~kcmp: cmp('k, 'id), ~vcmp: [@bs] (('v, 'v) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (t('k, 'v, 'id), t('k, 'v, 'id), ~kcmp: cmp('k, 'id), ~vcmp: ('v, 'v) => int) => int; -``` - -## eqU - -```re sig -let eqU: - (t('k, 'a, 'id), t('k, 'a, 'id), ~kcmp: cmp('k, 'id), ~veq: [@bs] (('a, 'a) => bool)) => bool; -``` - -## eq - -```re sig -let eq: (t('k, 'a, 'id), t('k, 'a, 'id), ~kcmp: cmp('k, 'id), ~veq: ('a, 'a) => bool) => bool; -``` - -`eq(m1, m2, cmp)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `cmp` is the equality predicate used to compare the data associated with the keys. - -## findFirstByU - -```re sig -let findFirstByU: (t('k, 'v, 'id), [@bs] (('k, 'v) => bool)) => option(('k, 'v)); -``` - -## findFirstBy - -```re sig -let findFirstBy: (t('k, 'v, 'id), ('k, 'v) => bool) => option(('k, 'v)); -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Map.Dict.fromArray([|(4, "4"), (1, "1"), (2, "2"), (3, "3")|], ~cmp=IntCmp.cmp); - -Belt.Map.Dict.findFirstBy(s0, (k, _) => k == 4) == Some((4, "4")); -``` - -## forEachU - -```re sig -let forEachU: (t('k, 'a, 'id), [@bs] (('k, 'a) => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('k, 'a, 'id), ('k, 'a) => unit) => unit; -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```re sig -let reduceU: (t('k, 'a, 'id), 'b, [@bs] (('b, 'k, 'a) => 'b)) => 'b; -``` - -## reduce - -```re sig -let reduce: (t('k, 'a, 'id), 'b, ('b, 'k, 'a) => 'b) => 'b; -``` - -`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```re sig -let everyU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => bool; -``` - -## every - -```re sig -let every: (t('k, 'a, 'id), ('k, 'a) => bool) => bool; -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```re sig -let someU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => bool; -``` - -## some - -```re sig -let some: (t('k, 'a, 'id), ('k, 'a) => bool) => bool; -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```re sig -let size: t('k, 'a, 'id) => int; -``` - -## toList - -```re sig -let toList: t('k, 'a, 'id) => list(('k, 'a)); -``` - -In increasing order. - -## toArray - -```re sig -let toArray: t('k, 'a, 'id) => array(('k, 'a)); -``` - -## fromArray - -```re sig -let fromArray: (array(('k, 'a)), ~cmp: cmp('k, 'id)) => t('k, 'a, 'id); -``` - -## keysToArray - -```re sig -let keysToArray: t('k, 'a, 'id) => array('k); -``` - -## valuesToArray - -```re sig -let valuesToArray: t('k, 'a, 'id) => array('a); -``` - -## minKey - -```re sig -let minKey: t('k, 'a, 'b) => option('k); -``` - -## minKeyUndefined - -```re sig -let minKeyUndefined: t('k, 'a, 'b) => Js.undefined('k); -``` - -## maxKey - -```re sig -let maxKey: t('k, 'a, 'b) => option('k); -``` - -## maxKeyUndefined - -```re sig -let maxKeyUndefined: t('k, 'a, 'b) => Js.undefined('k); -``` - -## minimum - -```re sig -let minimum: t('k, 'a, 'b) => option(('k, 'a)); -``` - -## minUndefined - -```re sig -let minUndefined: t('k, 'a, 'b) => Js.undefined(('k, 'a)); -``` - -## maximum - -```re sig -let maximum: t('k, 'a, 'b) => option(('k, 'a)); -``` - -## maxUndefined - -```re sig -let maxUndefined: t('k, 'a, 'b) => Js.undefined(('k, 'a)); -``` - -## get - -```re sig -let get: (t('k, 'a, 'id), 'k, ~cmp: cmp('k, 'id)) => option('a); -``` - -## getUndefined - -```re sig -let getUndefined: (t('k, 'a, 'id), 'k, ~cmp: cmp('k, 'id)) => Js.undefined('a); -``` - -## getWithDefault - -```re sig -let getWithDefault: (t('k, 'a, 'id), 'k, 'a, ~cmp: cmp('k, 'id)) => 'a; -``` - -## getExn - -```re sig -let getExn: (t('k, 'a, 'id), 'k, ~cmp: cmp('k, 'id)) => 'a; -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a, 'b, 'c) => unit; -``` - -## remove - -```re sig -let remove: (t('a, 'b, 'id), 'a, ~cmp: cmp('a, 'id)) => t('a, 'b, 'id); -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```re sig -let removeMany: (t('a, 'b, 'id), array('a), ~cmp: cmp('a, 'id)) => t('a, 'b, 'id); -``` - -## set - -```re sig -let set: (t('a, 'b, 'id), 'a, 'b, ~cmp: cmp('a, 'id)) => t('a, 'b, 'id); -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```re sig -let updateU: - (t('a, 'b, 'id), 'a, [@bs] (option('b) => option('b)), ~cmp: cmp('a, 'id)) => t('a, 'b, 'id); -``` - -## update - -```re sig -let update: (t('a, 'b, 'id), 'a, option('b) => option('b), ~cmp: cmp('a, 'id)) => t('a, 'b, 'id); -``` - -## mergeU - -```re sig -let mergeU: - ( - t('a, 'b, 'id), - t('a, 'c, 'id), - [@bs] (('a, option('b), option('c)) => option('d)), - ~cmp: cmp('a, 'id) - ) => - t('a, 'd, 'id); -``` - -## merge - -```re sig -let merge: - ( - t('a, 'b, 'id), - t('a, 'c, 'id), - ('a, option('b), option('c)) => option('d), - ~cmp: cmp('a, 'id) - ) => - t('a, 'd, 'id); -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```re sig -let mergeMany: (t('a, 'b, 'id), array(('a, 'b)), ~cmp: cmp('a, 'id)) => t('a, 'b, 'id); -``` - -## keepU - -```re sig -let keepU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => t('k, 'a, 'id); -``` - -## keep - -```re sig -let keep: (t('k, 'a, 'id), ('k, 'a) => bool) => t('k, 'a, 'id); -``` - -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. - -## partitionU - -```re sig -let partitionU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => (t('k, 'a, 'id), t('k, 'a, 'id)); -``` - -## partition - -```re sig -let partition: (t('k, 'a, 'id), ('k, 'a) => bool) => (t('k, 'a, 'id), t('k, 'a, 'id)); -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```re sig -let split: - (t('a, 'b, 'id), 'a, ~cmp: cmp('a, 'id)) => ((t('a, 'b, 'id), t('a, 'b, 'id)), option('b)); -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of `m` whose key is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```re sig -let mapU: (t('k, 'a, 'id), [@bs] ('a => 'b)) => t('k, 'b, 'id); -``` - -## map - -```re sig -let map: (t('k, 'a, 'id), 'a => 'b) => t('k, 'b, 'id); -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```re sig -let mapWithKeyU: (t('k, 'a, 'id), [@bs] (('k, 'a) => 'b)) => t('k, 'b, 'id); -``` - -## mapWithKey - -```re sig -let mapWithKey: (t('k, 'a, 'id), ('k, 'a) => 'b) => t('k, 'b, 'id); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/map-int.mdx b/pages/docs/manual/v8.0.0/api/belt/map-int.mdx deleted file mode 100644 index 1998e7b24..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/map-int.mdx +++ /dev/null @@ -1,373 +0,0 @@ -# MapInt - - - -Specalized when key type is `int`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison - - - -## key - -```re sig -type key = int; -``` - -## t - -```re sig -type t('value); -``` - -The type of maps from type `key` to type `'value`. - -## empty - -```re sig -let empty: t('v); -``` - -## isEmpty - -```re sig -let isEmpty: t('v) => bool; -``` - -## has - -```re sig -let has: (t('v), key) => bool; -``` - -## cmpU - -```re sig -let cmpU: (t('v), t('v), [@bs] (('v, 'v) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (t('v), t('v), ('v, 'v) => int) => int; -``` - -## eqU - -```re sig -let eqU: (t('v), t('v), [@bs] (('v, 'v) => bool)) => bool; -``` - -## eq - -```re sig -let eq: (t('v), t('v), ('v, 'v) => bool) => bool; -``` - -`eq(m1,m2)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. - -## findFirstByU - -```re sig -let findFirstByU: (t('v), [@bs] ((key, 'v) => bool)) => option((key, 'v)); -``` - -## findFirstBy - -```re sig -let findFirstBy: (t('v), (key, 'v) => bool) => option((key, 'v)); -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```re example -let s0 = Belt.Map.Int.fromArray([|(4, "4"), (1, "1"), (2, "2"), (3, "3")|]); - -Belt.Map.Int.findFirstBy(s0, (k, v) => k == 4) == Some((4, "4")); -``` - -## forEachU - -```re sig -let forEachU: (t('v), [@bs] ((key, 'v) => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('v), (key, 'v) => unit) => unit; -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```re sig -let reduceU: (t('v), 'v2, [@bs] (('v2, key, 'v) => 'v2)) => 'v2; -``` - -## reduce - -```re sig -let reduce: (t('v), 'v2, ('v2, key, 'v) => 'v2) => 'v2; -``` - -`reduce(m, a, f)` computes `f(kN, dN, ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```re sig -let everyU: (t('v), [@bs] ((key, 'v) => bool)) => bool; -``` - -## every - -```re sig -let every: (t('v), (key, 'v) => bool) => bool; -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```re sig -let someU: (t('v), [@bs] ((key, 'v) => bool)) => bool; -``` - -## some - -```re sig -let some: (t('v), (key, 'v) => bool) => bool; -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```re sig -let size: t('v) => int; -``` - -## toList - -```re sig -let toList: t('v) => list((key, 'v)); -``` - -In increasing order. - -## toArray - -```re sig -let toArray: t('v) => array((key, 'v)); -``` - -## fromArray - -```re sig -let fromArray: array((key, 'v)) => t('v); -``` - -## keysToArray - -```re sig -let keysToArray: t('v) => array(key); -``` - -## valuesToArray - -```re sig -let valuesToArray: t('v) => array('v); -``` - -## minKey - -```re sig -let minKey: t('a) => option(key); -``` - -## minKeyUndefined - -```re sig -let minKeyUndefined: t('a) => Js.undefined(key); -``` - -## maxKey - -```re sig -let maxKey: t('a) => option(key); -``` - -## maxKeyUndefined - -```re sig -let maxKeyUndefined: t('a) => Js.undefined(key); -``` - -## minimum - -```re sig -let minimum: t('v) => option((key, 'v)); -``` - -## minUndefined - -```re sig -let minUndefined: t('v) => Js.undefined((key, 'v)); -``` - -## maximum - -```re sig -let maximum: t('v) => option((key, 'v)); -``` - -## maxUndefined - -```re sig -let maxUndefined: t('v) => Js.undefined((key, 'v)); -``` - -## get - -```re sig -let get: (t('v), key) => option('v); -``` - -## getUndefined - -```re sig -let getUndefined: (t('v), key) => Js.undefined('v); -``` - -## getWithDefault - -```re sig -let getWithDefault: (t('v), key, 'v) => 'v; -``` - -## getExn - -```re sig -let getExn: (t('v), key) => 'v; -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a) => unit; -``` - -**raise** when invariant is not held - -## remove - -```re sig -let remove: (t('v), key) => t('v); -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```re sig -let removeMany: (t('v), array(key)) => t('v); -``` - -## set - -```re sig -let set: (t('v), key, 'v) => t('v); -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```re sig -let updateU: (t('v), key, [@bs] (option('v) => option('v))) => t('v); -``` - -## update - -```re sig -let update: (t('v), key, option('v) => option('v)) => t('v); -``` - -## mergeU - -```re sig -let mergeU: (t('v), t('v2), [@bs] ((key, option('v), option('v2)) => option('c))) => t('c); -``` - -## merge - -```re sig -let merge: (t('v), t('v2), (key, option('v), option('v2)) => option('c)) => t('c); -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```re sig -let mergeMany: (t('v), array((key, 'v))) => t('v); -``` - -## keepU - -```re sig -let keepU: (t('v), [@bs] ((key, 'v) => bool)) => t('v); -``` - -## keep - -```re sig -let keep: (t('v), (key, 'v) => bool) => t('v); -``` - -## partitionU - -```re sig -let partitionU: (t('v), [@bs] ((key, 'v) => bool)) => (t('v), t('v)); -``` - -## partition - -```re sig -let partition: (t('v), (key, 'v) => bool) => (t('v), t('v)); -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```re sig -let split: (key, t('v)) => (t('v), option('v), t('v)); -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of `m` whose key is strictly greater than `x`; `data` is `None` if m contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```re sig -let mapU: (t('v), [@bs] ('v => 'v2)) => t('v2); -``` - -## map - -```re sig -let map: (t('v), 'v => 'v2) => t('v2); -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```re sig -let mapWithKeyU: (t('v), [@bs] ((key, 'v) => 'v2)) => t('v2); -``` - -## mapWithKey - -```re sig -let mapWithKey: (t('v), (key, 'v) => 'v2) => t('v2); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/map-string.mdx b/pages/docs/manual/v8.0.0/api/belt/map-string.mdx deleted file mode 100644 index ee0cae32f..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/map-string.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# MapString - - - -Specalized when key type is `string`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison - - - -## key - -```re sig -type key = string; -``` - -## t - -```re sig -type t('value); -``` - -The type of maps from type `key` to type `'value`. - -## empty - -```re sig -let empty: t('v); -``` - -## isEmpty - -```re sig -let isEmpty: t('v) => bool; -``` - -## has - -```re sig -let has: (t('v), key) => bool; -``` - -## cmpU - -```re sig -let cmpU: (t('v), t('v), [@bs] (('v, 'v) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (t('v), t('v), ('v, 'v) => int) => int; -``` - -## eqU - -```re sig -let eqU: (t('v), t('v), [@bs] (('v, 'v) => bool)) => bool; -``` - -## eq - -```re sig -let eq: (t('v), t('v), ('v, 'v) => bool) => bool; -``` - -`eq(m1, m2)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. - -## findFirstByU - -```re sig -let findFirstByU: (t('v), [@bs] ((key, 'v) => bool)) => option((key, 'v)); -``` - -## findFirstBy - -```re sig -let findFirstBy: (t('v), (key, 'v) => bool) => option((key, 'v)); -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```re example -let s0 = Belt.Map.String.fromArray([|("4", 4), ("1", 1), ("2", 2), ("3", 3)|]); - -Belt.Map.String.findFirstBy(s0, (k, _) => k == "4") == Some(("4", 4)); -``` - -## forEachU - -```re sig -let forEachU: (t('v), [@bs] ((key, 'v) => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('v), (key, 'v) => unit) => unit; -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```re sig -let reduceU: (t('v), 'v2, [@bs] (('v2, key, 'v) => 'v2)) => 'v2; -``` - -## reduce - -```re sig -let reduce: (t('v), 'v2, ('v2, key, 'v) => 'v2) => 'v2; -``` - -`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...), where k1 ... kN)` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```re sig -let everyU: (t('v), [@bs] ((key, 'v) => bool)) => bool; -``` - -## every - -```re sig -let every: (t('v), (key, 'v) => bool) => bool; -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```re sig -let someU: (t('v), [@bs] ((key, 'v) => bool)) => bool; -``` - -## some - -```re sig -let some: (t('v), (key, 'v) => bool) => bool; -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```re sig -let size: t('v) => int; -``` - -## toList - -```re sig -let toList: t('v) => list((key, 'v)); -``` - -In increasing order. - -## toArray - -```re sig -let toArray: t('v) => array((key, 'v)); -``` - -## fromArray - -```re sig -let fromArray: array((key, 'v)) => t('v); -``` - -## keysToArray - -```re sig -let keysToArray: t('v) => array(key); -``` - -## valuesToArray - -```re sig -let valuesToArray: t('v) => array('v); -``` - -## minKey - -```re sig -let minKey: t('a) => option(key); -``` - -## minKeyUndefined - -```re sig -let minKeyUndefined: t('a) => Js.undefined(key); -``` - -## maxKey - -```re sig -let maxKey: t('a) => option(key); -``` - -## maxKeyUndefined - -```re sig -let maxKeyUndefined: t('a) => Js.undefined(key); -``` - -## minimum - -```re sig -let minimum: t('v) => option((key, 'v)); -``` - -## minUndefined - -```re sig -let minUndefined: t('v) => Js.undefined((key, 'v)); -``` - -## maximum - -```re sig -let maximum: t('v) => option((key, 'v)); -``` - -## maxUndefined - -```re sig -let maxUndefined: t('v) => Js.undefined((key, 'v)); -``` - -## get - -```re sig -let get: (t('v), key) => option('v); -``` - -## getUndefined - -```re sig -let getUndefined: (t('v), key) => Js.undefined('v); -``` - -## getWithDefault - -```re sig -let getWithDefault: (t('v), key, 'v) => 'v; -``` - -## getExn - -```re sig -let getExn: (t('v), key) => 'v; -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a) => unit; -``` - -**raise** when invariant is not held - -## remove - -```re sig -let remove: (t('v), key) => t('v); -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```re sig -let removeMany: (t('v), array(key)) => t('v); -``` - -## set - -```re sig -let set: (t('v), key, 'v) => t('v); -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```re sig -let updateU: (t('v), key, [@bs] (option('v) => option('v))) => t('v); -``` - -## update - -```re sig -let update: (t('v), key, option('v) => option('v)) => t('v); -``` - -## mergeU - -```re sig -let mergeU: (t('v), t('v2), [@bs] ((key, option('v), option('v2)) => option('c))) => t('c); -``` - -## merge - -```re sig -let merge: (t('v), t('v2), (key, option('v), option('v2)) => option('c)) => t('c); -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```re sig -let mergeMany: (t('v), array((key, 'v))) => t('v); -``` - -## keepU - -```re sig -let keepU: (t('v), [@bs] ((key, 'v) => bool)) => t('v); -``` - -## keep - -```re sig -let keep: (t('v), (key, 'v) => bool) => t('v); -``` - -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. - -## partitionU - -```re sig -let partitionU: (t('v), [@bs] ((key, 'v) => bool)) => (t('v), t('v)); -``` - -## partition - -```re sig -let partition: (t('v), (key, 'v) => bool) => (t('v), t('v)); -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of s that do not satisfy `p`. - -## split - -```re sig -let split: (key, t('v)) => (t('v), option('v), t('v)); -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of m whose key is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```re sig -let mapU: (t('v), [@bs] ('v => 'v2)) => t('v2); -``` - -## map - -```re sig -let map: (t('v), 'v => 'v2) => t('v2); -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```re sig -let mapWithKeyU: (t('v), [@bs] ((key, 'v) => 'v2)) => t('v2); -``` - -## mapWithKey - -```re sig -let mapWithKey: (t('v), (key, 'v) => 'v2) => t('v2); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/map.mdx b/pages/docs/manual/v8.0.0/api/belt/map.mdx deleted file mode 100644 index 6fee6ff3c..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/map.mdx +++ /dev/null @@ -1,643 +0,0 @@ -# Map - -The top level provides generic immutable map operations. - -It also has three specialized inner modules `Belt.Map.Int`, `Belt.Map.String` and `Belt.Map.Dict`. - -## t - -```re sig -type t('key, 'value, 'identity); -``` - -`'key` is the field type - -`'value` is the element type - -`'identity` the identity of the collection - -## id - -```re sig -type id('key, 'id) = Belt_Id.comparable('key, 'id); -``` - -The identity needed for making an empty map. - -## make - -```re sig -let make: (~id: id('k, 'id)) => t('k, 'v, 'id); -``` - -`make(~id)` creates a new map by taking in the comparator. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -let m = Belt.Map.make(~id=(module IntCmp)); - -Belt.Map.set(m, 0, "a"); -``` - -## isEmpty - -```re sig -let isEmpty: t('a, 'b, 'c) => bool; -``` - -`isEmpty(m)` checks whether a map m is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.isEmpty(Belt.Map.fromArray([|(1, "1")|], ~id=(module IntCmp))) == false; -``` - -## has - -```re sig -let has: (t('k, 'v, 'id), 'k) => bool; -``` - -`has(m, k)` checks whether `m` has the key `k`. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.has(Belt.Map.fromArray([|(1, "1")|], ~id=(module IntCmp)), 1) == true; -``` - -## cmpU - -```re sig -let cmpU: (t('k, 'v, 'id), t('k, 'v, 'id), [@bs] (('v, 'v) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (t('k, 'v, 'id), t('k, 'v, 'id), ('v, 'v) => int) => int; -``` - -`cmp(m0, m1, vcmp);` - -Total ordering of map given total ordering of value function. - -It will compare size first and each element following the order one by one. - -## eq - -```re sig -let eqU: (t('k, 'v, 'id), t('k, 'v, 'id), [@bs] (('v, 'v) => bool)) => bool; -``` - -`eq(m1, m2, veq)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `veq` is the equality predicate used to compare the data associated with the keys. - -## eq - -```re sig -let eq: (t('k, 'v, 'id), t('k, 'v, 'id), ('v, 'v) => bool) => bool; -``` - -## findFirstByU - -```re sig -let findFirstByU: (t('k, 'v, 'id), [@bs] (('k, 'v) => bool)) => option(('k, 'v)); -``` - -## findFirstBy - -```re sig -let findFirstBy: (t('k, 'v, 'id), ('k, 'v) => bool) => option(('k, 'v)); -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -let s0 = Belt.Map.fromArray(~id=(module IntCmp), [|(4, "4"), (1, "1"), (2, "2"), (3, "")|]); - -Belt.Map.findFirstBy(s0, (k, v) => k == 4); /* (4, "4") */ -``` - -## forEachU - -```re sig -let forEachU: (t('k, 'v, 'id), [@bs] (('k, 'v) => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('k, 'v, 'id), ('k, 'v) => unit) => unit; -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -let s0 = Belt.Map.fromArray(~id=(module IntCmp), [|(4, "4"), (1, "1"), (2, "2"), (3, "")|]); - -let acc = ref([]); - -Belt.Map.forEach(s0, (k, v) => acc := [(k, v), ...acc^]); - -acc^ == [(4, "4"), (3, "3"), (2, "2"), (1, "1")]; -``` - -## reduceU - -```re sig -let reduceU: (t('k, 'v, 'id), 'acc, [@bs] (('acc, 'k, 'v) => 'acc)) => 'acc; -``` - -## reduce - -```re sig -let reduce: (t('k, 'v, 'id), 'acc, ('acc, 'k, 'v) => 'acc) => 'acc; -``` - -`reduce(m, a, f)` computes `(f(kN, dN) ... (f(k1, d1, a))...)`, where `k1 ... kN` are the keys of all bindings in m (in increasing order), and `d1 ... dN` are the associated data. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -let s0 = Belt.Map.fromArray(~id=(module IntCmp), [|(4, "4"), (1, "1"), (2, "2"), (3, "3")|]); - -Belt.Map.reduce(s0, [], (acc, k, v) => [(k, v), ...acc]); /* [(4, "4"), (3, "3"), (2, "2"), (1, "1"), 0] */ -``` - -## everyU - -```re sig -let everyU: (t('k, 'v, 'id), [@bs] (('k, 'v) => bool)) => bool; -``` - -## every - -```re sig -let every: (t('k, 'v, 'id), ('k, 'v) => bool) => bool; -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```re sig -let someU: (t('k, 'v, 'id), [@bs] (('k, 'v) => bool)) => bool; -``` - -## some - -```re sig -let some: (t('k, 'v, 'id), ('k, 'v) => bool) => bool; -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```re sig -let size: t('k, 'v, 'id) => int; -``` - -`size(s)` - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.size(Belt.Map.fromArray([|(2, "2"), (2, "1"), (3, "3")|], ~id=(module IntCmp))) == 2; -``` - -## toArray - -```re sig -let toArray: t('k, 'v, 'id) => array(('k, 'v)); -``` - -`toArray(s)` - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.toArray(Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp))) -== [|(1, "1"), (2, "2"), (3, "3")|]; -``` - -## toList - -```re sig -let toList: t('k, 'v, 'id) => list(('k, 'v)); -``` - -In increasing order. - -See `Belt.Map.toArray` - -## fromArray - -```re sig -let fromArray: (array(('k, 'v)), ~id: id('k, 'id)) => t('k, 'v, 'id); -``` - -`fromArray(kvs, ~id);` - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.toArray(Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp))) -== [|(1, "1"), (2, "2"), (3, "3")|]; -``` - -## keysToArray - -```re sig -let keysToArray: t('k, 'v, 'id) => array('k); -``` - -`keysToArray(s);` - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.keysToArray(Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp))) == [|1, 2, 3|]; -``` - -## valuesToArray - -```re sig -let valuesToArray: t('k, 'v, 'id) => array('v); -``` - -`valuesToArray(s);` - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.valuesToArray(Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp))) == [|"1", "2", "3"|]; -``` - -## minKey - -```re sig -let minKey: t('k, 'a, 'b) => option('k); -``` - -`minKey(s)` returns the minimum key, None if not exist. - -## minKeyUndefined - -```re sig -let minKeyUndefined: t('k, 'a, 'b) => Js.undefined('k); -``` - -See `Belt.Map.minKey` - -## maxKey - -```re sig -let maxKey: t('k, 'a, 'b) => option('k); -``` - -`maxKey(s)` returns the maximum key, None if not exist. - -## maxKeyUndefined - -```re sig -let maxKeyUndefined: t('k, 'a, 'b) => Js.undefined('k); -``` - -See `Belt.Map.maxKey` - -## minimum - -```re sig -let minimum: t('k, 'v, 'a) => option(('k, 'v)); -``` - -`minimum(s)` returns the minimum key value pair, None if not exist - -## minUndefined - -```re sig -let minUndefined: t('k, 'v, 'a) => Js.undefined(('k, 'v)); -``` - -See `Belt.Map.minimum` - -## maximum - -```re sig -let maximum: t('k, 'v, 'a) => option(('k, 'v)); -``` - -`maximum(s)` returns the maximum key value pair, None if not exist. - -## maxUndefined - -```re sig -let maxUndefined: t('k, 'v, 'a) => Js.undefined(('k, 'v)); -``` - -See `Belt.Map.maximum` - -## get - -```re sig -let get: (t('k, 'v, 'id), 'k) => option('v); -``` - -`get(s, k)` - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -Belt.Map.get(Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp)), 2) == Some("2"); - -Belt.Map.get(Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp)), 2) == None; -``` - -## getUndefined - -```re sig -let getUndefined: (t('k, 'v, 'id), 'k) => Js.undefined('v); -``` - -See `Belt.Map.get` - -Returns `undefined` when not found - -## getWithDefault - -```re sig -let getWithDefault: (t('k, 'v, 'id), 'k, 'v) => 'v; -``` - -`getWithDefault(s, k, default)` - -See `Belt.Map.get` - -Returns default when `k` is not found. - -## getExn - -```re sig -let getExn: (t('k, 'v, 'id), 'k) => 'v; -``` - -`getExn(s, k)` - -See `Belt.Map.getExn` - -raise when `k` not exist - -## remove - -```re sig -let remove: (t('k, 'v, 'id), 'k) => t('k, 'v, 'id); -``` - -`remove(m, x)` when `x` is not in `m`, `m` is returned reference unchanged. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -let s0 = Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp)); - -let s1 = Belt.Map.remove(s0, 1); - -let s2 = Belt.Map.remove(s1, 1); - -s1 === s2; - -Belt.Map.keysToArray(s1) == [|2, 3|]; -``` - -## removeMany - -```re sig -let removeMany: (t('k, 'v, 'id), array('k)) => t('k, 'v, 'id); -``` - -`removeMany(s, xs)` - -Removing each of `xs` to `s`, note unlike `Belt.Map.remove`, the reference of return value might be changed even if none in `xs` exists `s`. - -## set - -```re sig -let set: (t('k, 'v, 'id), 'k, 'v) => t('k, 'v, 'id); -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, with a new binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = (a, b) => Pervasives.compare(a, b); - }); - -let s0 = Belt.Map.fromArray([|(2, "2"), (1, "1"), (3, "3")|], ~id=(module IntCmp)); - -let s1 = Belt.Map.set(s0, 2, "3"); - -Belt.Map.valuesToArray(s1) == [|"1", "3", "3"|]; -``` - -## updateU - -```re sig -let updateU: (t('k, 'v, 'id), 'k, [@bs] (option('v) => option('v))) => t('k, 'v, 'id); -``` - -## update - -```re sig -let update: (t('k, 'v, 'id), 'k, option('v) => option('v)) => t('k, 'v, 'id); -``` - -`update(m, x, f)` returns a map containing the same bindings as `m`, except for the binding of `x`. Depending on the value of `y` where `y` is `f(get(x, m))`, the binding of `x` is added, removed or updated. If `y` is `None`, the binding is removed if it exists; otherwise, if `y` is `Some(z)` then `x` is associated to `z` in the resulting map. - -## mergeMany - -```re sig -let mergeMany: (t('k, 'v, 'id), array(('k, 'v))) => t('k, 'v, 'id); -``` - -`mergeMany(s, xs)` - -Adding each of `xs` to `s`, note unlike `add`, the reference of return value might be changed even if all values in `xs` exist `s`. - -## mergeU - -```re sig -let mergeU: -(t('k, 'v, 'id), t('k, 'v2, 'id), [@bs] (('k, option('v), option('v2)) => option('v3))) => -t('k, 'v3, 'id); -``` - -## merge - -```re sig -let merge: -(t('k, 'v, 'id), t('k, 'v2, 'id), ('k, option('v), option('v2)) => option('v3)) => -t('k, 'v3, 'id); -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## keepU - -```re sig -let keepU: (t('k, 'v, 'id), [@bs] (('k, 'v) => bool)) => t('k, 'v, 'id); -``` - -## keep - -```re sig -let keep: (t('k, 'v, 'id), ('k, 'v) => bool) => t('k, 'v, 'id); -``` - -`keep(m, p)` returns the map with all the bindings in m that satisfy predicate `p`. - -## partitionU - -```re sig -let partitionU: (t('k, 'v, 'id), [@bs] (('k, 'v) => bool)) => (t('k, 'v, 'id), t('k, 'v, 'id)); -``` - -## partition - -```re sig -let partition: (t('k, 'v, 'id), ('k, 'v) => bool) => (t('k, 'v, 'id), t('k, 'v, 'id)); -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```re sig -let split: (t('k, 'v, 'id), 'k) => ((t('k, 'v, 'id), t('k, 'v, 'id)), option('v)); -``` - -`split(x, m)` returns a tuple `(l, r)`, data, where `l` is the map with all the bindings of `m` whose 'k is strictly less than `x`; `r` is the map with all the bindings of m whose 'k is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```re sig -let mapU: (t('k, 'v, 'id), [@bs] ('v => 'v2)) => t('k, 'v2, 'id); -``` - -## map - -```re sig -let map: (t('k, 'v, 'id), 'v => 'v2) => t('k, 'v2, 'id); -``` - -`map(m, f) returns a map with same domain as`m`, where the associated value`a`of all bindings of`m`has been replaced by the result of the application of`f`to`a`. The bindings are passed to`f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```re sig -let mapWithKeyU: (t('k, 'v, 'id), [@bs] (('k, 'v) => 'v2)) => t('k, 'v2, 'id); -``` - -## mapWithKey - -```re sig -let mapWithKey: (t('k, 'v, 'id), ('k, 'v) => 'v2) => t('k, 'v2, 'id); -``` - -`mapWithKey(m, f)` - -The same as `Belt.Map.map` except that `f` is supplied with one more argument: the key. - -## getData - -```re sig -let getData: t('k, 'v, 'id) => Belt_MapDict.t('k, 'v, 'id); -``` - -`getData(s0)` - -Advanced usage only - -Returns the raw data (detached from comparator), but its type is still manifested, so that user can pass identity directly without boxing. - -## getId - -```re sig -let getId: t('k, 'v, 'id) => id('k, 'id); -``` - -Advanced usage only - -Returns the identity of s0. - -## packIdData - -```re sig -let packIdData: (~id: id('k, 'id), ~data: Belt_MapDict.t('k, 'v, 'id)) => t('k, 'v, 'id); -``` - -`packIdData(~id, ~data)` - -Advanced usage only - -Returns the packed collection. diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-map-int.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-map-int.mdx deleted file mode 100644 index 1364551bf..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-map-int.mdx +++ /dev/null @@ -1,299 +0,0 @@ -# MutableMapInt - -## key - -```re sig -type key = int; -``` - -## t - -```re sig -type t('a); -``` - -## make - -```re sig -let make: unit => t('a); -``` - -## clear - -```re sig -let clear: t('a) => unit; -``` - -## isEmpty - -```re sig -let isEmpty: t('a) => bool; -``` - -## has - -```re sig -let has: (t('a), key) => bool; -``` - -## cmpU - -```re sig -let cmpU: (t('a), t('a), [@bs] (('a, 'a) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (t('a), t('a), ('a, 'a) => int) => int; -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```re sig -let eqU: (t('a), t('a), [@bs] (('a, 'a) => bool)) => bool; -``` - -## eq - -```re sig -let eq: (t('a), t('a), ('a, 'a) => bool) => bool; -``` - -`eq(m1, m2, cmp)` - -## forEachU - -```re sig -let forEachU: (t('a), [@bs] ((key, 'a) => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('a), (key, 'a) => unit) => unit; -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The application order of `f` is in increasing order. - -## reduceU - -```re sig -let reduceU: (t('a), 'b, [@bs] (('b, key, 'a) => 'b)) => 'b; -``` - -## reduce - -```re sig -let reduce: (t('a), 'b, ('b, key, 'a) => 'b) => 'b; -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```re sig -let everyU: (t('a), [@bs] ((key, 'a) => bool)) => bool; -``` - -## every - -```re sig -let every: (t('a), (key, 'a) => bool) => bool; -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## someU - -```re sig -let someU: (t('a), [@bs] ((key, 'a) => bool)) => bool; -``` - -## some - -```re sig -let some: (t('a), (key, 'a) => bool) => bool; -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## size - -```re sig -let size: t('a) => int; -``` - -## toList - -```re sig -let toList: t('a) => list((key, 'a)); -``` - -In increasing order - -## toArray - -```re sig -let toArray: t('a) => array((key, 'a)); -``` - -## fromArray - -```re sig -let fromArray: array((key, 'a)) => t('a); -``` - -## keysToArray - -```re sig -let keysToArray: t('a) => array(key); -``` - -## valuesToArray - -```re sig -let valuesToArray: t('a) => array('a); -``` - -## minKey - -```re sig -let minKey: t('a) => option(key); -``` - -## minKeyUndefined - -```re sig -let minKeyUndefined: t('a) => Js.undefined(key); -``` - -## maxKey - -```re sig -let maxKey: t('a) => option(key); -``` - -## maxKeyUndefined - -```re sig -let maxKeyUndefined: t('a) => Js.undefined(key); -``` - -## minimum - -```re sig -let minimum: t('a) => option((key, 'a)); -``` - -## minUndefined - -```re sig -let minUndefined: t('a) => Js.undefined((key, 'a)); -``` - -## maximum - -```re sig -let maximum: t('a) => option((key, 'a)); -``` - -## maxUndefined - -```re sig -let maxUndefined: t('a) => Js.undefined((key, 'a)); -``` - -## get - -```re sig -let get: (t('a), key) => option('a); -``` - -## getUndefined - -```re sig -let getUndefined: (t('a), key) => Js.undefined('a); -``` - -## getWithDefault - -```re sig -let getWithDefault: (t('a), key, 'a) => 'a; -``` - -## getExn - -```re sig -let getExn: (t('a), key) => 'a; -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a) => unit; -``` - -Raise when invariant is not held. - -## remove - -```re sig -let remove: (t('a), key) => unit; -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```re sig -let removeMany: (t('a), array(key)) => unit; -``` - -## set - -```re sig -let set: (t('a), key, 'a) => unit; -``` - -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```re sig -let updateU: (t('a), key, [@bs] (option('a) => option('a))) => unit; -``` - -## update - -```re sig -let update: (t('a), key, option('a) => option('a)) => unit; -``` - -## mapU - -```re sig -let mapU: (t('a), [@bs] ('a => 'b)) => t('b); -``` - -## map - -```re sig -let map: (t('a), 'a => 'b) => t('b); -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```re sig -let mapWithKeyU: (t('a), [@bs] ((key, 'a) => 'b)) => t('b); -``` - -## mapWithKey - -```re sig -let mapWithKey: (t('a), (key, 'a) => 'b) => t('b); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-map-string.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-map-string.mdx deleted file mode 100644 index 9c2f6b4d6..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-map-string.mdx +++ /dev/null @@ -1,299 +0,0 @@ -# MutableMapString - -## key - -```re sig -type key = string; -``` - -## t - -```re sig -type t('a); -``` - -## make - -```re sig -let make: unit => t('a); -``` - -## clear - -```re sig -let clear: t('a) => unit; -``` - -## isEmpty - -```re sig -let isEmpty: t('a) => bool; -``` - -## has - -```re sig -let has: (t('a), key) => bool; -``` - -## cmpU - -```re sig -let cmpU: (t('a), t('a), [@bs] (('a, 'a) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (t('a), t('a), ('a, 'a) => int) => int; -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```re sig -let eqU: (t('a), t('a), [@bs] (('a, 'a) => bool)) => bool; -``` - -## eq - -```re sig -let eq: (t('a), t('a), ('a, 'a) => bool) => bool; -``` - -`eq(m1, m2, cmp)` - -## forEachU - -```re sig -let forEachU: (t('a), [@bs] ((key, 'a) => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('a), (key, 'a) => unit) => unit; -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The application order of `f` is in increasing order. - -## reduceU - -```re sig -let reduceU: (t('a), 'b, [@bs] (('b, key, 'a) => 'b)) => 'b; -``` - -## reduce - -```re sig -let reduce: (t('a), 'b, ('b, key, 'a) => 'b) => 'b; -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```re sig -let everyU: (t('a), [@bs] ((key, 'a) => bool)) => bool; -``` - -## every - -```re sig -let every: (t('a), (key, 'a) => bool) => bool; -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## someU - -```re sig -let someU: (t('a), [@bs] ((key, 'a) => bool)) => bool; -``` - -## some - -```re sig -let some: (t('a), (key, 'a) => bool) => bool; -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## size - -```re sig -let size: t('a) => int; -``` - -## toList - -```re sig -let toList: t('a) => list((key, 'a)); -``` - -In increasing order - -## toArray - -```re sig -let toArray: t('a) => array((key, 'a)); -``` - -## fromArray - -```re sig -let fromArray: array((key, 'a)) => t('a); -``` - -## keysToArray - -```re sig -let keysToArray: t('a) => array(key); -``` - -## valuesToArray - -```re sig -let valuesToArray: t('a) => array('a); -``` - -## minKey - -```re sig -let minKey: t('a) => option(key); -``` - -## minKeyUndefined - -```re sig -let minKeyUndefined: t('a) => Js.undefined(key); -``` - -## maxKey - -```re sig -let maxKey: t('a) => option(key); -``` - -## maxKeyUndefined - -```re sig -let maxKeyUndefined: t('a) => Js.undefined(key); -``` - -## minimum - -```re sig -let minimum: t('a) => option((key, 'a)); -``` - -## minUndefined - -```re sig -let minUndefined: t('a) => Js.undefined((key, 'a)); -``` - -## maximum - -```re sig -let maximum: t('a) => option((key, 'a)); -``` - -## maxUndefined - -```re sig -let maxUndefined: t('a) => Js.undefined((key, 'a)); -``` - -## get - -```re sig -let get: (t('a), key) => option('a); -``` - -## getUndefined - -```re sig -let getUndefined: (t('a), key) => Js.undefined('a); -``` - -## getWithDefault - -```re sig -let getWithDefault: (t('a), key, 'a) => 'a; -``` - -## getExn - -```re sig -let getExn: (t('a), key) => 'a; -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a) => unit; -``` - -Raise when invariant is not held. - -## remove - -```re sig -let remove: (t('a), key) => unit; -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```re sig -let removeMany: (t('a), array(key)) => unit; -``` - -## set - -```re sig -let set: (t('a), key, 'a) => unit; -``` - -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```re sig -let updateU: (t('a), key, [@bs] (option('a) => option('a))) => unit; -``` - -## update - -```re sig -let update: (t('a), key, option('a) => option('a)) => unit; -``` - -## mapU - -```re sig -let mapU: (t('a), [@bs] ('a => 'b)) => t('b); -``` - -## map - -```re sig -let map: (t('a), 'a => 'b) => t('b); -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```re sig -let mapWithKeyU: (t('a), [@bs] ((key, 'a) => 'b)) => t('b); -``` - -## mapWithKey - -```re sig -let mapWithKey: (t('a), (key, 'a) => 'b) => t('b); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-map.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-map.mdx deleted file mode 100644 index c862f915d..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-map.mdx +++ /dev/null @@ -1,313 +0,0 @@ -# MutableMap - - - -A mutable sorted map module which allows customize compare behavior. - - - -Same as `Belt.Map`, but mutable. - -## t - -```re sig -type t('k, 'v, 'id); -``` - -## id - -```re sig -type id('key, 'id) = Belt_Id.comparable('key, 'id); -``` - -## make - -```re sig -let make: (~id: id('k, 'id)) => t('k, 'a, 'id); -``` - -## clear - -```re sig -let clear: t('a, 'b, 'c) => unit; -``` - -## isEmpty - -```re sig -let isEmpty: t('a, 'b, 'c) => bool; -``` - -## has - -```re sig -let has: (t('k, 'a, 'b), 'k) => bool; -``` - -## cmpU - -```re sig -let cmpU: (t('k, 'a, 'id), t('k, 'a, 'id), [@bs] (('a, 'a) => int)) => int; -``` - -## cmp - -```re sig -let cmp: (t('k, 'a, 'id), t('k, 'a, 'id), ('a, 'a) => int) => int; -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```re sig -let eqU: (t('k, 'a, 'id), t('k, 'a, 'id), [@bs] (('a, 'a) => bool)) => bool; -``` - -## eq - -```re sig -let eq: (t('k, 'a, 'id), t('k, 'a, 'id), ('a, 'a) => bool) => bool; -``` - -`eq(m1, m2, eqf)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `eqf` is the equality predicate used to compare the data associated with the keys. - -## forEachU - -```re sig -let forEachU: (t('k, 'a, 'id), [@bs] (('k, 'a) => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (t('k, 'a, 'id), ('k, 'a) => unit) => unit; -``` - -`forEach(m, f)` applies f to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```re sig -let reduceU: (t('k, 'a, 'id), 'b, [@bs] (('b, 'k, 'a) => 'b)) => 'b; -``` - -## reduce - -```re sig -let reduce: (t('k, 'a, 'id), 'b, ('b, 'k, 'a) => 'b) => 'b; -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```re sig -let everyU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => bool; -``` - -## every - -```re sig -let every: (t('k, 'a, 'id), ('k, 'a) => bool) => bool; -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. - -## someU - -```re sig -let someU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => bool; -``` - -## some - -```re sig -let some: (t('k, 'a, 'id), ('k, 'a) => bool) => bool; -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. - -## size - -```re sig -let size: t('k, 'a, 'id) => int; -``` - -## toList - -```re sig -let toList: t('k, 'a, 'id) => list(('k, 'a)); -``` - -In increasing order. - -## toArray - -```re sig -let toArray: t('k, 'a, 'id) => array(('k, 'a)); -``` - -## fromArray - -```re sig -let fromArray: (array(('k, 'a)), ~id: id('k, 'id)) => t('k, 'a, 'id); -``` - -## keysToArray - -```re sig -let keysToArray: t('k, 'a, 'b) => array('k); -``` - -## valuesToArray - -```re sig -let valuesToArray: t('b, 'a, 'c) => array('a); -``` - -## minKey - -```re sig -let minKey: t('k, 'a, 'b) => option('k); -``` - -## minKeyUndefined - -```re sig -let minKeyUndefined: t('k, 'a, 'b) => Js.undefined('k); -``` - -## maxKey - -```re sig -let maxKey: t('k, 'a, 'b) => option('k); -``` - -## maxKeyUndefined - -```re sig -let maxKeyUndefined: t('k, 'a, 'b) => Js.undefined('k); -``` - -## minimum - -```re sig -let minimum: t('k, 'a, 'b) => option(('k, 'a)); -``` - -## minUndefined - -```re sig -let minUndefined: t('k, 'a, 'b) => Js.undefined(('k, 'a)); -``` - -## maximum - -```re sig -let maximum: t('k, 'a, 'b) => option(('k, 'a)); -``` - -## maxUndefined - -```re sig -let maxUndefined: t('k, 'a, 'b) => Js.undefined(('k, 'a)); -``` - -## get - -```re sig -let get: (t('k, 'a, 'id), 'k) => option('a); -``` - -## getUndefined - -```re sig -let getUndefined: (t('k, 'a, 'id), 'k) => Js.undefined('a); -``` - -## getWithDefault - -```re sig -let getWithDefault: (t('k, 'a, 'id), 'k, 'a) => 'a; -``` - -## getExn - -```re sig -let getExn: (t('k, 'a, 'id), 'k) => 'a; -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a, 'b, 'c) => unit; -``` - -Raise when invariant is not held. - -## remove - -```re sig -let remove: (t('k, 'a, 'id), 'k) => unit; -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```re sig -let removeMany: (t('k, 'a, 'id), array('k)) => unit; -``` - -## set - -```re sig -let set: (t('k, 'a, 'id), 'k, 'a) => unit; -``` - -`set(m, x, y)` do the in-place modification - -## updateU - -```re sig -let updateU: (t('k, 'a, 'id), 'k, [@bs] (option('a) => option('a))) => unit; -``` - -## update - -```re sig -let update: (t('k, 'a, 'id), 'k, option('a) => option('a)) => unit; -``` - -## mergeMany - -```re sig -let mergeMany: (t('k, 'a, 'id), array(('k, 'a))) => unit; -``` - -## mapU - -```re sig -let mapU: (t('k, 'a, 'id), [@bs] ('a => 'b)) => t('k, 'b, 'id); -``` - -## map - -```re sig -let map: (t('k, 'a, 'id), 'a => 'b) => t('k, 'b, 'id); -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```re sig -let mapWithKeyU: (t('k, 'a, 'id), [@bs] (('k, 'a) => 'b)) => t('k, 'b, 'id); -``` - -## mapWithKey - -```re sig -let mapWithKey: (t('k, 'a, 'id), ('k, 'a) => 'b) => t('k, 'b, 'id); -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-queue.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-queue.mdx deleted file mode 100644 index 4cdfca820..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-queue.mdx +++ /dev/null @@ -1,175 +0,0 @@ -# MutableQueue - - - -An FIFO(first in first out) queue data structure. - - - -## t - -``` -type t('a); -``` - -The type of queues containing elements of `type('a)`. - -## make - -``` -let make: unit => t('a); -``` - -Returns a new queue, initially empty. - -## clear - -``` -let clear: t('a) => unit; -``` - -Discard all elements from the queue. - -## isEmpty - -``` -let isEmpty: t('a) => bool; -``` - -Returns `true` if the given queue is empty, `false` otherwise. - -## fromArray - -``` -let fromArray: array('a) => t('a); -``` - -`fromArray` a is equivalent to `Array.forEach(a, add(q, a));` - -## add - -``` -let add: (t('a), 'a) => unit; -``` - -`add(q, x)` adds the element `x` at the end of the queue `q`. - -## peek - -``` -let peek: t('a) => option('a); -``` - -`peekOpt(q)` returns the first element in queue `q`, without removing it from the queue. - -## peekUndefined - -``` -let peekUndefined: t('a) => Js.undefined('a); -``` - -`peekUndefined(q)` returns `undefined` if not found. - -## peekExn - -``` -let peekExn: t('a) => 'a; -``` - -raise an exception if `q` is empty - -## pop - -``` -let pop: t('a) => option('a); -``` - -`pop(q)` removes and returns the first element in queue `q`. - -## popUndefined - -``` -let popUndefined: t('a) => Js.undefined('a); -``` - -`popUndefined(q)` removes and returns the first element in queue `q`. it will return `undefined` if it is already empty. - -## popExn - -``` -let popExn: t('a) => 'a; -``` - -`popExn(q)` raise an exception if q is empty. - -## copy - -``` -let copy: t('a) => t('a); -``` - -`copy(q)` returns a fresh queue. - -## size - -``` -let size: t('a) => int; -``` - -Returns the number of elements in a queue. - -## mapU - -``` -let mapU: (t('a), [@bs] ('a => 'b)) => t('b); -``` - -## map - -``` -let map: (t('a), 'a => 'b) => t('b); -``` - -## forEachU - -``` -let forEachU: (t('a), [@bs] ('a => unit)) => unit; -``` - -## forEach - -``` -let forEach: (t('a), 'a => unit) => unit; -``` - -`forEach(q, f) applies`f`in turn to all elements of`q`, from the least recently entered to the most recently entered. The queue itself is unchanged. - -## reduceU - -``` -let reduceU: (t('a), 'b, [@bs] (('b, 'a) => 'b)) => 'b; -``` - -## reduce - -``` -let reduce: (t('a), 'b, ('b, 'a) => 'b) => 'b; -``` - -`reduce(q, accu, f)` is equivalent to `List.reduce(l, accu, f)`, where `l` is the list of `q`'s elements. The queue remains unchanged. - -## transfer - -``` -let transfer: (t('a), t('a)) => unit; -``` - -`transfer(q1, q2)` adds all of `q1`'s elements at the end of the queue `q2`, then clears `q1`. It is equivalent to the sequence `forEach((x) => add(x, q2), q1);`; clear `q1`, but runs in constant time. - -## toArray - -``` -let toArray: t('a) => array('a); -``` - -First added will be in the beginning of the array. diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-set-int.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-set-int.mdx deleted file mode 100644 index 7e4e10cd0..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-set-int.mdx +++ /dev/null @@ -1,563 +0,0 @@ -# MutableSetInt - - - -This module is [Belt.MutableSet](./mutable-set) specialized with key type to be a `int` type. -It is more efficient in general, the API is the same with [Belt.MutableSet](./mutable-set) except its key type is fixed, and identity is not needed (using the built-in one). - - - -## value - -```re sig -type value = int; -``` - -The type of the set elements - -## t - -```re sig -type t; -``` - -Type of the sets. - -## make - -```re sig -let make: unit => t; -``` - -Returns empty set. - -```re example -let set = Belt.MutableSet.Int.make(); -``` - -## fromArray - -```re sig -let fromArray: array(value) => t; -``` - -Creates new set from array of elements. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|1, 3, 2, 4|]) - -s0->Belt.MutableSet.Int.toArray; /* [|1, 2, 3, 4|] */ -``` - -## fromSortedArrayUnsafe - -```re sig -let fromSortedArrayUnsafe: array(value) => t; -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```re sig -let copy: t => t; -``` - -Returns copy of a set. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|1, 3, 2, 4|]) - -let copied = s0->Belt.MutableSet.Int.copy; -copied->Belt.MutableSet.Int.toArray /* [|1, 2, 3, 4|] */ -``` - -## isEmpty - -```re sig -let isEmpty: t => bool; -``` - -Checks if set is empty. - -```re example -let empty = Belt.MutableSet.Int.fromArray([||]); -let notEmpty = Belt.MutableSet.Int.fromArray([|1|]); - -Belt.MutableSet.Int.isEmpty(empty); /* true */ -Belt.MutableSet.Int.isEmpty(notEmpty); /* false */ -``` - -## has - -```re sig -let has: (t, value) => bool; -``` - -Checks if element exists in set. - -```re example -let set = Belt.MutableSet.Int.fromArray([|1, 4, 2, 5|]); - -set->Belt.MutableSet.Int.has(3) /* false */ -set->Belt.MutableSet.Int.has(1) /* true */ -``` - -## add - -```re sig -let add: (t, value) => unit; -``` - -Adds element to set. If element existed in set, value is unchanged. - -```re example -let s0 = Belt.MutableSet.Int.make(); -s0->Belt.MutableSet.Int.add(1); -s0->Belt.MutableSet.Int.add(2); -s0->Belt.MutableSet.Int.add(2); - -s0->Belt.MutableSet.Int.toArray; /* [|1, 2|] */ -``` - -## addCheck - -``` -let addCheck: (t, value) => bool; -``` - -## mergeMany - -```re sig -let mergeMany: (t, array(value)) => unit; -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```re example -let set = Belt.MutableSet.Int.make(); - -set->Belt.MutableSet.Int.mergeMany([|5, 4, 3, 2, 1|]); -set->Belt.MutableSet.Int.toArray; /* [|1, 2, 3, 4, 5|] */ -``` - -## remove - -```re sig -let remove: (t, value) => unit; -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|2,3,1,4,5|]); -s0->Belt.MutableSet.Int.remove(1); -s0->Belt.MutableSet.Int.remove(3); -s0->Belt.MutableSet.Int.remove(3); - -s0->Belt.MutableSet.Int.toArray; /* [|2,4,5|] */ -``` - -## removeCheck - -```re sig -let removeCheck: (t, value) => bool; -``` - -## removeMany - -```re sig -let removeMany: (t, array(value)) => unit; -``` - -Removes each element of array from set. - -```re example -let set = Belt.MutableSet.Int.fromArray([|1, 2, 3, 4|]); - -set->Belt.MutableSet.Int.removeMany([|5, 4, 3, 2, 1|]); -set->Belt.MutableSet.Int.toArray; /* [||] */ -``` - -## union - -```re sig -let union: (t, t) => t; -``` - -Returns union of two sets. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.MutableSet.Int.fromArray([|5,2,3,1,5,4|]); -let union = Belt.MutableSet.Int.union(s0, s1); -union->Belt.MutableSet.Int.toArray; /* [|1,2,3,4,5,6|] */ -``` - -## intersect - -```re sig -let intersect: (t, t) => t; -``` - -Returns intersection of two sets. - -```re example - -let s0 = Belt.MutableSet.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.MutableSet.Int.fromArray([|5,2,3,1,5,4|]); -let intersect = Belt.MutableSet.Int.intersect(s0, s1); -intersect->Belt.MutableSet.Int.toArray; /* [|2,3,5|] */ -``` - -## diff - -```re sig -let diff: (t, t) => t; -``` - -Returns elements from first set, not existing in second set. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.MutableSet.Int.fromArray([|5,2,3,1,5,4|]); -Belt.MutableSet.Int.toArray(Belt.MutableSet.Int.diff(s0, s1)); /* [|6|] */ -Belt.MutableSet.Int.toArray(Belt.MutableSet.Int.diff(s1,s0)); /* [|1,4|] */ -``` - -## subset - -```re sig -let subset: (t, t) => bool; -``` - -Checks if second set is subset of first set. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.MutableSet.Int.fromArray([|5,2,3,1,5,4|]); -let s2 = Belt.MutableSet.Int.intersect(s0, s1); -Belt.MutableSet.Int.subset(s2, s0); /* true */ -Belt.MutableSet.Int.subset(s2, s1); /* true */ -Belt.MutableSet.Int.subset(s1, s0); /* false */ -``` - -## cmp - -```re sig -let cmp: (t, t) => int; -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```re sig -let eq: (t, t) => bool; -``` - -Checks if two sets are equal. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|5,2,3|]); -let s1 = Belt.MutableSet.Int.fromArray([|3,2,5|]); - -Belt.MutableSet.Int.eq(s0, s1); /* true */ -``` - -## forEachU - -```re sig -let forEachU: (t, [@bs] (value => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t, value => unit) => unit; -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|5,2,3,5,6|]); -let acc = ref([]); -s0->Belt.MutableSet.Int.forEach(x => { - acc := Belt.List.add(acc^, x) -}); -acc; /* [6,5,3,2] */ -``` - -## reduceU - -```re sig -let reduceU: (t, 'a, [@bs] (('a, value) => 'a)) => 'a; -``` - -## reduce - -``` -let reduce: (t, 'a, ('a, value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|5,2,3,5,6|]); -s0->Belt.MutableSet.Int.reduce([], (acc, element) => - acc->Belt.List.add(element) -); /* [6,5,3,2] */ -``` - -## everyU - -```re sig -let everyU: (t, [@bs] (value => bool)) => bool; -``` - -## every - -```re sig -let every: (t, value => bool) => bool; -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```re example -let isEven = x => x mod 2 == 0; - -let s0 = Belt.MutableSet.Int.fromArray([|2,4,6,8|]); -s0->Belt.MutableSet.Int.every(isEven); /* true */ -``` - -## someU - -```re sig -let someU: (t, [@bs] (value => bool)) => bool; -``` - -## some - -```re sig -let some: (t, value => bool) => bool; -``` - -Checks if at least one element of the set satisfies the predicate. - -```re example -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.MutableSet.Int.fromArray([|1,2,4,6,8|]); -s0->Belt.MutableSet.Int.some(isOdd); /* true */ -``` - -## keepU - -```re sig -let keepU: (t, [@bs] (value => bool)) => t; -``` - -## keep - -```re sig -let keep: (t, value => bool) => t; -``` - -Returns the set of all elements that satisfy the predicate. - -```re example -let isEven = x => x mod 2 == 0; - -let s0 = Belt.MutableSet.Int.fromArray([|1,2,3,4,5|]); -let s1 = s0->Belt.MutableSet.Int.keep(isEven); - -s1->Belt.MutableSet.Int.toArray; /* [|2, 4|] */ -``` - -## partitionU - -```re sig -let partitionU: (t, [@bs] (value => bool)) => (t, t); -``` - -## partition - -```re sig -let partition: (t, value => bool) => (t, t); -``` - -```re example -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.MutableSet.Int.fromArray([|1,2,3,4,5|]); -let (s1, s2) = s0->Belt.MutableSet.Int.partition(isOdd); - -s1->Belt.MutableSet.Int.toArray; /* [|1,3,5|] */ -s2->Belt.MutableSet.Int.toArray; /* [|2,4|] */ -``` - -## size - -```re sig -let size: t => int; -``` - -Returns size of the set. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|1,2,3,4|]); - -s0->Belt.MutableSet.Int.size; /* 4 */ -``` - -## toList - -```re sig -let toList: t => list(value); -``` - -Returns list of ordered set elements. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|3,2,1,5|]); - -s0->Belt.MutableSet.Int.toList; /* [1,2,3,5] */ -``` - -## toArray - -```re sig -let toArray: t => array(value); -``` - -Returns array of ordered set elements. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|3,2,1,5|]); - -s0->Belt.MutableSet.Int.toArray; /* [|1,2,3,5|] */ -``` - -## minimum - -```re sig -let minimum: t => option(value); -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.MutableSet.Int.make(); -let s1 = Belt.MutableSet.Int.fromArray([|3,2,1,5|]); - -s0->Belt.MutableSet.Int.minimum; /* None */ -s1->Belt.MutableSet.Int.minimum; /* Some(1) */ -``` - -## minUndefined - -```re sig -let minUndefined: t => Js.undefined(value); -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.MutableSet.Int.make(); -let s1 = Belt.MutableSet.Int.fromArray([|3,2,1,5|]); - -s0->Belt.MutableSet.Int.minUndefined; /* undefined */ -s1->Belt.MutableSet.Int.minUndefined; /* 1 */ -``` - -## maximum - -```re sig -let maximum: t => option(value); -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.MutableSet.Int.make(); -let s1 = Belt.MutableSet.Int.fromArray([|3,2,1,5|]); - -s0->Belt.MutableSet.Int.maximum; /* None */ -s1->Belt.MutableSet.Int.maximum; /* Some(5) */ -``` - -## maxUndefined - -```re sig -let maxUndefined: t => Js.undefined(value); -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.MutableSet.Int.make(); -let s1 = Belt.MutableSet.Int.fromArray([|3,2,1,5|]); - -s0->Belt.MutableSet.Int.maxUndefined; /* undefined */ -s1->Belt.MutableSet.Int.maxUndefined; /* 5 */ -``` - -## get - -```re sig -let get: (t, value) => option(value); -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|1,2,3,4,5|]); - -s0->Belt.MutableSet.Int.get(3); /* Some(3) */ -s0->Belt.MutableSet.Int.get(20); /* None */ -``` - -## getUndefined - -```re sig -let getUndefined: (t, value) => Js.undefined(value); -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```re sig -let getExn: (t, value) => value; -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```re sig -let split: (t, value) => ((t, t), bool); -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```re example -let s0 = Belt.MutableSet.Int.fromArray([|1,2,3,4,5|]); - -let ((smaller, larger), present) = s0->Belt.MutableSet.Int.split(3); - -present; /* true */ -smaller->Belt.MutableSet.Int.toArray; /* [|1,2|] */ -larger->Belt.MutableSet.Int.toArray; /* [|4,5|] */ - -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t => unit; -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-set-string.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-set-string.mdx deleted file mode 100644 index aeab80160..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-set-string.mdx +++ /dev/null @@ -1,565 +0,0 @@ -# MutableSetString - - - -This module is [Belt.MutableSet](./mutable-set) specialized with key type to be a `string` type. -It is more efficient in general, the API is the same with [Belt.MutableSet](./mutable-set) except its key type is fixed, and identity is not needed (using the built-in one) - - - -## value - -```re sig -type value = string; -``` - -The type of the set elements. - -## t - -```re sig -type t; -``` - -The type of sets. - -## make - -```re sig -let make: unit => t; -``` - -Returns empty set. - -```re example -let set = Belt.MutableSet.String.make(); -``` - -## fromArray - -```re sig -let fromArray: array(value) => t; -``` - -Creates new set from array of elements. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "orange", "banana"|]) - -s0->Belt.MutableSet.String.toArray; /* [|"apple", "banana", "orange"|] */ -``` - -## fromSortedArrayUnsafe - -```re sig -let fromSortedArrayUnsafe: array(value) => t; -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```re sig -let copy: t => t; -``` - -Returns copy of a set. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"orange", "apple"|]) - -let copied = s0->Belt.MutableSet.String.copy; -copied->Belt.MutableSet.String.toArray /* [|"apple", "orange"|] */ -``` - -## isEmpty - -```re sig -let isEmpty: t => bool; -``` - -Checks if set is empty. - -```re example -let empty = Belt.MutableSet.String.fromArray([||]); -let notEmpty = Belt.MutableSet.String.fromArray([|"apple"|]); - -Belt.MutableSet.String.isEmpty(empty); /* true */ -Belt.MutableSet.String.isEmpty(notEmpty); /* false */ -``` - -## has - -```re sig -let has: (t, value) => bool; -``` - -Checks if element exists in set. - -```re example -let set = Belt.MutableSet.String.fromArray([|"apple", "orange", "banana"|]); - -set->Belt.MutableSet.String.has("strawberry") /* false */ -set->Belt.MutableSet.String.has("apple") /* true */ -``` - -## add - -```re sig -let add: (t, value) => unit; -``` - -Adds element to set. If element existed in set, value is unchanged. - -```re example -let s0 = Belt.MutableSet.String.make(); -s0->Belt.MutableSet.String.add("apple"); -s0->Belt.MutableSet.String.add("banana"); -s0->Belt.MutableSet.String.add("banana"); - -s0->Belt.MutableSet.String.toArray; /* [|"apple", "banana"|] */ -``` - -## addCheck - -```re sig -let addCheck: (t, value) => bool; -``` - -## mergeMany - -```re sig -let mergeMany: (t, array(value)) => unit; -``` - -Adds each element of array to set. - -```re example -let set = Belt.MutableSet.String.make(); - -set->Belt.MutableSet.String.mergeMany([|"apple", "banana", "orange", "strawberry"|]); -set->Belt.MutableSet.String.toArray; /* [|"apple", "banana", "orange", "strawberry"|] */ -``` - -## remove - -```re sig -let remove: (t, value) => unit; -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"orange", "banana", "apple"|]); -s0->Belt.MutableSet.String.remove("apple"); -s0->Belt.MutableSet.String.remove("banana"); -s0->Belt.MutableSet.String.remove("banana"); - -s0->Belt.MutableSet.String.toArray; /* [|"orange"|] */ -``` - -## removeCheck - -```re sig -let removeCheck: (t, value) => bool; -``` - -## removeMany - -```re sig -let removeMany: (t, array(value)) => unit; -``` - -Removes each element of array from set. - -```re example -let set = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange"|]); - -set->Belt.MutableSet.String.removeMany([|"strawberry", "apple", "banana", "orange"|]); -set->Belt.MutableSet.String.toArray; /* [||] */ -``` - -## union - -```re sig -let union: (t, t) => t; -``` - -Returns union of two sets. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange", "carrot"|]); -let s1 = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange", "strawberry"|]); -let union = Belt.MutableSet.String.union(s0, s1); -union->Belt.MutableSet.String.toArray; /* [|"apple", "banana", "carrot", "orange", "strawberry"|] */ -``` - -## intersect - -```re sig -let intersect: (t, t) => t; -``` - -Returns intersection of two sets. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange", "carrot"|]); -let s1 = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange", "strawberry"|]); -let intersect = Belt.MutableSet.String.intersect(s0, s1); -intersect->Belt.MutableSet.String.toArray; /* [|"apple", "banana", "orange"|] */ -``` - -## diff - -```re sig -let diff: (t, t) => t; -``` - -Returns elements from first set, not existing in second set. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange", "carrot"|]); -let s1 = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange", "strawberry"|]); -Belt.MutableSet.String.toArray(Belt.MutableSet.String.diff(s0, s1)); /* [|"carrot"|] */ -Belt.MutableSet.String.toArray(Belt.MutableSet.String.diff(s1, s0)); /* [|"strawberry"|] */ -``` - -## subset - -```re sig -let subset: (t, t) => bool; -``` - -Checks if second set is subset of first set. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"5", "2", "3", "5", "6"|]); -let s1 = Belt.MutableSet.String.fromArray([|"5", "2", "3", "1", "5", "4"|]); -let s2 = Belt.MutableSet.String.intersect(s0, s1); -Belt.MutableSet.String.subset(s2, s0); /* true */ -Belt.MutableSet.String.subset(s2, s1); /* true */ -Belt.MutableSet.String.subset(s1, s0); /* false */ -``` - -## cmp - -```re sig -let cmp: (t, t) => int; -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```re sig -let eq: (t, t) => bool; -``` - -Checks if two sets are equal. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "orange"|]); -let s1 = Belt.MutableSet.String.fromArray([|"orange", "apple"|]); - -Belt.MutableSet.String.eq(s0, s1); /* true */ -``` - -## forEachU - -```re sig -let forEachU: (t, [@bs] (value => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t, value => unit) => unit; -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"banana", "orange", "apple"|]); -let acc = ref([]); -s0->Belt.MutableSet.String.forEach(x => { - acc := Belt.List.add(acc^, x) -}); -acc; /* ["orange", "banana", "apple"] */ -``` - -## reduceU - -```re sig -let reduceU: (t, 'a, [@bs] (('a, value) => 'a)) => 'a; -``` - -## reduce - -```re sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "orange"|]); -s0->Belt.MutableSet.String.reduce(0, (acc, element) => - acc + String.length(element) -); /* 11 */ -``` - -## everyU - -```re sig -let everyU: (t, [@bs] (value => bool)) => bool; -``` - -## every - -```re sig -let every: (t, value => bool) => bool; -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```re example -let hasAtLeastFiveChars = x => String.length(x) >= 5; - -let s0 = Belt.MutableSet.String.fromArray([|"apple", "carrot"|]); -s0->Belt.MutableSet.String.every(hasAtLeastFiveChars); /* true */ -``` - -## someU - -```re sig -let someU: (t, [@bs] (value => bool)) => bool; -``` - -## some - -```re sig -let some: (t, value => bool) => bool; -``` - -Checks if at least one element of the set satisfies the predicate. - -```re example -let hasFiveChars = x => String.length(x) == 5; - -let s0 = Belt.MutableSet.String.fromArray([|"strawberry", "apple"|]); -s0->Belt.MutableSet.String.some(hasFiveChars); /* true */ -``` - -## keepU - -```re sig -let keepU: (t, [@bs] (value => bool)) => t; -``` - -## keep - -```re sig -let keep: (t, value => bool) => t; -``` - -Returns the set of all elements that satisfy the predicate. - -```re example -let hasFiveChars = x => String.length(x) == 5; - -let s0 = Belt.MutableSet.String.fromArray([|"apple", "orange", "banana"|]); -let s1 = s0->Belt.MutableSet.String.keep(hasFiveChars); - -s1->Belt.MutableSet.String.toArray; /* [|"apple"|] */ -``` - -## partitionU - -```re sig -let partitionU: (t, [@bs] (value => bool)) => (t, t); -``` - -## partition - -```re sig -let partition: (t, value => bool) => (t, t); -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```re example -let hasFiveChars = x => String.length(x) == 5; - -let s0 = Belt.MutableSet.String.fromArray([|"apple", "carrot"|]); -let (s1, s2) = s0->Belt.MutableSet.String.partition(hasFiveChars); - -s1->Belt.MutableSet.String.toArray; /* [|"apple"|] */ -s2->Belt.MutableSet.String.toArray; /* [|"carrot"|] */ -``` - -## size - -```re sig -let size: t => int; -``` - -Returns size of the set. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple"|]); - -s0->Belt.MutableSet.String.size; /* 1 */ -``` - -## toList - -```re sig -let toList: t => list(value); -``` - -Returns list of ordered set elements. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "watermelon"|]); - -s0->Belt.MutableSet.String.toList; /* ["apple", "watermelon"] */ -``` - -## toArray - -```re sig -let toArray: t => array(value); -``` - -Returns array of ordered set elements. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "watermelon"|]); - -s0->Belt.MutableSet.String.toArray; /* [|"apple", "watermelon"|] */ -``` - -## minimum - -```re sig -let minimum: t => option(value); -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.MutableSet.String.make(); -let s1 = Belt.MutableSet.String.fromArray([|"apple", "orange"|]); - -s0->Belt.MutableSet.String.minimum; /* None */ -s1->Belt.MutableSet.String.minimum; /* Some("apple") */ -``` - -## minUndefined - -```re sig -let minUndefined: t => Js.undefined(value); -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.MutableSet.String.make(); -let s1 = Belt.MutableSet.String.fromArray([|"apple", "orange"|]); - -s0->Belt.MutableSet.String.minUndefined; /* undefined */ -s1->Belt.MutableSet.String.minUndefined; /* "apple" */ -``` - -## maximum - -```re sig -let maximum: t => option(value); -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.MutableSet.String.make(); -let s1 = Belt.MutableSet.String.fromArray([|"apple", "orange"|]); - -s0->Belt.MutableSet.String.maximum; /* None */ -s1->Belt.MutableSet.String.maximum; /* Some("orange") */ -``` - -## maxUndefined - -```re sig -let maxUndefined: t => Js.undefined(value); -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.MutableSet.String.make(); -let s1 = Belt.MutableSet.String.fromArray([|"apple", "orange"|]); - -s0->Belt.MutableSet.String.maxUndefined; /* undefined */ -s1->Belt.MutableSet.String.maxUndefined; /* orange */ -``` - -## get - -```re sig -let get: (t, value) => option(value); -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "carrot"|]); - -s0->Belt.MutableSet.String.get("carrot"); /* Some("carrot") */ -s0->Belt.MutableSet.String.get("watermelon"); /* None */ -``` - -## getUndefined - -```re sig -let getUndefined: (t, value) => Js.undefined(value); -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```re sig -let getExn: (t, value) => value; -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```re sig -let split: (t, value) => ((t, t), bool); -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```re example -let s0 = Belt.MutableSet.String.fromArray([|"apple", "banana", "orange"|]); - -let ((smaller, larger), present) = s0->Belt.MutableSet.String.split("banana"); - -present; /* true */ -smaller->Belt.MutableSet.String.toArray; /* [|"apple"|] */ -larger->Belt.MutableSet.String.toArray; /* [|"orange"|] */ -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t => unit; -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-set.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-set.mdx deleted file mode 100644 index 21bd2ab4a..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-set.mdx +++ /dev/null @@ -1,745 +0,0 @@ -# MutableSet - - - -A **mutable** sorted set module which allows customize compare behavior. -The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map. - -It also has three specialized inner modules [Belt.MutableSet.Int](./mutable-set-int) and [Belt.MutableSet.String](./mutable-set-string) - This module separates data from function which is more verbose but slightly more efficient - - - -```re example -module PairComparator = - Belt.Id.MakeComparable({ - type t = (int, int); - let cmp = ((a0, a1), (b0, b1)) => - switch (Pervasives.compare(a0, b0)) { - | 0 => Pervasives.compare(a1, b1) - | c => c - }; - }); - -let mySet = Belt.MutableSet.make(~id=(module PairComparator)); -mySet->Belt.MutableSet.add((1, 2)); -``` - -## t - -```re sig -type t('value, 'id); -``` - -`'value` is the element type - -`'id` the identity of the collection - -## id - -```re sig -type id('value, 'id) = Belt_Id.comparable('value, 'id); -``` - -The identity needed for making a set from scratch - -## make - -```re sig -let make: (~id: id('value, 'id)) => t('value, 'id); -``` - -Creates a new set by taking in the comparator - -## fromArray - -```re sig -let fromArray: (array('value), ~id: id('value, 'id)) => t('value, 'id); -``` - -Creates new set from array of elements. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|1, 3, 2, 4|], ~id=(module IntCmp)) - -s0->Belt.MutableSet.toArray; /* [|1, 2, 3, 4|] */ -``` - -## fromSortedArrayUnsafe - -```re sig -let fromSortedArrayUnsafe: (array('value), ~id: id('value, 'id)) => t('value, 'id); -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```re sig -let copy: t('value, 'id) => t('value, 'id); -``` - -Returns copy of a set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|1, 3, 2, 4|], ~id=(module IntCmp)) - -let copied = s0->Belt.MutableSet.copy; -copied->Belt.MutableSet.toArray /* [|1, 2, 3, 4|] */ -``` - -## isEmpty - -```re sig -let isEmpty: t('a, 'b) => bool; -``` - -Checks if set is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let empty = Belt.MutableSet.fromArray([||], ~id=(module IntCmp)); -let notEmpty = Belt.MutableSet.fromArray([|1|],~id=(module IntCmp)); - -Belt.MutableSet.isEmpty(empty); /* true */ -Belt.MutableSet.isEmpty(notEmpty); /* false */ -``` - -## has - -```re sig -let has: (t('value, 'a), 'value) => bool; -``` - -Checks if element exists in set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let set = Belt.MutableSet.fromArray([|1, 4, 2, 5|], ~id=(module IntCmp)); - -set->Belt.MutableSet.has(3) /* false */ -set->Belt.MutableSet.has(1) /* true */ -``` - -## add - -```re sig -let add: (t('value, 'id), 'value) => unit; -``` - -Adds element to set. If element existed in set, value is unchanged. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.make(~id=(module IntCmp)); -s0->Belt.MutableSet.add(1); -s0->Belt.MutableSet.add(2); -s0->Belt.MutableSet.add(2); - -s0->Belt.MutableSet.toArray; /* [|1, 2|] */ -``` - -## addCheck - -```re sig -let addCheck: (t('value, 'id), 'value) => bool; -``` - -## mergeMany - -```re sig -let mergeMany: (t('value, 'id), array('value)) => unit; -``` - -Adds each element of array to set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let set = Belt.MutableSet.make(~id=(module IntCmp)); - -set->Belt.MutableSet.mergeMany([|5, 4, 3, 2, 1|]); -set->Belt.MutableSet.toArray; /* [|1, 2, 3, 4, 5|] */ -``` - -## remove - -```re sig -let remove: (t('value, 'id), 'value) => unit; -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|2,3,1,4,5|], ~id=(module IntCmp)); -s0->Belt.MutableSet.remove(1); -s0->Belt.MutableSet.remove(3); -s0->Belt.MutableSet.remove(3); - -s0->Belt.MutableSet.toArray; /* [|2,4,5|] */ -``` - -## removeCheck - -```re sig -let removeCheck: (t('value, 'id), 'value) => bool; -``` - -## removeMany - -```re sig -let removeMany: (t('value, 'id), array('value)) => unit; -``` - -Removes each element of array from set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let set = Belt.MutableSet.fromArray([|1, 2, 3, 4|],~id=(module IntCmp)); - -set->Belt.MutableSet.removeMany([|5, 4, 3, 2, 1|]); -set->Belt.MutableSet.toArray; /* [||] */ -``` - -## union - -```re sig -let union: (t('value, 'id), t('value, 'id)) => t('value, 'id); -``` - -Returns union of two sets. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -let union = Belt.MutableSet.union(s0, s1); -union->Belt.MutableSet.toArray; /* [|1,2,3,4,5,6|] */ -``` - -## intersect - -```re sig -let intersect: (t('value, 'id), t('value, 'id)) => t('value, 'id); -``` - -Returns intersection of two sets. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -let intersect = Belt.MutableSet.intersect(s0, s1); -intersect->Belt.MutableSet.toArray; /* [|2,3,5|] */ -``` - -## diff - -```re sig -let diff: (t('value, 'id), t('value, 'id)) => t('value, 'id); -``` - -Returns elements from first set, not existing in second set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -Belt.MutableSet.toArray(Belt.MutableSet.diff(s0, s1)); /* [|6|] */ -Belt.MutableSet.toArray(Belt.MutableSet.diff(s1,s0)); /* [|1,4|] */ -``` - -## subset - -```re sig -let subset: (t('value, 'id), t('value, 'id)) => bool; -``` - -Checks if second set is subset of first set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -let s2 = Belt.MutableSet.intersect(s0, s1); -Belt.MutableSet.subset(s2, s0); /* true */ -Belt.MutableSet.subset(s2, s1); /* true */ -Belt.MutableSet.subset(s1, s0); /* false */ -``` - -## cmp - -```re sig -let cmp: (t('value, 'id), t('value, 'id)) => int; -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```re sig -let eq: (t('value, 'id), t('value, 'id)) => bool; -``` - -Checks if two sets are equal. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|5,2,3|], ~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|3,2,5|], ~id=(module IntCmp)); - -Belt.MutableSet.eq(s0, s1); /* true */ -``` - -## forEachU - -```re sig -let forEachU: (t('value, 'id), [@bs] ('value => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t('value, 'id), 'value => unit) => unit; -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let acc = ref([]); -s0->Belt.MutableSet.forEach(x => { - acc := Belt.List.add(acc^, x) -}); -acc; /* [6,5,3,2] */ -``` - -## reduceU - -```re sig -let reduceU: (t('value, 'id), 'a, [@bs] (('a, 'value) => 'a)) => 'a; -``` - -## reduce - -```re sig -let reduce: (t('value, 'id), 'a, ('a, 'value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -s0->Belt.MutableSet.reduce([], (acc, element) => - acc->Belt.List.add(element) -); /* [6,5,3,2] */ -``` - -## everyU - -```re sig -let everyU: (t('value, 'id), [@bs] ('value => bool)) => bool; -``` - -## every - -```re sig -let every: (t('value, 'id), 'value => bool) => bool; -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isEven = x => x mod 2 == 0; - -let s0 = Belt.MutableSet.fromArray([|2,4,6,8|], ~id=(module IntCmp)); -s0->Belt.MutableSet.every(isEven); /* true */ -``` - -## someU - -```re sig -let someU: (t('value, 'id), [@bs] ('value => bool)) => bool; -``` - -## some - -```re sig -let some: (t('value, 'id), 'value => bool) => bool; -``` - -Checks if at least one element of the set satisfies the predicate. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.MutableSet.fromArray([|1,2,4,6,8|], ~id=(module IntCmp)); -s0->Belt.MutableSet.some(isOdd); /* true */ -``` - -## keepU - -```re sig -let keepU: (t('value, 'id), [@bs] ('value => bool)) => t('value, 'id); -``` - -## keep - -```re sig -let keep: (t('value, 'id), 'value => bool) => t('value, 'id); -``` - -Returns the set of all elements that satisfy the predicate. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isEven = x => x mod 2 == 0; - -let s0 = Belt.MutableSet.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); -let s1 = s0->Belt.MutableSet.keep(isEven); - -s1->Belt.MutableSet.toArray; /* [|2, 4|] */ -``` - -## partitionU - -```re sig -let partitionU: (t('value, 'id), [@bs] ('value => bool)) => (t('value, 'id), t('value, 'id)); -``` - -## partition - -```re sig -let partition: (t('value, 'id), 'value => bool) => (t('value, 'id), t('value, 'id)); -``` - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.MutableSet.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); -let (s1, s2) = s0->Belt.MutableSet.partition(isOdd); - -s1->Belt.MutableSet.toArray; /* [|1,3,5|] */ -s2->Belt.MutableSet.toArray; /* [|2,4|] */ -``` - -## size - -```re sig -let size: t('value, 'id) => int; -``` - -Returns size of the set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|1,2,3,4|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.size; /* 4 */ -``` - -## toList - -```re sig -let toList: t('value, 'id) => list('value); -``` - -Returns list of ordered set elements. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.toList; /* [1,2,3,5] */ -``` - -## toArray - -```re sig -let toArray: t('value, 'id) => array('value); -``` - -Returns array of ordered set elements. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.toArray; /* [|1,2,3,5|] */ -``` - -## minimum - -```re sig -let minimum: t('value, 'id) => option('value); -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.make(~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.minimum; /* None */ -s1->Belt.MutableSet.minimum; /* Some(1) */ -``` - -## minUndefined - -```re sig -let minUndefined: t('value, 'id) => Js.undefined('value); -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.make(~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.minUndefined; /* undefined */ -s1->Belt.MutableSet.minUndefined; /* 1 */ -``` - -## maximum - -```re sig -let maximum: t('value, 'id) => option('value); -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.make(~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.maximum; /* None */ -s1->Belt.MutableSet.maximum; /* Some(5) */ -``` - -## maxUndefined - -```re sig -let maxUndefined: t('value, 'id) => Js.undefined('value); -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.make(~id=(module IntCmp)); -let s1 = Belt.MutableSet.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.maxUndefined; /* undefined */ -s1->Belt.MutableSet.maxUndefined; /* 5 */ -``` - -## get - -```re sig -let get: (t('value, 'id), 'value) => option('value); -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); - -s0->Belt.MutableSet.get(3); /* Some(3) */ -s0->Belt.MutableSet.get(20); /* None */ -``` - -## getUndefined - -```re sig -let getUndefined: (t('value, 'id), 'value) => Js.undefined('value); -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```re sig -let getExn: (t('value, 'id), 'value) => 'value; -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```re sig -let split: (t('value, 'id), 'value) => ((t('value, 'id), t('value, 'id)), bool); -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.MutableSet.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); - -let ((smaller, larger), present) = s0->Belt.MutableSet.split(3); - -present; /* true */ -smaller->Belt.MutableSet.toArray; /* [|1,2|] */ -larger->Belt.MutableSet.toArray; /* [|4,5|] */ - -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a, 'b) => unit; -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v8.0.0/api/belt/mutable-stack.mdx b/pages/docs/manual/v8.0.0/api/belt/mutable-stack.mdx deleted file mode 100644 index a28a3fe80..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/mutable-stack.mdx +++ /dev/null @@ -1,105 +0,0 @@ -# MutableStack - - - -First in last out stack. This module implements stacks, with in-place modification. - - - -## t - -``` -type t('a); -``` - -## make - -``` -let make: unit => t('a); -``` - -Returns a new stack, initially empty. - -## clear - -``` -let clear: t('a) => unit; -``` - -Discard all elements from the stack. - -## copy - -``` -let copy: t('a) => t('a); -``` - -`copy(x)` O(1) operation, return a new stack. - -## push - -``` -let push: (t('a), 'a) => unit; -``` - -## popUndefined - -``` -let popUndefined: t('a) => Js.undefined('a); -``` - -## pop - -``` -let pop: t('a) => option('a); -``` - -## topUndefined - -``` -let topUndefined: t('a) => Js.undefined('a); -``` - -## top - -``` -let top: t('a) => option('a); -``` - -## isEmpty - -``` -let isEmpty: t('a) => bool; -``` - -## size - -``` -let size: t('a) => int; -``` - -## forEachU - -``` -let forEachU: (t('a), [@bs] ('a => unit)) => unit; -``` - -## forEach - -``` -let forEach: (t('a), 'a => unit) => unit; -``` - -## dynamicPopIterU - -``` -let dynamicPopIterU: (t('a), [@bs] ('a => unit)) => unit; -``` - -## dynamicPopIter - -``` -let dynamicPopIter: (t('a), 'a => unit) => unit; -``` - -`dynamicPopIter(s, f)` apply `f` to each element of `s`. The item is poped before applying `f`, `s` will be empty after this opeartion. This function is useful for worklist algorithm. diff --git a/pages/docs/manual/v8.0.0/api/belt/option.mdx b/pages/docs/manual/v8.0.0/api/belt/option.mdx deleted file mode 100644 index 708e58d47..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/option.mdx +++ /dev/null @@ -1,256 +0,0 @@ -# Option - - - -In Belt we represent the existence and nonexistence of a value by wrapping it -with the `option` type. In order to make it a bit more convenient to work with -option-types, Belt provides utility-functions for it. - -The `option` type is a part of the Reason / OCaml standard library which is defined like this: - - - -```re sig -type option('a) = None | Some('a) -``` - -```re example -let someString: option(string) = Some("foo"); -``` - -## getExn - -```re sig -let getExn: option('a) => 'a; -``` - -Raises an Error in case `None` is provided. Use with care. - -```re example -Belt.Option.getExn(Some(3)); /* 3 */ - -Belt.Option.getExn(None); /* Raises an Error */ -``` - -## mapWithDefault - -```re sig -let mapWithDefault: (option('a), 'b, 'a => 'b) => 'b; -``` - -If `optionValue` is of `Some(value)`, -this function returns that value applied with `f`, in other words `f(value)`. - -If `optionValue` is `None`, the default is returned. - -```re example -let someValue = Some(3); -someValue->Belt.Option.mapWithDefault(0, x => x + 5); /* 8 */ - -let noneValue = None; -noneValue->Belt.Option.mapWithDefault(0, x => x + 5); /* 0 */ -``` - -## mapWithDefaultU - -```re sig -let mapWithDefaultU: (option('a), 'b, (.'a => 'b)) => 'b; -``` - -Uncurried version of [mapWithDefault](#mapWithDefault). - -## map - -```re sig -let map: (option('a), 'a => 'b) => option('b); -``` - -If `optionValue` is `Some(value)` this returns `f(value)`, otherwise it returns `None`. - -```re example -Belt.Option.map(Some(3), x => x * x); /* Some(9) */ - -Belt.Option.map(None, x => x * x); /* None */ -``` - -## mapU - -```re sig -let mapU: (option('a), [@bs] ('a => 'b)) => option('b); -``` - -Uncurried version of [map](#map). - -## flatMap - -```re sig -let flatMap: (option('a), 'a => option('b)) => option('b); -``` - -If `optionValue` is `Some(value)`, returns `f(value)`, otherwise returns -`None`.
-The function `f` must have a return type of `option('a)`. - -```re example -let addIfAboveOne = value => - if (value > 1) { - Some(value + 1); - } else { - None; - }; - -Belt.Option.flatMap(Some(2), addIfAboveOne); /* Some(3) */ - -Belt.Option.flatMap(Some(-4), addIfAboveOne); /* None */ - -Belt.Option.flatMap(None, addIfAboveOne); /* None */ -``` - -## flatMapU - -```re sig -let flatMapU: (option('a), [@bs] ('a => option('b))) => option('b); -``` - -Uncurried version of flatMap. - -## getWithDefault - -```re sig -let getWithDefault: (option('a), 'a) => 'a; -``` - -If `optionalValue` is `Some(value)`, returns `value`, otherwise default. - -```re example -Belt.Option.getWithDefault(None, "Banana"); /* Banana */ - -Belt.Option.getWithDefault(Some("Apple"), "Banana"); /* Apple */ -``` - -```re example -let greet = (firstName: option(string)) => - Belt.Option.("Greetings " ++ firstName->getWithDefault("Anonymous")); - -Some("Jane")->greet; /* "Greetings Jane" */ - -None->greet; /* "Greetings Anonymous" */ -``` - -```re example -Belt.Option.getWithDefault(Some(1812), 1066); /* 1812 */ - -Belt.Option.getWithDefault(None, 1066); /* 1066 */ -``` - -## isSome - -```re sig -let isSome: option('a) => bool; -``` - -Returns `true` if the argument is `Some(value)`, `false` otherwise. - -```re example -Belt.Option.isSome(None); /* false */ - -Belt.Option.isSome(Some(1)); /* true */ -``` - -## isNone - -```re sig -let isNone: option('a) => bool; -``` - -Returns `true` if the argument is `None`, `false` otherwise. - -```re example -Belt.Option.isNone(None); /* true */ - -Belt.Option.isNone(Some(1)); /* false */ -``` - -## eq - -```re sig -let eq: (option('a), option('b), ('a, 'b) => bool) => bool; -``` - -Evaluates two optional values for equality with respect to a predicate -function. If both `optValue1` and `optValue2` are `None`, returns `true`. -If one of the arguments is `Some(value)` and the other is `None`, returns -`false`. - -If arguments are `Some(value1)` and `Some(value2)`, returns the result of -`predicate(value1, value2)`; the predicate function must return a bool. - -```re example -let clockEqual = (a, b) => a mod 12 == b mod 12; - -open Belt.Option; - -eq(Some(3), Some(15), clockEqual); /* true */ - -eq(Some(3), None, clockEqual); /* false */ - -eq(None, Some(3), clockEqual); /* false */ - -eq(None, None, clockEqual); /* true */ -``` - -## eqU - -```re sig -let eqU: (option('a), option('b), (.'a, 'b) => bool) => bool; -``` - -Uncurried version of [eq](#eq). - -## cmp - -```re sig -let cmp: (option('a), option('b), ('a, 'b) => int) => int; -``` - -`cmp(optValue1, optValue2, comparisonFunction)` compares two optional values -with respect to given `comparisonFunction`. - -If both `optValue1` and `optValue2` are `None`, it returns `0`. - -If the first argument is `Some(value1)` and the second is `None`, returns `1` -(something is greater than nothing). - -If the first argument is `None` and the second is `Some(value2)`, returns `-1` -(nothing is less than something). - -If the arguments are `Some(value1)` and `Some(value2)`, returns the result of -`comparisonFunction(value1, value2)`; comparisonFunction takes two arguments -and returns `-1` if the first argument is less than the second, `0` if the -arguments are equal, and `1` if the first argument is greater than the second. - -```re example -let clockCompare = (a, b) => compare(a mod 12, b mod 12); - -open Belt.Option; - -cmp(Some(3), Some(15), clockCompare); /* 0 */ - -cmp(Some(3), Some(14), clockCompare); /* 1 */ - -cmp(Some(2), Some(15), clockCompare); /* (-1) */ - -cmp(None, Some(15), clockCompare); /* (-1) */ - -cmp(Some(14), None, clockCompare); /* 1 */ - -cmp(None, None, clockCompare); /* 0 */ -``` - -## cmpU - -```re sig -let cmpU: (option('a), option('b), ((.'a, 'b) => int)) => int; -``` - -Uncurried version of [cmp](#cmp). diff --git a/pages/docs/manual/v8.0.0/api/belt/range.mdx b/pages/docs/manual/v8.0.0/api/belt/range.mdx deleted file mode 100644 index f5e694b83..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/range.mdx +++ /dev/null @@ -1,130 +0,0 @@ -# Range - - - -A small utility module to provide inclusive range operations for `[start, -finish]`. Internally it is relying on loops instead of creating new arrays, -which makes it pretty performant and memory friendly. - - - -## forEachU - -```re sig -let forEachU: (int, int, [@bs] (int => unit)) => unit; -``` - -## forEach - -```re sig -let forEach: (int, int, int => unit) => unit; -``` - -`forEach(start, finish, action);` - -equivalent to `Belt.Array.(forEach(range(start, finish), action));` - -```re example -Belt.Range.forEach(0, 4, (i) => Js.log(i)); - -/** - * prints: - * 0 - * 1 - * 2 - * 3 - * 4 - */ -``` - -## everyU - -```re sig -let everyU: (int, int, [@bs] (int => bool)) => bool; -``` - -## every - -```re sig -let every: (int, int, int => bool) => bool; -``` - -`every(start, finish, p);` - -equivalent to `Belt.Array.(every(range(start, finish), p));` - -```re example -Belt.Range.every(0, 4, (i) => i < 5); /* true */ - -Belt.Range.every(0, 4, (i) => i < 4); /* false */ -``` - -## everyByU - -```re sig -let everyByU: (int, int, ~step: int, [@bs] (int => bool)) => bool; -``` - -## everyBy - -```re sig -let everyBy: (int, int, ~step: int, int => bool) => bool; -``` - -`everyBy(start, finish, ~step, p);` - -See `Belt_Array.rangeBy` - -equivalent to `Belt.Array.(every(rangeBy(start, finish, ~step), p));` - -```re example -Belt.Range.everyBy(0, 4, ~step=1, (i) => i mod 2 === 0); /* false */ - -Belt.Range.everyBy(0, 4, ~step=2, (i) => i mod 2 === 0); /* true */ -``` - -## someU - -```re sig -let someU: (int, int, [@bs] (int => bool)) => bool; -``` - -## some - -```re sig -let some: (int, int, int => bool) => bool; -``` - -`some(start, finish, p);` - -equivalent to `Belt.Array.(some(range(start, finish), p));` - -```re example -Belt.Range.some(0, 4, (i) => i > 5); /* false */ - -Belt.Range.some(0, 4, (i) => i > 2); /* true */ -``` - -## someByU - -```re sig -let someByU: (int, int, ~step: int, [@bs] (int => bool)) => bool; -``` - -## someBy - -```re sig -let someBy: (int, int, ~step: int, int => bool) => bool; -``` - -`someBy(start, finish, ~step, p);` - -See `Belt_Array.rangeBy` - -equivalent to `Belt.Array.(some(rangeBy(start, finish, ~step), p));` - -```re example -Belt.Range.someBy(1, 5, ~step=2, (i) => i mod 2 === 0); /* false */ - -Belt.Range.someBy(0, 4, ~step=2, (i) => i mod 2 === 0); /* true */ -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/result.mdx b/pages/docs/manual/v8.0.0/api/belt/result.mdx deleted file mode 100644 index be9286410..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/result.mdx +++ /dev/null @@ -1,242 +0,0 @@ -# Result - - - -Result types are really useful to describe the result of a certain operation -without relying on exceptions or `option` types. - -This module gives you useful utilities to create and combine `Result` data. - - - -## t - -```re sig -type t('a, 'b) = - | Ok('a) - | Error('b); -``` - -The type `Result.t(result, err)` describes a variant of two states: -`Ok(someResult)` represents a successful operation, whereby -``Error(someError)` signals an erronous operation. - -In this concrete example, we are defining our own `Result` type to reflect an HTTP like -query operation: - -```re example -type responseError = NotAvailable | NotFound; -type queryResult = Belt.Result.t(string, responseError); - -let failQueryUser = (username: string): queryResult => { - Error(NotAvailable) -}; -``` - -## getExn - -```re sig -let getExn: t('a, 'b) => 'a; -``` - -`getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception - -```re example -Belt.Result.getExn(Belt.Result.Ok(42)) == 42; - -Belt.Result.getExn(Belt.Result.Error("Invalid data")); /* raises exception */ -``` - -## mapWithDefaultU - -```re sig -let mapWithDefaultU: (t('a, 'c), 'b, (.'a => 'b)) => 'b; -``` - -## mapWithDefault - -```re sig -let mapWithDefault: (t('a, 'c), 'b, 'a => 'b) => 'b; -``` - -`mapWithDefault(res, default, f);`: When res is `Ok(n)`, returns `f(n)`, -otherwise `default`. - -```re example -let ok = Belt.Result.Ok(42) -Belt.Result.mapWithDefault(ok, 0, (x) => x / 2) == 21; - -let error = Belt.Result.Error("Invalid data") -Belt.Result.mapWithDefault(error, 0, (x) => x / 2) == 0; -``` - -## mapU - -```re sig -let mapU: (t('a, 'c), [@bs] ('a => 'b)) => t('b, 'c); -``` - -## map - -```re sig -let map: (t('a, 'c), 'a => 'b) => t('b, 'c); -``` - -`map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res -unchanged. Function `f` takes a value of the same type as `n` and returns an -ordinary value. - -```re example -let f = (x) => sqrt(float_of_int(x)); - -Belt.Result.map(Ok(64), f) == Ok(8.0); - -Belt.Result.map(Error("Invalid data"), f) == Error("Invalid data"); -``` - -## flatMapU - -```re sig -let flatMapU: (t('a, 'c), [@bs] ('a => t('b, 'c))) => t('b, 'c); -``` - -## flatMap - -```re sig -let flatMap: (t('a, 'c), 'a => t('b, 'c)) => t('b, 'c); -``` - -`flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res -unchanged. Function `f` takes a value of the same type as `n` and returns a -`Belt.Result`. - -```re example -let recip = (x) => - if (x !== 0.0) { - Belt.Result.Ok(1.0 /. x); - } else { - Belt.Result.Error("Divide by zero"); - }; - -Belt.Result.flatMap(Ok(2.0), recip) == Ok(0.5); - -Belt.Result.flatMap(Ok(0.0), recip) == Error("Divide by zero"); - -Belt.Result.flatMap(Error("Already bad"), recip) == Error("Already bad"); -``` - -## getWithDefault - -```re sig -let getWithDefault: (t('a, 'b), 'a) => 'a; -``` - -`getWithDefault(res, defaultValue)`: If `res` is `Ok(n)`, returns `n`, -otherwise `default` - -```re example -Belt.Result.getWithDefault(Ok(42), 0) == 42; - -Belt.Result.getWithDefault(Error("Invalid Data"), 0) == 0; -``` - -## isOk - -```re sig -let isOk: t('a, 'b) => bool; -``` - -`isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is -the `Error(e)` variant. - -## isError - -```re sig -let isError: t('a, 'b) => bool; -``` - -`isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if -it is the `Ok(n)` variant. - -## eqU - -```re sig -let eqU: (t('a, 'c), t('b, 'd), (.'a, 'b) => bool) => bool; -``` - -## eq - -```re sig -let eq: (t('a, 'c), t('b, 'd), ('a, 'b) => bool) => bool; -``` - -`eq(res1, res2, f)`: Determine if two `Belt.Result` variables are equal with -respect to an equality function. If `res1` and `res2` are of the form `Ok(n)` -and `Ok(m)`, return the result of `f(n, m)`. If one of `res1` and `res2` are of -the form `Error(e)`, return false If both `res1` and `res2` are of the form -`Error(e)`, return true - -```re example -let good1 = Belt.Result.Ok(42); - -let good2 = Belt.Result.Ok(32); - -let bad1 = Belt.Result.Error("invalid"); - -let bad2 = Belt.Result.Error("really invalid"); - -let mod10equal = (a, b) => a mod 10 === b mod 10; - -Belt.Result.eq(good1, good2, mod10equal) == true; - -Belt.Result.eq(good1, bad1, mod10equal) == false; - -Belt.Result.eq(bad2, good2, mod10equal) == false; - -Belt.Result.eq(bad1, bad2, mod10equal) == true; -``` - -## cmpU - -```re sig -let cmpU: (t('a, 'c), t('b, 'd), (.'a, 'b) => int) => int; -``` - -## cmp - -```re sig -let cmp: (t('a, 'c), t('b, 'd), ('a, 'b) => int) => int; -``` - -`cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a -comparison function. The comparison function returns -1 if the first variable -is "less than" the second, 0 if the two variables are equal, and 1 if the first -is "greater than" the second. - -If `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of -`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`, -return -1 (nothing is less than something) If `res1` is of the form `Ok(n)` and -`res2` of the form `Error(e)`, return 1 (something is greater than nothing) If -both `res1` and `res2` are of the form `Error(e)`, return 0 (equal) - -```re example -let good1 = Belt.Result.Ok(59); - -let good2 = Belt.Result.Ok(37); - -let bad1 = Belt.Result.Error("invalid"); - -let bad2 = Belt.Result.Error("really invalid"); - -let mod10cmp = (a, b) => Pervasives.compare(a mod 10, b mod 10); - -Belt.Result.cmp(Ok(39), Ok(57), mod10cmp) == 1; - -Belt.Result.cmp(Ok(57), Ok(39), mod10cmp) == (-1); - -Belt.Result.cmp(Ok(39), Error("y"), mod10cmp) == 1; - -Belt.Result.cmp(Error("x"), Ok(57), mod10cmp) == (-1); - -Belt.Result.cmp(Error("x"), Error("y"), mod10cmp) == 0; -``` diff --git a/pages/docs/manual/v8.0.0/api/belt/set-dict.mdx b/pages/docs/manual/v8.0.0/api/belt/set-dict.mdx deleted file mode 100644 index 43a783e79..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/set-dict.mdx +++ /dev/null @@ -1,708 +0,0 @@ -# SetDict - - - -This module seprate identity from data, it is a bit more verboe but slightly more efficient due to the fact that there is no need to pack identity and data back after each operation - - - -## t - -```re sig -type t('value, 'identity); -``` - -`'value` is the element type - -`'identity` the identity of the collection - -## cmp - -```re sig -type cmp('value, 'id) = BeltId.cmp('value, 'id); -``` - -Type of compare function. - -## empty - -```re sig -let empty: t('value, 'id); -``` - -```re example -let s0 = Belt.Set.Dict.empty; -``` - -## fromArray - -```re sig -let fromArray: (array('value), ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Creates new set from array of elements. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|1, 3, 2, 4|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.toArray; /* [|1, 2, 3, 4|] */ -``` - -## fromSortedArrayUnsafe - -```re sig -let fromSortedArrayUnsafe: array('value) => t('value, 'id); -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```re sig -let isEmpty: t('a, 'b) => bool; -``` - -Checks if set is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let empty = Belt.Set.Dict.fromArray([||], ~cmp=IntCmp.cmp); -let notEmpty = Belt.Set.Dict.fromArray([|1|], ~cmp=IntCmp.cmp); - -Belt.Set.Dict.isEmpty(empty); /* true */ -Belt.Set.Dict.isEmpty(notEmpty); /* false */ -``` - -## has - -```re sig -let has: (t('value, 'id), 'value, ~cmp: cmp('value, 'id)) => bool; -``` - -Checks if element exists in set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let set = Belt.Set.Dict.fromArray([|1, 4, 2, 5|], ~cmp=IntCmp.cmp); - -set->Belt.Set.Dict.has(3) /* false */ -set->Belt.Set.Dict.has(1) /* true */ -``` - -## add - -```re sig -let add: (t('value, 'id), 'value, ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Adds element to set. If element existed in set, value is unchanged. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.empty; -let s1 = s0->Belt.Set.Dict.add(1, ~cmp=IntCmp.cmp); -let s2 = s1->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp); -let s3 = s2->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp); -s0->Belt.Set.Dict.toArray; /* [||] */ -s1->Belt.Set.Dict.toArray; /* [|1|] */ -s2->Belt.Set.Dict.toArray; /* [|1, 2|] */ -s3->Belt.Set.Dict.toArray; /* [|1,2 |] */ -s2 == s3; /* true */ -``` - -## mergeMany - -```re sig -let mergeMany: (t('value, 'id), array('value), ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let set = Belt.Set.Dict.empty; - -let newSet = set->Belt.Set.Dict.mergeMany([|5, 4, 3, 2, 1|], ~cmp=IntCmp.cmp); -newSet->Belt.Set.Dict.toArray; /* [|1, 2, 3, 4, 5|] */ -``` - -## remove - -```re sig -let remove: (t('value, 'id), 'value, ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|2,3,1,4,5|], ~cmp=IntCmp.cmp); -let s1 = s0->Belt.Set.Dict.remove(1, ~cmp=IntCmp.cmp); -let s2 = s1->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp); -let s3 = s2->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp); - -s1->Belt.Set.Dict.toArray; /* [|2,3,4,5|] */ -s2->Belt.Set.Dict.toArray; /* [|2,4,5|] */ -s2 == s3; /* true */ -``` - -## removeMany - -```re sig -let removeMany: (t('value, 'id), array('value), ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let set = Belt.Set.Dict.fromArray([|1, 2, 3, 4|],~cmp=IntCmp.cmp); - -let newSet = set->Belt.Set.Dict.removeMany([|5, 4, 3, 2, 1|], ~cmp=IntCmp.cmp); -newSet->Belt.Set.Dict.toArray; /* [||] */ -``` - -## union - -```re sig -let union: (t('value, 'id), t('value, 'id), ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Returns union of two sets. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|5,2,3,5,6|], ~cmp=IntCmp.cmp); -let s1 = Belt.Set.Dict.fromArray([|5,2,3,1,5,4|], ~cmp=IntCmp.cmp); -let union = Belt.Set.Dict.union(s0, s1, ~cmp=IntCmp.cmp); -union->Belt.Set.Dict.toArray; /* [|1,2,3,4,5,6|] */ -``` - -## intersect - -```re sig -let intersect: (t('value, 'id), t('value, 'id), ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Returns intersection of two sets. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|5,2,3,5,6|], ~cmp=IntCmp.cmp); -let s1 = Belt.Set.Dict.fromArray([|5,2,3,1,5,4|], ~cmp=IntCmp.cmp); -let intersect = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp); -intersect->Belt.Set.Dict.toArray; /* [|2,3,5|] */ -``` - -## diff - -```re sig -let diff: (t('value, 'id), t('value, 'id), ~cmp: cmp('value, 'id)) => t('value, 'id); -``` - -Returns elements from first set, not existing in second set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|5,2,3,5,6|], ~cmp=IntCmp.cmp); -let s1 = Belt.Set.Dict.fromArray([|5,2,3,1,5,4|], ~cmp=IntCmp.cmp); - -let diff1 = Belt.Set.Dict.diff(s0, s1, ~cmp=IntCmp.cmp); -let diff2 = Belt.Set.Dict.diff(s1,s0, ~cmp=IntCmp.cmp); - -diff1->Belt.Set.Dict.toArray; /* [|6|] */ -diff2->Belt.Set.Dict.toArray; /* [|1,4|] */ -``` - -## subset - -```re sig -let subset: (t('value, 'id), t('value, 'id), ~cmp: cmp('value, 'id)) => bool; -``` - -Checks if second set is subset of first set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|5,2,3,5,6|], ~cmp=IntCmp.cmp); -let s1 = Belt.Set.Dict.fromArray([|5,2,3,1,5,4|], ~cmp=IntCmp.cmp); -let s2 = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp); -Belt.Set.Dict.subset(s2, s0, ~cmp=IntCmp.cmp); /* true */ -Belt.Set.Dict.subset(s2, s1, ~cmp=IntCmp.cmp); /* true */ -Belt.Set.Dict.subset(s1, s0, ~cmp=IntCmp.cmp); /* false */ -``` - -## cmp - -```re sig -let cmp: (t('value, 'id), t('value, 'id), ~cmp: cmp('value, 'id)) => int; -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```re sig -let eq: (t('value, 'id), t('value, 'id), ~cmp: cmp('value, 'id)) => bool; -``` - -Checks if two sets are equal. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|5,2,3|], ~cmp=IntCmp.cmp); -let s1 = Belt.Set.Dict.fromArray([|3,2,5|], ~cmp=IntCmp.cmp); - -Belt.Set.Dict.eq(s0, s1, ~cmp=IntCmp.cmp); /* true */ -``` - -## forEachU - -```re sig -let forEachU: (t('value, 'id), [@bs] ('value => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t('value, 'id), 'value => unit) => unit; -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|5,2,3,5,6|], ~cmp=IntCmp.cmp); -let acc = ref([]); -s0->Belt.Set.Dict.forEach(x => { - acc := Belt.List.add(acc^, x) -}); -acc; /* [6,5,3,2] */ -``` - -## reduceU - -```re sig -let reduceU: (t('value, 'id), 'a, [@bs] (('a, 'value) => 'a)) => 'a; -``` - -## reduce - -```re sig -let reduce: (t('value, 'id), 'a, ('a, 'value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|5,2,3,5,6|], ~cmp=IntCmp.cmp); -s0->Belt.Set.Dict.reduce([], (acc, element) => - acc->Belt.List.add(element) -); /* [6,5,3,2] */ -``` - -## everyU - -```re sig -let everyU: (t('value, 'id), [@bs] ('value => bool)) => bool; -``` - -## every - -```re sig -let every: (t('value, 'id), 'value => bool) => bool; -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isEven = x => x mod 2 == 0; - -let s0 = Belt.Set.Dict.fromArray([|2,4,6,8|], ~cmp=IntCmp.cmp); -s0->Belt.Set.Dict.every(isEven); /* true */ -``` - -## someU - -```re sig -let someU: (t('value, 'id), [@bs] ('value => bool)) => bool; -``` - -## some - -```re sig -let some: (t('value, 'id), 'value => bool) => bool; -``` - -Checks if at least one element of the set satisfies the predicate. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.Set.Dict.fromArray([|1,2,4,6,8|], ~cmp=IntCmp.cmp); -s0->Belt.Set.Dict.some(isOdd); /* true */ -``` - -## keepU - -```re sig -let keepU: (t('value, 'id), [@bs] ('value => bool)) => t('value, 'id); -``` - -## keep - -```re sig -let keep: (t('value, 'id), 'value => bool) => t('value, 'id); -``` - -Returns the set of all elements that satisfy the predicate. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isEven = x => x mod 2 == 0; - -let s0 = Belt.Set.Dict.fromArray([|1,2,3,4,5|], ~cmp=IntCmp.cmp); -let s1 = s0->Belt.Set.Dict.keep(isEven); - -s1->Belt.Set.Dict.toArray; /* [|2,4|] */ -``` - -## partitionU - -```re sig -let partitionU: (t('value, 'id), [@bs] ('value => bool)) => (t('value, 'id), t('value, 'id)); -``` - -## partition - -```re sig -let partition: (t('value, 'id), 'value => bool) => (t('value, 'id), t('value, 'id)); -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.Set.Dict.fromArray([|1,2,3,4,5|], ~cmp=IntCmp.cmp); -let (s1, s2) = s0->Belt.Set.Dict.partition(isOdd); - -s1->Belt.Set.Dict.toArray; /* [|1,3,5|] */ -s2->Belt.Set.Dict.toArray; /* [|2,4|] */ -``` - -## size - -```re sig -let size: t('value, 'id) => int; -``` - -Returns size of the set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|1,2,3,4|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.size; /* 4 */ -``` - -## toList - -```re sig -let toList: t('value, 'id) => list('value); -``` - -Returns list of ordered set elements. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|3,2,1,5|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.toList; /* [1,2,3,5] */ -``` - -## toArray - -```re sig -let toArray: t('value, 'id) => array('value); -``` - -Returns array of ordered set elements. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|3,2,1,5|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.toArray; /* [|1,2,3,5|] */ -``` - -## minimum - -```re sig -let minimum: t('value, 'id) => option('value); -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.empty; -let s1 = Belt.Set.Dict.fromArray([|3,2,1,5|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.minimum; /* None */ -s1->Belt.Set.Dict.minimum; /* Some(1) */ -``` - -## minUndefined - -```re sig -let minUndefined: t('value, 'id) => Js.undefined('value); -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.empty; -let s1 = Belt.Set.Dict.fromArray([|3,2,1,5|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.minUndefined; /* undefined */ -s1->Belt.Set.Dict.minUndefined; /* 1 */ -``` - -## maximum - -```re sig -let maximum: t('value, 'id) => option('value); -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.empty; -let s1 = Belt.Set.Dict.fromArray([|3,2,1,5|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.maximum; /* None */ -s1->Belt.Set.Dict.maximum; /* Some(5) */ -``` - -## maxUndefined - -```re sig -let maxUndefined: t('value, 'id) => Js.undefined('value); -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.empty; -let s1 = Belt.Set.Dict.fromArray([|3,2,1,5|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.maxUndefined; /* undefined */ -s1->Belt.Set.Dict.maxUndefined; /* 5 */ -``` - -## get - -```re sig -let get: (t('value, 'id), 'value, ~cmp: cmp('value, 'id)) => option('value); -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|1,2,3,4,5|], ~cmp=IntCmp.cmp); - -s0->Belt.Set.Dict.get(3, ~cmp=IntCmp.cmp); /* Some(3) */ -s0->Belt.Set.Dict.get(20, ~cmp=IntCmp.cmp); /* None */ -``` - -## getUndefined - -```re sig -let getUndefined: (t('value, 'id), 'value, ~cmp: cmp('value, 'id)) => Js.undefined('value); -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```re sig -let getExn: (t('value, 'id), 'value, ~cmp: cmp('value, 'id)) => 'value; -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```re sig -let split: (t('value, 'id), 'value, ~cmp: cmp('value, 'id)) => ((t('value, 'id), t('value, 'id)), bool); -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```re example -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); - -let s0 = Belt.Set.Dict.fromArray([|1,2,3,4,5|], ~cmp=IntCmp.cmp); - -let ((smaller, larger), present) = - s0->Belt.Set.Dict.split(3, ~cmp=IntCmp.cmp); - -present; /* true */ -smaller->Belt.Set.Dict.toArray; /* [|1,2|] */ -larger->Belt.Set.Dict.toArray; /* [|4,5|] */ - -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t('a, 'b) => unit; -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v8.0.0/api/belt/set-int.mdx b/pages/docs/manual/v8.0.0/api/belt/set-int.mdx deleted file mode 100644 index 451661041..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/set-int.mdx +++ /dev/null @@ -1,541 +0,0 @@ -# SetInt - - - -Specalized when value type is `int`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison. - - - -## value - -```re sig -type value = int; -``` - -The type of the set elements. - -## t - -```re sig -type t; -``` - -Type of the sets. - -## empty - -```re sig -let empty: t; -``` - -Empty set - -```re example -let s0 = Belt.Set.Int.empty; -``` - -## fromArray - -```re sig -let fromArray: array(value) => t; -``` - -Creates new set from array of elements. - -```re example -let s0 = Belt.Set.Int.fromArray([|1, 3, 2, 4|]) - -s0->Belt.Set.Int.toArray; /* [|1, 2, 3, 4|] */ -``` - -## fromSortedArrayUnsafe - -```re sig -let fromSortedArrayUnsafe: array(value) => t; -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```re sig -let isEmpty: t => bool; -``` - -Checks if set is empty. - -```re example -let empty = Belt.Set.Int.fromArray([||]); -let notEmpty = Belt.Set.Int.fromArray([|1|]); - -Belt.Set.Int.isEmpty(empty); /* true */ -Belt.Set.Int.isEmpty(notEmpty); /* false */ -``` - -## has - -```re sig -let has: (t, value) => bool; -``` - -Checks if element exists in set. - -```re example -let set = Belt.Set.Int.fromArray([|1, 4, 2, 5|]); - -set->Belt.Set.Int.has(3) /* false */ -set->Belt.Set.Int.has(1) /* true */ -``` - -## add - -```re sig -let add: (t, value) => t; -``` - -Adds element to set. If element existed in set, value is unchanged. - -```re example -let s0 = Belt.Set.Int.empty; -let s1 = s0->Belt.Set.Int.add(1); -let s2 = s1->Belt.Set.Int.add(2); -let s3 = s2->Belt.Set.Int.add(2); -s0->Belt.Set.Int.toArray; /* [||] */ -s1->Belt.Set.Int.toArray; /* [|1|] */ -s2->Belt.Set.Int.toArray; /* [|1, 2|] */ -s3->Belt.Set.Int.toArray; /* [|1,2 |] */ -s2 == s3; /* true */ -``` - -## mergeMany - -```re sig -let mergeMany: (t, array(value)) => t; -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```re example -let set = Belt.Set.Int.empty; - -let newSet = set->Belt.Set.Int.mergeMany([|5, 4, 3, 2, 1|]); -newSet->Belt.Set.Int.toArray; /* [|1, 2, 3, 4, 5|] */ -``` - -## remove - -```re sig -let remove: (t, value) => t; -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```re example -let s0 = Belt.Set.Int.fromArray([|2,3,1,4,5|]); -let s1 = s0->Belt.Set.Int.remove(1); -let s2 = s1->Belt.Set.Int.remove(3); -let s3 = s2->Belt.Set.Int.remove(3); - -s1->Belt.Set.Int.toArray; /* [|2,3,4,5|] */ -s2->Belt.Set.Int.toArray; /* [|2,4,5|] */ -s2 == s3; /* true */ -``` - -## removeMany - -```re sig -let removeMany: (t, array(value)) => t; -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```re example -let set = Belt.Set.Int.fromArray([|1, 2, 3, 4|]); - -let newSet = set->Belt.Set.Int.removeMany([|5, 4, 3, 2, 1|]); -newSet->Belt.Set.Int.toArray; /* [||] */ -``` - -## union - -```re sig -let union: (t, t) => t; -``` - -Returns union of two sets. - -```re example -let s0 = Belt.Set.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.Set.Int.fromArray([|5,2,3,1,5,4|]); -let union = Belt.Set.Int.union(s0, s1); -union->Belt.Set.Int.toArray; /* [|1,2,3,4,5,6|] */ -``` - -## intersect - -```re sig -let intersect: (t, t) => t; -``` - -Returns intersection of two sets. - -```re example - -let s0 = Belt.Set.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.Set.Int.fromArray([|5,2,3,1,5,4|]); -let intersect = Belt.Set.Int.intersect(s0, s1); -intersect->Belt.Set.Int.toArray; /* [|2,3,5|] */ -``` - -## diff - -```re sig -let diff: (t, t) => t; -``` - -Returns elements from first set, not existing in second set. - -```re example -let s0 = Belt.Set.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.Set.Int.fromArray([|5,2,3,1,5,4|]); -Belt.Set.Int.toArray(Belt.Set.Int.diff(s0, s1)); /* [|6|] */ -Belt.Set.Int.toArray(Belt.Set.Int.diff(s1,s0)); /* [|1,4|] */ -``` - -## subset - -```re sig -let subset: (t, t) => bool; -``` - -Checks if second set is subset of first set. - -```re example -let s0 = Belt.Set.Int.fromArray([|5,2,3,5,6|]); -let s1 = Belt.Set.Int.fromArray([|5,2,3,1,5,4|]); -let s2 = Belt.Set.Int.intersect(s0, s1); -Belt.Set.Int.subset(s2, s0); /* true */ -Belt.Set.Int.subset(s2, s1); /* true */ -Belt.Set.Int.subset(s1, s0); /* false */ -``` - -## cmp - -```re sig -let cmp: (t, t) => int; -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```re sig -let eq: (t, t) => bool; -``` - -Checks if two sets are equal. - -```re example -let s0 = Belt.Set.Int.fromArray([|5,2,3|]); -let s1 = Belt.Set.Int.fromArray([|3,2,5|]); - -Belt.Set.Int.eq(s0, s1); /* true */ -``` - -## forEachU - -```re sig -let forEachU: (t, [@bs] (value => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t, value => unit) => unit; -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```re example -let s0 = Belt.Set.Int.fromArray([|5,2,3,5,6|]); -let acc = ref([]); -s0->Belt.Set.Int.forEach(x => { - acc := Belt.List.add(acc^, x) -}); -acc; /* [6,5,3,2] */ -``` - -## reduceU - -```re sig -let reduceU: (t, 'a, [@bs] (('a, value) => 'a)) => 'a; -``` - -## reduce - -```re sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```re example -let s0 = Belt.Set.Int.fromArray([|5,2,3,5,6|]); -s0->Belt.Set.Int.reduce([], (acc, element) => - acc->Belt.List.add(element) -); /* [6,5,3,2] */ -``` - -## everyU - -```re sig -let everyU: (t, [@bs] (value => bool)) => bool; -``` - -## every - -```re sig -let every: (t, value => bool) => bool; -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```re example -let isEven = x => x mod 2 == 0; - -let s0 = Belt.Set.Int.fromArray([|2,4,6,8|]); -s0->Belt.Set.Int.every(isEven); /* true */ -``` - -## someU - -```re sig -let someU: (t, [@bs] (value => bool)) => bool; -``` - -## some - -```re sig -let some: (t, value => bool) => bool; -``` - -Checks if at least one element of the set satisfies the predicate. - -```re example -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.Set.Int.fromArray([|1,2,4,6,8|]); -s0->Belt.Set.Int.some(isOdd); /* true */ -``` - -## keepU - -```re sig -let keepU: (t, [@bs] (value => bool)) => t; -``` - -## keep - -```re sig -let keep: (t, value => bool) => t; -``` - -Returns the set of all elements that satisfy the predicate. - -```re example -let isEven = x => x mod 2 == 0; - -let s0 = Belt.Set.Int.fromArray([|1,2,3,4,5|]); -let s1 = s0->Belt.Set.Int.keep(isEven); - -s1->Belt.Set.Int.toArray; /* [|2,4|] */ -``` - -## partitionU - -```re sig -let partitionU: (t, [@bs] (value => bool)) => (t, t); -``` - -## partition - -```re sig -let partition: (t, value => bool) => (t, t); -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```re example -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.Set.Int.fromArray([|1,2,3,4,5|]); -let (s1, s2) = s0->Belt.Set.Int.partition(isOdd); - -s1->Belt.Set.Int.toArray; /* [|1,3,5|] */ -s2->Belt.Set.Int.toArray; /* [|2,4|] */ -``` - -## size - -```re sig -let size: t => int; -``` - -Returns size of the set. - -```re example -let s0 = Belt.Set.Int.fromArray([|1,2,3,4|]); - -s0->Belt.Set.Int.size; /* 4 */ -``` - -## toList - -```re sig -let toList: t => list(value); -``` - -Returns list of ordered set elements. - -```re example -let s0 = Belt.Set.Int.fromArray([|3,2,1,5|]); - -s0->Belt.Set.Int.toList; /* [1,2,3,5] */ -``` - -## toArray - -```re sig -let toArray: t => array(value); -``` - -Returns array of ordered set elements. - -```re example -let s0 = Belt.Set.Int.fromArray([|3,2,1,5|]); - -s0->Belt.Set.Int.toArray; /* [|1,2,3,5|] */ -``` - -## minimum - -```re sig -let minimum: t => option(value); -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.Set.Int.empty; -let s1 = Belt.Set.Int.fromArray([|3,2,1,5|]); - -s0->Belt.Set.Int.minimum; /* None */ -s1->Belt.Set.Int.minimum; /* Some(1) */ -``` - -## minUndefined - -```re sig -let minUndefined: t => Js.undefined(value); -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.Set.Int.empty; -let s1 = Belt.Set.Int.fromArray([|3,2,1,5|]); - -s0->Belt.Set.Int.minUndefined; /* undefined */ -s1->Belt.Set.Int.minUndefined; /* 1 */ -``` - -## maximum - -```re sig -let maximum: t => option(value); -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.Set.Int.empty; -let s1 = Belt.Set.Int.fromArray([|3,2,1,5|]); - -s0->Belt.Set.Int.maximum; /* None */ -s1->Belt.Set.Int.maximum; /* Some(5) */ -``` - -## maxUndefined - -```re sig -let maxUndefined: t => Js.undefined(value); -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.Set.Int.empty; -let s1 = Belt.Set.Int.fromArray([|3,2,1,5|]); - -s0->Belt.Set.Int.maxUndefined; /* undefined */ -s1->Belt.Set.Int.maxUndefined; /* 5 */ -``` - -## get - -```re sig -let get: (t, value) => option(value); -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```re example -let s0 = Belt.Set.Int.fromArray([|1,2,3,4,5|]); - -s0->Belt.Set.Int.get(3); /* Some(3) */ -s0->Belt.Set.Int.get(20); /* None */ -``` - -## getUndefined - -```re sig -let getUndefined: (t, value) => Js.undefined(value); -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```re sig -let getExn: (t, value) => value; -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```re sig -let split: (t, value) => ((t, t), bool); -``` - -Returns a tuple `((l, r), present)`, where `l` is the set of elements of set that are strictly less than value, `r` is the set of elements of set that are strictly greater than value, `present` is `false` if set contains no element equal to value, or `true` if set contains an element equal to value. - -```re example -let s0 = Belt.Set.Int.fromArray([|1,2,3,4,5|]); - -let ((smaller, larger), present) = s0->Belt.Set.Int.split(3); - -present; /* true */ -smaller->Belt.Set.Int.toArray; /* [|1,2|] */ -larger->Belt.Set.Int.toArray; /* [|4,5|] */ -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t => unit; -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v8.0.0/api/belt/set-string.mdx b/pages/docs/manual/v8.0.0/api/belt/set-string.mdx deleted file mode 100644 index e4494bed5..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/set-string.mdx +++ /dev/null @@ -1,542 +0,0 @@ -# SetString - - - -Specalized when value type is `string`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison. - - - -## value - -```re sig -type value = string; -``` - -The type of the set elements. - -## t - -```re sig -type t; -``` - -The type of sets. - -## empty - -```re sig -let empty: t; -``` - -Empty set - -```re example -let s0 = Belt.Set.String.empty; -``` - -## fromArray - -```re sig -let fromArray: array(value) => t; -``` - -Creates new set from array of elements. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "orange", "banana"|]) - -s0->Belt.Set.String.toArray; /* [|"apple", "banana", "orange"|] */ -``` - -## fromSortedArrayUnsafe - -```re sig -let fromSortedArrayUnsafe: array(value) => t; -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```re sig -let isEmpty: t => bool; -``` - -Checks if set is empty. - -```re example -let empty = Belt.Set.String.fromArray([||]); -let notEmpty = Belt.Set.String.fromArray([|"apple"|]); - -Belt.Set.String.isEmpty(empty); /* true */ -Belt.Set.String.isEmpty(notEmpty); /* false */ -``` - -## has - -```re sig -let has: (t, value) => bool; -``` - -Checks if element exists in set. - -```re example -let set = Belt.Set.String.fromArray([|"apple", "orange", "banana"|]); - -set->Belt.Set.String.has("strawberry") /* false */ -set->Belt.Set.String.has("apple") /* true */ -``` - -## add - -```re sig -let add: (t, value) => t; -``` - -Adds element to set. If element existed in set, value is unchanged. - -```re example -let s0 = Belt.Set.String.empty; -let s1 = s0->Belt.Set.String.add("apple"); -let s2 = s1->Belt.Set.String.add("banana"); -let s3 = s2->Belt.Set.String.add("banana"); -s0->Belt.Set.String.toArray; /* [||] */ -s1->Belt.Set.String.toArray; /* [|"apple"|] */ -s2->Belt.Set.String.toArray; /* [|"apple", "banana"|] */ -s3->Belt.Set.String.toArray; /* [|"apple", "banana"|] */ -s2 == s3; /* true */ -``` - -## mergeMany - -```re sig -let mergeMany: (t, array(value)) => t; -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```re example -let set = Belt.Set.String.empty; - -let newSet = - set->Belt.Set.String.mergeMany([|"apple", "banana", "orange", "strawberry"|]); - -newSet->Belt.Set.String.toArray; /* [|"apple", "banana", "orange", "strawberry"|] */ -``` - -## remove - -```re sig -let remove: (t, value) => t; -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```re example -let s0 = Belt.Set.String.fromArray([|"orange", "banana", "apple"|]); -let s1 = s0->Belt.Set.String.remove("apple"); -let s2 = s1->Belt.Set.String.remove("banana"); -let s3 = s2->Belt.Set.String.remove("banana"); - -s1->Belt.Set.String.toArray; /* [|"orange", "banana"|] */ -s2->Belt.Set.String.toArray; /* [|"orange"|] */ -s2 == s3; /* true */ -``` - -## removeMany - -```re sig -let removeMany: (t, array(value)) => t; -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```re example -let set = Belt.Set.String.fromArray([|"apple", "banana", "orange"|]); - -let newSet = set->Belt.Set.String.removeMany([|"strawberry", "apple", "banana", "orange"|]); -newSet->Belt.Set.String.toArray; /* [||] */ -``` - -## union - -```re sig -let union: (t, t) => t; -``` - -Returns union of two sets. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "banana", "orange", "carrot"|]); -let s1 = Belt.Set.String.fromArray([|"apple", "banana", "orange", "strawberry"|]); -let union = Belt.Set.String.union(s0, s1); -union->Belt.Set.String.toArray; /* [|"apple", "banana", "carrot", "orange", "strawberry"|] */ -``` - -## intersect - -```re sig -let intersect: (t, t) => t; -``` - -Returns intersection of two sets. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "banana", "orange", "carrot"|]); -let s1 = Belt.Set.String.fromArray([|"apple", "banana", "orange", "strawberry"|]); -let intersect = Belt.Set.String.intersect(s0, s1); -intersect->Belt.Set.String.toArray; /* [|"apple", "banana", "orange"|] */ -``` - -## diff - -```re sig -let diff: (t, t) => t; -``` - -Returns elements from first set, not existing in second set. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "banana", "orange", "carrot"|]); -let s1 = Belt.Set.String.fromArray([|"apple", "banana", "orange", "strawberry"|]); -Belt.Set.String.toArray(Belt.Set.String.diff(s0, s1)); /* [|"carrot"|] */ -Belt.Set.String.toArray(Belt.Set.String.diff(s1, s0)); /* [|"strawberry"|] */ -``` - -## subset - -```re sig -let subset: (t, t) => bool; -``` - -Checks if second set is subset of first set. - -```re example -let s0 = Belt.Set.String.fromArray([|"5", "2", "3", "5", "6"|]); -let s1 = Belt.Set.String.fromArray([|"5", "2", "3", "1", "5", "4"|]); -let s2 = Belt.Set.String.intersect(s0, s1); -Belt.Set.String.subset(s2, s0); /* true */ -Belt.Set.String.subset(s2, s1); /* true */ -Belt.Set.String.subset(s1, s0); /* false */ -``` - -## cmp - -```re sig -let cmp: (t, t) => int; -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```re sig -let eq: (t, t) => bool; -``` - -Checks if two sets are equal. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "orange"|]); -let s1 = Belt.Set.String.fromArray([|"orange", "apple"|]); - -Belt.Set.String.eq(s0, s1); /* true */ -``` - -## forEachU - -```re sig -let forEachU: (t, [@bs] (value => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t, value => unit) => unit; -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```re example -let s0 = Belt.Set.String.fromArray([|"banana", "orange", "apple"|]); -let acc = ref([]); -s0->Belt.Set.String.forEach(x => { - acc := Belt.List.add(acc^, x) -}); -acc; /* ["orange", "banana", "apple"] */ -``` - -## reduceU - -```re sig -let reduceU: (t, 'a, [@bs] (('a, value) => 'a)) => 'a; -``` - -## reduce - -```re sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "orange"|]); -s0->Belt.Set.String.reduce(0, (acc, element) => - acc + String.length(element) -); /* 11 */ -``` - -## everyU - -```re sig -let everyU: (t, [@bs] (value => bool)) => bool; -``` - -## every - -```re sig -let every: (t, value => bool) => bool; -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```re example -let hasAtLeastFiveChars = x => String.length(x) >= 5; - -let s0 = Belt.Set.String.fromArray([|"apple", "carrot"|]); -s0->Belt.Set.String.every(hasAtLeastFiveChars); /* true */ -``` - -## someU - -```re sig -let someU: (t, [@bs] (value => bool)) => bool; -``` - -## some - -```re sig -let some: (t, value => bool) => bool; -``` - -Checks if at least one element of the set satisfies the predicate. - -```re example -let hasFiveChars = x => String.length(x) == 5; - -let s0 = Belt.Set.String.fromArray([|"strawberry", "apple"|]); -s0->Belt.Set.String.some(hasFiveChars); /* true */ -``` - -## keepU - -```re sig -let keepU: (t, [@bs] (value => bool)) => t; -``` - -## keep - -```re sig -let keep: (t, value => bool) => t; -``` - -Returns the set of all elements that satisfy the predicate. - -```re example -let hasFiveChars = x => String.length(x) == 5; - -let s0 = Belt.Set.String.fromArray([|"apple", "orange", "banana"|]); -let s1 = s0->Belt.Set.String.keep(hasFiveChars); - -s1->Belt.Set.String.toArray; /* [|"apple"|] */ -``` - -## partitionU - -```re sig -let partitionU: (t, [@bs] (value => bool)) => (t, t); -``` - -## partition - -```re sig -let partition: (t, value => bool) => (t, t); -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```re example -let hasFiveChars = x => String.length(x) == 5; - -let s0 = Belt.Set.String.fromArray([|"apple", "carrot"|]); -let (s1, s2) = s0->Belt.Set.String.partition(hasFiveChars); - -s1->Belt.Set.String.toArray; /* [|"apple"|] */ -s2->Belt.Set.String.toArray; /* [|"carrot"|] */ -``` - -## size - -```re sig -let size: t => int; -``` - -Returns size of the set. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple"|]); - -s0->Belt.Set.String.size; /* 1 */ -``` - -## toList - -```re sig -let toList: t => list(value); -``` - -Returns list of ordered set elements. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "watermelon"|]); - -s0->Belt.Set.String.toList; /* ["apple", "watermelon"] */ -``` - -## toArray - -```re sig -let toArray: t => array(value); -``` - -Returns array of ordered set elements. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "watermelon"|]); - -s0->Belt.Set.String.toArray; /* [|"apple", "watermelon"|] */ -``` - -## minimum - -```re sig -let minimum: t => option(value); -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.Set.String.empty; -let s1 = Belt.Set.String.fromArray([|"apple", "orange"|]); - -s0->Belt.Set.String.minimum; /* None */ -s1->Belt.Set.String.minimum; /* Some("apple") */ -``` - -## minUndefined - -```re sig -let minUndefined: t => Js.undefined(value); -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.Set.String.empty; -let s1 = Belt.Set.String.fromArray([|"apple", "orange"|]); - -s0->Belt.Set.String.minUndefined; /* undefined */ -s1->Belt.Set.String.minUndefined; /* "apple" */ -``` - -## maximum - -```re sig -let maximum: t => option(value); -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.Set.String.empty; -let s1 = Belt.Set.String.fromArray([|"apple", "orange"|]); - -s0->Belt.Set.String.maximum; /* None */ -s1->Belt.Set.String.maximum; /* Some("orange") */ -``` - -## maxUndefined - -```re sig -let maxUndefined: t => Js.undefined(value); -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.Set.String.empty; -let s1 = Belt.Set.String.fromArray([|"apple", "orange"|]); - -s0->Belt.Set.String.maxUndefined; /* undefined */ -s1->Belt.Set.String.maxUndefined; /* orange */ -``` - -## get - -```re sig -let get: (t, value) => option(value); -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "carrot"|]); - -s0->Belt.Set.String.get("carrot"); /* Some("carrot") */ -s0->Belt.Set.String.get("watermelon"); /* None */ -``` - -## getUndefined - -```re sig -let getUndefined: (t, value) => Js.undefined(value); -``` - -See [get](#get) - returns `undefined` when element does not exist. - -## getExn - -```re sig -let getExn: (t, value) => value; -``` - -See [get](#get) - raise when element does not exist. - -## split - -```re sig -let split: (t, value) => ((t, t), bool); -``` - -Returns a triple `((l, r), present)`, where `l` is the set of elements of set that are strictly less than value, `r` is the set of elements of set that are strictly greater than value, `present` is `false` if set contains no element equal to value, or `true` if set contains an element equal to value. - -```re example -let s0 = Belt.Set.String.fromArray([|"apple", "banana", "orange"|]); - -let ((smaller, larger), present) = s0->Belt.Set.String.split("banana"); - -present; /* true */ -smaller->Belt.Set.String.toArray; /* [|"apple"|] */ -larger->Belt.Set.String.toArray; /* [|"orange"|] */ -``` - -## checkInvariantInternal - -```re sig -let checkInvariantInternal: t => unit; -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v8.0.0/api/belt/set.mdx b/pages/docs/manual/v8.0.0/api/belt/set.mdx deleted file mode 100644 index 40849ba50..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/set.mdx +++ /dev/null @@ -1,590 +0,0 @@ -# Set - - - -A **immutable** sorted set module which allows customize compare behavior. -The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map. - -It also has three specialized inner modules [Belt.Set.Int](./set-int), [Belt.Set.String](./set-string) and [Belt.Set.Dict](./set-dict) - This module separates data from function which is more verbose but slightly more efficient - - - -```re example -module PairComparator = - Belt.Id.MakeComparable({ - type t = (int, int); - let cmp = ((a0, a1), (b0, b1)) => - switch (Pervasives.compare(a0, b0)) { - | 0 => Pervasives.compare(a1, b1) - | c => c - }; - }); - -let mySet = Belt.Set.make(~id=(module PairComparator)); -let mySet2 = Belt.Set.add(mySet, (1, 2)); -``` - -**Note:** This module's examples will assume a predeclared module for integers -called `IntCmp`. It is declared like this: - -```re prelude -module IntCmp = - Belt.Id.MakeComparable({ - type t = int; - let cmp = Pervasives.compare; - }); -``` - -## t - -```re sig -type t('value, 'identity); -``` - -`'value` is the element type - -`'identity` the identity of the collection - -## id - -```re sig -type id('value, 'id) = Belt_Id.comparable('value, 'id); -``` - -The identity needed for making a set from scratch - -## make - -```re sig -let make: (~id: id('value, 'id)) => t('value, 'id); -``` - -Creates a new set by taking in the comparator - -```re example -let set = Belt.Set.make(~id=(module IntCmp)); -``` - -## fromArray - -```re sig -let fromArray: (array('value), ~id: id('value, 'id)) => t('value, 'id); -``` - -Creates new set from array of elements. - -```re example -let s0 = Belt.Set.fromArray([|1, 3, 2, 4|], ~id=(module IntCmp)) - -s0->Belt.Set.toArray; /* [|1, 2, 3, 4|] */ -``` - -## fromSortedArrayUnsafe - -```re sig -let fromSortedArrayUnsafe: (array('value), ~id: id('value, 'id)) => t('value, 'id); -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```re sig -let isEmpty: t('a, 'b) => bool; -``` - -Checks if set is empty. - -```re example -let empty = Belt.Set.fromArray([||], ~id=(module IntCmp)); -let notEmpty = Belt.Set.fromArray([|1|],~id=(module IntCmp)); - -Belt.Set.isEmpty(empty); /* true */ -Belt.Set.isEmpty(notEmpty); /* false */ -``` - -## has - -```re sig -let has: (t('value, 'id), 'value) => bool; -``` - -Checks if element exists in set. - -```re example -let set = Belt.Set.fromArray([|1, 4, 2, 5|], ~id=(module IntCmp)); - -set->Belt.Set.has(3) /* false */ -set->Belt.Set.has(1) /* true */ -``` - -## add - -```re sig -let add: (t('value, 'id), 'value) => t('value, 'id); -``` - -Adds element to set. If element existed in set, value is unchanged. - -```re example -let s0 = Belt.Set.make(~id=(module IntCmp)); -let s1 = s0->Belt.Set.add(1); -let s2 = s1->Belt.Set.add(2); -let s3 = s2->Belt.Set.add(2); -s0->Belt.Set.toArray; /* [||] */ -s1->Belt.Set.toArray; /* [|1|] */ -s2->Belt.Set.toArray; /* [|1, 2|] */ -s3->Belt.Set.toArray; /* [|1,2 |] */ -s2 == s3; /* true */ -``` - -## mergeMany - -```re sig -let mergeMany: (t('value, 'id), array('value)) => t('value, 'id); -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```re example -let set = Belt.Set.make(~id=(module IntCmp)); - -let newSet = set->Belt.Set.mergeMany([|5, 4, 3, 2, 1|]); -newSet->Belt.Set.toArray; /* [|1, 2, 3, 4, 5|] */ -``` - -## remove - -```re sig -let remove: (t('value, 'id), 'value) => t('value, 'id); -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```re example -let s0 = Belt.Set.fromArray([|2,3,1,4,5|], ~id=(module IntCmp)); -let s1 = s0->Belt.Set.remove(1); -let s2 = s1->Belt.Set.remove(3); -let s3 = s2->Belt.Set.remove(3); - -s1->Belt.Set.toArray; /* [|2,3,4,5|] */ -s2->Belt.Set.toArray; /* [|2,4,5|] */ -s2 == s3; /* true */ -``` - -## removeMany - -```re sig -let removeMany: (t('value, 'id), array('value)) => t('value, 'id); -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```re example -let set = Belt.Set.fromArray([|1, 2, 3, 4|],~id=(module IntCmp)); - -let newSet = set->Belt.Set.removeMany([|5, 4, 3, 2, 1|]); -newSet->Belt.Set.toArray; /* [||] */ -``` - -## union - -```re sig -let union: (t('value, 'id), t('value, 'id)) => t('value, 'id); -``` - -Returns union of two sets. - -```re example -let s0 = Belt.Set.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -let union = Belt.Set.union(s0, s1); -union->Belt.Set.toArray; /* [|1,2,3,4,5,6|] */ -``` - -## intersect - -```re sig -let intersect: (t('value, 'id), t('value, 'id)) => t('value, 'id); -``` - -Returns intersection of two sets. - -```re example -let s0 = Belt.Set.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -let intersect = Belt.Set.intersect(s0, s1); -intersect->Belt.Set.toArray; /* [|2,3,5|] */ -``` - -## diff - -```re sig -let diff: (t('value, 'id), t('value, 'id)) => t('value, 'id); -``` - -Returns elements from first set, not existing in second set. - -```re example -let s0 = Belt.Set.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -Belt.Set.toArray(Belt.Set.diff(s0, s1)); /* [|6|] */ -Belt.Set.toArray(Belt.Set.diff(s1,s0)); /* [|1,4|] */ -``` - -## subset - -```re sig -let subset: (t('value, 'id), t('value, 'id)) => bool; -``` - -Checks if second set is subset of first set. - -```re example -let s0 = Belt.Set.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|5,2,3,1,5,4|], ~id=(module IntCmp)); -let s2 = Belt.Set.intersect(s0, s1); -Belt.Set.subset(s2, s0); /* true */ -Belt.Set.subset(s2, s1); /* true */ -Belt.Set.subset(s1, s0); /* false */ -``` - -## cmp - -```re sig -let cmp: (t('value, 'id), t('value, 'id)) => int; -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```re sig -let eq: (t('value, 'id), t('value, 'id)) => bool; -``` - -Checks if two sets are equal. - -```re example -let s0 = Belt.Set.fromArray([|5,2,3|], ~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|3,2,5|], ~id=(module IntCmp)); - -Belt.Set.eq(s0, s1); /* true */ -``` - -## forEachU - -```re sig -let forEachU: (t('value, 'id), [@bs] ('value => unit)) => unit; -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```re sig -let forEach: (t('value, 'id), 'value => unit) => unit; -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```re example -let s0 = Belt.Set.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -let acc = ref([]); -s0->Belt.Set.forEach(x => { - acc := Belt.List.add(acc^, x) -}); -acc; /* [6,5,3,2] */ -``` - -## reduceU - -```re sig -let reduceU: (t('value, 'id), 'a, [@bs] (('a, 'value) => 'a)) => 'a; -``` - -## reduce - -```re sig -let reduce: (t('value, 'id), 'a, ('a, 'value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```re example -let s0 = Belt.Set.fromArray([|5,2,3,5,6|], ~id=(module IntCmp)); -s0->Belt.Set.reduce([], (acc, element) => - acc->Belt.List.add(element) -); /* [6,5,3,2] */ -``` - -## everyU - -```re sig -let everyU: (t('value, 'id), [@bs] ('value => bool)) => bool; -``` - -## every - -```re sig -let every: (t('value, 'id), 'value => bool) => bool; -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```re example -let isEven = x => x mod 2 == 0; - -let s0 = Belt.Set.fromArray([|2,4,6,8|], ~id=(module IntCmp)); -s0->Belt.Set.every(isEven); /* true */ -``` - -## someU - -```re sig -let someU: (t('value, 'id), [@bs] ('value => bool)) => bool; -``` - -## some - -```re sig -let some: (t('value, 'id), 'value => bool) => bool; -``` - -Checks if at least one element of the set satisfies the predicate. - -```re example -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.Set.fromArray([|1,2,4,6,8|], ~id=(module IntCmp)); -s0->Belt.Set.some(isOdd); /* true */ -``` - -## keepU - -```re sig -let keepU: (t('value, 'id), [@bs] ('value => bool)) => t('value, 'id); -``` - -## keep - -```re sig -let keep: (t('value, 'id), 'value => bool) => t('value, 'id); -``` - -Returns the set of all elements that satisfy the predicate. - -```re example -let isEven = x => x mod 2 == 0; - -let s0 = Belt.Set.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); -let s1 = s0->Belt.Set.keep(isEven); - -s1->Belt.Set.toArray; /* [|2,4|] */ -``` - -## partitionU - -```re sig -let partitionU: (t('value, 'id), [@bs] ('value => bool)) => (t('value, 'id), t('value, 'id)); -``` - -## partition - -```re sig -let partition: (t('value, 'id), 'value => bool) => (t('value, 'id), t('value, 'id)); -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```re example -let isOdd = x => x mod 2 != 0; - -let s0 = Belt.Set.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); -let (s1, s2) = s0->Belt.Set.partition(isOdd); - -s1->Belt.Set.toArray; /* [|1,3,5|] */ -s2->Belt.Set.toArray; /* [|2,4|] */ -``` - -## size - -```re sig -let size: t('value, 'id) => int; -``` - -Returns size of the set. - -```re example -let s0 = Belt.Set.fromArray([|1,2,3,4|], ~id=(module IntCmp)); - -s0->Belt.Set.size; /* 4 */ -``` - -## toArray - -```re sig -let toArray: t('value, 'id) => array('value); -``` - -Returns array of ordered set elements. - -```re example -let s0 = Belt.Set.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.Set.toArray; /* [|1,2,3,5|] */ -``` - -## toList - -```re sig -let toList: t('value, 'id) => list('value); -``` - -Returns list of ordered set elements. - -```re example -let s0 = Belt.Set.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.Set.toList; /* [1,2,3,5] */ -``` - -## minimum - -```re sig -let minimum: t('value, 'id) => option('value); -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.Set.make(~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.Set.minimum; /* None */ -s1->Belt.Set.minimum; /* Some(1) */ -``` - -## minUndefined - -```re sig -let minUndefined: t('value, 'id) => Js.undefined('value); -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.Set.make(~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.Set.minUndefined; /* undefined */ -s1->Belt.Set.minUndefined; /* 1 */ -``` - -## maximum - -Returns maximum value of the collection. `None` if collection is empty. - -```re example -let s0 = Belt.Set.make(~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.Set.maximum; /* None */ -s1->Belt.Set.maximum; /* Some(5) */ -``` - -## maxUndefined - -```re sig -let maxUndefined: t('value, 'id) => Js.undefined('value); -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```re example -let s0 = Belt.Set.make(~id=(module IntCmp)); -let s1 = Belt.Set.fromArray([|3,2,1,5|], ~id=(module IntCmp)); - -s0->Belt.Set.maxUndefined; /* undefined */ -s1->Belt.Set.maxUndefined; /* 5 */ -``` - -## get - -```re sig -let get: (t('value, 'id), 'value) => option('value); -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```re example -let s0 = Belt.Set.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); - -s0->Belt.Set.get(3); /* Some(3) */ -s0->Belt.Set.get(20); /* None */ -``` - -## getUndefined - -```re sig -let getUndefined: (t('value, 'id), 'value) => Js.undefined('value); -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```re sig -let getExn: (t('value, 'id), 'value) => 'value; -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```re sig -let split: (t('value, 'id), 'value) => ((t('value, 'id), t('value, 'id)), bool); -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```re example -let s0 = Belt.Set.fromArray([|1,2,3,4,5|], ~id=(module IntCmp)); - -let ((smaller, larger), present) = s0->Belt.Set.split(3); - -present; /* true */ -smaller->Belt.Set.toArray; /* [|1,2|] */ -larger->Belt.Set.toArray; /* [|4,5|] */ - -``` - -## getData - -```re sig -let getData: t('value, 'id) => Belt_SetDict.t('value, 'id); -``` - -**Advanced usage only** - -Returns the raw data (detached from comparator), but its type is still manifested, so that user can pass identity directly without boxing. - -## getId - -```re sig -let getId: t('value, 'id) => id('value, 'id); -``` - -**Advanced usage only** - -Returns the identity of set. - -## packIdData - -```re sig -let packIdData: (~id: id('value, 'id), ~data: Belt_SetDict.t('value, 'id)) => t('value, 'id); -``` - -**Advanced usage only** - -Returns the packed collection. diff --git a/pages/docs/manual/v8.0.0/api/belt/sort-array-int.mdx b/pages/docs/manual/v8.0.0/api/belt/sort-array-int.mdx deleted file mode 100644 index 615e6d847..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/sort-array-int.mdx +++ /dev/null @@ -1,59 +0,0 @@ -# SortArrayInt - - - -This is a specialized module for `Belt.SortArray`, the docs in that module also applies here, except the comparator is fixed and inlined. - - - -## element - -```re sig -type element = int; -``` - -## strictlySortedLength - -```re sig -let strictlySortedLength: array(element) => int; -``` - -The same as `Belt.SortArray.strictlySortedLength` except the comparator is fixed. - -Returns `+n` means increasing order `-n` means negative order. - -## isSorted - -```re sig -let isSorted: array(element) => bool; -``` - -`sorted(xs)` return true if `xs` is in non strict increasing order. - -## stableSortInPlace - -```re sig -let stableSortInPlace: array(element) => unit; -``` - -The same as `Belt.SortArray.stableSortInPlaceBy` except the comparator is fixed. - -## stableSort - -```re sig -let stableSort: array(element) => array(element); -``` - -The same as `Belt.SortArray.stableSortBy` except the comparator is fixed. - -## binarySearch - -```re sig -let binarySearch: (array(element), element) => int; -``` - -If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value. - -If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot(-1) = 0` if `key` is larger than all elements return `- (len + 1)` since `lnot(-(len+1)) = len`. diff --git a/pages/docs/manual/v8.0.0/api/belt/sort-array-string.mdx b/pages/docs/manual/v8.0.0/api/belt/sort-array-string.mdx deleted file mode 100644 index 1633802de..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/sort-array-string.mdx +++ /dev/null @@ -1,59 +0,0 @@ -# SortArrayString - - - -This is a specialized module for `Belt.SortArray`, the docs in that module also applies here, except the comparator is fixed and inlined. - - - -## element - -```re sig -type element = string; -``` - -## strictlySortedLength - -```re sig -let strictlySortedLength: array(element) => int; -``` - -The same as `Belt.SortArray.strictlySortedLength` except the comparator is fixed. - -Returns `+n` means increasing order `-n` means negative order. - -## isSorted - -```re sig -let isSorted: array(element) => bool; -``` - -`sorted(xs)` return true if `xs` is in non strict increasing order. - -## stableSortInPlace - -```re sig -let stableSortInPlace: array(element) => unit; -``` - -The same as `Belt.SortArray.stableSortInPlaceBy` except the comparator is fixed. - -## stableSort - -```re sig -let stableSort: array(element) => array(element); -``` - -The same as `Belt.SortArray.stableSortBy` except the comparator is fixed. - -## binarySearch - -```re sig -let binarySearch: (array(element), element) => int; -``` - -If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value. - -If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot(-1) = 0` if `key` is larger than all elements return `- (len + 1)` since `lnot(-(len+1)) = len`. diff --git a/pages/docs/manual/v8.0.0/api/belt/sort-array.mdx b/pages/docs/manual/v8.0.0/api/belt/sort-array.mdx deleted file mode 100644 index 7722f42d7..000000000 --- a/pages/docs/manual/v8.0.0/api/belt/sort-array.mdx +++ /dev/null @@ -1,111 +0,0 @@ -# SortArray - -## SortArrayInt - -```re sig -module Int : Belt_SortArrayInt -``` - -Specalized when key type is `int`, more efficient than the generic type - -## SortArrayString - -```re sig -module String: Belt_SortArrayString -``` - -Specalized when key type is `string`, more efficient than the generic type - -## strictlySortedLengthU - -```re sig -let strictlySortedLengthU: (array('a), [@bs] (('a, 'a) => bool)) => int; -``` - -## strictlySortedLength - -```re sig -let strictlySortedLength: (array('a), ('a, 'a) => bool) => int; -``` - -`strictlySortedLenght(xs, cmp);` return `+n` means increasing order `-n` means negative order - -```re example -Belt.SortArray.strictlySortedLength([|1, 2, 3, 4, 3|], (x, y) => x < y) == 4; - -Belt.SortArray.strictlySortedLength([||], (x, y) => x < y) == 0; - -Belt.SortArray.strictlySortedLength([|1|], (x, y) => x < y) == 1; - -Belt.SortArray.strictlySortedLength([|4, 3, 2, 1|], (x, y) => x < y) == (-4); -``` - -## isSortedU - -```re sig -let isSortedU: (array('a), [@bs] (('a, 'a) => int)) => bool; -``` - -## isSorted - -```re sig -let isSorted: (array('a), ('a, 'a) => int) => bool; -``` - -`isSorted(arr, cmp)`: Returns true if array is increasingly sorted (equal is okay) - -## stableSortInPlaceByU - -```re sig -let stableSortInPlaceByU: (array('a), [@bs] (('a, 'a) => int)) => unit; -``` - -## stableSortInPlaceBy - -```re sig -let stableSortInPlaceBy: (array('a), ('a, 'a) => int) => unit; -``` - -## stableSortByU - -```re sig -let stableSortByU: (array('a), [@bs] (('a, 'a) => int)) => array('a); -``` - -## stableSortBy - -```re sig -let stableSortBy: (array('a), ('a, 'a) => int) => array('a); -``` - -`stableSortBy(xs, cmp)`: Returns a fresh array Sort `xs` in place using -comparator `cmp`, the stable means if the elements are equal, their order will -be preserved - -## binarySearchByU - -```re sig -let binarySearchByU: (array('a), 'a, [@bs] (('a, 'a) => int)) => int; -``` - -## binarySearchBy - -```re sig -let binarySearchBy: (array('a), 'a, ('a, 'a) => int) => int; -``` - -If value is not found and value is less than one or more elements in array, the -negative number returned is the bitwise complement of the index of the first -element that is larger than value. - -If value is not found and value is greater -than all elements in array, the negative number returned is the bitwise -complement of (the index of the last element plus 1)for example, if `key` is -smaller than all elements return `-1` since `lnot(-1) == 0` if `key` is larger -than all elements return `lnot(-1) == 0` since `lnot(- (len + 1)) == len` - -```re example -Belt.SortArray.binarySearchBy([|1, 2, 3, 4, 33, 35, 36|], 33, Pervasives.compare) == 4; - -lnot(Belt.SortArray.binarySearchBy([|1, 3, 5, 7|], 4, Pervasives.compare)) == 2; -``` diff --git a/pages/docs/manual/v8.0.0/api/dom.mdx b/pages/docs/manual/v8.0.0/api/dom.mdx deleted file mode 100644 index 050f1b88f..000000000 --- a/pages/docs/manual/v8.0.0/api/dom.mdx +++ /dev/null @@ -1,855 +0,0 @@ -# Dom - - - -The Dom module offers a canonical set of dom related types that third party libraries can depend on. It only provides types, no functions to manipulate the values of certain types whatsoever. - - - -## animation - -```re sig -type animation -``` - -## cssStyleDeclaration - -```re sig -type cssStyleDeclaration -``` - -## cssStyleSheet - -```re sig -type cssStyleSheet -``` - -## node - -```re sig -type node -``` - -## characterData - -```re sig -type characterData -``` - -## cdataSection - -```re sig -type cdataSection -``` - -## comment - -```re sig -type comment -``` - -## document - -```re sig -type document -``` - -## documentType - -```re sig -type documentType -``` - -## domImplementation - -```re sig -type domImplementation -``` - -## element - -```re sig -type element -``` - -## htmlCollection - -```re sig -type htmlCollection -``` - -## htmlFormControlsCollection - -```re sig -type htmlFormControlsCollection -``` - -## htmlOptionsCollection - -```re sig -type htmlOptionsCollection -``` - -## intersectionObserver - -```re sig -type intersectionObserver -``` - -## intersectionObserverEntry - -```re sig -type intersectionObserverEntry -``` - -## mutationObserver - -```re sig -type mutationObserver -``` - -## mutationRecord - -```re sig -type mutationRecord -``` - -## performanceObserver - -```re sig -type performanceObserver -``` - -## performanceObserverEntryList - -```re sig -type performanceObserverEntryList -``` - -## reportingObserver - -```re sig -type reportingObserver -``` - -## reportingObserverOptions - -```re sig -type reportingObserverOptions -``` - -## resizeObserver - -```re sig -type resizeObserver -``` - -## resizeObserverEntry - -```re sig -type resizeObserverEntry -``` - -## namedNodeMap - -```re sig -type namedNodeMap -``` - -## nodeList - -```re sig -type nodeList -``` - -## radioNodeList - -```re sig -type radioNodeList -``` - -## processingInstruction - -```re sig -type processingInstruction -``` - -## shadowRoot - -```re sig -type shadowRoot -``` - -## text - -```re sig -type text -``` - -## domRect - -```re sig -type domRect -``` - -## dataTransfer - -```re sig -type dataTransfer -``` - -## domStringMap - -```re sig -type domStringMap -``` - -## history - -```re sig -type history -``` - -## htmlDocument - -```re sig -type htmlDocument -``` - -## htmlElement - -```re sig -type htmlElement -``` - -## htmlAnchorElement - -```re sig -type htmlAnchorElement -``` - -## htmlAreaElement - -```re sig -type htmlAreaElement -``` - -## htmlAudioElement - -```re sig -type htmlAudioElement -``` - -## htmlBaseElement - -```re sig -type htmlBaseElement -``` - -## htmlBodyElement - -```re sig -type htmlBodyElement -``` - -## htmlBrElement - -```re sig -type htmlBrElement -``` - -## htmlButtonElement - -```re sig -type htmlButtonElement -``` - -## htmlCanvasElement - -```re sig -type htmlCanvasElement -``` - -## htmlDataElement - -```re sig -type htmlDataElement -``` - -## htmlDataListElement - -```re sig -type htmlDataListElement -``` - -## htmlDialogElement - -```re sig -type htmlDialogElement -``` - -## htmlDivElement - -```re sig -type htmlDivElement -``` - -## htmlDlistElement - -```re sig -type htmlDlistElement -``` - -## htmlEmbedElement - -```re sig -type htmlEmbedElement -``` - -## htmlFieldSetElement - -```re sig -type htmlFieldSetElement -``` - -## htmlFormElement - -```re sig -type htmlFormElement -``` - -## htmlHeadElement - -```re sig -type htmlHeadElement -``` - -## htmlHeadingElement - -```re sig -type htmlHeadingElement -``` - -## htmlHrElement - -```re sig -type htmlHrElement -``` - -## htmlHtmlElement - -```re sig -type htmlHtmElement -``` - -## htmlIframeElement - -```re sig -type htmlIframeElement -``` - -## htmlImageElement - -```re sig -type htmlImageElement -``` - -## htmlInputElement - -```re sig -type htmlInputElement -``` - -## htmlLabelElement - -```re sig -type htmlLabelElement -``` - -## htmlLegendElement - -```re sig -type htmlLegendElement -``` - -## htmlLiElement - -```re sig -type htmlLiElement -``` - -## htmlLinkElement - -```re sig -type htmlLinkElement -``` - -## htmlMapElement - -```re sig -type htmlMapElement -``` - -## htmlMediaElement - -```re sig -type htmlMediaElement -``` - -## htmlMenuElement - -```re sig -type htmlMenuElement -``` - -## htmlMetaElement - -```re sig -type htmlMetaElement -``` - -## htmlMeterElement - -```re sig -type htmlMeterElement -``` - -## htmlModElement - -```re sig -type htmlModElement -``` - -## htmlOListElement - -```re sig -type htmlOListElement -``` - -## htmlObjectElement - -```re sig -type htmlObjectElement -``` - -## htmlOptGroupElement - -```re sig -type htmlOptGroupElement -``` - -## htmlOptionElement - -```re sig -type htmlOptionElement -``` - -## htmlOutputElement - -```re sig -type htmlOutputElement -``` - -## htmlParagraphElement - -```re sig -type htmlParagraphElement -``` - -## htmlParamElement - -```re sig -type htmlParamElement -``` - -## htmlPreElement - -```re sig -type htmlPreElement -``` - -## htmlProgressElement - -```re sig -type htmlProgressElement -``` - -## htmlQuoteElement - -```re sig -type htmlQuoteElement -``` - -## htmlScriptElement - -```re sig -type htmlScriptElement -``` - -## htmlSelectElement - -```re sig -type htmlSelectElement -``` - -## htmlSlotElement - -```re sig -type htmlSlotElement -``` - -## htmlSourceElement - -```re sig -type htmlSourceElement -``` - -## htmlSpanElement - -```re sig -type htmlSpanElement -``` - -## htmlStyleElement - -```re sig -type htmlStyleElement -``` - -## htmlTableCaptionElement - -```re sig -type htmlTableCaptionElement -``` - -## htmlTableCellElement - -```re sig -type htmlTableCellElement -``` - -## htmlTableColElement - -```re sig -type htmlTableColElement -``` - -## htmlTableDataCellElement - -```re sig -type htmlTableDataCellElement -``` - -## htmlTableElement - -```re sig -type htmlTableElement -``` - -## htmlTableHeaderCellElement - -```re sig -type htmlTableHeaderCellElement -``` - -## htmlTableRowElement - -```re sig -type htmlTableRowElement -``` - -## htmlTableSectionElement - -```re sig -type htmlTableSectionElement -``` - -## htmlTextAreaElement - -```re sig -type htmlTextAreaElement -``` - -## htmlTimeElement - -```re sig -type htmlTimeElement -``` - -## htmlTitleElement - -```re sig -type htmlTitleElement -``` - -## htmlTrackElement - -```re sig -type htmlTrackElement -``` - -## htmlUlistElement - -```re sig -type htmlUlistElement -``` - -## htmlUnknownElement - -```re sig -type htmlUnknownElement -``` - -## htmlVideoElement - -```re sig -type htmlVideoElement -``` - -## location - -```re sig -type location -``` - -## window - -```re sig -type window -``` - -## xmlDocument - -```re sig -type xmlDocument -``` - -## event - -```re sig -type event -``` - -## uiEvent - -```re sig -type uiEvent -``` - -## animationEvent - -```re sig -type animationEvent -``` - -## beforeUnloadEvent - -```re sig -type beforeUnloadEvent -``` - -## clipboardEvent - -```re sig -type clipboardEvent -``` - -## closeEvent - -```re sig -type closeEvent -``` - -## compositionEvent - -```re sig -type compositionEvent -``` - -## customEvent - -```re sig -type customEvent -``` - -## dragEvent - -```re sig -type dragEvent -``` - -## errorEvent - -```re sig -type errorEvent -``` - -## focusEvent - -```re sig -type focusEvent -``` - -## idbVersionChangeEvent - -```re sig -type idbVersionChangeEvent -``` - -## inputEvent - -```re sig -type inputEvent -``` - -## keyboardEvent - -```re sig -type keyboardEvent -``` - -## mouseEvent - -```re sig -type mouseEvent -``` - -## pageTransitionEvent - -```re sig -type pageTransitionEvent -``` - -## pointerEvent - -```re sig -type pointerEvent -``` - -## popStateEvent - -```re sig -type popStateEvent -``` - -## progressEvent - -```re sig -type progressEvent -``` - -## relatedEvent - -```re sig -type relatedEvent -``` - -## storageEvent - -```re sig -type storageEvent -``` - -## svgZoomEvent - -```re sig -type svgZoomEvent -``` - -## timeEvent - -```re sig -type timeEvent -``` - -## touchEvent - -```re sig -type touchEvent -``` - -## trackEvent - -```re sig -type trackEvent -``` - -## transitionEvent - -```re sig -type transitionEvent -``` - -## webGlContextEvent - -```re sig -type webGlContextEvent -``` - -## wheelEvent - -```re sig -type wheelEvent -``` - -## range - -```re sig -type range -``` - -## selection - -```re sig -type selection -``` - -## domTokenList - -```re sig -type domTokenList -``` - -## domSettableTokenList - -```re sig -type domSettableTokenList -``` - -## nodeFilter - -```re sig -type nodeFilter = { - acceptNode: (Dom.element) => int -} -``` - -## nodeIterator - -```re sig -type nodeIterator -``` - -## treeWalker - -```re sig -type treeWalker -``` - -## svgRect - -```re sig -type svgRect -``` - -## svgPoint - -```re sig -type svgPoint -``` - -## eventPointerId - -```re sig -type eventPointerId -``` diff --git a/pages/docs/manual/v8.0.0/api/dom/storage.mdx b/pages/docs/manual/v8.0.0/api/dom/storage.mdx deleted file mode 100644 index 5c79ca0bd..000000000 --- a/pages/docs/manual/v8.0.0/api/dom/storage.mdx +++ /dev/null @@ -1,55 +0,0 @@ -# Storage - -## t - -```re prelude sig -type t -``` - -## getItem - -```re sig -external getItem: (string, t) => option = "getItem" -``` - -## setItem - -```re sig -external setItem: (string, string, t) => unit = "setItem" -``` - -## removeItem - -```re sig -external removeItem: (string, t) => unit = "removeItem" -``` - -## clear - -```re sig -external clear: t => unit = "clear" -``` - -## key - -```re sig -external key: (int, t) => option = "key" -``` - -## length - -```re sig -external length: t => int = "length" -``` - -## localStorage - -```re sig -[@bs.val] external localStorage: t = "localStorage" -``` - -## sessionStorage - -```re sig -[@bs.val] external sessionStorage: t = "sessionStorage" -``` diff --git a/pages/docs/manual/v8.0.0/api/dom/storage2.mdx b/pages/docs/manual/v8.0.0/api/dom/storage2.mdx deleted file mode 100644 index 3719686f9..000000000 --- a/pages/docs/manual/v8.0.0/api/dom/storage2.mdx +++ /dev/null @@ -1,61 +0,0 @@ -# Storage2 - - - -The same as [Dom.Storage](./storage2), but with `t` on first argument position for proper `->` usage. - - - -## t - -```re prelude sig -type t -``` - -## getItem - -```re sig -external getItem: (t, string) => option(string) = "getItem" -``` - -## setItem - -```re sig -external setItem: (t, string, string) => unit = "setItem" -``` - -## removeItem - -```re sig -external removeItem: (t, string) => unit = "removeItem" -``` - -## clear - -```re sig -external clear: t => unit = "clear" -``` - -## key - -```re sig -external key: (t, int) => option(string) = "key" -``` - -## length - -```re sig -external length: t => int = "length" -``` - -## localStorage - -```re sig -[@bs.val] external localStorage: t = "localStorage" -``` - -## sessionStorage - -```re sig -[@bs.val] external sessionStorage: t = "sessionStorage" -``` diff --git a/pages/docs/manual/v8.0.0/api/js.mdx b/pages/docs/manual/v8.0.0/api/js.mdx deleted file mode 100644 index 27660939d..000000000 --- a/pages/docs/manual/v8.0.0/api/js.mdx +++ /dev/null @@ -1,183 +0,0 @@ -# Js - -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/array-2) 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._ - -In the meantime, there are several options for dealing with the data-last APIs: - -```re example -/* Js.String (data-last API used with pipe last operator) */ -Js.log("2019-11-10" |> Js.String.split("-")); -Js.log("ReScript" |> Js.String.startsWith("Re")); - -/* Js.String (data-last API used with pipe first operator) */ -Js.log("2019-11-10"->Js.String.split("-", _)); -Js.log("ReScript"->Js.String.startsWith("Re", _)); - -/* Js.String (data-last API used without any piping) */ -Js.log(Js.String.split("-", "2019-11-10")); -Js.log(Js.String.startsWith("Re", "ReScript")); -``` - -## Js.Xxx2 Modules - -Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latters are old modules. - -## Object - -```re -type t(+'a); -``` - -Js object type. - -```re -let x: { - . - "x": int, - "y": int, -} = [%obj {x: 1, y: 2}]; -``` - -## Nullable and Undefined - -```re -type null(+'a); -``` - -nullable, value of this type can be either null or 'a this type is the same as type t in Js.Null - -```re -type undefined(+'a); -``` - -value of this type can be either undefined or 'a this type is the same as type t in Js.Undefined - -```re -type nullable(+'a); -``` - -value of this type can be undefined, null or 'a this type is the same as type t n Js.Null_undefined - -```re -type null_undefined('a) = Js.nullable('a); -``` - -```re -let toOption: Js.nullable('a) => option('a); -``` - -```re -let undefinedToOption: Js.undefined('a) => option('a); -``` - -```re -let nullToOption: Js.null('a) => option('a); -``` - -```re -let test: Js.nullable('a) => bool; -``` - -```re -let isNullable: Js.nullable('a) => bool; -``` - -```re -let testAny: 'a => bool; -``` - -The same as `Js.test` except that it is more permissive on the types of input. - -```re -type promise(+'a, +'e); -``` - -Deprecated. please use `Js.Promise`. -The promise type, defined here for interoperation across packages. - -```re -let null: Js.null('a); -``` - -The same as empty in `Js.Null`. Will be compiled as `null`. - -```re -let undefined: Js.undefined('a); -``` - -The same as empty `Js.Undefined`. Will be compiled as `undefined`. - -## TypeOf - -```re -let typeof: 'a => string; -``` - -`typeof x` will be compiled as `typeof x` in JS. Please consider functions in `Js.Types` for a type safe way of reflection. - -## Logging - -```re -let log: 'a => unit; -let log2: ('a, 'b) => unit; -let log3: ('a, 'b, 'c) => unit; -let log4: ('a, 'b, 'c, 'd) => unit; -``` - -A convenience function to log everything. - -```re -let logMany: array('a) => unit; -``` - -A convenience function to log more than 4 arguments - -## Comparison - -```re -let eqNull: ('a, null('a)) => bool; -let eqUndefined: ('a, undefined('a)) => bool; -let eqNullable: ('a, nullable('a)) => bool; -``` - -```re -let unsafe_lt: ('a, 'a) => bool; -``` - -`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. - -```re -let unsafe_le: ('a, 'a) => bool; -``` - -`unsafe_le a b` will be compiled as `a <= b`. See also `Js.unsafe_lt`. - -```re -let unsafe_gt: ('a, 'a) => bool; -``` - -`unsafe_gt a b` will be compiled as `a > b`. See also `Js.unsafe_lt`. - -```re -let unsafe_ge: ('a, 'a) => bool; -``` - -`unsafe_ge a b` will be compiled as `a >= b`. See also `Js.unsafe_lt`. diff --git a/pages/docs/manual/v8.0.0/api/js/array-2.mdx b/pages/docs/manual/v8.0.0/api/js/array-2.mdx deleted file mode 100644 index c646ce666..000000000 --- a/pages/docs/manual/v8.0.0/api/js/array-2.mdx +++ /dev/null @@ -1,916 +0,0 @@ -# Array2 - - - -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: - -```re example -let isEven = (x) => {x mod 2 == 0}; -let square = (x) => {x * x}; -let result = Js.Array2.( - reduce(map(filter([|5, 2, 3, 4, 1|], isEven), square), (+), 0) - ); -``` - -With pipe first, we call the functions in the “natural” order: - -```re example -let isEven = (x) => {x mod 2 == 0}; -let square = (x) => {x * x}; -let result = Js.Array2.( - [|5, 2, 3, 4, 1|] -> - filter(isEven) -> - map(square) -> - reduce((+), 0) - ); -``` - - - -## t - -```re sig -type t('a) = array('a); -``` - -The type used to describe a JavaScript array. - -## array_like - -```re sig -type array_like('a); -``` - -A type used to describe JavaScript objects that are like an array or are iterable. - -## from - -```re sig -let from: array_like('a) => array('b); -``` - -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. - -```re example -let strArr = Js.String.castToArrayLike("abcd"); -Js.Array2.from(strArr) == [|"a", "b", "c", "d"|]; -``` - -## fromMap - -```re sig -let fromMap: (array_like('a), 'a => 'b) => array('b); -``` - -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. - -```re example -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|]; -``` - -## isArray - -```re sig -let isArray: 'a => bool; -``` - -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. - -```re example -Js.Array2.isArray([|5, 2, 3, 1, 4|]) == true; -Js.Array2.isArray([5, 2, 3, 1, 4]) == true; -Js.Array2.isArray("abcd") == false; -``` - -## length - -```re sig -let length: array('a) => int; -``` - -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. - -## copyWithin - -```re sig -let copyWithin: (t('a), ~to_: int) => t('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array2.copyWithin(arr, ~to_=2) - == [|100, 101, 100, 101, 102|]; -arr == [|100, 101, 100, 101, 102|]; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (t('a), ~to_: int, ~from: int) => t('a); -``` - -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. - -```re example -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|]; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (t('a), ~to_: int, ~start: int, ~end_: int) => t('a); -``` - -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. - -```re example -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|]; -``` - -## fillInPlace - -```re sig -let fillInPlace: (t('a), 'a) => t('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array2.fillInPlace(arr, 99) - == [|99, 99, 99, 99, 99|]; -arr == [|99, 99, 99, 99, 99|]; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (t('a), 'a, ~from: int) => t('a); -``` - -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. - -```re example -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|]; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (t('a), 'a, ~start: int, ~end_: int) => t('a); -``` - -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. - -```re example -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|]; -``` - -## pop - -```re sig -let pop: t('a) => option('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array2.pop(arr) == Some(104); -arr == [|100, 101, 102, 103|]; - -let empty: array(int) = [| |]; -Js.Array2.pop(empty) == None; -``` - -## push - -```re sig -let push: (t('a), 'a) => int; -``` - -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. - -```re example -let arr = [|"ant", "bee", "cat"|]; -Js.Array2.push(arr, "dog") == 4; -arr == [|"ant", "bee", "cat", "dog"|]; -``` - -## pushMany - -```re sig -let pushMany: (t('a), array('a)) => int; -``` - -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. - -```re example -let arr = [|"ant", "bee", "cat"|]; -Js.Array2.pushMany(arr, [|"dog", "elk"|]) == 5; -arr == [|"ant", "bee", "cat", "dog", "elk"|]; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t('a) => t('a); -``` - -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. - -```re example -let arr = [|"ant", "bee", "cat"|]; -Js.Array2.reverseInPlace(arr) == [|"cat", "bee", "ant"|]; -arr == [|"cat", "bee", "ant"|]; -``` - -## shift - -```re sig -let shift: t('a) => option('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array2.shift(arr) == Some(100); -arr == [|101, 102, 103, 104|]; - -let empty: array(int) = [| |]; -Js.Array2.shift(empty) == None; -``` - -## sortInPlace - -```re sig -let sortInPlace: t('a) => t('a); -``` - -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. - -```re example -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|]; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: (t('a), ('a, 'a) => int) => t('a); -``` - -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. - -```re example -// 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|]; -``` - -## spliceInPlace - -```re sig -let spliceInPlace: (t('a), ~pos: int, ~remove: int, ~add: array('a)) => t('a); -``` - -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. - -```re example -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"|]; -``` - -## removeFromInPlace - -```re sig -let removeFromInPlace: (t('a), ~pos: int) => t('a); -``` - -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. - -```re example -let arr = [|"a", "b", "c", "d", "e", "f"|]; -Js.Array2.removeFromInPlace(arr, ~pos=4) == [|"e", "f"|]; -arr == [|"a", "b", "c", "d"|]; -``` - -## removeCountInPlace - -```re sig -let removeCountInPlace: (t('a), ~pos: int, ~count: int) => t('a); -``` - -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. - -```re example -let arr = [|"a", "b", "c", "d", "e", "f"|]; -Js.Array2.removeCountInPlace(arr, ~pos=2, ~count=3) == [|"c", "d", "e"|]; -arr == [|"a", "b", "f"|]; -``` - -## unshift - -```re sig -let unshift: (t('a), 'a) => int; -``` - -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. - -```re example -let arr = [|"b", "c", "d"|]; -Js.Array2.unshift(arr, "a") == 4; -arr == [|"a", "b", "c", "d"|]; -``` - -## unshiftMany - -```re sig -let unshiftMany: (t('a), array('a)) => int; -``` - -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. - -```re example -let arr = [|"d", "e"|]; -Js.Array2.unshiftMany(arr, [|"a", "b", "c"|]) == 5; -arr == [|"a", "b", "c", "d", "e"|]; -``` - -## append - -```re sig -let append: (t('a), 'a) => t('a); -``` - -Deprecated. `append()` is not type-safe. Use `concat()` instead. - -## concat - -```re sig -let concat: (t('a), t('a)) => t('a); -``` - -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. - -```re example -Js.Array2.concat([|"a", "b"|], [|"c", "d", "e"|]) - == [|"a", "b", "c", "d", "e"|]; -``` - -## concatMany - -```re sig -let concatMany: (t('a), array(t('a))) => t('a); -``` - -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. - -```re example -Js.Array2.concatMany([|"a", "b", "c"|], [| [|"d", "e"|], [|"f", "g", "h"|] |]) - == [|"a", "b", "c", "d", "e", "f", "g", "h"|]; -``` - -## includes - -```re sig -let includes: (t('a), 'a) => bool; -``` - -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. - -```re example -Js.Array2.includes([|"a", "b", "c"|], "b") == true; -Js.Array2.includes([|"a", "b", "c"|], "x") == false; -``` - -## indexOf - -```re sig -let indexOf: (t('a), 'a) => int; -``` - -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. - -```re example -Js.Array2.indexOf([|100, 101, 102, 103|], 102) == 2; -Js.Array2.indexOf([|100, 101, 102, 103|], 999) == -1; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (t('a), 'a, ~from: int) => int; -``` - -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. - -```re example -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; -``` - -## joinWith - -```re sig -let joinWith: (t('a), string) => string; -``` - -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. - -```re example -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"; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (t('a), 'a) => int; -``` - -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. - -```re example -Js.Array2.lastIndexOf([|"a", "b", "a", "c"|], "a") == 2; -Js.Array2.lastIndexOf([|"a", "b", "a", "c"|], "x") == -1; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (t('a), 'a, ~from: int) => int; -``` - -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. - -```re example -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; -``` - -## slice - -```re sig -let slice: (t('a), ~start: int, ~end_: int) => t('a); -``` - -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. - -```re example -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) == [| |]; -``` - -## copy - -```re sig -let copy: t('a) => t('a); -``` - -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. - -## sliceFrom - -```re sig -let sliceFrom: (t('a), int) => t('a); -``` - -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. - -```re example -Js.Array2.sliceFrom([|100, 101, 102, 103, 104|], 2) == [|102, 103, 104|]; -``` - -## toString - -```re sig -let toString: t('a) => string; -``` - -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. - -```re example -Js.Array2.toString([|3.5, 4.6, 7.8|]) == "3.5,4.6,7.8"; -Js.Array2.toString([|"a", "b", "c"|]) == "a,b,c"; -``` - -## toLocaleString - -```re sig -let toLocaleString: t('a) => string; -``` - -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. - -```re example -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 -``` - -## every - -```re sig -let every: (t('a), 'a => bool) => bool; -``` - -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. - -```re example -let isEven = (x) => {x mod 2 == 0}; -Js.Array2.every( [|6, 22, 8, 4|], isEven) == true; -Js.Array2.every([|6, 22, 7, 4|], isEven) == false; -``` - -## everyi - -````re sig -let everyi: (t('a), ('a, int) => bool) => bool; -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. - -```re example -// determine if all even-index items are positive -let evenIndexPositive = (item, index) => - {(index mod 2 == 0) ? item > 0 : true;}; - -Js.Array2.everyi([|6, -3, 5, 8|], evenIndexPositive) == true; -Js.Array2.everyi([|6, 3, -5, 8|], evenIndexPositive) == false; -```` - -## filter - -```re sig -let filter: (t('a), 'a => bool) => t('a); -``` - -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. - -```re example -let nonEmpty = (s) => {s != ""}; -Js.Array2.filter( [|"abc", "", "", "def", "ghi"|], nonEmpty) - == [|"abc", "def", "ghi"|]; -``` - -## filteri - -```re sig -let filteri: (t('a), ('a, int) => bool) => t('a); -``` - -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. - -```re example -// keep only positive elements at odd indices -let positiveOddElement = (item, index) => - {(index mod 2 == 1) && (item > 0)}; - -Js.Array2.filteri([|6, 3, 5, 8, 7, -4, 1|], - positiveOddElement) == [|3, 8|]; -``` - -## find - -```re sig -let find: (t('a), 'a => bool) => option('a); -``` - -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. - -```re example -// 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; -``` - -## findi - -```re sig -let findi: (t('a), ('a, int) => bool) => option('a); -``` - -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. - -```re example -// find first positive item at an odd index -let positiveOddElement = (item, index) => - {(index mod 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; -``` - -## findIndex - -```re sig -let findIndex: (t('a), 'a => bool) => int; -``` - -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. - -```re example -Js.Array2.findIndex([|33, 22, -55, 77, -44|], (x) => {x < 0}) == 2; -Js.Array2.findIndex([|33, 22, 55, 77, 44|], (x) => {x < 0}) == -1; -``` - -## findIndexi - -```re sig -let findIndexi: (t('a), ('a, int) => bool) => int; -``` - -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. - -```re example -// find index of first positive item at an odd index -let positiveOddElement = (item, index) => - {(index mod 2 == 1) && (item > 0)}; - -Js.Array2.findIndexi([|66, -33, 55, 88, 22|], positiveOddElement) == 3; -Js.Array2.findIndexi([|66, -33, 55, -88, 22|], positiveOddElement) == -1; -``` - -## forEach - -```re sig -let forEach: (t('a), 'a => unit) => unit; -``` - -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. - -```re example -// display all elements in an array -Js.Array2.forEach([|"a", "b", "c"|], (x) => {Js.log(x)}) == (); -``` - -## forEachi - -```re sig -let forEachi: (t('a), ('a, int) => unit) => unit; -``` - -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. - -```re example -// display all elements in an array as a numbered list -Js.Array2.forEachi([|"a", "b", "c"|], (item, index) => {Js.log2((index + 1), item)}) == (); -``` - -## map - -```re sig -let map: (t('a), 'a => 'b) => t('b); -``` - -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. - -```re example -Js.Array2.map([|12, 4, 8|], (x) => {x * x}) == [|144, 16, 64|]; -Js.Array2.map([|"animal", "vegetable", "mineral"|], Js.String.length) - == [|6, 9, 7|]; -``` - -## mapi - -```re sig -let mapi: (t('a), ('a, int) => 'b) => t('b); -``` - -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. - -```re example -// multiply each item in array by its position -let product = (item, index) => {item * index}; -Js.Array2.mapi([|10, 11, 12|], product) == [|0, 11, 24|]; -``` - -## reduce - -```re sig -let reduce: (t('a), ('b, 'a) => 'b, 'b) => 'b; -``` - -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. - -```re example -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) -``` - -## reducei - -```re sig -let reducei: (t('a), ('b, 'a, int) => 'b, 'b) => 'b; -``` - -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. - -```re example -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => { - if (index mod 2 == 0) { - accumulator + item; - } else { - accumulator; - } -}; - -Js.Array2.reducei([|2, 5, 1, 4, 3|], sumOfEvens, 0) == 6; -``` - -## reduceRight - -```re sig -let reduceRight: (t('a), ('b, 'a) => 'b, 'b) => 'b; -``` - -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. - -```re example -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) -``` - -## reduceRighti - -```re sig -let reduceRighti: (t('a), ('b, 'a, int) => 'b, 'b) => 'b; -``` - -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. - -```re example -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => { - if (index mod 2 == 0) { - accumulator + item; - } else { - accumulator; - } -}; - -Js.Array2.reduceRighti([|2, 5, 1, 4, 3|], sumOfEvens, 0) == 6; -``` - -## some - -```re sig -let some: (t('a), 'a => bool) => bool; -``` - -Returns `true` if the predicate function given as the second argument to `some()` returns `true` for any element in the array; `false` otherwise. - -```re example -let isEven = (x) => {x mod 2 == 0}; - -Js.Array2.some([|3, 7, 5, 2, 9|], isEven) == true; -Js.Array2.some([|3, 7, 5, 1, 9|], isEven) == false; -``` - -## somei - -```re sig -let somei: (t('a), ('a, int) => bool) => bool; -``` - -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 - -```re example -// 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; -``` - -## unsafe_get - -```re sig -let unsafe_get: (array('a), int) => 'a; -``` - -Returns the value at the given position in the array if the position is in bounds; returns the JavaScript value `undefined` otherwise. - -```re example -let arr = [|100, 101, 102, 103|]; -Js.Array2.unsafe_get(arr, 3) == 103; -Js.Array2.unsafe_get(arr, 4); // returns undefined -``` - -## unsafe_set - -```re sig -let unsafe_set: (array('a), int, 'a) => unit; -``` - -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._ - -```re example -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. -``` diff --git a/pages/docs/manual/v8.0.0/api/js/array.mdx b/pages/docs/manual/v8.0.0/api/js/array.mdx deleted file mode 100644 index 938eedb6a..000000000 --- a/pages/docs/manual/v8.0.0/api/js/array.mdx +++ /dev/null @@ -1,952 +0,0 @@ -# Array - - - -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. - -Here is an example to find the sum of squares of all even numbers in an array. -Without pipe last, we must call the functions in reverse order: - -```re example -let isEven = (x) => {x mod 2 == 0}; -let square = (x) => {x * x}; -let result = Js.Array.( - reduce((+), 0, map(square, filter(isEven,[|5, 2, 3, 4, 1|]))) - ); -``` - -With pipe last, we call the functions in the “natural” order: - -```re example -let isEven = (x) => {x mod 2 == 0}; -let square = (x) => {x * x}; -let result = Js.Array.( - [|5, 2, 3, 4, 1|] |> - filter(isEven) |> - map(square) |> - reduce((+), 0) - ); -``` - - - -## t - -```re sig -type t('a) = array('a); -``` - -The type used to describe a JavaScript array. - -## array_like - -```re sig -type array_like('a) = Js_array2.array_like('a); -``` - -A type used to describe JavaScript objects that are like an array or are iterable. - -## from - -```re sig -let from: array_like('a) => array('b); -``` - -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. - -```re example -let strArr = Js.String.castToArrayLike("abcd"); -Js.Array.from(strArr) == [|"a", "b", "c", "d"|]; -``` - -## fromMap - -```re sig -let fromMap: (array_like('a), 'a => 'b) => array('b); -``` - -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. - -```re example -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|]; -``` - -## isArray - -```re sig -let isArray: 'a => bool; -``` - -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. - -```re example -Js.Array.isArray([|5, 2, 3, 1, 4|]) == true; -Js.Array.isArray([5, 2, 3, 1, 4]) == true; -Js.Array.isArray("abcd") == false; -``` - -## length - -```re sig -let length: array('a) => int; -``` - -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. - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t('a)) => t('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array.copyWithin(~to_=2, arr) - == [|100, 101, 100, 101, 102|]; -arr == [|100, 101, 100, 101, 102|]; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t('a)) => t('a); -``` - -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. - -```re example -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|]; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t('a)) => t('a); -``` - -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. - -```re example -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|]; -``` - -## fillInPlace - -```re sig -let fillInPlace: ('a, t('a)) => t('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array.fillInPlace(99, arr) - == [|99, 99, 99, 99, 99|]; -arr == [|99, 99, 99, 99, 99|]; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: ('a, ~from: int, t('a)) => t('a); -``` - -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. - -```re example -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|]; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: ('a, ~start: int, ~end_: int, t('a)) => t('a); -``` - -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. - -```re example -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|]; -``` - -## pop - -```re sig -let pop: t('a) => option('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array.pop(arr) == Some(104); -arr == [|100, 101, 102, 103|]; - -let empty: array(int) = [| |]; -Js.Array.pop(empty) == None; -``` - -## push - -```re sig -let push: ('a, t('a)) => int; -``` - -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. - -```re example -let arr = [|"ant", "bee", "cat"|]; -Js.Array.push("dog", arr) == 4; -arr == [|"ant", "bee", "cat", "dog"|]; -``` - -## pushMany - -```re sig -let pushMany: (array('a), t('a)) => int; -``` - -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. - -```re example -let arr = [|"ant", "bee", "cat"|]; -Js.Array.pushMany([|"dog", "elk"|], arr) == 5; -arr == [|"ant", "bee", "cat", "dog", "elk"|]; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t('a) => t('a); -``` - -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. - -```re example -let arr = [|"ant", "bee", "cat"|]; -Js.Array.reverseInPlace(arr) == [|"cat", "bee", "ant"|]; -arr == [|"cat", "bee", "ant"|]; -``` - -## shift - -```re sig -let shift: t('a) => option('a); -``` - -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. - -```re example -let arr = [|100, 101, 102, 103, 104|]; -Js.Array.shift(arr) == Some(100); -arr == [|101, 102, 103, 104|]; - -let empty: array(int) = [| |]; -Js.Array.shift(empty) == None; -``` - -## sortInPlace - -```re sig -let sortInPlace: t('a) => t('a); -``` - -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. - -```re example -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|]; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: (('a, 'a) => int, t('a)) => t('a); -``` - -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. - -```re example -// 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|]; -``` - -## spliceInPlace - -```re sig -let spliceInPlace: (~pos: int, ~remove: int, ~add: array('a), t('a)) => t('a); -``` - -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. - -```re example -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"|]; -``` - -## removeFromInPlace - -```re sig -let removeFromInPlace: (~pos: int, t('a)) => t('a); -``` - -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. - -```re example -let arr = [|"a", "b", "c", "d", "e", "f"|]; -Js.Array.removeFromInPlace(~pos=4, arr) == [|"e", "f"|]; -arr == [|"a", "b", "c", "d"|]; -``` - -## removeCountInPlace - -```re sig -let removeCountInPlace: (~pos: int, ~count: int, t('a)) => t('a); -``` - -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. - -```re example -let arr = [|"a", "b", "c", "d", "e", "f"|]; -Js.Array.removeCountInPlace(~pos=2, ~count=3, arr) == [|"c", "d", "e"|]; -arr == [|"a", "b", "f"|]; -``` - -## unshift - -```re sig -let unshift: ('a, t('a)) => int; -``` - -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. - -```re example -let arr = [|"b", "c", "d"|]; -Js.Array.unshift("a", arr) == 4; -arr == [|"a", "b", "c", "d"|]; -``` - -## unshiftMany - -```re sig -let unshiftMany: (array('a), t('a)) => int; -``` - -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. - -```re example -let arr = [|"d", "e"|]; -Js.Array.unshiftMany([|"a", "b", "c"|], arr) == 5; -arr == [|"a", "b", "c", "d", "e"|]; -``` - -## append - -```re sig -let append: ('a, t('a)) => t('a); -``` - -Deprecated. `append()` is not type-safe. Use `concat()` instead. - -## concat - -```re sig -let concat: (t('a), t('a)) => t('a); -``` - -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. - -```re example -Js.Array.concat([|"c", "d", "e"|], [|"a", "b"|]) - == [|"a", "b", "c", "d", "e"|]; -``` - -## concatMany - -```re sig -let concatMany: (array(t('a)), t('a)) => t('a); -``` - -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. - -```re example -Js.Array.concatMany([| [|"d", "e"|], [|"f", "g", "h"|] |], [|"a", "b", "c"|]) - == [|"a", "b", "c", "d", "e", "f", "g", "h"|]; -``` - -## includes - -```re sig -let includes: ('a, t('a)) => bool; -``` - -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. - -```re example -Js.Array.includes("b", [|"a", "b", "c"|]) == true; -Js.Array.includes("x", [|"a", "b", "c"|]) == false; -``` - -## indexOf - -```re sig -let indexOf: ('a, t('a)) => int; -``` - -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. - -```re example -Js.Array.indexOf(102, [|100, 101, 102, 103|]) == 2; -Js.Array.indexOf(999, [|100, 101, 102, 103|]) == -1; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: ('a, ~from: int, t('a)) => int; -``` - -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. - -```re example -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; -``` - -## join - -```re sig -let join: t('a) => string; -``` - -Deprecated. Use `joinWith` instead. - -## joinWith - -```re sig -let joinWith: (string, t('a)) => string; -``` - -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. - -```re example -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"; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: ('a, t('a)) => int; -``` - -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. - -```re example -Js.Array.lastIndexOf("a", [|"a", "b", "a", "c"|]) == 2; -Js.Array.lastIndexOf("x", [|"a", "b", "a", "c"|]) == -1; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: ('a, ~from: int, t('a)) => int; -``` - -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. - -```re example -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; -``` - -## lastIndexOf_start - -```re sig -let lastIndexOf_start: ('a, t('a)) => int; -``` - -Deprecated. Please use `lastIndexOf`. - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t('a)) => t('a); -``` - -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. - -```re example -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) == [| |]; -``` - -## copy - -```re sig -let copy: t('a) => t('a); -``` - -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. - -## slice_copy - -```re sig -let slice_copy: (unit, t('a)) => t('a); -``` - -Deprecated. Please use `copy`. - -## sliceFrom - -```re sig -let sliceFrom: (int, t('a)) => t('a); -``` - -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. - -```re example -Js.Array.sliceFrom(2, [|100, 101, 102, 103, 104|]) == [|102, 103, 104|]; -``` - -## slice_start - -```re sig -let slice_start: (int, t('a)) => t('a); -``` - -Deprecated. Please `sliceFrom`. - -## toString - -```re sig -let toString: t('a) => string; -``` - -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. - -```re example -Js.Array.toString([|3.5, 4.6, 7.8|]) == "3.5,4.6,7.8"; -Js.Array.toString([|"a", "b", "c"|]) == "a,b,c"; -``` - -## toLocaleString - -```re sig -let toLocaleString: t('a) => string; -``` - -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. - -```re example -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 -``` - -## every - -```re sig -let every: ('a => bool, t('a)) => bool; -``` - -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. - -```re example -let isEven = (x) => {x mod 2 == 0}; -Js.Array.every(isEven, [|6, 22, 8, 4|]) == true; -Js.Array.every(isEven, [|6, 22, 7, 4|]) == false; -``` - -## everyi - -```re sig -let everyi: (('a, int) => bool, t('a)) => bool; -``` - -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. - -```re example -// determine if all even-index items are positive -let evenIndexPositive = (item, index) => - {(index mod 2 == 0) ? item > 0 : true;}; - -Js.Array.everyi(evenIndexPositive, [|6, -3, 5, 8|]) == true; -Js.Array.everyi(evenIndexPositive, [|6, 3, -5, 8|]) == false; -``` - -## filter - -```re sig -let filter: ('a => bool, t('a)) => t('a); -``` - -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. - -```re example -let nonEmpty = (s) => {s != ""}; -Js.Array.filter(nonEmpty, [|"abc", "", "", "def", "ghi"|]) - == [|"abc", "def", "ghi"|]; -``` - -## filteri - -```re sig -let filteri: (('a, int) => bool, t('a)) => t('a); -``` - -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. - -```re example -// keep only positive elements at odd indices -let positiveOddElement = (item, index) => - {(index mod 2 == 1) && (item > 0)}; - -Js.Array.filteri(positiveOddElement, - [|6, 3, 5, 8, 7, -4, 1|]) == [|3, 8|]; -``` - -## find - -```re sig -let find: ('a => bool, t('a)) => option('a); -``` - -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. - -```re example -// 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; -``` - -## findi - -```re sig -let findi: (('a, int) => bool, t('a)) => option('a); -``` - -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. - -```re example -// find first positive item at an odd index -let positiveOddElement = (item, index) => - {(index mod 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; -``` - -## findIndex - -```re sig -let findIndex: ('a => bool, t('a)) => int; -``` - -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. - -```re example -Js.Array.findIndex((x) => {x < 0}, [|33, 22, -55, 77, -44|]) == 2; -Js.Array.findIndex((x) => {x < 0}, [|33, 22, 55, 77, 44|]) == -1; -``` - -## findIndexi - -```re sig -let findIndexi: (('a, int) => bool, t('a)) => int; -``` - -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. - -```re example -// find index of first positive item at an odd index -let positiveOddElement = (item, index) => - {(index mod 2 == 1) && (item > 0)}; - -Js.Array.findIndexi(positiveOddElement, [|66, -33, 55, 88, 22|]) == 3; -Js.Array.findIndexi(positiveOddElement, [|66, -33, 55, -88, 22|]) == -1; -``` - -## forEach - -```re sig -let forEach: ('a => unit, t('a)) => unit; -``` - -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. - -```re example -// display all elements in an array -Js.Array.forEach((x) => Js.log(x), [|"a", "b", "c"|]) == (); -``` - -## forEachi - -```re sig -let forEachi: (('a, int) => unit, t('a)) => unit; -``` - -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. - -```re example -// display all elements in an array as a numbered list -Js.Array.forEachi((item, index) => Js.log2((index + 1), item), [|"a", "b", "c"|]) == (); -``` - -## map - -```re sig -let map: ('a => 'b, t('a)) => t('b); -``` - -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. - -```re example -Js.Array.map((x) => x * x, [|12, 4, 8|]) == [|144, 16, 64|]; -Js.Array.map(Js.String.length, [|"animal", "vegetable", "mineral"|]) - == [|6, 9, 7|]; -``` - -## mapi - -```re sig -let mapi: (('a, int) => 'b, t('a)) => t('b); -``` - -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. - -```re example -// multiply each item in array by its position -let product = (item, index) => {item * index}; -Js.Array.mapi(product, [|10, 11, 12|]) == [|0, 11, 24|]; -``` - -## reduce - -```re sig -let reduce: (('b, 'a) => 'b, 'b, t('a)) => 'b; -``` - -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. - -```re example -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) -``` - -## reducei - -```re sig -let reducei: (('b, 'a, int) => 'b, 'b, t('a)) => 'b; -``` - -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. - -```re example -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => { - if (index mod 2 == 0) { - accumulator + item; - } else { - accumulator; - } -}; - -Js.Array.reducei(sumOfEvens, 0, [|2, 5, 1, 4, 3|]) == 6; -``` - -## reduceRight - -```re sig -let reduceRight: (('b, 'a) => 'b, 'b, t('a)) => 'b; -``` - -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. - -```re example -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) -``` - -## reduceRighti - -```re sig -let reduceRighti: (('b, 'a, int) => 'b, 'b, t('a)) => 'b; -``` - -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. - -```re example -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => { - if (index mod 2 == 0) { - accumulator + item; - } else { - accumulator; - } -}; - -Js.Array.reduceRighti(sumOfEvens, 0, [|2, 5, 1, 4, 3|]) == 6; -``` - -## some - -```re sig -let some: ('a => bool, t('a)) => bool; -``` - -Returns `true` if the predicate function given as the first argument to `some()` returns `true` for any element in the array; `false` otherwise. - -```re example -let isEven = (x) => {x mod 2 == 0}; - -Js.Array.some(isEven, [|3, 7, 5, 2, 9|]) == true; -Js.Array.some(isEven, [|3, 7, 5, 1, 9|]) == false; -``` - -## somei - -```re sig -let somei: (('a, int) => bool, t('a)) => bool; -``` - -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 - -```re example -// 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; -``` - -## unsafe_get - -```re sig -let unsafe_get: (array('a), int) => 'a; -``` - -Returns the value at the given position in the array if the position is in bounds; returns -the JavaScript value `undefined` otherwise. - -```re example -let arr = [|100, 101, 102, 103|]; -Js.Array.unsafe_get(arr, 3) == 103; -Js.Array.unsafe_get(arr, 4); // returns undefined -``` - -## unsafe_set - -```re sig -let unsafe_set: (array('a), int, 'a) => unit; -``` - -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._ - -```re example -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. -``` diff --git a/pages/docs/manual/v8.0.0/api/js/console.mdx b/pages/docs/manual/v8.0.0/api/js/console.mdx deleted file mode 100644 index be97d2482..000000000 --- a/pages/docs/manual/v8.0.0/api/js/console.mdx +++ /dev/null @@ -1,113 +0,0 @@ -# Console - - - -Provide console (logging) utilities. - - - -## log - -```re sig -let log: 'a => unit; -``` - -```re sig -let log2: ('a, 'b) => unit; -``` - -```re sig -let log3: ('a, 'b, 'c) => unit; -``` - -```re sig -let log4: ('a, 'b, 'c, 'd) => unit; -``` - -```re sig -let logMany: array('a) => unit; -``` - -## info - -```re sig -let info: 'a => unit; -``` - -```re sig -let info2: ('a, 'b) => unit; -``` - -```re sig -let info3: ('a, 'b, 'c) => unit; -``` - -```re sig -let info4: ('a, 'b, 'c, 'd) => unit; -``` - -```re sig -let infoMany: array('a) => unit; -``` - -## warn - -```re sig -let warn: 'a => unit; -``` - -```re sig -let warn2: ('a, 'b) => unit; -``` - -```re sig -let warn3: ('a, 'b, 'c) => unit; -``` - -```re sig -let warn4: ('a, 'b, 'c, 'd) => unit; -``` - -```re sig -let warnMany: array('a) => unit; -``` - -## error - -```re sig -let error: 'a => unit; -``` - -```re sig -let error2: ('a, 'b) => unit; -``` - -```re sig -let error3: ('a, 'b, 'c) => unit; -``` - -```re sig -let error4: ('a, 'b, 'c, 'd) => unit; -``` - -```re sig -let errorMany: array('a) => unit; -``` - -## trace - -```re sig -let trace: unit => unit; -``` - -## timeStart - -```re sig -let timeStart: string => unit; -``` - -## timeEnd - -```re sig -let timeEnd: string => unit; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/date.mdx b/pages/docs/manual/v8.0.0/api/js/date.mdx deleted file mode 100644 index 1981141fe..000000000 --- a/pages/docs/manual/v8.0.0/api/js/date.mdx +++ /dev/null @@ -1,1063 +0,0 @@ -# Date - - - -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. - - - -In these examples, we will be using this date: - -```re prelude -let exampleDate = Js.Date.fromFloat(123456654321.0); -``` - -which is Thu, 29 Nov 1973 21:30:54 GMT. There is no particular significance to this date. -The code used to access this date is running in the Europe/Austria time zone with the `en_US.utf8` locale. - -In all of these functions, month values are in the range 0-11, where January is month zero. - -## t - -```re sig -type t; -``` - -## valueOf - -```re sig -let valueOf: t => float; -``` - -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.) - -```re example -Js.Date.valueOf(exampleDate) == 123456654321.0; -``` - -## make - -```re sig -let make: unit => t; -``` - -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. - -```re example -let now = Js.Date.make(); -``` - -## fromFloat - -```re sig -let fromFloat: float => t; -``` - -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. - -```re example -Js.Date.fromFloat(123456654321.0) == exampleDate; -``` - -## fromString - -```re sig -let fromString: string => t; -``` - -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. - -```re example -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 -``` - -## makeWithYM - -```re sig -let makeWithYM: (~year: float, ~month: float, unit) => t; -``` - -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. - -```re example -let november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ()); -``` - -## makeWithYMD - -```re sig -let makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t; -``` - -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. - -## makeWithYMDH - -```re sig -let makeWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => t; -``` - -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. - -## makeWithYMDHM - -```re sig -let makeWithYMDHM: (~year: float, ~month: float, ~date: float, ~hours: float, ~minutes: float, unit) => t; -``` - -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. - -## makeWithYMDHMS - -```re sig -let makeWithYMDHMS: (~year: float, ~month: float, ~date: float, ~hours: float, ~minutes: float, ~seconds: float, unit) => t; -``` - -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. - -```re example -Js.Date.makeWithYMDHMS(~year=1973.0, ~month=11.0, ~date=29.0, - ~hours=21.0, ~minutes=30.0, ~seconds=54.321, ()) == exampleDate; -``` - -## utcWithYM - -```re sig -let utcWithYM: (~year: float, ~month: float, unit) => float; -``` - -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. - -```re example -let november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ()); -``` - -## utcWithYMD - -```re sig -let 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 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. - -## utcWithYMDH - -```re sig -let 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 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. - -## utcWithYMDHM - -```re sig -let 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 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. - -## utcWithYMDHMS - -```re sig -let utcWithYMDHMS: (~year: float, ~month: float, ~date: float, ~hours: float, ~minutes: float, ~seconds: 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. - -## now - -```re sig -let now: unit => float; -``` - -Returns the current time as number of milliseconds since Unix epoch. - -## parse - -```re sig -let parse: string => t; -``` - -Deprecated. Use [`fromString()`](#fromstring). - -## parseAsFloat - -```re sig -let parseAsFloat: string => float; -``` - -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. - -## getDate - -```re sig -let getDate: t => 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. - -```re example -Js.Date.getDate(exampleDate) == 29.0; -``` - -## getDay - -```re sig -let getDay: t => float; -``` - -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. - -```re example -Js.Date.getDay(exampleDate) == 4.0; -``` - -## getFullYear - -```re sig -let getFullYear: t => float; -``` - -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. - -```re example -Js.Date.getFullYear(exampleDate) == 1973.0; -``` - -## getHours - -```re sig -let getHours: t => float; -``` - -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. - -```re example -Js.Date.getHours(exampleDate) == 22.0; // Vienna is in GMT+01:00 -``` - -## getMilliseconds - -```re sig -let getMilliseconds: t => float; -``` - -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. - -```re example -Js.Date.getMilliseconds(exampleDate) == 321.0; -``` - -## getMinutes - -```re sig -let getMinutes: t => float; -``` - -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. - -```re example -Js.Date.getMinutes(exampleDate) == 30.0; -``` - -## getMonth - -```re sig -let getMonth: t => float; -``` - -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. - -```re example -Js.Date.getMonth(exampleDate) == 10.0; -``` - -## getSeconds - -```re sig -let getSeconds: t => float; -``` - -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. - -```re example -Js.Date.getSeconds(exampleDate) == 54.0; -``` - -## getTime - -```re sig -let getTime: t => float; -``` - -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. - -```re example -Js.Date.getTime(exampleDate) == 123456654321.0 -``` - -## getTimezoneOffset - -```re sig -let getTimezoneOffset: t => float; -``` - -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. - -```re example -Js.Date.getTimezoneOffset(exampleDate) == -60.0; -``` - -## getUTCDate - -```re sig -let getUTCDate: t => float; -``` - -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. - -```re example -Js.Date.getUTCDate(exampleDate) == 29.0; -``` - -## getUTCDay - -```re sig -let getUTCDay: t => float; -``` - -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. - -```re example -Js.Date.getUTCDay(exampleDate) == 4.0; -``` - -## getUTCFullYear - -```re sig -let getUTCFullYear: t => float; -``` - -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. - -```re example -Js.Date.getUTCFullYear(exampleDate) == 1973.0; -``` - -## getUTCHours - -```re sig -let getUTCHours: t => float; -``` - -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. - -```re example -Js.Date.getUTCHours(exampleDate) == 21.0; -``` - -## getUTCMilliseconds - -```re sig -let getUTCMilliseconds: t => float; -``` - -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. - -```re example -Js.Date.getUTCMilliseconds(exampleDate) == 321.0; -``` - -## getUTCMinutes - -```re sig -let getUTCMinutes: t => float; -``` - -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. - -```re example -Js.Date.getUTCMinutes(exampleDate) == 30.0; -``` - -## getUTCMonth - -```re sig -let getUTCMonth: t => float; -``` - -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. - -```re example -Js.Date.getUTCMonth(exampleDate) == 10.0; -``` - -## getUTCSeconds - -```re sig -let getUTCSeconds: t => float; -``` - -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. - -```re example -Js.Date.getUTCSeconds(exampleDate) == 54.0; -``` - -## getYear - -```re sig -let getYear: t => float; -``` - -Deprecated. Use `getFullYear()` instead. - -## setDate - -```re sig -let setDate: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setFullYear - -```re sig -let setFullYear: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setFullYearM - -```re sig -let setFullYearM: (t, ~year: float, ~month: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setFullYearMD - -```re sig -let setFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setHours - -```re sig -let setHours: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setHoursM - -```re sig -let setHoursM: (t, ~hours: float, ~minutes: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setHoursMS - -```re sig -let setHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setHoursMSMs - -```re sig -let setHoursMSMs: (t, ~hours: float, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setMilliseconds - -```re sig -let setMilliseconds: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setMinutes - -```re sig -let setMinutes: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setMinutesS - -```re sig -let setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setMinutesSMs - -```re sig -let setMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setMonth - -```re sig -let setMonth: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setMonthD - -```re sig -let setMonthD: (t, ~month: float, ~date: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setSeconds - -```re sig -let setSeconds: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setSecondsMs - -```re sig -let setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setTime - -```re sig -let setTime: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCDate - -```re sig -let setUTCDate: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCFullYear - -```re sig -let setUTCFullYear: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCFullYearM - -```re sig -let setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCFullYearMD - -```re sig -let setUTCFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCHours - -```re sig -let setUTCHours: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCHoursM - -```re sig -let setUTCHoursM: (t, ~hours: float, ~minutes: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCHoursMS - -```re sig -let setUTCHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCHoursMSMs - -```re sig -let setUTCHoursMSMs: (t, ~hours: float, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCMilliseconds - -```re sig -let setUTCMilliseconds: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCMinutes - -```re sig -let setUTCMinutes: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCMinutesS - -```re sig -let setUTCMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCMinutesSMs - -```re sig -let setUTCMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCMonth - -```re sig -let setUTCMonth: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCMonthD - -```re sig -let setUTCMonthD: (t, ~month: float, ~date: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCSeconds - -```re sig -let setUTCSeconds: (t, float) => float; -``` - -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. - -```re example -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); -``` - -## setUTCSecondsMs - -```re sig -let setUTCSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float; -``` - -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. - -```re example -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); -``` - -## setUTCTime - -```re sig -let setUTCTime: (t, float) => float; -``` - -Same as [`setTime()`](#settime). - -## setYear - -```re sig -let setYear: (t, float) => float; -``` - -Deprecated. Use [`setFullYear()`](#setfullyear) instead. - -## toDateString - -```re sig -let toDateString: t => string; -``` - -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. - -```re example -Js.Date.toDateString(exampleDate) == "Thu Nov 29 1973"; -``` - -## toGMTString - -```re sig -let toGMTString: t => string; -``` - -Deprecated. Use [`toUTCString()`](#toutcstring) instead. - -## toISOString - -```re sig -let toISOString: t => string; -``` - -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. - -```re example -Js.Date.toISOString(exampleDate) == "1973-11-29T21:30:54.321Z"; -``` - -## toJSON - -```re sig -let toJSON: t => string; -``` - -Deprecated. This method is unsafe. It will be changed to return `option` in a future release. Please use `toJSONUnsafe()` instead. - -## toJSONUnsafe - -```re sig -let toJSONUnsafe: t => string; -``` - -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. - -```re example -Js.Date.toJSONUnsafe(exampleDate) == "1973-11-29T21:30:54.321Z"; -``` - -## toLocaleDateString - -```re sig -let toLocaleDateString: t => string; -``` - -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. - -```re example -Js.Date.toLocaleDateString(exampleDate) == "11/29/1973"; // for en_US.utf8 -Js.Date.toLocaleDateString(exampleDate) == "29.11.73"; // for de_DE.utf8 -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -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. - -```re example -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 -``` - -## toLocaleTimeString - -```re sig -let toLocaleTimeString: t => string; -``` - -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. - -```re example -Js.Date.toLocaleTimeString(exampleDate) == "10:30:54 PM"; // for en_US.utf8 -Js.Date.toLocaleTimeString(exampleDate) == "22:30:54"; // for de_DE.utf8 -``` - -## toString - -```re sig -let toString: t => string; -``` - -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. - -```re example -Js.Date.toString(exampleDate) == "Thu Nov 29 1973 22:30:54 GMT+0100 (Central European Standard Time)"; -``` - -## toTimeString - -```re sig -let toTimeString: t => string; -``` - -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. - -```re example -Js.Date.toTimeString(exampleDate) == "22:30:54 GMT+0100 (Central European Standard Time)"; -``` - -## toUTCString - -```re sig -let toUTCString: t => string; -``` - -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. - -```re example -Js.Date.toUTCString(exampleDate) == "Thu, 29 Nov 1973 21:30:54 GMT"; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/dict.mdx b/pages/docs/manual/v8.0.0/api/js/dict.mdx deleted file mode 100644 index 642969029..000000000 --- a/pages/docs/manual/v8.0.0/api/js/dict.mdx +++ /dev/null @@ -1,169 +0,0 @@ -# Dict - - - -Provide utilities for JS dictionary object. - -**Note:** This module's examples will assume this predeclared dictionary: - -```re prelude -let ages = Js.Dict.fromList( - [("Maria", 30), ("Vinh", 22), ("Fred", 49)] -); -``` - - - -## t - -```re sig -type t('a); -``` - -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. - -## key - -```re sig -type key = string; -``` - -The type for dictionary keys. This means that dictionaries _must_ use `string`s as their keys. - -## get - -```re sig -let get: (t('a), key) => option('a); -``` - -`Js.Dict.get(key)` returns `None` if the key is not found in the dictionary, `Some(value)` otherwise. - -```re example -Js.Dict.get(ages, "Vinh") == Some(22); -Js.Dict.get(ages, "Paul") == None; -``` - -## unsafeGet - -```re sig -let unsafeGet: (t('a), key) => '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). - -```re example -Js.Dict.unsafeGet(ages, "Fred") == 49; -Js.Dict.unsafeGet(ages, "Paul"); // returns undefined -``` - -## set - -```re sig -let set: (t('a), key, 'a) => unit; -``` - -`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._ - -```re example -Js.Dict.set(ages, "Maria", 31) -Js.log(ages == - Js.Dict.fromList([("Maria", 31), ("Vinh", 22), ("Fred", 49)])); - -Js.Dict.set(ages, "David", 66) -Js.log(ages == - Js.Dict.fromList([("Maria", 31), ("Vinh", 22), ("Fred", 49), ("David", 66)])); -``` - -## keys - -```re sig -let keys: t('a) => array(string); -``` - -Returns all the keys in the dictionary `dict`. - -```re example -Js.Dict.keys(ages) == [|"Maria", "Vinh", "Fred"|]; -``` - -## empty - -```re sig -let empty: unit => t('a); -``` - -Returns an empty dictionary. - -## unsafeDeleteKey - -```re sig -let unsafeDeleteKey: (. t(string), string) => unit; -``` - -Experimental internal function - -## entries - -```re sig -let entries: t('a) => array((key, 'a)); -``` - -Returns an array of key/value pairs in the given dictionary (ES2017). - -```re example -Js.Dict.entries(ages) == [|("Maria", 30), ("Vinh", 22), ("Fred", 49)|] -``` - -## values - -```re sig -let values: t('a) => array('a); -``` - -Returns the values in the given dictionary (ES2017). - -```re example -Js.Dict.values(ages) == [|30, 22, 49|] -``` - -## fromList - -```re sig -let fromList: list((key, 'a)) => t('a); -``` - -Creates a new dictionary containing each (key, value) pair in its list argument. - -```re example -let capitals = Js.Dict.fromList([("Japan", "Tokyo"), ("France", "Paris"), ("Egypt", "Cairo")]); -``` - -## fromArray - -```re sig -let fromArray: array((key, 'a)) => t('a); -``` - -Creates a new dictionary containing each (key, value) pair in its array argument. - -```re example -let capitals2 = Js.Dict.fromArray([|("Germany", "Berlin"), ("Burkina Faso", "Ouagadougou")|]); -``` - -## map - -```re sig -let map: ((. 'a) => 'b, t('a)) => t('b); -``` - -`map(f, dict)` maps `dict` to a new dictionary with the same keys, using the function `f` to map each value. - -```re example -let prices = Js.Dict.fromList([("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([("pen", 0.90), ("book", 4.50), ("stapler", 6.30)]); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/exn.mdx b/pages/docs/manual/v8.0.0/api/js/exn.mdx deleted file mode 100644 index dbfe8be2d..000000000 --- a/pages/docs/manual/v8.0.0/api/js/exn.mdx +++ /dev/null @@ -1,103 +0,0 @@ -# Exn - - - -Provide utilities for dealing with JS exceptions. - - - -## t - -```re sig - type t; -``` - -## exn - -```re sig - type exn += - pri - | Error(t); -``` - -## asJsExn - -```re sig -let asJsExn: exn => option(t); -``` - -## stack - -```re sig -let stack: t => option(string); -``` - -## message - -```re sig -let message: t => option(string); -``` - -## name - -```re sig -let name: t => option(string); -``` - -## fileName - -```re sig -let fileName: t => option(string); -``` - -## isCamlExceptionOrOpenVariant - -```re sig -let isCamlExceptionOrOpenVariant: 'a => bool; -``` - -Internal use only. - -## raiseError - -```re sig -let raiseError: string => 'a; -``` - -Raise Js exception Error object with stacktrace. - -## raiseEvalError - -```re sig -let raiseEvalError: string => 'a; -``` - -## raiseRangeError - -```re sig -let raiseRangeError: string => 'a; -``` - -## raiseReferenceError - -```re sig -let raiseReferenceError: string => 'a; -``` - -## raiseSyntaxError - -```re sig -let raiseSyntaxError: string => 'a; -``` - -## raiseTypeError - -```re sig -let raiseTypeError: string => 'a; -``` - -## raiseUriError - -```re sig -let raiseUriError: string => 'a; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/float.mdx b/pages/docs/manual/v8.0.0/api/js/float.mdx deleted file mode 100644 index a7cec6ce8..000000000 --- a/pages/docs/manual/v8.0.0/api/js/float.mdx +++ /dev/null @@ -1,282 +0,0 @@ -# Float - - - -Provide utilities for JS float. - - - -## \_NaN - -```re sig -let _NaN: float; -``` - -The special value "Not a Number". - -## isNaN - -```re sig -let isNaN: float => bool; -``` - -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`. - -Returns true if the given value is `_NaN`, false otherwise. - -## isFinite - -```re sig -let isFinite: float => bool; -``` - -Tests if the given value is finite. -Returns true if the given value is a finite number, false otherwise. - -```re example -/* returns [false] */ -Js.Float.isFinite(infinity); -``` - -```re example -/* returns [false] */ -Js.Float.isFinite(neg_infinity); -``` - -```re example -/* returns [false] */ -Js.Float.isFinite(Js.Float._NaN); -``` - -```re example -/* returns [true] */ -Js.Float.isFinite(1234.); -``` - -## toExponential - -```re sig -let toExponential: float => string; -``` - -Formats a float using exponential (scientific) notation. -Returns a string representing the given value in exponential notation. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```re example -/* prints "7.71234e+1" */ -Js.log @@ Js.Float.toExponential(77.1234); -``` - -```re example -/* prints "7.7e+1" */ -Js.log @@ Js.Float.toExponential(77.); -``` - -## toExponentialWithPrecision - -```re sig -let toExponentialWithPrecision: (float, ~digits: int) => string; -``` - -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). - -Returns a `string` representing the given value in exponential notation. - -The output will be rounded or padded with zeroes if necessary. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```re example -/* prints "7.71e+1" */ -Js.log @@ Js.Float.toExponentialWithPrecision(77.1234, ~digits=2); -``` - -## toFixed - -```re sig -let toFixed: float => string; -``` - -Formats a `float` using fixed point notation. -Returns a `string` representing the given value in fixed-point notation (usually). -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```re example -/* prints "12346" (note the rounding) */ -Js.log @@ Js.Float.toFixed(12345.6789); -``` - -```re example -/* print "1.2e+21" */ -Js.log @@ Js.Float.toFixed(1.2e21); -``` - -## toFixedWithPrecision - -```re sig -let toFixedWithPrecision: (float, ~digits: int) => string; -``` - -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. - -Returns a `string` representing the given value in fixed-point notation (usually). - -The output will be rounded or padded with zeroes if necessary. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```re example -/* prints "12345.7" (note the rounding) */ -Js.log @@ Js.Float.toFixedWithPrecision(12345.6789, ~digits=1); -``` - -```re example -/* prints "0.00" (note the added zeroes) */ -Js.log @@ Js.Float.toFixedWithPrecision(0., ~digits=2); -``` - -## toPrecision - -```re sig -let toPrecision: float => string; -``` - -Formats a `float` 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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```re example -/* prints "12345.6789" */ -Js.log @@ Js.Float.toPrecision(12345.6789); -``` - -```re example -/* print "1.2e+21" */ -Js.log @@ Js.Float.toPrecision(1.2e21); -``` - -## toPrecisionWithPrecision - -```re sig -let toPrecisionWithPrecision: (float, ~digits: int) => string; -``` - -Formats a `float` using some fairly arbitrary rules. -`digits` specifies how many digits should appear in total. The value must be 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 for digits before the decimal point. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```re example -/* prints "1e+4" */ -Js.log @@ Js.Float.toPrecisionWithPrecision(12345.6789, ~digits=1); -``` - -```re example -/* prints "0.0" */ -Js.log @@ Js.Float.toPrecisionWithPrecision(0., ~digits=2); -``` - -## toString - -```re sig -let toString: float => string; -``` - -Formats a `float` as a `string`. -Returns a `string` representing the given value in fixed-point (usually). - -```re example -/* prints "12345.6789" */ -Js.log @@ Js.Float.toString(12345.6789); -``` - -## toStringWithRadix - -```re sig -let toStringWithRadix: (float, ~radix: int) => string; -``` - -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). - -Returns a `string` representing the given value in fixed-point (usually). -Raises `RangeError` if `radix` is not in the range \[2, 36\] (inclusive). - -```re example -/* prints "110" */ -Js.log @@ Js.Float.toStringWithRadix(6., ~radix=2); -``` - -```re example -/* prints "11.001000111101011100001010001111010111000010100011111" */ -Js.log @@ Js.Float.toStringWithRadix(3.14, ~radix=2); -``` - -```re example -/* prints "deadbeef" */ -Js.log @@ Js.Float.toStringWithRadix(3735928559., ~radix=16); -``` - -```re example -/* prints "3f.gez4w97ry0a18ymf6qadcxr" */ -Js.log @@ Js.Float.toStringWithRadix(123.456, ~radix=36); -``` - -## fromString - -```re sig -let fromString: string => float; -``` - -Parses the given `string` into a `float` using JavaScript semantics. -Returns the number as a `float` if successfully parsed, `_NaN` otherwise. - -```re example -/* returns 123 */ -Js.Float.fromString("123"); -``` - -```re example -/* returns 12.3 */ -Js.Float.fromString("12.3"); -``` - -```re example -/* returns 0 */ -Js.Float.fromString(""); -``` - -```re example -/* returns 17 */ -Js.Float.fromString("0x11"); -``` - -```re example -/* returns 3 */ -Js.Float.fromString("0b11"); -``` - -```re example -/* returns 9 */ -Js.Float.fromString("0o11"); -``` - -```re example -/* returns [_NaN] */ -Js.Float.fromString("foo"); -``` - -```re example -/* returns [_NaN] */ -Js.Float.fromString("100a"); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/global.mdx b/pages/docs/manual/v8.0.0/api/js/global.mdx deleted file mode 100644 index 8725970fa..000000000 --- a/pages/docs/manual/v8.0.0/api/js/global.mdx +++ /dev/null @@ -1,182 +0,0 @@ -# Global - - - -Provide bindings to JS global functions in global namespace. - - - -```re sig -type intervalId; -``` - -Identify an interval started by `Js.Global.setInterval`. - -```re sig -type timeoutId; -``` - -Identify timeout started by `Js.Global.setTimeout`. - -## clearInterval - -```re sig -let clearInterval: intervalId => unit; -``` - -Clear an interval started by `Js.Global.setInterval` - -```re example -/* 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^, (. intervalId) => - Js.Global.clearInterval(intervalId) - ); -``` - -## clearTimeout - -```re sig -let clearTimeout: timeoutId => unit; -``` - -Clear a timeout started by `Js.Global.setTimeout`. - -```re example -/* 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^, (. timer) => Js.Global.clearTimeout(timer)); - timer := Js.Nullable.return(Js.Global.setTimeout(work, mins * 60 * 1000)); -}; -``` - -## setInterval - -```re sig -let setInterval: (unit => unit, int) => intervalId; -``` - -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. - -```re example -/* Will count up and print the count to the console every second */ - -let count = ref(0); - -let tick = () => { - count := count^ + 1; - Js.log(Belt.Int.toString(count^)); -}; - -Js.Global.setInterval(tick, 1000); -``` - -## setIntervalFloat - -```re sig -let setIntervalFloat: (unit => unit, float) => intervalId; -``` - -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. - -```re example -/* Will count up and print the count to the console every second */ - -let count = ref(0); - -let tick = () => { - count := count^ + 1; - Js.log(Belt.Int.toString(count^)); -}; - -Js.Global.setIntervalFloat(tick, 1000.0); -``` - -## setTimeout - -```re sig -let setTimeout: (unit => unit, int) => timeoutId; -``` - -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. - -```re example -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!"; - -Js.Global.setTimeout(() => Js.log(message), 1000); -``` - -## setTimeoutFloat - -```re sig -let setTimeoutFloat: (unit => unit, float) => timeoutId; -``` - -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. - -```re example -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!"; - -Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0); -``` - -## encodeURI - -```re sig -let encodeURI: string => string; -``` - -URL-encodes a string. - -## decodeURI - -```re sig -let decodeURI: string => string; -``` - -Decodes a URL-enmcoded string produced by encodeURI. - -## encodeURIComponent - -```re sig -let encodeURIComponent: string => string; -``` - -URL-encodes a string, including characters with special meaning in a URI. - -## decodeURIComponent - -```re sig -let decodeURIComponent: string => string; -``` - -Decodes a URL-enmcoded string produced by encodeURIComponent diff --git a/pages/docs/manual/v8.0.0/api/js/int.mdx b/pages/docs/manual/v8.0.0/api/js/int.mdx deleted file mode 100644 index f2c7e7465..000000000 --- a/pages/docs/manual/v8.0.0/api/js/int.mdx +++ /dev/null @@ -1,146 +0,0 @@ -# Int - - - -Provide utilities for handling `int`. - - - -## toExponential - -```re sig -let toExponential: int => string; -``` - -Formats an `int` using exponential (scientific) notation. -Returns a `string` representing the given value in exponential notation. -Raises `RangeError` if digits is not in the range \[0, 20\] (inclusive). - -```re example -/* prints "7.7e+1" */ -Js.log(Js.Int.toExponential(77)); -``` - -## toExponentialWithPrecision - -```re sig -let toExponentialWithPrecision: (int, ~digits: int) => string; -``` - -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. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```re example -/* prints "7.70e+1" */ -Js.log(Js.Int.toExponentialWithPrecision(77, ~digits=2)); - -/* prints "5.68e+3" */ -Js.log(Js.Int.toExponentialWithPrecision(5678, ~digits=2)); -``` - -## toPrecision - -```re sig -let toPrecision: int => string; -``` - -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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```re example -/* prints "123456789" */ -Js.log(Js.Int.toPrecision(123456789)); -``` - -## toPrecisionWithPrecision - -```re sig -let toPrecisionWithPrecision: (int, ~digits: int) => string; -``` - -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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```re example -/* prints "1.2e+8" */ -Js.log(Js.Int.toPrecisionWithPrecision(123456789, ~digits=2)); - -/* prints "0.0" */ -Js.log(Js.Int.toPrecisionWithPrecision(0, ~digits=2)); -``` - -## toString - -```re sig -let toString: int => string; -``` - -Formats an `int` as a `string`. -Returns a `string` representing the given value in fixed-point (usually). - -```re example -/* prints "123456789" */ -Js.log(Js.Int.toString(123456789)); -``` - -## toStringWithRadix - -```re sig -let toStringWithRadix: (int, ~radix: int) => string; -``` - -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). -Raises `RangeError` if `radix` is not in the range \[2, 36\] (inclusive). - -```re example -/* 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)); -``` - -## toFloat - -```re sig -let toFloat: int => float; -``` - -## equal - -```re sig -let equal: (int, int) => bool; -``` - -## max - -```re sig -let max: int; -``` - -## min - -```re sig -let min: int; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/json.mdx b/pages/docs/manual/v8.0.0/api/js/json.mdx deleted file mode 100644 index 4126f8a04..000000000 --- a/pages/docs/manual/v8.0.0/api/js/json.mdx +++ /dev/null @@ -1,303 +0,0 @@ -# Json - - - -Provide utilities for JSON. - - - -## t - -```re sig -type t; -``` - -The JSON data structure. - -## kind - -```re sig -type kind('a) = - | String: kind(Js_string.t) - | Number: kind(float) - | Object: kind(Js_dict.t(t)) - | Array: kind(array(t)) - | Boolean: kind(bool) - | Null: kind(Js_types.null_val); -``` - -Underlying type of a JSON value. - -## tagged_t - -```re sig -type tagged_t = - | JSONFalse - | JSONTrue - | JSONNull - | JSONString(string) - | JSONNumber(float) - | JSONObject(Js_dict.t(t)) - | JSONArray(array(t)); -``` - -## classify - -```re sig -let classify: t => tagged_t; -``` - -## test - -```re sig -let test: ('a, kind('b)) => bool; -``` - -`test(v, kind)` returns `true` if `v` is of `kind`. - -## decodeString - -```re sig -let decodeString: t => option(Js_string.t); -``` - -`decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise. - -## decodeNumber - -```re sig -let decodeNumber: t => option(float); -``` - -`decodeNumber(json)` returns `Some(n)` if `json` is a `number`, `None` otherwise. - -## decodeObject - -```re sig -let decodeObject: t => option(Js_dict.t(t)); -``` - -`decodeObject(json)` returns `Some(o)` if `json` is an `object`, `None` otherwise. - -## decodeArray - -```re sig -let decodeArray: t => option(array(t)); -``` - -`decodeArray(json)` returns `Some(a)` if `json` is an `array`, `None` otherwise. - -## decodeBoolean - -```re sig -let decodeBoolean: t => option(bool); -``` - -`decodeBoolean(json)` returns `Some(b)` if `json` is a `boolean`, `None` otherwise. - -## decodeNull - -```re sig -let decodeNull: t => option(Js_null.t('a)); -``` - -`decodeNull(json)` returns `Some(null)` if `json` is a `null`, `None` otherwise. - -## null - -```re sig -let null: t; -``` - -`null` is the singleton null JSON value. - -## string - -```re sig -let string: string => t; -``` - -`string(s)` makes a JSON string of the `string` `s`. - -## number - -```re sig -let number: float => t; -``` - -`number(n)` makes a JSON number of the `float` `n`. - -## boolean - -```re sig -let boolean: bool => t; -``` - -`boolean(b)` makes a JSON boolean of the `bool` `b`. - -## object\_ - -```re sig -let object_: Js_dict.t(t) => t; -``` - -`object_(dict)` makes a JSON object of the `Js.Dict.t` `dict`. - -## array - -```re sig -let array: array(t) => t; -``` - -`array_(a)` makes a JSON array of the `Js.Json.t` array `a`. - -## stringArray - -```re sig -let stringArray: array(string) => t; -``` - -`stringArray(a)` makes a JSON array of the `string` array `a`. - -## numberArray - -```re sig -let numberArray: array(float) => t; -``` - -`numberArray(a)` makes a JSON array of the `float` array `a`. - -## booleanArray - -```re sig -let booleanArray: array(bool) => t; -``` - -`booleanArray(a)` makes a JSON array of the `bool` array `a`. - -## objectArray - -```re sig -let objectArray: array(Js_dict.t(t)) => t; -``` - -`objectArray(a) makes a JSON array of the `JsDict.t`array`a`. - -## parseExn - -```re sig -let parseExn: string => t; -``` - -`parseExn(s)` parses the `string` `s` into a JSON data structure. -Returns a JSON data structure. -Raises `SyntaxError` if the given string is not a valid JSON. Note: `SyntaxError` is a JavaScript exception. - -```re example -/* parse a simple JSON string */ - -let json = - try (Js.Json.parseExn({| "foo" |})) { - | _ => failwith("Error parsing JSON string") - }; - -switch (Js.Json.classify(json)) { -| Js.Json.JSONString(value) => Js.log(value) -| _ => failwith("Expected a string") -}; -``` - -```re example -/* parse a complex JSON string */ - -let getIds = s => { - let json = - try (Js.Json.parseExn(s)) { - | _ => failwith("Error parsing JSON string") - }; - - switch (Js.Json.classify(json)) { - | Js.Json.JSONObject(value) => - /* In this branch, compiler infer value : Js.Json.t Js.Dict.t */ - 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 ] } |})); -``` - -## stringify - -```re sig -let stringify: t => string; -``` - -`stringify(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure. - -```re example -/* 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([|"bucklescript", "ocaml", "js"|]), - ); - - Js.log(Js.Json.stringify(Js.Json.object_(dict))); -}; -``` - -## stringifyWithSpace - -```re sig -let stringifyWithSpace: (t, int) => string; -``` - -`stringify(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure with spacing. - -```re example -/* 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([|"bucklescript", "ocaml", "js"|]), - ); - - Js.log(Js.Json.stringifyWithSpace(Js.Json.object_(dict), 2)); -}; -``` - -## stringifyAny - -```re sig -let stringifyAny: 'a => option(string); -``` - -`stringifyAny(value)` formats any value into a JSON string. - -```re example -/* prints `["foo", "bar"]` */ -Js.log(Js.Json.stringifyAny([|"foo", "bar"|])); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/list.mdx b/pages/docs/manual/v8.0.0/api/js/list.mdx deleted file mode 100644 index 44ad1fd9a..000000000 --- a/pages/docs/manual/v8.0.0/api/js/list.mdx +++ /dev/null @@ -1,143 +0,0 @@ -# List - - - -Provide utilities for list. - - - -## t - -```re sig -type t('a) = list('a); -``` - -## length - -```re sig -let length: t('a) => int; -``` - -## cons - -```re sig -let cons: ('a, t('a)) => t('a); -``` - -## isEmpty - -```re sig -let isEmpty: t('a) => bool; -``` - -## hd - -```re sig -let hd: t('a) => option('a); -``` - -## tl - -```re sig -let tl: t('a) => option(t('a)); -``` - -## nth - -```re sig -let nth: (t('a), int) => option('a); -``` - -## revAppend - -```re sig -let revAppend: (t('a), t('a)) => t('a); -``` - -## rev - -```re sig -let rev: t('a) => t('a); -``` - -## mapRev - -```re sig -let mapRev: ((. 'a) => 'b, t('a)) => t('b); -``` - -## map - -```re sig -let map: ((. 'a) => 'b, t('a)) => t('b); -``` - -## iter - -```re sig -let iter: ((. 'a) => unit, t('a)) => unit; -``` - -## iteri - -```re sig -let iteri: ((. int, 'a) => unit, t('a)) => unit; -``` - -## foldLeft - -```re sig -let foldLeft: ((. 'a, 'b) => 'a, 'a, list('b)) => 'a; -``` - -Application order is left to right, tail-recurisve. - -## foldRight - -```re sig -let foldRight: ((. 'a, 'b) => 'b, list('a), 'b) => 'b; -``` - -Application order is right to left, tail-recursive. - -## flatten - -```re sig -let flatten: t(t('a)) => t('a); -``` - -## filter - -```re sig -let filter: ((. 'a) => bool, t('a)) => t('a); -``` - -## filterMap - -```re sig -let filterMap: ((. 'a) => option('b), t('a)) => t('b); -``` - -## countBy - -```re sig -let countBy: ((. 'a) => bool, list('a)) => int; -``` - -## init - -```re sig -let init: (int, (. int) => 'a) => t('a); -``` - -## toVector - -```re sig -let toVector: t('a) => Js_vector.t('a); -``` - -## equal - -```re sig -let equal: ((. 'a, 'a) => bool, list('a), list('a)) => bool; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/math.mdx b/pages/docs/manual/v8.0.0/api/js/math.mdx deleted file mode 100644 index 1195d6c1c..000000000 --- a/pages/docs/manual/v8.0.0/api/js/math.mdx +++ /dev/null @@ -1,626 +0,0 @@ -# Math - - - -Provide utilities for JS Math. Note: The constants `_E`, `_LN10`, `_LN2`, `_LOG10E`, `_LOG2E`, `_PI`, `_SQRT1_2`, and `_SQRT2` begin with an underscore because ReasonML variable names cannot begin with a capital letter. (Module names begin with upper case.) - - - -## \_E - -```re sig -let _E: float; -``` - -Euler's number; ≈ 2.718281828459045. See [`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) on MDN. - -## \_LN2 - -```re sig -let _LN2: float; -``` - -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. - -## \_LN10 - -```re sig -let _LN10: float; -``` - -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. - -## \_LOG2E - -```re sig -let _LOG2E: float; -``` - -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. - -## \_LOG10E - -```re sig -let _LOG10E: float; -``` - -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. - -## \_PI - -```re sig -let _PI: float; -``` - -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. - -## \_SQRT1_2 - -```re sig -let _SQRT1_2: float; -``` - -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. - -## \_SQRT2 - -```re sig -let _SQRT2: float; -``` - -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. - -## abs_int - -```re sig -let abs_int: int => int; -``` - -Absolute value for integer argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. - -## abs_float - -```re sig -let abs_float: float => float; -``` - -Absolute value for float argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. - -## acos - -```re sig -let acos: float => float; -``` - -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. - -## acosh - -```re sig -let acosh: float => float; -``` - -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. - -## asin - -```re sig -let asin: float => float; -``` - -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. - -## asinh - -```re sig -let asinh: float => float; -``` - -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. - -## atan - -```re sig -let atan: float => float; -``` - -Arctangent (in radians) of argument. See [`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) on MDN. - -## atanh - -```re sig -let atanh: float => float; -``` - -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. - -## atan2 - -```re sig -let atan2: (~y: float, ~x: float, unit) => float; -``` - -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. - -```re example -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; -``` - -## cbrt - -```re sig -let cbrt: float => float; -``` - -Cube root. See [`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) on MDN - -## unsafe_ceil_int - -```re sig -let unsafe_ceil_int: float => int; -``` - -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. - -```re example -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 -``` - -## unsafe_ceil - -```re sig -let unsafe_ceil: float => int; -``` - -Deprecated; please use [`unsafe_ceil_int`](#unsafe_ceil_int) instead. - -## ceil_int - -```re sig -let ceil_int: float => 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. - -```re example -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; -``` - -## ceil - -```re sig -let ceil: float => int; -``` - -Deprecated; please use [`ceil_int`](#ceil_int) instead. - -## ceil_float - -```re sig -let ceil_float: float => float; -``` - -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. - -```re example -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; -``` - -## clz32 - -```re sig -let clz32: int => int; -``` - -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. - -```re example -Js.Math.clz32(0) == 32; -Js.Math.clz32(-1) == 0; -Js.Math.clz32(255) == 24; -``` - -## cos - -```re sig -let cos: float => float; -``` - -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. - -## cosh - -```re sig -let cosh: float => float; -``` - -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. - -## exp - -```re sig -let exp: float => float; -``` - -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. - -## expm1 - -```re sig -let expm1: float => float; -``` - -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. - -## unsafe_floor_int - -```re sig -let unsafe_floor_int: float => int; -``` - -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. - -```re example -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 -``` - -## unsafe_floor - -```re sig -let unsafe_floor: float => int; -``` - -Deprecated; please use [`unsafe_floor_int`](#unsafe_floor_int) instead. - -## floor_int - -```re sig -let floor_int: float => 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. - -```re example -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; -``` - -## floor - -```re sig -let floor: float => int; -``` - -Deprecated; please use [`floor_int`](#floor_int) instead. - -## floor_float - -```re sig -let floor_float: float => float; -``` - -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. - -```re example -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; -``` - -## fround - -```re sig -let fround: float => float; -``` - -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. - -```re example -Js.Math.fround(5.5) == 5.5; -Js.Math.fround(5.05) == 5.050000190734863; -``` - -## hypot - -```re sig -let hypot: (float, float) => float; -``` - -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. - -## hypotMany - -```re sig -let hypotMany: array(float) => float; -``` - -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. - -```re example -Js.Math.hypotMany([|3.0, 4.0, 12.0|]) == 13.0; -``` - -## imul - -```re sig -let imul: (int, int) => int; -``` - -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. - -## log - -```re sig -let log: float => float; -``` - -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. - -```re example -Js.Math.log(Js.Math._E) == 1.0; -Js.Math.log(100.0) == 4.605170185988092; -``` - -## log1p - -```re sig -let log1p: float => float; -``` - -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. - -```re example -Js.Math.log1p(Js.Math._E -. 1.0) == 1.0; -Js.Math.log1p(99.0) == 4.605170185988092; -``` - -## log10 - -```re sig -let log10: float => float; -``` - -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. - -```re example -Js.Math.log10(1000.0) == 3.0; -Js.Math.log10(0.01) == -2.0; -Js.Math.log10(Js.Math.sqrt(10.0)) == 0.5; -``` - -## log2 - -```re sig -let log2: float => float; -``` - -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. - -```re example -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 -``` - -## max_int - -```re sig -let max_int: (int, int) => int; -``` - -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. - -## maxMany_int - -```re sig -let maxMany_int: array(int) => int; -``` - -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. - -## max_float - -```re sig -let max_float: (float, float) => float; -``` - -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. - -## maxMany_float - -```re sig -let maxMany_float: array(float) => float; -``` - -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. - -## min_int - -```re sig -let min_int: (int, int) => int; -``` - -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. - -## minMany_int - -```re sig -let minMany_int: array(int) => int; -``` - -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. - -## min_float - -```re sig -let min_float: (float, float) => float; -``` - -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. - -## minMany_float - -```re sig -let minMany_float: array(float) => float; -``` - -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. - -## pow_int - -```re sig -let pow_int: (~base: int, ~exp: int) => int; -``` - -Raises 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. - -```re example -Js.Math.pow_int(~base=3, ~exp=4) == 81; -``` - -## pow_float - -```re sig -let pow_float: (~base: float, ~exp: float) => float; -``` - -Raises 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. - -```re example -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; -``` - -## random - -```re sig -let random: unit => float; -``` - -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. - -## random_int - -```re sig -let random_int: (int, int) => int; -``` - -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. - -## unsafe_round - -```re sig -let unsafe_round: float => int; -``` - -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. - -```re example -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 -``` - -## round - -```re sig -let round: float => float; -``` - -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. - -## sign_int - -```re sig -let sign_int: int => int; -``` - -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. - -## sign_float - -```re sig -let sign_float: float => float; -``` - -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. - -## sin - -```re sig -let sin: float => float; -``` - -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. - -## sinh - -```re sig -let sinh: float => float; -``` - -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. - -## sqrt - -```re sig -let sqrt: float => float; -``` - -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. - -## tan - -```re sig -let tan: float => float; -``` - -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. - -## tanh - -```re sig -let tanh: float => float; -``` - -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. - -## unsafe_trunc - -```re sig -let unsafe_trunc: float => int; -``` - -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. - -## trunc - -```re sig -let trunc: float => float; -``` - -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. diff --git a/pages/docs/manual/v8.0.0/api/js/null-undefined.mdx b/pages/docs/manual/v8.0.0/api/js/null-undefined.mdx deleted file mode 100644 index d06eede59..000000000 --- a/pages/docs/manual/v8.0.0/api/js/null-undefined.mdx +++ /dev/null @@ -1,114 +0,0 @@ -# Null_undefined - - - -Provide utilities around `Js.null_undefined`. - - - -## t - -```re sig -type t('a) = Js.null_undefined('a); -``` - -Local alias for `Js.null_undefined('a)`. - -## return - -```re sig -let return: 'a => t('a); -``` - -Constructs a value of `Js.null_undefined('a)` containing a value of `'a`. - -## test - -```re sig -let test: t('a) => bool; -``` - -## isNullable - -```re sig -let isNullable: t('a) => bool; -``` - -Returns `true` if the given value is null or undefined, `false` otherwise. - -## null - -```re sig -let null: t('a); -``` - -The null value of type `Js.null_undefined('a)`. - -## undefined - -```re sig -let undefined: t('a); -``` - -The undefined value of type `Js.null_undefined('a)`. - -## bind - -```re sig -let bind: (t('a), (. 'a) => 'b) => t('b); -``` - -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)`. - -```re example -let maybeGreetWorld = (maybeGreeting: Js.null_undefined(string)) => - Js.Null_undefined.bind(maybeGreeting, [@bs] greeting => greeting ++ " world!"); -``` - -## iter - -```re sig -let iter: (t('a), (. 'a) => unit) => unit; -``` - -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. - -```re example -let maybeSay = (maybeMessage: Js.null_undefined(string)) => - Js.Null_undefined.iter(maybeMessage, [@bs] message => Js.log(message)); -``` - -## fromOption - -```re sig -let fromOption: option('a) => t('a); -``` - -Maps `option('a)` to `Js.null_undefined('a)`. -`Some(a)` => `a` -`None` => `undefined` - -## from_opt - -```re sig -let from_opt: option('a) => t('a); -``` - -## toOption - -```re sig -let toOption: t('a) => option('a); -``` - -Maps `Js.null_undefined('a)` to `option('a)`. -`a` => `Some(a)` -`undefined` => `None` -`null` => `None` - -## to_opt - -```re sig -let to_opt: t('a) => option('a); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/null.mdx b/pages/docs/manual/v8.0.0/api/js/null.mdx deleted file mode 100644 index 6ac03a635..000000000 --- a/pages/docs/manual/v8.0.0/api/js/null.mdx +++ /dev/null @@ -1,107 +0,0 @@ -# Null - - - -Provide utilities around `null('a)`. - - - -```re sig -type t('a) = Js.null('a); -``` - -Local alias for `Js.null('a)`. - -```re sig -let return: 'a => t('a); -``` - -Constructs a value of `Js.null('a)` containing a value of `'a`. - -## test - -```re sig -let test: t('a) => bool; -``` - -Returns `true` if the given value is empty (`null`), `false` otherwise. - -## empty - -```re sig -let empty: t('a); -``` - -The empty value, `null`. - -## getUnsafe - -```re sig -let getUnsafe: t('a) => 'a; -``` - -## getExn - -```re sig -let getExn: t('a) => 'a; -``` - -## bind - -```re sig -let bind: (t('a), (. 'a) => 'b) => t('b); -``` - -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)`. - -```re example -let maybeGreetWorld = (maybeGreeting: Js.null(string)) => - Js.Null.bind(maybeGreeting, [@bs] greeting => greeting ++ " world!"); -``` - -## iter - -```re sig -let iter: (t('a), (. 'a) => unit) => unit; -``` - -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. - -```re example -let maybeSay = (maybeMessage: Js.null(string)) => - Js.Null.iter(maybeMessage, [@bs] message => Js.log(message)); -``` - -## fromOption - -```re sig -let fromOption: option('a) => t('a); -``` - -Maps `option('a)` to `Js.null('a)`. -`Some(a)` => `a` -`None` => `empty` - -## from_opt - -```re sig -let from_opt: option('a) => t('a); -``` - -## toOption - -```re sig -let toOption: t('a) => option('a); -``` - -Maps `Js.null('a)` to `option('a)`. -`a` => `Some(a)` -`empty` => `None` - -## to_opt - -```re sig -let to_opt: t('a) => option('a); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/nullable.mdx b/pages/docs/manual/v8.0.0/api/js/nullable.mdx deleted file mode 100644 index b03f23134..000000000 --- a/pages/docs/manual/v8.0.0/api/js/nullable.mdx +++ /dev/null @@ -1,114 +0,0 @@ -# Nullable - - - -Provide utilities around `Js.null_undefined`. - - - -## t - -```re sig -type t('a) = Js.null_undefined('a); -``` - -Local alias for `Js.null_undefined('a)`. - -## return - -```re sig -let return: 'a => t('a); -``` - -Constructs a value of `Js.null_undefined('a)` containing a value of `'a`. - -## test - -```re sig -let test: t('a) => bool; -``` - -## isNullable - -```re sig -let isNullable: t('a) => bool; -``` - -Returns `true` if the given value is null or undefined, `false` otherwise. - -## null - -```re sig -let null: t('a); -``` - -The null value of type `Js.null_undefined('a)`. - -## undefined - -```re sig -let undefined: t('a); -``` - -The undefined value of type `Js.null_undefined('a)`. - -## bind - -```re sig -let bind: (t('a), (. 'a) => 'b) => t('b); -``` - -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)`. - -```re example -let maybeGreetWorld = (maybeGreeting: Js.null_undefined(string)) => - Js.Nullable.bind(maybeGreeting, [@bs] greeting => greeting ++ " world!"); -``` - -## iter - -```re sig -let iter: (t('a), (. 'a) => unit) => unit; -``` - -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. - -```re example -let maybeSay = (maybeMessage: Js.null_undefined(string)) => - Js.Nullable.iter(maybeMessage, [@bs] message => Js.log(message)); -``` - -## fromOption - -```re sig -let fromOption: option('a) => t('a); -``` - -Maps `option('a)` to `Js.null_undefined('a)`. -`Some(a)` => `a` -`None` => `undefined` - -## from_opt - -```re sig -let from_opt: option('a) => t('a); -``` - -## toOption - -```re sig -let toOption: t('a) => option('a); -``` - -Maps `Js.null_undefined('a)` to `option('a)`. -`a` => `Some(a)` -`undefined` => `None` -`null` => `None` - -## to_opt - -```re sig -let to_opt: t('a) => option('a); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/obj.mdx b/pages/docs/manual/v8.0.0/api/js/obj.mdx deleted file mode 100644 index 00b50115b..000000000 --- a/pages/docs/manual/v8.0.0/api/js/obj.mdx +++ /dev/null @@ -1,57 +0,0 @@ -# Obj - - - -Provide utilities for Js.t. - - - -## empty - -```re sig -let empty: unit => Js.t({..}); -``` - -`empty()` returns the empty object `{}`. - -## assign - -```re sig -let assign: (Js.t({..}), Js.t({..})) => Js.t({..}); -``` - -`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`. - -```re example -/* Copy an object */ - -let obj = [%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 = [%obj {a: 1, b: 1}]; -let source = [%obj {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); -``` - -## keys - -```re sig -let keys: Js.t('a) => array(string); -``` - -`keys(obj)` returns an `array` of the keys of `obj`'s own enumerable properties. diff --git a/pages/docs/manual/v8.0.0/api/js/option.mdx b/pages/docs/manual/v8.0.0/api/js/option.mdx deleted file mode 100644 index b0f29795f..000000000 --- a/pages/docs/manual/v8.0.0/api/js/option.mdx +++ /dev/null @@ -1,171 +0,0 @@ -# Option - - - -Provide utilities for handling `option`. - - - -## t - -```re sig -type t('a) = option('a); -``` - -## some - -```re sig -let some: 'a => option('a); -``` - -Wraps the given value in `Some()` - -```re example -Js.Option.some(1066) == Some(1066); -``` - -## isSome - -```re sig -let isSome: option('a) => bool; -``` - -Returns `true` if the argument is `Some(value)`; `false` if the argument is `None`. - -## isSomeValue - -```re sig -let isSomeValue: ((. 'a, 'a) => bool, 'a, option('a)) => bool; -``` - -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)`. - -```re example -let clockEqual = (. a, b) => (a mod 12 == b mod 12); -Js.Option.isSomeValue(clockEqual, 3, Some(15)) == true; -Js.Option.isSomeValue(clockEqual, 3, Some(4)) == false; -Js.Option.isSomeValue(clockEqual, 3, None) == false; -``` - -## isNone - -```re sig -let isNone: option('a) => bool; -``` - -Returns `true` if the argument is `None`; `false` otherwise. - -## getExn - -```re sig -let getExn: option('a) => 'a; -``` - -If the argument to `getExn()` is of the form `Some(value)`, returns `value`. If given `None`, it throws a `getExn` exception. - -## equal - -```re sig -let equal: ((. 'a, 'b) => bool, option('a), option('b)) => bool; -``` - -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` - -```re example -let clockEqual = (. a, b) => (a mod 12 == b mod 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; -``` - -## andThen - -```re sig -let andThen: ((. 'a) => option('b), option('a)) => option('b); -``` - -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)`. - -```re example -let reciprocal = (. x) => (x == 0) ? None : Some(1.0 /. (float_of_int(x))); -Js.Option.andThen(reciprocal, Some(5)) == Some(0.2); -Js.Option.andThen(reciprocal, Some(0)) == None; -Js.Option.andThen(reciprocal, None) == None; -``` - -## map - -```re sig -let map: ((. 'a) => 'b, option('a)) => option('b); -``` - -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. - -```re example -let square = (. x) => (x * x); -Js.Option.map(square, Some(3)) == Some(9); -Js.Option.map(square, None) == None; -``` - -## getWithDefault - -```re sig -let getWithDefault: ('a, option('a)) => 'a; -``` - -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. - -```re example -Js.Option.getWithDefault(1066, Some(15)) == 15; -Js.Option.getWithDefault(1066, None) == 1066; -``` - -## default - -```re sig -let default: ('a, option('a)) => 'a; -``` - -**See:** [getWithDefault](#getWithDefault) - -## filter - -```re sig -let filter: ((. 'a) => bool, option('a)) => option('a); -``` - -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`. - -```re example -let isEven = (. x) => {x mod 2 == 0}; -Js.Option.filter(isEven, Some(2)) == Some(2); -Js.Option.filter(isEven, Some(3)) == None; -Js.Option.filter(isEven, None) == None; -``` - -## firstSome - -```re sig -let firstSome: (option('a), option('a)) => option('a); -``` - -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. - -```re example -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; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/promise.mdx b/pages/docs/manual/v8.0.0/api/js/promise.mdx deleted file mode 100644 index 443553ba6..000000000 --- a/pages/docs/manual/v8.0.0/api/js/promise.mdx +++ /dev/null @@ -1,91 +0,0 @@ -# Promise - - - -Provide bindings to JS promise. - - - -## t - -```re sig -type t(+'a); -``` - -## error - -```re sig -type error; -``` - -## make - -```re sig -let make: ((~resolve: (. 'a) => unit, ~reject: (. exn) => unit) => unit) => t('a); -``` - -## resolve - -```re sig -let resolve: 'a => t('a); -``` - -## reject - -```re sig -let reject: exn => t('a); -``` - -## all - -```re sig -let all: array(t('a)) => t(array('a)); -``` - -## all2 - -```re sig -let all2: ((t('a0), t('a1))) => t(('a0, 'a1)); -``` - -## all3 - -```re sig -let all3: ((t('a0), t('a1), t('a2))) => t(('a0, 'a1, 'a2)); -``` - -## all4 - -```re sig -let all4: ((t('a0), t('a1), t('a2), t('a3))) => t(('a0, 'a1, 'a2, 'a3)); -``` - -## all5 - -```re sig -let all5: ((t('a0), t('a1), t('a2), t('a3), t('a4))) => t(('a0, 'a1, 'a2, 'a3, 'a4)); -``` - -## all6 - -```re sig -let all6: ((t('a0), t('a1), t('a2), t('a3), t('a4), t('a5))) => t(('a0, 'a1, 'a2, 'a3, 'a4, 'a5)); -``` - -## race - -```re sig -let race: array(t('a)) => t('a); -``` - -## then\_ - -```re sig -let then_: ('a => t('b), t('a)) => t('b); -``` - -## catch - -```re sig -let catch: (error => t('a), t('a)) => t('a); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/re.mdx b/pages/docs/manual/v8.0.0/api/js/re.mdx deleted file mode 100644 index 9e2862254..000000000 --- a/pages/docs/manual/v8.0.0/api/js/re.mdx +++ /dev/null @@ -1,243 +0,0 @@ -# Re - - - -Provide bindings to JS regular expressions (RegExp). - - - -## t - -```re sig -type t -``` - -The RegExp object. - -## result - -```re sig -type result -``` - -The result of a executing a RegExp on a string. - -## captures - -```re sig -let captures: result => array(Js.nullable(string)); -``` - -An `array` of the match and captures, the first is the full match and the remaining are the substring captures. - -## matches - -```re sig -let matches: result => array(string); -``` - -Deprecated. Use captures instead. -An `array` of the matches, the first is the full match and the remaining are the substring matches. - -## index - -```re sig -let index: result => int; -``` - -0-based index of the match in the input string. - -## input - -```re sig -let input: result => string; -``` - -The original input string. - -## fromString - -```re sig -let fromString: string => t; -``` - -Constructs a RegExp object (Js.Re.t) from a `string`. -Regex literals ([%re "/.../"]) should generally be preferred, but fromString is very useful when you need to insert a string into a regex. - -```re example -/* A function that extracts the content of the first element with the given tag */ - -let contentOf = (tag, xmlString) => - Js.Re.fromString("<" ++ tag ++ ">(.*?)<\\/" ++ tag ++ ">") - -> Js.Re.exec_(xmlString) - -> ( - fun - | Some(result) => Js.Nullable.toOption(Js.Re.captures(result)[1]) - | None => None - ); -``` - -## fromStringWithFlags - -```re sig -let fromStringWithFlags: (string, ~flags: string) => t; -``` - -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) - -## flags - -```re sig -let flags: t => string; -``` - -Returns the enabled flags as a string. - -## global - -```re sig -let global: t => bool; -``` - -Returns a `bool` indicating whether the global flag is set. - -## ignoreCase - -```re sig -let ignoreCase: t => bool; -``` - -Returns a `bool` indicating whether the ignoreCase flag is set. - -## lastIndex - -```re sig -let lastIndex: t => int; -``` - -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. - -```re example -let re = [%re "/ab*/g"]; -let str = "abbcdefabh"; - -let break = ref(false); -while (! break^) { - switch (Js.Re.exec_(re, str)) { - | Some(result) => - Js.Nullable.iter( - Js.Re.captures(result)[0], - [@bs] match => { - let next = Belt.Int.toString(Js.Re.lastIndex(re)); - Js.log("Found " ++ match ++ ". Next match starts at " ++ next); - }, - ) - | None => break := true - }; -}; -``` - -## setLastIndex - -```re sig -let setLastIndex: (t, int) => unit; -``` - -Sets the index at which the next match will start its search from. - -## multiline - -```re sig -let multiline: t => bool; -``` - -Returns a `bool` indicating whether the multiline flag is set. - -## source - -```re sig -let source: t => string; -``` - -Returns the pattern as a `string`. - -## sticky - -```re sig -let sticky: t => bool; -``` - -Returns a `bool` indicating whether the sticky flag is set. - -## unicode - -```re sig -let unicode: t => bool; -``` - -Returns a `bool` indicating whether the unicode flag is set. - -## exec\_ - -```re sig -let exec_: (t, string) => option(result); -``` - -Executes a search on a given string using the given RegExp object. -Returns `Some(Js.Re.result)` if a match is found, `None` otherwise. - -```re example -/* Match "quick brown" followed by "jumps", ignoring characters in between - * Remember "brown" and "jumps" - * Ignore case - */ - -let re = [%re "/quick\s(brown).+?(jumps)/ig"]; -let result = (Js.Re.exec_(re, "The Quick Brown Fox Jumps Over The Lazy Dog")); -``` - -## exec - -```re sig -let exec: (string, t) => option(result); -``` - -Deprecated. please use `Js.Re.exec_` instead. - -## test\_ - -```re sig -let test_: (t, string) => bool; -``` - -Tests whether the given RegExp object will match a given `string`. -Returns true if a match is found, false otherwise. - -```re example -/* 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" */ -``` - -## test - -```re sig -let test: (string, t) => bool; -``` - -Deprecated. please use `Js.Re.test_` instead. diff --git a/pages/docs/manual/v8.0.0/api/js/result.mdx b/pages/docs/manual/v8.0.0/api/js/result.mdx deleted file mode 100644 index 0b7d1054f..000000000 --- a/pages/docs/manual/v8.0.0/api/js/result.mdx +++ /dev/null @@ -1,15 +0,0 @@ -# Result - - - -Define the interface for result. - - - -## t - -```re sig -type t('good, 'bad) = - | Ok('good) - | Error('bad); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/string-2.mdx b/pages/docs/manual/v8.0.0/api/js/string-2.mdx deleted file mode 100644 index 49bd3df88..000000000 --- a/pages/docs/manual/v8.0.0/api/js/string-2.mdx +++ /dev/null @@ -1,784 +0,0 @@ -# String2 - - - -Provide bindings to JS string. Optimized for pipe-first. - - - -## t - -```re sig -type t = string; -``` - -## make - -```re sig -let make: 'a => t; -``` - -`make(value)` converts the given value to a `string`. - -```re example -Js.String2.make(3.5) == "3.5"; -Js.String2.make([|1,2,3|]) == "1,2,3"; -``` - -## fromCharCode - -```re sig -let fromCharCode: int => t; -``` - -`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. - -```re sig -Js.String2.fromCharCode(65) == "A"; -Js.String2.fromCharCode(0x3c8) == {js|ψ|js}; -Js.String2.fromCharCode(0xd55c) == {js|한|js}; -Js.String2.fromCharCode(-64568) == {js|ψ|js}; -``` - -## fromCharCodeMany - -```re sig -let fromCharCodeMany: array(int) => t; -``` - -`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. - -## fromCodePoint - -```re sig -let fromCodePoint: int => t; -``` - -`fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. -If the number is not a valid code point, it raises `RangeError`. -Thus, `fromCodePoint(0x1F63A)` will produce a correct value, unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN. - -```re example -Js.String2.fromCodePoint(65) == "A"; -Js.String2.fromCodePoint(0x3c8) == {js|ψ|js}; -Js.String2.fromCodePoint(0xd55c) == {js|한|js}; -Js.String2.fromCodePoint(0x1f63a) == {js|😺|js}; -``` - -## fromCodePointMany - -```re sig -let fromCodePointMany: array(int) => t; -``` - -`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. - -```re example -Js.String2.fromCodePointMany([|0xd55c, 0xae00, 0x1f63a|]) == {js|한글😺|js}; -``` - -## length - -```re sig -let length: t => int; -``` - -`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. - -```re example -Js.String2.length("abcd") == 4; -``` - -## get - -```re sig -let get: (t, int) => t; -``` - -`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(string)`. - -```re example -Js.String2.get("Reason", 0) == "R"; -Js.String2.get("Reason", 4) == "o"; -Js.String2.get({js|Rẽasöń|js}, 5) == {js|ń|js}; -``` - -## charAt - -```re sig -let charAt: (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. - -```re example -Js.String2.charAt("Reason", 0) == "R"; -Js.String2.charAt("Reason", 12) == ""; -Js.String2.charAt({js|Rẽasöń|js}, 5) == {js|ń|js}; -``` - -## charCodeAt - -```re sig -let charCodeAt: (t, int) => float; -``` - -`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. - -```re example -Js.String2.charCodeAt({js|😺|js}, 0) == 0xd83d->float_of_int; -Js.String2.codePointAt({js|😺|js}, 0) == Some(0x1f63a); -``` - -## codePointAt - -```re sig -let codePointAt: (t, int) => option(int); -``` - -`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. - -```re example -Js.String2.codePointAt({js|¿😺?|js}, 1) == Some(0x1f63a); -Js.String2.codePointAt("abc", 5) == None; -``` - -## concat - -```re sig -let concat: (t, t) => t; -``` - -`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. - -```re example -Js.String2.concat("cow", "bell") == "cowbell"; -``` - -## concatMany - -```re sig -let concatMany: (t, array(t)) => t; -``` - -`concat(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. - -```re example -Js.String2.concatMany("1st", [|"2nd", "3rd", "4th"|]) == "1st2nd3rd4th"; -``` - -## endsWith - -```re sig -let endsWith: (t, t) => bool; -``` - -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. - -```re example -Js.String2.endsWith("BuckleScript", "Script") == true; -Js.String2.endsWith("BuckleShoes", "Script") == false; -``` - -## endsWithFrom - -```re sig -let endsWithFrom: (t, t, int) => bool; -``` - -`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. - -```re example -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; -``` - -## includes - -```re sig -let includes: (t, t) => bool; -``` - -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. - -```re example -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; -``` - -## includesFrom - -```re sig -let includesFrom: (t, t, int) => bool; -``` - -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. - -```re example -Js.String2.includesFrom("programmer", "gram", 1) == true; -Js.String2.includesFrom("programmer", "gram", 4) == false; -Js.String2.includesFrom({js|대한민국|js}, {js|한|js}, 1) == true; -``` - -## indexOf - -```re sig -let indexOf: (t, t) => int; -``` - -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. - -```re example -Js.String2.indexOf("bookseller", "ok") == 2; -Js.String2.indexOf("bookseller", "sell") == 4; -Js.String2.indexOf("beekeeper", "ee") == 1; -Js.String2.indexOf("bookseller", "xyz") == -1; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (t, t, int) => int; -``` - -`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. - -```re example -Js.String2.indexOfFrom("bookseller", "ok", 1) == 2; -Js.String2.indexOfFrom("bookseller", "sell", 2) == 4; -Js.String2.indexOfFrom("bookseller", "sell", 5) == -1; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (t, t) => int; -``` - -`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. - -```re example -Js.String2.lastIndexOf("bookseller", "ok") == 2; -Js.String2.lastIndexOf("beekeeper", "ee") == 4; -Js.String2.lastIndexOf("abcdefg", "xyz") == -1; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (t, t, int) => int; -``` - -`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. - -```re example -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; -``` - -## localeCompare - -```re sig -let localeCompare: (t, t) => float; -``` - -`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. - -```re example -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; -``` - -## match - -```re sig -let match: (t, Js_re.t) => option(array(t)); -``` - -`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. - -```re example -Js.String2.match("The better bats", [%re "/b[aeiou]t/"]) == Some([|"bet"|]); -Js.String2.match("The better bats", [%re "/b[aeiou]t/g"]) == Some([|"bet", "bat"|]); -Js.String2.match("Today is 2018-04-05.", [%re "/(\\d+)-(\\d+)-(\\d+)/"]) == Some([|"2018-04-05", "2018", "04", "05"|]); -Js.String2.match("The large container.", [%re "/b[aeiou]g/"]) == None; -``` - -## normalize - -```re sig -let normalize: t => t; -``` - -`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. - -## normalizeByForm - -```re sig -let normalizeByForm: (t, t) => t; -``` - -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.. - -## repeat - -```re sig -let repeat: (t, int) => t; -``` - -`repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`. Raises `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. - -```re example -Js.String2.repeat("ha", 3) == "hahaha"; -Js.String2.repeat("empty", 0) == ""; -``` - -## replace - -```re sig -let replace: (t, t, t) => t; -``` - -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. - -```re example -Js.String2.replace("old string", "old", "new") == "new string"; -Js.String2.replace("the cat and the dog", "the", "this") == "this cat and the dog"; -``` - -## replaceByRe - -```re sig -let replaceByRe: (t, Js_re.t, t) => t; -``` - -`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. - -```re example -Js.String2.replaceByRe("vowels be gone", [%re "/[aeiou]/g"], "x") == "vxwxls bx gxnx"; -Js.String2.replaceByRe("Juan Fulano", [%re "/(\\w+) (\\w+)/"], "$2, $1") == "Fulano, Juan"; -``` - -## unsafeReplaceBy0 - -```re sig -let unsafeReplaceBy0: (t, Js_re.t, (t, int, t) => t) => t; -``` - -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. - -```re example -let str = "beautiful vowels"; -let re = [%re "/[aeiou]/g"]; -let matchFn = (matchPart, _offset, _wholeString) => - Js.String2.toUpperCase(matchPart); - -Js.String2.unsafeReplaceBy0(str, re, matchFn) - == "bEAUtIfUl vOwEls"; -``` - -## unsafeReplaceBy1 - -```re sig -let unsafeReplaceBy1: (t, Js_re.t, (t, t, int, t) => t) => t; -``` - -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. - -```re example -let str = "increment 23"; -let re = [%re "/increment (\\d+)/g"]; -let matchFn = (_matchPart, p1, _offset, wholeString) => - wholeString ++ " is " ++ Belt.Int.toString(int_of_string(p1) + 1); - -Js.String2.unsafeReplaceBy1(str, re, matchFn) - == "increment 23 is 24"; -``` - -## unsafeReplaceBy2 - -```re sig -let unsafeReplaceBy2: (t, Js_re.t, (t, t, t, int, t) => t) => t; -``` - -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. - -```re example -let str = "7 times 6"; -let re = [%re "/(\\d+) times (\\d+)/"]; -let matchFn = (matchPart, p1, p2, offset, wholeString) => - Belt.Int.toString(int_of_string(p1) * int_of_string(p2)); - -Js.String2.unsafeReplaceBy2(str, re, matchFn) == "42"; -``` - -## unsafeReplaceBy3 - -```re sig -let unsafeReplaceBy3: (t, Js_re.t, (t, t, t, t, int, t) => t) => t; -``` - -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. - -## search - -```re sig -let search: (t, Js_re.t) => int; -``` - -`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. - -```re example -Js.String2.search("testing 1 2 3", [%re "/\\d+/"]) == 8; -Js.String2.search("no numbers", [%re "/\\d+/"]) == -1; -``` - -## slice - -```re sig -let slice: (t, ~from: int, ~to_: int) => t; -``` - -`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. - -```re example -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) == ""; -``` - -## sliceToEnd - -```re sig -let sliceToEnd: (t, ~from: int) => t; -``` - -`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. - -```re example -Js.String2.sliceToEnd("abcdefg", ~from=4) == "efg"; -Js.String2.sliceToEnd("abcdefg", ~from=(-2)) == "fg"; -Js.String2.sliceToEnd("abcdefg", ~from=7) == ""; -``` - -## split - -```re sig -let split: (t, t) => array(t); -``` - -`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. - -```re example -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"|]; -``` - -## splitAtMost - -```re sig -let splitAtMost: (t, t, ~limit: int) => array(t); -``` - -`splitAtMost(str, delimiter, ~limit:n)` 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. - -```re example -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=3) == [|"ant", "bee", "cat"|]; -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=0) == [||]; -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=9) == [|"ant", "bee", "cat", "dog", "elk"|]; -``` - -## splitByRe - -```re sig -let splitByRe: (t, Js_re.t) => array(option(t)); -``` - -`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. - -```re example -Js.String2.splitByRe("art; bed , cog ;dad", [%re "/\\s*[,;]\\s*/"]) - == [|Some("art"), Some("bed"), Some("cog"), Some("dad")|]; -``` - -## splitByReAtMost - -```re sig -let splitByReAtMost: (t, Js_re.t, ~limit: int) => array(option(t)); -``` - -`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. - -```re example -Js.String2.splitByReAtMost("one: two: three: four", [%re "/\\s*:\\s*/"], ~limit=3) - == [|Some("one"), Some("two"), Some("three")|]; - -Js.String2.splitByReAtMost("one: two: three: four", [%re "/\\s*:\\s*/"], ~limit=0) - == [||]; - -Js.String2.splitByReAtMost("one: two: three: four", [%re "/\\s*:\\s*/"], ~limit=8) - == [|Some("one"), Some("two"), Some("three"), Some("four")|]; -``` - -## startsWith - -```re sig -let startsWith: (t, t) => bool; -``` - -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. - -```re example -Js.String2.startsWith("BuckleScript", "Buckle") == true; -Js.String2.startsWith("BuckleScript", "") == true; -Js.String2.startsWith("JavaScript", "Buckle") == false; -``` - -## startsWithFrom - -```re sig -let startsWithFrom: (t, t, int) => bool; -``` - -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. - -```re example -Js.String2.startsWithFrom("BuckleScript", "kle", 3) == true; -Js.String2.startsWithFrom("BuckleScript", "", 3) == true; -Js.String2.startsWithFrom("JavaScript", "Buckle", 2) == false; -``` - -## substr - -```re sig -let substr: (t, ~from: int) => t; -``` - -`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. - -```re example -Js.String2.substr("abcdefghij", ~from=3) == "defghij"; -Js.String2.substr("abcdefghij", ~from=(-3)) == "hij"; -Js.String2.substr("abcdefghij", ~from=12) == ""; -``` - -## substrAtMost - -```re sig -let substrAtMost: (t, ~from: int, ~length: int) => t; -``` - -`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. - -```re example -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) == ""; -``` - -## substring - -```re sig -let substring: (t, ~from: int, ~to_: int) => t; -``` - -`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. - -```re example -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"; -``` - -## substringToEnd - -```re sig -let substringToEnd: (t, ~from: int) => t; -``` - -`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. - -```re example -Js.String2.substringToEnd("playground", ~from=4) == "ground"; -Js.String2.substringToEnd("playground", ~from=(-3)) == "playground"; -Js.String2.substringToEnd("playground", ~from=12) == ""; -``` - -## toLowerCase - -```re sig -let toLowerCase: t => t; -``` - -`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. - -```re example -Js.String2.toLowerCase("ABC") == "abc"; -Js.String2.toLowerCase({js|ΣΠ|js}) == {js|σπ|js}; -Js.String2.toLowerCase({js|ΠΣ|js}) == {js|πς|js}; -``` - -## toLocaleLowerCase - -```re sig -let toLocaleLowerCase: t => t; -``` - -`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. - -## toUpperCase - -```re sig -let toUpperCase: t => t; -``` - -`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. - -```re example -Js.String2.toUpperCase("abc") == "ABC"; -Js.String2.toUpperCase({js|Straße|js}) == {js|STRASSE|js}; -Js.String2.toUpperCase({js|πς|js}) == {js|ΠΣ|js}; -``` - -## toLocaleUpperCase - -```re sig -let toLocaleUpperCase: t => t; -``` - -`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. - -## trim - -```re sig -let trim: t => t; -``` - -`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. - -```re example -Js.String2.trim(" abc def ") == "abc def"; -Js.String2.trim("\n\r\t abc def \n\n\t\r ") == "abc def"; -``` - -## anchor - -```re sig -let anchor: (t, t) => t; -``` - -`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. - -```re example -Js.String2.anchor("Page One", "page1") == "Page One"; -``` - -## link - -```re sig -let link: (t, t) => t; -``` - -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. - -```re example -Js.String2.link("Go to page two", "page2.html") == "Go to page two"; -``` - -## castToArrayLike - -```re sig -let castToArrayLike: t => Js_array2.array_like(t); -``` - -Casts its argument to an `array_like` entity that can be processed by functions such as `Js.Array2.fromMap()` - -```re example -let s = "abcde"; -let arr = Js.Array2.fromMap(Js.String2.castToArrayLike(s), (x)=>{x}); -arr == [|"a", "b", "c", "d", "e"|]; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/string.mdx b/pages/docs/manual/v8.0.0/api/js/string.mdx deleted file mode 100644 index c5a6fc6e3..000000000 --- a/pages/docs/manual/v8.0.0/api/js/string.mdx +++ /dev/null @@ -1,800 +0,0 @@ -# String - - - -Provide bindings to JS string. Optimized for pipe-last. - - - -## t - -```re sig -type t = string; -``` - -## make - -```re sig -let make: 'a => t; -``` - -`make(value)` converts the given value to a `string`. - -```re example -Js.String2.make(3.5) == "3.5"; -Js.String2.make([|1,2,3|]) == "1,2,3"; -``` - -## fromCharCode - -```re sig -let fromCharCode: int => t; -``` - -`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. - -```re sig -Js.String2.fromCharCode(65) == "A"; -Js.String2.fromCharCode(0x3c8) == {js|ψ|js}; -Js.String2.fromCharCode(0xd55c) == {js|한|js}; -Js.String2.fromCharCode(-64568) == {js|ψ|js}; -``` - -## fromCharCodeMany - -```re sig -let fromCharCodeMany: array(int) => t; -``` - -`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. - -## fromCodePoint - -```re sig -let fromCodePoint: int => t; -``` - -`fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. -If the number is not a valid code point, it raises `RangeError`. -Thus, `fromCodePoint(0x1F63A)` will produce a correct value, unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN. - -```re example -Js.String2.fromCodePoint(65) == "A"; -Js.String2.fromCodePoint(0x3c8) == {js|ψ|js}; -Js.String2.fromCodePoint(0xd55c) == {js|한|js}; -Js.String2.fromCodePoint(0x1f63a) == {js|😺|js}; -``` - -## fromCodePointMany - -```re sig -let fromCodePointMany: array(int) => t; -``` - -`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. - -```re example -Js.String2.fromCodePointMany([|0xd55c, 0xae00, 0x1f63a|]) == {js|한글😺|js}; -``` - -## length - -```re sig -let length: t => int; -``` - -`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. - -```re example -Js.String2.length("abcd") == 4; -``` - -## get - -```re sig -let get: (t, int) => t; -``` - -`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(string)`. - -```re example -Js.String2.get("Reason", 0) == "R"; -Js.String2.get("Reason", 4) == "o"; -Js.String2.get({js|Rẽasöń|js}, 5) == {js|ń|js}; -``` - -## charAt - -```re sig -let charAt: (int, t) => 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. - -```re example -Js.String.charAt(0, "Reason") == "R"; -Js.String.charAt(12, "Reason") == ""; -Js.String.charAt(5, {js|Rẽasöń|js}) == {js|ń|js}; -``` - -## charCodeAt - -```re sig -let charCodeAt: (int, t) => float; -``` - -`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. - -```re example -Js.String.charCodeAt(0, {js|😺|js}) == 0xd83d->float_of_int; -Js.String.codePointAt(0, {js|😺|js}) == Some(0x1f63a); -``` - -## codePointAt - -```re sig -let codePointAt: (int, t) => option(int); -``` - -`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. - -```re example -Js.String.codePointAt(1, {js|¿😺?|js}) == Some(0x1f63a); -Js.String.codePointAt(5, "abc") == None; -``` - -## concat - -```re sig -let concat: (t, t) => t; -``` - -`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. - -```re example -Js.String.concat("bell", "cow") == "cowbell"; -``` - -## concatMany - -```re sig -let concatMany: (array(t), t) => t; -``` - -`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. - -```re example -Js.String.concatMany([|"2nd", "3rd", "4th"|], "1st") == "1st2nd3rd4th"; -``` - -## endsWith - -```re sig -let endsWith: (t, t) => bool; -``` - -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. - -```re example -Js.String.endsWith("Script", "BuckleScript") == true; -Js.String.endsWith("Script", "BuckleShoes") == false; -``` - -## endsWithFrom - -```re sig -let endsWithFrom: (t, int, t) => bool; -``` - -`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. - -```re example -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; -``` - -## includes - -```re sig -let includes: (t, t) => bool; -``` - -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. - -```re example -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; -``` - -## includesFrom - -```re sig -let includesFrom: (t, int, t) => bool; -``` - -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. - -```re example -Js.String.includesFrom("gram", 1, "programmer") == true; -Js.String.includesFrom("gram", 4, "programmer") == false; -Js.String.includesFrom({js|한|js}, 1, {js|대한민국|js}) == true; -``` - -## indexOf - -```re sig -let indexOf: (t, t) => int; -``` - -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. - -```re example -Js.String.indexOf("ok", "bookseller") == 2; -Js.String.indexOf("sell", "bookseller") == 4; -Js.String.indexOf( "ee", "beekeeper") == 1; -Js.String.indexOf("xyz", "bookseller") == -1; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (t, t, int) => int; -``` - -`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. - -```re example -Js.String.indexOfFrom("ok", 1, "bookseller") == 2; -Js.String.indexOfFrom("sell", 2, "bookseller") == 4; -Js.String.indexOfFrom("sell", 5, "bookseller") == -1; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (t, t) => int; -``` - -`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. - -```re example -Js.String.lastIndexOf("ok", "bookseller") == 2; -Js.String.lastIndexOf("ee", "beekeeper") == 4; -Js.String.lastIndexOf("xyz", "abcdefg") == -1; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (t, int, t) => int; -``` - -`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. - -```re example -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; -``` - -## localeCompare - -```re sig -let localeCompare: (t, t) => float; -``` - -`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. - -```re example -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; -``` - -## match - -```re sig -let match: (Js_re.t, t) => option(array(t)); -``` - -`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. - -```re example -Js.String.match([%re "/b[aeiou]t/"], "The better bats") == Some([|"bet"|]); -Js.String.match([%re "/b[aeiou]t/g"], "The better bats") == Some([|"bet", "bat"|]); -Js.String.match([%re "/(\\d+)-(\\d+)-(\\d+)/"], "Today is 2018-04-05.") == Some([|"2018-04-05", "2018", "04", "05"|]); -Js.String.match([%re "/b[aeiou]g/"], "The large container.") == None; -``` - -## normalize - -```re sig -let normalize: t => t; -``` - -`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. - -## normalizeByForm - -```re sig -let normalizeByForm: (t, t) => t; -``` - -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. - -## repeat - -```re sig -let repeat: (t, int) => t; -``` - -`repeat(n, str)` returns a `string` that consists of `n` repetitions of `str`. Raises `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. - -```re example -Js.String.repeat(3, "ha") == "hahaha"; -Js.String.repeat(0, "empty") == ""; -``` - -## replace - -```re sig -let replace: (t, t, t) => t; -``` - -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. - -```re example -Js.String.replace("old", "new", "old string") == "new string"; -Js.String.replace("the", "this", "the cat and the dog") == "this cat and the dog"; -``` - -## replaceByRe - -```re sig -let replaceByRe: (Js_re.t, t, t) => t; -``` - -`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. - -```re example -Js.String.replaceByRe([%re "/[aeiou]/g"], "x", "vowels be gone") == "vxwxls bx gxnx"; -Js.String.replaceByRe([%re "/(\\w+) (\\w+)/"], "$2, $1", "Juan Fulano") == "Fulano, Juan"; -``` - -## unsafeReplaceBy0 - -```re sig -let unsafeReplaceBy0: (Js_re.t, (t, int, t) => t, t) => t; -``` - -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. - -```re example -let str = "beautiful vowels"; -let re = [%re "/[aeiou]/g"]; -let matchFn = (matchPart, _offset, _wholeString) => - Js.String.toUpperCase(matchPart); - -Js.String.unsafeReplaceBy0(re, matchFn, str) - == "bEAUtIfUl vOwEls"; -``` - -## unsafeReplaceBy1 - -```re sig -let unsafeReplaceBy1: (Js_re.t, (t, t, int, t) => t, t) => t; -``` - -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. - -```re example -let str = "increment 23"; -let re = [%re "/increment (\\d+)/g"]; -let matchFn = (_matchPart, p1, _offset, wholeString) => - wholeString ++ " is " ++ Belt.Int.toString(int_of_string(p1) + 1); - -Js.String.unsafeReplaceBy1(re, matchFn, str) - == "increment 23 is 24"; -``` - -## unsafeReplaceBy2 - -```re sig -let unsafeReplaceBy2: (Js_re.t, (t, t, t, int, t) => t, t) => t; -``` - -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. - -```re example -let str = "7 times 6"; -let re = [%re "/(\\d+) times (\\d+)/"]; -let matchFn = (_matchPart, p1, p2, _offset, _wholeString) => - Belt.Int.toString(int_of_string(p1) * int_of_string(p2)); - -Js.String.unsafeReplaceBy2(re, matchFn, str) == "42"; -``` - -## unsafeReplaceBy3 - -```re sig -let unsafeReplaceBy3: (Js_re.t, (t, t, t, t, int, t) => t, t) => t; -``` - -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. - -## search - -```re sig -let search: (Js_re.t, t) => int; -``` - -`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. - -```re example -Js.String.search([%re "/\\d+/"], "testing 1 2 3") == 8; -Js.String.search([%re "/\\d+/"], "no numbers") == -1; -``` - -## slice - -```re sig -let slice: (~from: int, ~to_: int, t) => t; -``` - -`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. - -```re example -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") == ""; -``` - -## sliceToEnd - -```re sig -let sliceToEnd: (~from: int, t) => t; -``` - -`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. - -```re example -Js.String.sliceToEnd(~from=4, "abcdefg") == "efg"; -Js.String.sliceToEnd(~from=(-2), "abcdefg") == "fg"; -Js.String.sliceToEnd(~from=7, "abcdefg") == ""; -``` - -## split - -```re sig -let split: (t, t) => array(t); -``` - -`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. - -```re example -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"|]; -``` - -## splitAtMost - -```re sig -let splitAtMost: (t, ~limit: int, t) => array(t); -``` - -`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. - -```re example -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"|]; -``` - -## splitLimited - -```re sig -let splitLimited: (t, int, t) => array(t); -``` - -Deprecated - Please use splitAtMost. - -## splitByRe - -```re sig -let splitByRe: (Js_re.t, t) => array(option(t)); -``` - -`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. - -```re example -Js.String.splitByRe([%re "/\\s*[,;]\\s*/"], "art; bed , cog ;dad") - == [|Some("art"), Some("bed"), Some("cog"), Some("dad")|]; -``` - -## splitByReAtMost - -```re sig -let splitByReAtMost: (Js_re.t, ~limit: int, t) => array(option(t)); -``` - -`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. - -```re example -Js.String.splitByReAtMost([%re "/\\s*:\\s*/"], ~limit=3, "one: two: three: four") - == [|Some("one"), Some("two"), Some("three")|]; - -Js.String.splitByReAtMost([%re "/\\s*:\\s*/"], ~limit=0, "one: two: three: four") - == [||]; - -Js.String.splitByReAtMost([%re "/\\s*:\\s*/"], ~limit=8, "one: two: three: four") - == [|Some("one"), Some("two"), Some("three"), Some("four")|]; -``` - -## splitRegexpLimited - -```re sig -let splitRegexpLimited: (Js_re.t, int, t) => array(t); -``` - -Deprecated - Please use splitByReAtMost. - -## startsWith - -```re sig -let startsWith: (t, t) => bool; -``` - -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. - -```re example -Js.String.startsWith("Buckle", "BuckleScript") == true; -Js.String.startsWith("", "BuckleScript") == true; -Js.String.startsWith("Buckle", "JavaScript") == false; -``` - -## startsWithFrom - -```re sig -let startsWithFrom: (t, int, t) => bool; -``` - -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. - -```re example -Js.String.startsWithFrom("kle", 3, "BuckleScript") == true; -Js.String.startsWithFrom("", 3, "BuckleScript") == true; -Js.String.startsWithFrom("Buckle", 2, "JavaScript") == false; -``` - -## substr - -```re sig -let substr: (~from: int, t) => t; -``` - -`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. - -```re example -Js.String.substr(~from=3, "abcdefghij") == "defghij"; -Js.String.substr(~from=(-3), "abcdefghij") == "hij"; -Js.String.substr(~from=12, "abcdefghij") == ""; -``` - -## substrAtMost - -```re sig -let substrAtMost: (~from: int, ~length: int, t) => t; -``` - -`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. - -```re example -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") == ""; -``` - -## substring - -```re sig -let substring: (~from: int, ~to_: int, t) => t; -``` - -`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. - -```re example -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"; -``` - -## substringToEnd - -```re sig -let substringToEnd: (~from: int, t) => t; -``` - -`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. - -```re example -Js.String.substringToEnd(~from=4, "playground") == "ground"; -Js.String.substringToEnd(~from=(-3), "playground") == "playground"; -Js.String.substringToEnd(~from=12, "playground") == ""; -``` - -## toLowerCase - -```re sig -let toLowerCase: t => t; -``` - -`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. - -```re example -Js.String.toLowerCase("ABC") == "abc"; -Js.String.toLowerCase({js|ΣΠ|js}) == {js|σπ|js}; -Js.String.toLowerCase({js|ΠΣ|js}) == {js|πς|js}; -``` - -## toLocaleLowerCase - -```re sig -let toLocaleLowerCase: t => t; -``` - -`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. - -## toUpperCase - -```re sig -let toUpperCase: t => t; -``` - -`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. - -```re example -Js.String.toUpperCase("abc") == "ABC"; -Js.String.toUpperCase({js|Straße|js}) == {js|STRASSE|js}; -Js.String.toUpperCase({js|πς|js}) == {js|ΠΣ|js}; -``` - -## toLocaleUpperCase - -```re sig -let toLocaleUpperCase: t => t; -``` - -`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. - -## trim - -```re sig -let trim: t => t; -``` - -`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. - -```re example -Js.String.trim(" abc def ") == "abc def"; -Js.String.trim("\n\r\t abc def \n\n\t\r ") == "abc def"; -``` - -## anchor - -```re sig -let anchor: (t, t) => t; -``` - -`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. - -```re example -Js.String.anchor("page1", "Page One") == "Page One" -``` - -## link - -```re sig -let link: (t, t) => t; -``` - -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. - -```re example -Js.String.link("page2.html", "Go to page two") == "Go to page two"; -``` - -## castToArrayLike - -```re sig -let castToArrayLike: t => Js_array2.array_like(t); -``` - -Casts its argument to an `array_like` entity that can be processed by functions such as `Js.Array2.fromMap()` - -```re example -let s = "abcde"; -let arr = Js.Array2.fromMap(Js.String.castToArrayLike(s), (x)=>{x}); -arr == [|"a", "b", "c", "d", "e"|]; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2.mdx deleted file mode 100644 index d374bec11..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2.mdx +++ /dev/null @@ -1,41 +0,0 @@ -# TypedArray2 - - - -Provide bindings to JS typed array. - - - -## array_buffer - -```re sig -type array_buffer; -``` - -## array_like - -```re sig -type array_like('a); -``` - -## module ArrayBuffer - -## module Int8Array - -## module Uint8Array - -## module Uint8ClampedArray - -## module Int16Array - -## module Uint16Array - -## module Int32Array - -## module Uint32Array - -## module Float32Array - -## module Float64Array - -## module DataView diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_array-buffer.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_array-buffer.mdx deleted file mode 100644 index 34ee237db..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_array-buffer.mdx +++ /dev/null @@ -1,39 +0,0 @@ -# TypedArray2.ArrayBuffer - - - -Provide bindings to JS typed array ArrayBuffer. - - - -## t - -```re sig -type t = Js_typed_array2.array_buffer; -``` - -## make - -```re sig -let make: int => t; -``` - -Takes length. initializes elements to 0. - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## slice - -```re sig -let slice: (t, ~start: int, ~end_: int) => Js_typed_array2.array_buffer; -``` - -## sliceFrom - -```re sig -let sliceFrom: (t, int) => Js_typed_array2.array_buffer; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_data-view.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_data-view.mdx deleted file mode 100644 index a2ce87588..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_data-view.mdx +++ /dev/null @@ -1,223 +0,0 @@ -# TypedArray2.DataView - - - -Provide bindings to JS typed array DataView. - - - -## t - -```re sig -type t; -``` - -## make - -```re sig -let make: Js_typed_array2.array_buffer => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## getInt8 - -```re sig -let getInt8: (t, int) => int; -``` - -## getUint8 - -```re sig -let getUint8: (t, int) => int; -``` - -## getInt16 - -```re sig -let getInt16: (t, int) => int; -``` - -## getInt16LittleEndian - -```re sig -let getInt16LittleEndian: (t, int) => int; -``` - -## getUint16 - -```re sig -let getUint16: (t, int) => int; -``` - -## getUint16LittleEndian - -```re sig -let getUint16LittleEndian: (t, int) => int; -``` - -## getInt32 - -```re sig -let getInt32: (t, int) => int; -``` - -## getInt32LittleEndian - -```re sig -let getInt32LittleEndian: (t, int) => int; -``` - -## getUint32 - -```re sig -let getUint32: (t, int) => int; -``` - -## getUint32LittleEndian - -```re sig -let getUint32LittleEndian: (t, int) => int; -``` - -## getFloat32 - -```re sig -let getFloat32: (t, int) => float; -``` - -## getFloat32LittleEndian - -```re sig -let getFloat32LittleEndian: (t, int) => float; -``` - -## getFloat64 - -```re sig -let getFloat64: (t, int) => float; -``` - -## getFloat64LittleEndian - -```re sig -let getFloat64LittleEndian: (t, int) => float; -``` - -## setInt8 - -```re sig -let setInt8: (t, int, int) => unit; -``` - -## setUint8 - -```re sig -let setUint8: (t, int, int) => unit; -``` - -## setInt16 - -```re sig -let setInt16: (t, int, int) => unit; -``` - -## setInt16LittleEndian - -```re sig -let setInt16LittleEndian: (t, int, int) => unit; -``` - -## setUint16 - -```re sig -let setUint16: (t, int, int) => unit; -``` - -## setUint16LittleEndian - -```re sig -let setUint16LittleEndian: (t, int, int) => unit; -``` - -## setInt32 - -```re sig -let setInt32: (t, int, int) => unit; -``` - -## setInt32LittleEndian - -```re sig -let setInt32LittleEndian: (t, int, int) => unit; -``` - -## setUint32 - -```re sig -let setUint32: (t, int, int) => unit; -``` - -## setUint32LittleEndian - -```re sig -let setUint32LittleEndian: (t, int, int) => unit; -``` - -## setFloat32 - -```re sig -let setFloat32: (t, int, float) => unit; -``` - -## setFloat32LittleEndian - -```re sig -let setFloat32LittleEndian: (t, int, float) => unit; -``` - -## setFloat64 - -```re sig -let setFloat64: (t, int, float) => unit; -``` - -## setFloat64LittleEndian - -```re sig -let setFloat64LittleEndian: (t, int, float) => unit; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_float-32-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_float-32-array.mdx deleted file mode 100644 index f1f59321e..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_float-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Float32Array - - - -Provide bindings to JS typed array Float32Array. - - - -## t - -```re sig -type elt = float; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_float-64-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_float-64-array.mdx deleted file mode 100644 index f61bc84c2..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_float-64-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Float64Array - - - -Provide bindings to JS typed array Float64Array. - - - -## t - -```re sig -type elt = float; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-16-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-16-array.mdx deleted file mode 100644 index 3bf2c8b9c..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Int16Array - - - -Provide bindings to JS typed array Int16Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-32-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-32-array.mdx deleted file mode 100644 index 3160e5acc..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray2.Int32Array - - - -Provide bindings to JS typed array Int32Array. - - - -## t - -```re sig -type elt = int32; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` - -## create - -```re sig -let create: array(elt) => t; -``` - -## of_buffer - -```re sig -let of_buffer: Js_typed_array2.array_buffer => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-8-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-8-array.mdx deleted file mode 100644 index 3b80b300f..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_int-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Int8Array - - - -Provide bindings to JS typed array Int8Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-16-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-16-array.mdx deleted file mode 100644 index f48817c3c..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint16Array - - - -Provide bindings to JS typed array Uint16Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-32-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-32-array.mdx deleted file mode 100644 index c04c8ac09..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.UInt32Array - - - -Provide bindings to JS typed array Uint32Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-array.mdx deleted file mode 100644 index e43293454..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint8Array - - - -Provide bindings to JS typed array Uint8Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx deleted file mode 100644 index 42299a5de..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint8ClampedArray - - - -Provide bindings to JS typed array Uint8ClampedArray. - - - -## t - -```re sig -type elt = int; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array2.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array2.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array2.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array.mdx deleted file mode 100644 index cc34eb8cb..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array.mdx +++ /dev/null @@ -1,49 +0,0 @@ -# TypedArray - - - -Provide bindings to JS typed array. - - - -## array_buffer - -```re sig -type array_buffer; -``` - -## array_like - -```re sig -type array_like('a); -``` - -## module type Type - -```re sig -module type Type = {type t;}; -``` - -## module ArrayBuffer - -## module type S - -## module Int8Array - -## module Uint8Array - -## module Uint8ClampedArray - -## module Int16Array - -## module Uint16Array - -## module Int32Array - -## module Uint32Array - -## module Float32Array - -## module Float64Array - -## module DataView diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_array-buffer.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_array-buffer.mdx deleted file mode 100644 index f3e9642b4..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_array-buffer.mdx +++ /dev/null @@ -1,39 +0,0 @@ -# TypedArray.ArrayBuffer - - - -Provide bindings to JS typed array ArrayBuffer. - - - -## t - -```re sig -type t = Js_typed_array.array_buffer; -``` - -## make - -```re sig -let make: int => t; -``` - -Takes length. initializes elements to 0. - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => Js_typed_array.array_buffer; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => Js_typed_array.array_buffer; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_data-view.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_data-view.mdx deleted file mode 100644 index 91815dd81..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_data-view.mdx +++ /dev/null @@ -1,223 +0,0 @@ -# TypedArray.DataView - - - -Provide bindings to JS typed array DataView. - - - -## t - -```re sig -type t = Js_typed_array2.DataView.t; -``` - -## make - -```re sig -let make: Js_typed_array.array_buffer => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## getInt8 - -```re sig -let getInt8: (t, int) => int; -``` - -## getUint8 - -```re sig -let getUint8: (t, int) => int; -``` - -## getInt16 - -```re sig -let getInt16: (t, int) => int; -``` - -## getInt16LittleEndian - -```re sig -let getInt16LittleEndian: (t, int) => int; -``` - -## getUint16 - -```re sig -let getUint16: (t, int) => int; -``` - -## getUint16LittleEndian - -```re sig -let getUint16LittleEndian: (t, int) => int; -``` - -## getInt32 - -```re sig -let getInt32: (t, int) => int; -``` - -## getInt32LittleEndian - -```re sig -let getInt32LittleEndian: (t, int) => int; -``` - -## getUint32 - -```re sig -let getUint32: (t, int) => int; -``` - -## getUint32LittleEndian - -```re sig -let getUint32LittleEndian: (t, int) => int; -``` - -## getFloat32 - -```re sig -let getFloat32: (t, int) => float; -``` - -## getFloat32LittleEndian - -```re sig -let getFloat32LittleEndian: (t, int) => float; -``` - -## getFloat64 - -```re sig -let getFloat64: (t, int) => float; -``` - -## getFloat64LittleEndian - -```re sig -let getFloat64LittleEndian: (t, int) => float; -``` - -## setInt8 - -```re sig -let setInt8: (t, int, int) => unit; -``` - -## setUint8 - -```re sig -let setUint8: (t, int, int) => unit; -``` - -## setInt16 - -```re sig -let setInt16: (t, int, int) => unit; -``` - -## setInt16LittleEndian - -```re sig -let setInt16LittleEndian: (t, int, int) => unit; -``` - -## setUint16 - -```re sig -let setUint16: (t, int, int) => unit; -``` - -## setUint16LittleEndian - -```re sig -let setUint16LittleEndian: (t, int, int) => unit; -``` - -## setInt32 - -```re sig -let setInt32: (t, int, int) => unit; -``` - -## setInt32LittleEndian - -```re sig -let setInt32LittleEndian: (t, int, int) => unit; -``` - -## setUint32 - -```re sig -let setUint32: (t, int, int) => unit; -``` - -## setUint32LittleEndian - -```re sig -let setUint32LittleEndian: (t, int, int) => unit; -``` - -## setFloat32 - -```re sig -let setFloat32: (t, int, float) => unit; -``` - -## setFloat32LittleEndian - -```re sig -let setFloat32LittleEndian: (t, int, float) => unit; -``` - -## setFloat64 - -```re sig -let setFloat64: (t, int, float) => unit; -``` - -## setFloat64LittleEndian - -```re sig -let setFloat64LittleEndian: (t, int, float) => unit; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_float-32-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_float-32-array.mdx deleted file mode 100644 index bfb095530..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_float-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Float32Array - - - -Provide bindings to JS typed array Float32Array. - - - -## t - -```re sig -type elt = float; -type typed_array('a) = Js_typed_array2.Float32Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` - -## create - -```re sig -let create: array(elt) => t; -``` - -## of_buffer - -```re sig -let of_buffer: Js_typed_array.array_buffer => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_float-64-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_float-64-array.mdx deleted file mode 100644 index 6d0cf20a7..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_float-64-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Float64Array - - - -Provide bindings to JS typed array Float64Array. - - - -## t - -```re sig -type elt = float; -type typed_array('a) = Js_typed_array2.Float64Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` - -## create - -```re sig -let create: array(elt) => t; -``` - -## of_buffer - -```re sig -let of_buffer: Js_typed_array.array_buffer => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_int-16-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_int-16-array.mdx deleted file mode 100644 index a77ed5973..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_int-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Int16Array - - - -Provide bindings to JS typed array Int16Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a) = Js_typed_array2.Int16Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_int-32-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_int-32-array.mdx deleted file mode 100644 index 7424bae43..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_int-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Int32Array - - - -Provide bindings to JS typed array Int32Array. - - - -## t - -```re sig -type elt = int32; -type typed_array('a) = Js_typed_array2.Int32Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` - -## create - -```re sig -let create: array(elt) => t; -``` - -## of_buffer - -```re sig -let of_buffer: Js_typed_array.array_buffer => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_int-8-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_int-8-array.mdx deleted file mode 100644 index 60e1c5187..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_int-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Int8Array - - - -Provide bindings to JS typed array Int8Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a) = Js_typed_array2.Int8Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_type-s.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_type-s.mdx deleted file mode 100644 index 1640c6865..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_type-s.mdx +++ /dev/null @@ -1,309 +0,0 @@ -# TypedArray type S - - - -TODO - - - -## t - -```re sig -type elt; -type typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-16-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_uint-16-array.mdx deleted file mode 100644 index a2aec5b41..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint16Array - - - -Provide bindings to JS typed array Uint16Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a) = Js_typed_array2.Uint16Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-32-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_uint-32-array.mdx deleted file mode 100644 index 34005a11e..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.UInt32Array - - - -Provide bindings to JS typed array Uint32Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a) = Js_typed_array2.Uint32Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-8-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_uint-8-array.mdx deleted file mode 100644 index 0804a9979..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint8Array - - - -Provide bindings to JS typed array Uint8Array. - - - -## t - -```re sig -type elt = int; -type typed_array('a) = Js_typed_array2.Uint8Array.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-8-clamped-array.mdx b/pages/docs/manual/v8.0.0/api/js/typed-array_uint-8-clamped-array.mdx deleted file mode 100644 index eb39c8315..000000000 --- a/pages/docs/manual/v8.0.0/api/js/typed-array_uint-8-clamped-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint8ClampedArray - - - -Provide bindings to JS typed array Uint8ClampedArray. - - - -## t - -```re sig -type elt = int; -type typed_array('a) = Js_typed_array2.Uint8ClampedArray.typed_array('a); -type t = typed_array(elt); -``` - -## unsafe_get - -```re sig -let unsafe_get: (t, int) => elt; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t, int, elt) => unit; -``` - -## buffer - -```re sig -let buffer: t => Js_typed_array.array_buffer; -``` - -## byteLength - -```re sig -let byteLength: t => int; -``` - -## byteOffset - -```re sig -let byteOffset: t => int; -``` - -## setArray - -```re sig -let setArray: (array(elt), t) => unit; -``` - -## setArrayOffset - -```re sig -let setArrayOffset: (array(elt), int, t) => unit; -``` - -## length - -```re sig -let length: t => int; -``` - -## copyWithin - -```re sig -let copyWithin: (~to_: int, t) => t; -``` - -## copyWithinFrom - -```re sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t; -``` - -## copyWithinFromRange - -```re sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t; -``` - -## fillInPlace - -```re sig -let fillInPlace: (elt, t) => t; -``` - -## fillFromInPlace - -```re sig -let fillFromInPlace: (elt, ~from: int, t) => t; -``` - -## fillRangeInPlace - -```re sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t; -``` - -## reverseInPlace - -```re sig -let reverseInPlace: t => t; -``` - -## sortInPlace - -```re sig -let sortInPlace: t => t; -``` - -## sortInPlaceWith - -```re sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t; -``` - -## includes - -```re sig -let includes: (elt, t) => bool; -``` - -ES2016 - -## indexOf - -```re sig -let indexOf: (elt, t) => int; -``` - -## indexOfFrom - -```re sig -let indexOfFrom: (elt, ~from: int, t) => int; -``` - -## join - -```re sig -let join: t => string; -``` - -## joinWith - -```re sig -let joinWith: (string, t) => string; -``` - -## lastIndexOf - -```re sig -let lastIndexOf: (elt, t) => int; -``` - -## lastIndexOfFrom - -```re sig -let lastIndexOfFrom: (elt, ~from: int, t) => int; -``` - -## slice - -```re sig -let slice: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```re sig -let copy: t => t; -``` - -## sliceFrom - -```re sig -let sliceFrom: (int, t) => t; -``` - -## subarray - -```re sig -let subarray: (~start: int, ~end_: int, t) => t; -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```re sig -let subarrayFrom: (int, t) => t; -``` - -## toString - -```re sig -let toString: t => string; -``` - -## toLocaleString - -```re sig -let toLocaleString: t => string; -``` - -## every - -```re sig -let every: ((. elt) => bool, t) => bool; -``` - -## everyi - -```re sig -let everyi: ((. elt, int) => bool, t) => bool; -``` - -## filter - -```re sig -let filter: ((. elt) => bool, t) => t; -``` - -## filteri - -```re sig -let filteri: ((. elt, int) => bool, t) => t; -``` - -## find - -```re sig -let find: ((. elt) => bool, t) => Js.undefined(elt); -``` - -## findi - -```re sig -let findi: ((. elt, int) => bool, t) => Js.undefined(elt); -``` - -## findIndex - -```re sig -let findIndex: ((. elt) => bool, t) => int; -``` - -## findIndexi - -```re sig -let findIndexi: ((. elt, int) => bool, t) => int; -``` - -## forEach - -```re sig -let forEach: ((. elt) => unit, t) => unit; -``` - -## forEachi - -```re sig -let forEachi: ((. elt, int) => unit, t) => unit; -``` - -## map - -```re sig -let map: ((. elt) => 'b, t) => typed_array('b); -``` - -## mapi - -```re sig -let mapi: ((. elt, int) => 'b, t) => typed_array('b); -``` - -## reduce - -```re sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reducei - -```re sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## reduceRight - -```re sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b; -``` - -## reduceRighti - -```re sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b; -``` - -## some - -```re sig -let some: ((. elt) => bool, t) => bool; -``` - -## somei - -```re sig -let somei: ((. elt, int) => bool, t) => bool; -``` - -## \_BYTES_PER_ELEMENT - -```re sig -let _BYTES_PER_ELEMENT: int; -``` - -## make - -```re sig -let make: array(elt) => t; -``` - -## fromBuffer - -```re sig -let fromBuffer: Js_typed_array.array_buffer => t; -``` - -## fromBufferOffset - -```re sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t; -``` - -Can throw an exception. - -## fromBufferRange - -```re sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```re sig -let fromLength: int => t; -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```re sig -let from: Js_typed_array.array_like(elt) => t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/types.mdx b/pages/docs/manual/v8.0.0/api/js/types.mdx deleted file mode 100644 index 2d3965e65..000000000 --- a/pages/docs/manual/v8.0.0/api/js/types.mdx +++ /dev/null @@ -1,78 +0,0 @@ -# Types - - - -Provide utilities for manipulating JS types. - - - -## symbol - -```re sig -type symbol; -``` - -## obj_val - -```re sig -type obj_val; -``` - -## undefined_val - -```re sig -type undefined_val; -``` - -## null_val - -```re sig -type null_val; -``` - -## function_val - -```re sig -type function_val; -``` - -## t - -```re sig -type t('a) = - | Undefined: t(undefined_val) - | Null: t(null_val) - | Boolean: t(bool) - | Number: t(float) - | String: t(string) - | Function: t(function_val) - | Object: t(obj_val) - | Symbol: t(symbol); -``` - -## test - -```re sig -let test: ('a, t('b)) => bool; -``` - -## tagged_t - -```re sig -type tagged_t = - | JSFalse - | JSTrue - | JSNull - | JSUndefined - | JSNumber(float) - | JSString(string) - | JSFunction(function_val) - | JSObject(obj_val) - | JSSymbol(symbol); -``` - -## classify - -```re sig -let classify: 'a => tagged_t; -``` diff --git a/pages/docs/manual/v8.0.0/api/js/undefined.mdx b/pages/docs/manual/v8.0.0/api/js/undefined.mdx deleted file mode 100644 index 2bc30704f..000000000 --- a/pages/docs/manual/v8.0.0/api/js/undefined.mdx +++ /dev/null @@ -1,119 +0,0 @@ -# Undefined - - - -Provide utilities around `Js.undefined`. - - - -## t - -```re sig -type t('a) = Js.undefined('a); -``` - -Local alias for 'a Js.undefined. - -## return - -```re sig -let return: 'a => t('a); -``` - -Constructs a value of `Js.undefined('a)` containing a value of `'a`. - -## test - -```re sig -let test: t('a) => bool; -``` - -Returns `true` if the given value is empty (undefined), `false` otherwise. - -## testAny - -```re sig -let testAny: 'a => bool; -``` - -Since 1.6.1 Returns `true` if the given value is empty (undefined). - -## empty - -```re sig -let empty: t('a); -``` - -The empty value, `undefined`. - -## getUnsafe - -```re sig -let getUnsafe: t('a) => 'a; -``` - -## getExn - -```re sig -let getExn: t('a) => 'a; -``` - -## bind - -```re sig -let bind: (t('a), (. 'a) => 'b) => t('b); -``` - -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)`. - -```re example -let maybeGreetWorld = (maybeGreeting: Js.undefined(string)) => - Js.Undefined.bind(maybeGreeting, [@bs] greeting => greeting ++ " world!"); -``` - -## iter - -```re sig -let iter: (t('a), (. 'a) => unit) => unit; -``` - -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. - -```re example -let maybeSay = (maybeMessage: Js.undefined(string)) => - Js.Undefined.iter(maybeMessage, [@bs] message => Js.log(message)); -``` - -## fromOption - -```re sig -let fromOption: option('a) => t('a); -``` - -Maps `option('a)` to `Js.undefined('a)`. -`Some(a)` => `a` -`None` => `empty` - -## from_opt - -```re sig -let from_opt: option('a) => t('a); -``` - -## toOption - -```re sig -let toOption: t('a) => option('a); -``` - -Maps `Js.undefined('a)` to `option('a)` -`a` => `Some(a)` -`empty` => `None` - -## to_opt - -```re sig -let to_opt: t('a) => option('a); -``` diff --git a/pages/docs/manual/v8.0.0/api/js/vector.mdx b/pages/docs/manual/v8.0.0/api/js/vector.mdx deleted file mode 100644 index 1ceef1474..000000000 --- a/pages/docs/manual/v8.0.0/api/js/vector.mdx +++ /dev/null @@ -1,157 +0,0 @@ -# Vector - - - -Provide vector utilities. - - - -## t - -```re sig -type t('a) = array('a); -``` - -## filterInPlace - -```re sig -let filterInPlace: ((. 'a) => bool, t('a)) => unit; -``` - -p : predicate -a : array - -## empty - -```re sig -let empty: t('a) => unit; -``` - -## pushBack - -```re sig -let pushBack: ('a, t('a)) => unit; -``` - -## copy - -```re sig -let copy: t('a) => t('a); -``` - -Create a shallow copy of a vector. - -## memByRef - -```re sig -let memByRef: ('a, t('a)) => bool; -``` - -Find by JS (===) equality. - -## iter - -```re sig -let iter: ((. 'a) => unit, t('a)) => unit; -``` - -## iteri - -```re sig -let iteri: ((. int, 'a) => unit, t('a)) => unit; -``` - -## toList - -```re sig -let toList: t('a) => list('a); -``` - -## map - -```re sig -let map: ((. 'a) => 'b, t('a)) => t('b); -``` - -## mapi - -```re sig -let mapi: ((. int, 'a) => 'b, t('a)) => t('b); -``` - -## foldLeft - -```re sig -let foldLeft: ((. 'a, 'b) => 'a, 'a, t('b)) => 'a; -``` - -## foldRight - -```re sig -let foldRight: ((. 'b, 'a) => 'a, t('b), 'a) => 'a; -``` - -## length - -```re sig -let length: t('a) => int; -``` - -Return the length (number of elements) of the given array. - -## get - -```re sig -let get: (t('a), int) => 'a; -``` - -`Vector.get(a, n)` returns the element number `n` of vector `a`. The first element has number 0. The last element has number `Vector.length(a) - 1`. You can also write `a[n]` instead of `Vector.get(a, n)`. -Raise `Invalid_argument "index out of bounds"` if `n` is outside the range 0 to (`Array.length(a) - 1`). - -## set - -```re sig -let set: (t('a), int, 'a) => unit; -``` - -`Vector.set(a, n, x)` modifies vector `a` in place, replacing element number `n` with `x`. -Raise `Invalid_argument "index out of bounds"` if `n` is outside the range 0 to `Array.length(a) - 1`. - -## make - -```re sig -let make: (int, 'a) => t('a); -``` - -`Vector.make(n, x)` returns a fresh vector of length `n`, initialized with `x`. All the elements of this new vector are initially physically equal to `x` (in the sense of the `==` predicate). -Consequently, if `x` is mutable, it is shared among all elements of the array, and modifying `x` through one of the array entries will modify all other entries at the same time. -Raise `Invalid_argument` if `n < 0` or `n > Sys.max_array_length`. If the value of `x` is a floating-point number, then the maximum size is only `Sys.max_array_length / 2`. - -## init - -```re sig -let init: (int, (. int) => 'a) => t('a); -``` - -Raises `RangeError` when n is negative. -n : size - -## append - -```re sig -let append: ('a, t('a)) => t('a); -``` - -`append(x, a)` returns a fresh vector with `x` appended to `a`. - -## unsafe_get - -```re sig -let unsafe_get: (t('a), int) => 'a; -``` - -## unsafe_set - -```re sig -let unsafe_set: (t('a), int, 'a) => unit; -``` diff --git a/pages/docs/manual/v8.0.0/array-and-list.mdx b/pages/docs/manual/v8.0.0/array-and-list.mdx deleted file mode 100644 index 598fe9cda..000000000 --- a/pages/docs/manual/v8.0.0/array-and-list.mdx +++ /dev/null @@ -1,182 +0,0 @@ ---- -title: "Array & List" -description: "Arrays and List data structures" -canonical: "/docs/manual/latest/array-and-list" ---- - -# Array and List - -## Array - -Arrays are our main ordered data structure. They work the same way as JavaScript arrays: they can be randomly accessed, dynamically resized, updated, etc. - - - -```re -let myArray = [|"hello", "world", "how are you"|]; -``` - -```ml -let myArray = [|"hello"; "world"; "how are you"|] -``` - -```js -var myArray = ["hello", "world", "how are you"]; -``` - - - -ReScript arrays' items must have the same type, i.e. homogeneous. - -### Usage - -See the [Js.Array](api/js/array) API. - -Access & update an array item like so: - - - -```re -let myArray = [|"hello", "world", "how are you"|]; - -let firstItem = myArray[0]; // "hello" - -myArray[0] = "hey"; // now [|"hey", "world", "how are you"|] - -let pushedValue = Js.Array2.push(myArray, "bye"); -``` - -```ml -let myArray = [|"hello"; "world"; "how are you"|] - -let firstItem = myArray(0) (* "hello" *) - -let () = myArray.(0) <- "hey" (* now [|"hey"; "world"; "how are you"|] *) -``` - -```js -var myArray = ["hello", "world", "how are you"]; - -var firstItem = myArray[0]; - -myArray[0] = "hey"; - -var pushedValue = myArray.push("bye"); -``` - - - -## List - -ReScript provides a singly linked list too. Lists are: - -- immutable -- fast at prepending items -- fast at getting the tail -- slow at everything else - - - -```re -let myList = [1, 2, 3]; -``` - -```ml -let myList = [1; 2; 3] -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; -``` - - - -Like arrays, lists' items need to be of the same type. - -### Usage - -You'd use list for its resizability, its fast prepend (adding at the head), and its fast split, all of which are immutable and relatively efficient. - -Do **not** use list if you need to randomly access an item or insert at non-head position. Your code would end up obtuse and/or slow. - -The standard lib provides a [List module](api/belt/list). - -#### Immutable Prepend - -Use the spread syntax: - - - -```re -let myList = [1, 2, 3]; -let anotherList = [0, ...myList]; -``` - -```ml -let myList = [1; 2; 3] -let anotherList = 0 :: myList -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; - -var anotherList = { - hd: 0, - tl: myList, -}; -``` - - - -`myList` didn't mutate. `anotherList` is now `[0, 1, 2, 3]`. This is efficient (constant time, not linear). `anotherList`'s last 3 elements are shared with `myList`! - -**Note that `[a, ...b, ...c]` is a syntax error**. We don't support multiple spread for a list. That'd be an accidental linear operation (`O(b)`), since each item of b would be one-by-one added to the head of `c`. You can use `List.concat` for this, but we highly discourage it. - -Updating an arbitrary item in the middle of a list is also discouraged, since its performance and allocation overhead would be linear (`O(n)`). - -#### Access - -`switch` (described in the [pattern matching section](pattern-matching-destructuring.md)) is usually used to access list items: - - - -```re -let message = - switch myList { - | [] => "This list is empty" - | [a, ...rest] => "The head of the list is the string " ++ Js.Int.toString(a) - }; -``` - -```ml -let message = - match myList with - | [] -> "This list is empty" - | a::rest -> "The head of the list is the string " ^ (Js.Int.toString a) -``` - -```js -var message = myList - ? "The head of the list is the string " + (1).toString() - : "This list is empty"; -``` - - diff --git a/pages/docs/manual/v8.0.0/bind-to-global-js-values.mdx b/pages/docs/manual/v8.0.0/bind-to-global-js-values.mdx deleted file mode 100644 index 9d64fc58a..000000000 --- a/pages/docs/manual/v8.0.0/bind-to-global-js-values.mdx +++ /dev/null @@ -1,187 +0,0 @@ ---- -title: "Bind to Global JS Values" -description: "JS interop with global JS values in ReScript" -canonical: "/docs/manual/latest/bind-to-global-js-values" ---- - -# Bind to Global JS Values - -**First**, make sure the value you'd like to model doesn't already exist in our [provided API](api/js). - -Some JS values, like `setTimeout`, live in the global scope. You can bind to them like so: - - - -```re -[@bs.val] external setTimeout: (unit => unit, int) => float = "setTimeout"; -[@bs.val] external clearTimeout: float => unit = "clearTimeout"; -``` - -```ml -external setTimeout: (unit -> unit) -> int -> float = "setTimeout" [@@bs.val] -external clearTimeout: float -> unit = "clearTimeout" [@@bs.val] -``` - -```js -// Empty output -``` - - - -(We already provide `setTimeout`, `clearTimeout` and others in the [Js.Global](api/js/global) module). - -This binds to the JavaScript [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrworkerGlobalScope/setTimeout) methods and the corresponding `clearTimeout`. The `external`'s type annotation specifies that `setTimeout`: - -- Takes a function that accepts `unit` and returns `unit` (which on the JS side turns into a function that accepts nothing and returns nothing aka `undefined`), -- and an integer that specifies the duration before calling said function, -- returns a number that is the timeout's ID. This number might be big, so we're modeling it as a float rather than the 32-bit int. - -### Tips & Tricks - -**The above isn't ideal**. See how `setTimeout` returns a `float` and `clearTimeout` accepts one. There's no guarantee that you're passing the float created by `setTimeout` into `clearTimeout`! For all we know, someone might pass it `Math.random()` into the latter. - -We're in a language with a great type system now! Let's leverage a popular feature to solve this problem: abstract types. - - - -```re -type timerId; -[@bs.val] external setTimeout: (unit => unit, int) => timerId = "setTimeout"; -[@bs.val] external clearTimeout: timerId => unit = "clearTimeout"; - -let id = setTimeout(() => Js.log("hello"), 100); -clearTimeout(id); -``` - -```ml -type timerId -external setTimeout: (unit -> unit) -> int -> timerId = "setTimeout" [@@bs.val] -external clearTimeout: timerId -> unit = "clearTimeout" [@@bs.val] - -let id = setTimeout (fun () -> Js.log "hello") 100 -let () = clearTimeout id -``` - -```js -var id = setTimeout(function (param) { - console.log("hello"); -}, 100); - -clearTimeout(id); -``` - - - -Clearly, `timerId` is a type that can only be created by `setTimeout`! Now we've guaranteed that `clearTimeout` _will_ be passed a valid ID. Whether it's a number under the hood is now a mere implementation detail. - -Since `external`s are inlined, we end up with JS output as readable as hand-written JS. - -## Global Modules - -If you want to bind to a value inside a global module, e.g. `Math.random`, attach a `bs.scope` to your `bs.val` external: - - - -```re -[@bs.scope "Math"] [@bs.val] external random: unit => float = "random"; -let someNumber = random(); -``` - -```ml -external random : unit -> float = "random" [@@bs.scope "Math"][@@bs.val] -let someNumber = random () -``` - -```js -var someNumber = Math.random(); -``` - - - -you can bind to an arbitrarily deep object by passing a tuple to `bs.scope`: - - - -```re -[@bs.val] [@bs.scope ("window", "location", "ancestorOrigins")] -external length: int = "length"; -``` - -```ml -external length: int = "length" -[@@bs.val][@@bs.scope ("window", "location", "ancestorOrigins")] -``` - -```js -// Empty output -``` - - - -This binds to `window.location.ancestorOrigins.length`. - -## Special Global Values - -Global values like `__filename` and `__DEV__` don't always exist; you can't even model them as an `option`, since the mere act of referring to them in ReScript (then compiled into JS) would trigger the usual `Uncaught ReferenceError: __filename is not defined` error in e.g. the browser environment. - -For these troublesome global values, ReScript provides a special approach: `%external(a_single_identifier)`. - - - -```re -switch ([%external __DEV__]) { -| Some(_) => Js.log("dev mode") -| None => Js.log("production mode") -}; -``` - -```ml -let () = match [%external __DEV__] with -| Some _ -> Js.log "dev mode" -| None -> Js.log "production mode" -``` - -```js -var match = typeof __DEV__ === "undefined" ? undefined : __DEV__; - -if (match !== undefined) { - console.log("dev mode"); -} else { - console.log("production mode"); -} -``` - - - -That first line's `typeof` check won't trigger a JS ReferenceError. - -Another example: - - - -```re -switch ([%external __filename]) { -| Some(f) => Js.log(f) -| None => Js.log("non-node environment") -}; -``` - -```ml -let () = match [%external __filename] with -| Some f -> Js.log f -| None -> Js.log "non-node environment" -``` - -```js -var match = typeof __filename === "undefined" ? undefined : __filename; - -if (match !== undefined) { - console.log(match); -} else { - console.log("non-node environment"); -} -``` - - - - diff --git a/pages/docs/manual/v8.0.0/bind-to-js-function.mdx b/pages/docs/manual/v8.0.0/bind-to-js-function.mdx deleted file mode 100644 index 09b23d5e5..000000000 --- a/pages/docs/manual/v8.0.0/bind-to-js-function.mdx +++ /dev/null @@ -1,630 +0,0 @@ ---- -title: "Bind to JS Function" -description: "JS interop with functions in ReScript" -canonical: "/docs/manual/latest/bind-to-js-function" ---- - -# Function - -Binding a JS function is like binding any other value: - - - -```re -// Import nodejs' path.dirname -[@bs.module "path"] external dirname: string => string = "dirname"; -let root = dirname("/User/github"); // returns "User" -``` - -```ml -(* Import nodejs' path.dirname *) -external dirname: string -> string = "dirname" [@@bs.module "path"] -let root = dirname "/User/github" (* returns "User" *) -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - - - -We also expose a few special features, described below. - -## Labeled Arguments - -ReScript has [labeled arguments](function.md#labeled-arguments) (that can also be optional). These work on an `external` too! You'd use them to _fix_ a JS function's unclear usage. Assuming we're modeling this: - -```js -// MyGame.js - -function draw(x, y, border) { - // suppose `border` is optional and defaults to false -} -draw(10, 20); -draw(20, 20, true); -``` - -It'd be nice if on ReScript's side, we can bind & call `draw` while labeling things a bit: - - - -```re -[@bs.module "MyGame"] -external draw: (~x: int, ~y: int, ~border: bool=?, unit) => unit = "draw"; - -draw(~x=10, ~y=20, ~border=true, ()); -draw(~x=10, ~y=20, ()); -``` - -```ml -external draw: x:int -> y:int -> ?border:bool -> unit -> unit = "draw" -[@@bs.module "MyGame"] - -let () = draw ~x:10 ~y:20 ~border:true () -let () = draw ~x:10 ~y:20 () -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, true); -MyGame.draw(10, 20, undefined); -``` - - - -We've compiled to the same function, but now the usage is much clearer on the ReScript side thanks to labels! - -**Note**: in this particular case, you need a unit, `()` after `border`, since `border` is an [optional argument at the last position](function.md#optional-labeled-arguments). Not having a unit to indicate you've finished applying the function would generate a warning. - -Note that you can change the order of labeled arguments on the ReScript side and BuckleScript will ensure that they appear the right way in the JavaScript output: - - - -```re -[@bs.module "MyGame"] -external draw: (~x: int, ~y: int, ~border: bool=?, unit) => unit = "draw"; - -draw(~x=10, ~y=20, ()); -draw(~y=20, ~x=10, ()); -``` - -```ml -external draw: x:int -> y:int -> ?border:bool -> unit -> unit = "draw" -[@@bs.module "MyGame"] - -let () = draw ~x:10 ~y:20 () -let () = draw ~y:20 ~x:10 () -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, undefined); -MyGame.draw(10, 20, undefined); -``` - - - -## Object Method - -Functions attached to JS objects (other than JS modules) require a special way of binding to them, using `bs.send`: - - - -```re -type document; // abstract type for a document object -[@bs.send] external getElementById: (document, string) => Dom.element = "getElementById"; -[@bs.val] external doc: document = "document"; - -let el = getElementById(doc, "myId"); -``` - -```ml -type document (* abstract type for a document object *) -external getElementById: document -> string -> Dom.element = "getElementById" [@@bs.send] -external doc: document = "document" [@@bs.val ] - -let el = getElementById doc "myId" -``` - -```js -var el = document.getElementById("myId"); -``` - - - -In a `bs.send`, the object is always the first argument. Actual arguments of the method follow (this is a bit what modern OOP objects are really). - -### Chaining - -Ever used `foo().bar().baz()` chaining ("fluent api") in JS OOP? We can model that in BuckleScript too, through the [pipe operator](pipe.md). - -## Variadic Function Arguments - -You might have JS functions that take an arbitrary amount of arguments. BuckleScript supports modeling those, under the condition that the arbitrary arguments part is homogenous (aka of the same type). If so, add `bs.variadic` to your `external`. - - - -```re -[@bs.module "path"] [@bs.variadic] -external join: array(string) => string = "join"; - -let v = join([|"a", "b"|]); -``` - -```ml -external join : string array -> string = "join" -[@@bs.module "path"][@@bs.variadic] - -let v = join [|"a"; "b"|] -``` - -```js -var Path = require("path"); -var v = Path.join("a", "b"); -``` - - - -`bs.module` will be explained in [Import from/Export to JS](import-from-export-to-js.md). - -## Modeling Polymorphic Function - -Apart from the above special-case, JS function in general are often arbitrary overloaded in terms of argument types and number. How would you bind to those? - -### Trick 1: Multiple `external`s - -If you can exhaustively enumerate the many forms an overloaded JS function can take, simply bind to each differently: - - - -```re -[@bs.module "MyGame"] external drawCat: unit => unit = "draw"; -[@bs.module "MyGame"] external drawDog: (~giveName: string) => unit = "draw"; -[@bs.module "MyGame"] external draw: (string, ~useRandomAnimal: bool) => unit = "draw"; -``` - -```ml -external drawCat: unit -> unit = "draw" [@@bs.module "MyGame"] -external drawDog: giveName:string -> unit = "draw" [@@bs.module "MyGame"] -external draw: string -> useRandomAnimal:bool -> unit = "draw" [@@bs.module "MyGame"] -``` - -```js -// Empty output -``` - - - -Note how all three externals bind to the same JS function, `draw`. - -### Trick 2: Polymorphic Variant + `bs.unwrap` - -If you have the irresistible urge of saying "if only this JS function argument was a variant instead of informally being either `string` or `int`", then good news: we do provide such `external` features through annotating a parameter as a polymorphic variant! Assuming you have the following JS function you'd like to bind to: - -```js -function padLeft(value, padding) { - if (typeof padding === "number") { - return Array(padding + 1).join(" ") + value; - } - if (typeof padding === "string") { - return padding + value; - } - throw new Error(`Expected string or number, got '${padding}'.`); -} -``` - -Here, `padding` is really conceptually a variant. Let's model it as such. - - - -```re -[@bs.val] -external padLeft: ( - string, - [@bs.unwrap] [ - | `Str(string) - | `Int(int) - ]) - => string = "padLeft"; - -padLeft("Hello World", `Int(4)); -padLeft("Hello World", `Str("Message from ReScript: ")); -``` - -```ml -external padLeft: - string -> - (([ - | `Str of string - | `Int of int - ]) [@bs.unwrap]) -> - string = "padLeft" [@@bs.val] - -let _ = padLeft "Hello World" (`Int 4) -let _ = padLeft "Hello World" (`Str "Message from ReScript: ") -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -Obviously, the JS side couldn't have an argument that's a polymorphic variant! But here, we're just piggy backing on poly variants' type checking and syntax. The secret is the `@bs.unwrap` annotation on the type. It strips the variant constructors and compile to just the payload's value. See the output. - -## Constrain Arguments Better - -Consider the Node `fs.readFileSync`'s second argument. It can take a string, but really only a defined set: `"ascii"`, `"utf8"`, etc. You can still bind it as a string, but we can use poly variants + `bs.string` to ensure that our usage's more correct: - - - -```re -[@bs.module "fs"] -external readFileSync: ( - ~name: string, - [@bs.string] [ - | `utf8 - | [@bs.as "ascii"] `useAscii - ], -) => string = "fs"; - -readFileSync(~name="xx.txt", `useAscii); -``` - -```ml -external readFileSync: - name:string -> - (([ - | `utf8 - | `useAscii [@bs.as "ascii"] - ]) [@bs.string]) -> - string = "fs" -[@@bs.module "fs"] - -let _ = readFileSync ~name:"xx.txt" `useAscii -``` - -```js -var Fs = require("fs"); -Fs.readFileSync("xx.txt", "ascii"); -``` - - - -- Attaching `[@bs.string]` to the whole poly variant type makes its constructor compile to a string of the same name. -- Attaching a `[@bs.as "bla"]` to a constructor lets you customize the final string. - -And now, passing something like `"myOwnUnicode"` or other variant constructor names to `readFileSync` would correctly error. - -Aside from string, you can also compile an argument to an int, using `bs.int` instead of `bs.string` in a similar way: - - - -```re -[@bs.val] -external testIntType: ( - [@bs.int] [ - | `onClosed - | [@bs.as 20] `onOpen - | `inBinary - ]) - => int = "testIntType"; -testIntType(`inBinary); -``` - -```ml -external testIntType: (([ - | `onClosed - | `onOpen [@bs.as 20] - | `inBinary - ]) [@bs.int]) -> - int = "testIntType" [@@bs.val] - -let _ = testIntType `inBinary -``` - -```js -testIntType(21); -``` - - - -`onClosed` compiles to `0`, `onOpen` to `20` and `inBinary` to **`21`**. - -## Special-case: Event Listeners - -One last trick with polymorphic variants: - - - -```re -type readline; - -[@bs.send] -external on: ( - readline, - [@bs.string] [ - | `close(unit => unit) - | `line(string => unit) - ] - ) - => readline = "on"; - -let register = rl => - rl - ->on(`close(event => ())) - ->on(`line(line => Js.log(line))); -``` - -```ml -type readline - -external on: - readline -> - (([ - | `close of unit -> unit - | `line of string -> unit - ]) [@bs.string]) -> - readline = "on" [@@bs.send] - -let register rl = - rl - |. on (`close (fun event -> ())) - |. on (`line (fun line -> Js.log line)) -``` - -```js -function register(rl) { - return rl - .on("close", function ($$event) {}) - .on("line", function (line) { - console.log(line); - }); -} -``` - - - - - -## Fixed Arguments - -Sometimes it's convenient to bind to a function using an `external`, while passing predetermined argument values to the JS function: - - - -```re -[@bs.val] -external processOnExit: ( - [@bs.as "exit"] _, - int => unit -) => unit = "process.on"; - -processOnExit(exitCode => - Js.log("error code: " ++ Js.Int.toString(exitCode)) -); -``` - -```ml -external processOnExit: - (_ [@bs.as "exit"]) -> - (int -> unit) -> - unit = "process.on" -[@@bs.val] - -let () = processOnExit (fun exitCode -> - Js.log ("error code: " ^ (Js.Int.toString exitCode)) -) -``` - -```js -process.on("exit", function (exitCode) { - console.log("error code: " + exitCode.toString()); -}); -``` - - - -The `[@bs.as "exit"]` and the placeholder `_` argument together indicates that you want the first argument to compile to the string `"exit"`. You can also use any JSON literal with `bs.as`: `[@bs.as {json|true|json}]`, `[@bs.as {json|{"name": "John"}|json}]`, etc. - -## Curry & Uncurry - -Curry is a delicious Indian dish. More importantly, in the context of ReScript (and functional programming in general), currying means that function taking multiple arguments can be applied a few arguments at time, until all the arguments are applied. - -See the `addFive` intermediate function? `add` takes in 3 arguments but received only 1. It's interpreted as "currying" the argument `5` and waiting for the next 2 arguments to be applied later on. Type signatures: - - - -```rei -let add: (int, int, int) => int; -let addFive: (int, int) => int; -let twelve: int; -``` - -```mli -val add: (int * int * int) => int -val addFive: (int * int) => int -val twelve: int -``` - - - -(In a dynamic language such as JS, currying would be dangerous, since accidentally forgetting to pass an argument doesn't error at compile time). - -### Drawback - -Unfortunately, due to JS not having currying because of the aforementioned reason, it's hard for ReScript multi-argument functions to map cleanly to JS functions 100% of the time: - -1. When all the arguments of a function are supplied (aka no currying), ReScript does its best to to compile e.g. a 3-arguments call into a plain JS call with 3 arguments. - -2. If it's too hard to detect whether a function application is complete\*, ReScript will use a runtime mechanism (the `Curry` module) to curry as many args as we can and check whether the result is fully applied. - -3. Some JS APIs like `throttle`, `debounce` and `promise` might mess with context, aka use the function `bind` mechanism, carry around `this`, etc. Such implementation clashes with the previous currying logic. - -\* If the call site is typed as having 3 arguments, we sometimes don't know whether it's a function that's being curried, or if the original one indeed has only 3 arguments. - -ReScript tries to do #1 as much as it can. Even when it bails and uses #2's currying mechanism, it's usually harmless. - -**However**, if you encounter #3, heuristics are not good enough: you need a guaranteed way of fully applying a function, without intermediate currying steps. We provide such guarantee through the use of the `@bs` "uncurrying" annotation on a function declaration & call site. - -### Solution: Use Guaranteed Uncurrying - -[Uncurried function](function.md#uncurried-function) annotation also works on `external`: - - - -```re -type timerId; -[@bs.val] external setTimeout: ((. unit) => unit, int) => timerId = "setTimeout"; - -let id = setTimeout((.) => Js.log("hello"), 1000); -``` - -```ml -type timerId -external setTimeout: ((unit -> unit) [@bs]) -> int -> timerId = "setTimeout" [@@bs.val] - -let id = setTimeout ((fun () -> Js.log "hello") [@bs]) 1000 -``` - -```js -var id = setTimeout(function () { - console.log("hello"); -}, 1000); -``` - - - -#### Extra Solution - -The above solution is safe, guaranteed, and performant, but sometimes visually a little burdensome. We provide an alternative solution if: - -- you're using `external` -- the `external` function takes in an argument that's another function -- you want the user **not** to need to annotate the call sites with the dot - - - -Then try `@bs.uncurry`: - - - -```re -[@bs.send] external map: (array('a), [@bs.uncurry] ('a => 'b)) => array('b) = "map"; -map([|1, 2, 3|], x => x + 1); -``` - -```ml -external map: 'a array -> (('a -> 'b) [@bs.uncurry]) -> 'b array = "map" [@@bs.send] -let _ = map [|1; 2; 3|] (fun x -> x + 1) -``` - -```js -// Empty output -``` - - - -In general, `bs.uncurry` is recommended; the compiler will do lots of optimizations to resolve the currying to uncurrying at compile time. However, there are some cases the compiler can't optimize it. In these cases, it will be converted to a runtime check. - -## Modeling `this`-based Callbacks - -Many JS libraries have callbacks which rely on this (the source), for example: - -```js -x.onload = function (v) { - console.log(this.response + v); -}; -``` - -Here, `this` would point to `x` (actually, it depends on how `onload` is called, but we digress). It's not correct to declare `x.onload` of type `(. unit) -> unit`. Instead, we introduced a special attribute, `bs.this`, which allows us to type `x` as so: - - - -```re -type x; -[@bs.val] external x: x = "x"; -[@bs.set] external setOnload: (x, [@bs.this] ((x, int) => unit)) => unit = "onload"; -[@bs.get] external resp: x => int = "response"; -setOnload(x, [@bs.this] ((o, v) => Js.log(resp(o) + v))); -``` - -```ml -type x -external x: x = "x" [@@bs.val] -external setOnload: x -> ((x -> int -> unit) [@bs.this]) -> unit = "onload" [@@bs.set] -external resp: x -> int = "response" [@@bs.get] -let _ = setOnload x ((fun o v -> Js.log ((resp o) + v)) [@bs.this]) -``` - -```js -x.onload = function (v) { - var o = this; - console.log((o.response + v) | 0); -}; -``` - - - -`bs.this` has its first parameter is reserved for `this` and for arity of 0, there is no need for a redundant `unit` type. - -## Function Nullable Return Value Wrapping - -For JS functions that return a value that can also be `undefined` or `null`, we provide `[@bs.return ...]`. To automatically convert that value to an `option` type (recall that ReScript `option` type's `None` value only compiles to `undefined` and not `null`). - - - -```re -type element; -type dom; - -[@bs.send] [@bs.return nullable] -external getElementById: (dom, string) => option(element) = "getElementById"; - -let test = dom => { - let elem = dom->(getElementById("haha")) - switch (elem) { - | None => 1 - | Some(_ui) => 2 - } -}; -``` - -```ml -type element -type dom -external getElementById : dom -> string -> element option = "getElementById" -[@@bs.send][@@bs.return nullable] - -let test dom = - let elem = dom |. (getElementById "haha") in - match elem with - | None -> 1 - | Some _ui -> 2 -``` - -```js -function test(dom) { - var elem = dom.getElementById("haha"); - if (elem == null) { - return 1; - } else { - console.log(elem); - return 2; - } -} -``` - - - -`bs.return(nullable)` attribute will automatically convert `null` and `undefined` to `option` type. - -Currently 4 directives are supported: `null_to_opt`, `undefined_to_opt`, `nullable` and `identity`. - - - -`identity` will make sure that compiler will do nothing about the returned value. It is rarely used, but introduced here for debugging purpose. diff --git a/pages/docs/manual/v8.0.0/bind-to-js-object.mdx b/pages/docs/manual/v8.0.0/bind-to-js-object.mdx deleted file mode 100644 index c5952aac0..000000000 --- a/pages/docs/manual/v8.0.0/bind-to-js-object.mdx +++ /dev/null @@ -1,215 +0,0 @@ ---- -title: "Bind to JS Object" -description: "Interop with JS objects in ReScript" -canonical: "/docs/manual/latest/bind-to-js-object" ---- - -# Bind to JS Object - -JavaScript objects are a combination of several use-cases: - -- As a "record" or "struct" in other languages (like ReScript and C). -- As a hash map. -- As a class. -- As a module to import/export. - -ReScript cleanly separates the binding methods for JS object based on these 4 use-cases. This page documents the first three. Binding to JS module objects is described in the [Import from/Export to JS](import-from-export-to-js.md) section. - - - -## Bind to Record-like JS Objects - -### Bind Using ReScript Record - -If your JavaScript object has fixed fields, then it's conceptually like a ReScript record. Since a ReScript record compiles to a clean JavaScript object, you can definitely type a JS object as a ReScript record! - - - -```re -type person = { - name: string, - friends: array(string), - age: int, -}; - -[@bs.module "MySchool"] external john: person = "john"; - -let johnName = john.name; -``` - -```ml -type person = { - name: string; - friends: string array; - age: int; -} - -external john: person = "john" [@@bs.module "MySchool"] - -let johnName = john.name -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -External is documented [here](external.md). `@bs.module` is documented [here](import-from-export-to-js.md). - -### Bind Using ReScript Object - -Alternatively, you can use [ReScript object](object.md) to model a JS object too: - - - -```re -type person = { - . - "name": string, - "friends": array(string), - "age": int, -}; - -[@bs.module "MySchool"] external john: person = "john"; - -let johnName = john##name; -``` - -```ml -type person = < - name: string; - friends: string array; - age: int -> Js.t - -external john: person = "john" [@@bs.module "MySchool"] - -let johnName = ## john name -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -### Bind Using Special `@bs` Getters & Setters - -Alternatively, you can use `bs.get` and `bs.set` to bind to individual fields of a JS object: - - - -```re -type textarea; -[@bs.set] external setName: (textarea, string) => unit = "name"; -[@bs.get] external getName: textarea => string = "name"; -``` - -```ml -type textarea; -external setName: textarea -> string -> unit = "name" [@@bs.set] -external getName: textarea -> string = "name" [@@bs.get] -``` - -```js - -``` - - - -You can also use `bs.get_index` and `bs.set_index` to access a dynamic property or an index: - - - -```re -type t; -[@bs.new] external create: int => t = "Int32Array"; -[@bs.get_index] external get: (t, int) => int = ""; -[@bs.set_index] external set: (t, int, int) => unit = ""; - -let i32arr = create(3); -i32arr->set(0, 42); -Js.log(i32arr->get(0)); -``` - -```ml -type t -external create: int -> t = "Int32Array" [@@bs.new] -external get: t -> int -> int = "" [@@bs.get_index] -external set: t -> int -> int -> unit = "" [@@bs.set_index] - -let i32arr = create 3 -let () = i32arr |. (set 0 42) -let () = Js.log (i32arr |. (get 0)) -``` - -```js -var i32arr = new Int32Array(3); -i32arr[0] = 42; -console.log(i32arr[0]); -``` - - - -## Bind to Hash Map-like JS Object - -If your JavaScript object: - -- might or might not add/remove keys -- contains only values that are of the same type - -Then it's not really an object, it's a hash map. Use [Js.Dict](api/js/dict), which contains operations like `get`, `set`, etc. and cleanly compiles to a JavaScript object still. - -## Bind to a JS Object That's a Class - -Use `bs.new` to emulate e.g. `new Date()`: - - - -```re -type t; -[@bs.new] external createDate: unit => t = "Date"; - -let date = createDate(); -``` - -```ml -type t -external createDate: unit -> t = "Date" [@@bs.new] - -let date = createDate () -``` - -```js -var date = new Date(); -``` - - - -You can chain `bs.new` and `bs.module` if the JS module you're importing is itself a class: - - - -```re -type t; -[@bs.new] [@bs.module] external book: unit => t = "Book"; -let myBook = book(); -``` - -```ml -type t -external book: unit -> t = "Book" [@@bs.new][@@bs.module] -let myBook = book () -``` - -```js -var Book = require("Book"); -var myBook = new Book(); -``` - - diff --git a/pages/docs/manual/v8.0.0/browser-support-polyfills.mdx b/pages/docs/manual/v8.0.0/browser-support-polyfills.mdx deleted file mode 100644 index c1de7a491..000000000 --- a/pages/docs/manual/v8.0.0/browser-support-polyfills.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: "Browser Support & Polyfills" -description: "Note on browser support in ReScript" -canonical: "/docs/manual/latest/browser-support-polyfills" ---- - -# Browser Support & Polyfills - -ReScript compiles to JavaScript **ES5**, with the exception of optionally allowing to compile to ES6's module import & export. - -For [old browsers](https://caniuse.com/#search=typed%20array), you also need to polyfill TypedArray. The following standard library functions require it: - -- `Int64.float_of_bits` -- `Int64.bits_of_float` -- `Int32.float_of_bits` -- `Int32.bits_of_float` - -If you don't use these functions, you're fine. Otherwise, it'll be a runtime failure. diff --git a/pages/docs/manual/v8.0.0/build-configuration.mdx b/pages/docs/manual/v8.0.0/build-configuration.mdx deleted file mode 100644 index 4d7938592..000000000 --- a/pages/docs/manual/v8.0.0/build-configuration.mdx +++ /dev/null @@ -1,179 +0,0 @@ ---- -title: "Build System Configuration" -description: "Details about the configuration of the ReScript build system (bsconfig.json)" -canonical: "/docs/manual/latest/build-configuration" ---- - -# Configuration - -`bsconfig.json` is the single, mandatory build meta file needed for bsb. - -**The complete configuration schema is [here](https://bucklescript.github.io/bucklescript/docson/#build-schema.json)**. We'll _non-exhaustively_ highlight the important parts in prose here. - -## name, namespace - -`name` is the name of the library, used as its "namespace". You can activate namespacing through `"namespace": true` in your `bsconfig.json`. Namespacing is almost **mandatory**; we haven't turned it on by default yet to preserve backward-compatibility. - -**Explanation**: by default, your files, once used as a third-party dependency, are available globally to the consumer. E.g. if you have an `Util.re` and the consumer also has a file of the same name, they will clash. Turning on `namespace` avoids this by wrapping all your own project's files into an extra module layer; instead of a global `Util` module, the consumer will see you as `MyProject.Util`. **The namespacing affects your consumers, not yourself**. - -Aka, in Bsb, "namespace" is just a fancy term for an auto-generated module that wraps all your project's files (efficiently and correctly, of course!) for third-party consumption. - -We don't do folder-level namespacing for your own project; all your own file names must be unique. This is a constraint that enables several features such as fast search and easier project reorganization. - -**Note**: the `bsconfig.json` `name` should be the same as the `package.json` `name`, to avoid confusing corner-cases. However, this means that you can't use a camelCased names such as `MyProject`, since `package.json` and npm forbid you to do so (some file systems are case-insensitive). To have the namespace/module as `MyProject`, write `"name": "my-project"`. Bsb will turn that into the camelCased name correctly. - -**Note on custom namespacing**: if for some reason, you need a namespace that is different from what your `name` will produce, you can directly send a string to the `namespace` option. For example, if your package is a binding named `bs-some-thing`, you can use `"namespace": "some-thing"` to get `SomeThing` namespace instead of `BsSomeThing`. - -## sources - -Your source files need to be specified explicitly (we don't want to accidentally drill down into some unrelated directories). Examples: - -```json -{ - "sources": ["src", "examples"] -} -``` - -```json -{ - "sources": { - "dir": "src", - "subdirs": ["page"] - } -} -``` - -```json -{ - "sources": [ - "examples", - { - "dir": "src", - "subdirs": true // recursively builds every subdirectory - } - ] -} -``` - -You can mark your directories as dev-only (for e.g. tests). These won't be built and exposed to third-parties, or even to other "dev" directories in the same project: - -```json -{ - "sources": { - "dir": "test", - "type": "dev" - } -} -``` - -## bs-dependencies, bs-dev-dependencies - -List of ReScript dependencies. Just like `package.json`'s dependencies, they'll be searched in `node_modules`. - -Note that only sources marked with `"type":"dev"` will be able to resolve modules from `bs-dev-dependencies`. - -## reason, refmt (old) - -`reason` config is enabled by default. To turn on JSX for [ReasonReact](https://reasonml.github.io/reason-react/en/), specify: - -```json -{ - "reason": { "react-jsx": 3 }, - "refmt": 3 -} -``` - -The `refmt` config **should be explicitly specified** as `3`. - -## js-post-build - -Hook that's invoked every time a file is recompiled. Good for JS build system interop, but please use it **sparingly**. Calling your custom command for every recompiled file slows down your build and worsens the building experience for even third-party users of your lib. - -Example: - -```json -{ - "js-post-build": { - "cmd": "/path/to/node ../../postProcessTheFile.js" - } -} -``` - -Note that the command's path resolution is done through the following: - -- `/myCommand` is resolved into `/myCommand` -- `myCommand/` is resolved into `node_modules/myCommand` -- `./myCommand` is resolved into `myProjectRoot/myCommand` -- `myCommand` is just called as `myCommand`. But note that Bsb doesn't read into your environment, so if you put `node`, it won't find it unless you specify an absolute path. Alternatively, point to a script that has the header `#!/usr/local/bin/node`. - -The command itself is called from inside `lib/bs`. - -## package-specs - -Output to either CommonJS (the default) or ES6 modules. Example: - -```json -{ - "package-specs": { - "module": "commonjs", - "in-source": true - } -} -``` - -- `"module": "es6-global"` resolves `node_modules` using relative paths. Good for development-time usage of ES6 in conjunction with browsers like Safari and Firefox that support ES6 modules today. **No more dev-time bundling**! -- `"in-source": true` generates output alongside source files. If you omit it, it'll generate the artifacts into `lib/js`. The output directory is not configurable otherwise. - -This configuration only applies to you, when you develop the project. When the project is used as a third-party library, the consumer's own `bsconfig.json` `package-specs` overrides the configuration here, logically. - -## suffix - -Either `".js"` or `".bs.js"`. Strongly prefer the latter. - -### Design Decisions - -Generating JS files with the `.bs.js` suffix means that, on the JS side, you can do `const myReScriptFile = require('./theFile.bs')`. The benefits: - -- It's immediately clear that we're dealing with a generated JS file here. -- It avoids clashes with a potential `theFile.js` file in the same folder. -- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**. -- The `.bs.js` suffix [lets bsb track JS artifacts much better](build-overview.md#tips-tricks). - -## warnings - -Selectively turn on/off certain warnings and/or turn them into hard errors. Example: - -```json -{ - "warnings": { - "number": "-44-102", - "error": "+5" - } -} -``` - -Turn off warning `44` and `102` (polymorphic comparison). Turn warning `5` (partial application whose result has function type and is ignored) into a hard error. - -The warning number are shown in the build output when they're triggered. The complete list is [here](https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec281), a little bit below. `100` and up are ReScript-specific. - -## bsc-flags - -Extra flags to pass to the underlying `bsc` call. Notably: `["-bs-super-errors"]` for turning on cleaner error output. No need to pass this flag for a new ReScript project; it's enabled by default. - -## Environment Variables - -We heavily disrecommend the usage of environment variables, but for certain cases, they're justified. - -### Error Output Coloring: `NINJA_ANSI_FORCED` - -This is mostly for other programmatic usage of `bsb` where outputting colors is not desired. - -When `NINJA_ANSI_FORCED` is set to `1`: `bsb` produces color. -When `NINJA_ANSI_FORCED` is set to `0`: `bsb` doesn't produce color. -When `NINJA_ANSI_FORCED` is not set: `bsb` might or might not produce color, depending on a smart detection of where it's outputted. - -> Note that bsc, the barebone compiler, will always be passed `-color always`. See more details in [this issue](https://github.com/rescript-lang/rescript/issues/2984#issuecomment-410669163). - -### BS_VSCODE error output adapted for VSCODE - -If you run bsb under VSCODE task runner like [this](https://github.com/rescript-lang/rescript/blob/master/jscomp/bsb/templates/basic-reason/.vscode/tasks.json#L6), it is recommended to have BS_VSCODE set diff --git a/pages/docs/manual/v8.0.0/build-overview.mdx b/pages/docs/manual/v8.0.0/build-overview.mdx deleted file mode 100644 index 8dd1ab754..000000000 --- a/pages/docs/manual/v8.0.0/build-overview.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: "Build System Overview" -description: "Documentation about the ReScript build system and its toolchain" -canonical: "/docs/manual/latest/build-overview" ---- - -# Build System Overview - -ReScript comes with a build system, bsb, that's meant to be fast, lean and used as the authoritative build system of the community. - -Bsb provides a few templates to quickly start a new project: - -```sh -bsb -init my-directory-name -``` - -Feel free to inspect the various files in the newly generated directory. To see all the templates available, do: - -```sh -bsb -themes -``` - -The build description file is called `bsconfig.json`. Every ReScript project needs one. - -**To build a project**, run: - -```sh -bsb -make-world -``` - -Add `-w` to keep the built-in watcher running. Any new file change will be picked up and the build will re-run. - -**Note**: third-party libraries (in `node_modules`) aren't watched, as doing so may exceed the node.js watcher count limit. If you're doing quick and dirty modifications inside `node_modules`, you have to do `bsb -clean-world -make-world` to rebuild them. - -**Note 3**: If you are developing across multiple devices, you may find the `-ws` configuration useful in order to have live-reloading across the network. Possible configurations are: - -- `bsb -make-world -w -ws _` (default) -- `bsb -make-world -w -ws 0.0.0.0:9999` -- `bsb -make-world -w -ws 5000` - -**To build only yourself**, use `bsb -make`. - -`bsb -help` to see all the available options. - -## Artifacts Cleaning - -If you ever get into a stable build for edge-case reasons, use: - -```sh -bsb -clean-world -``` - -Or `bsb -clean` to clean only your own artifacts. - -## Editor Support - -Bsb generates a `.merlin` file, used by various [editor plugins](editor-plugins.md) under the hood to power e.g. autocomplete, type hint, diagnosis, etc. - -### Tips & Tricks - -A typical problem with traditional build systems is that they're not resilient against the user moving/deleting source files. Most don't clean up the old artifacts correctly after such user action\*. Bsb is unfortunately no different, **unless** you turn on `"suffix": ".bs.js"` in `bsconfig.json`, in which case we can track which JS artifact belongs to which source file correctly, even against source file moving/deletion. - -## Design Decisions - -\* One such build system that tracks these correctly & efficiently is [Tup](http://gittup.org/tup/). See the (rather accessible!) paper [here](http://gittup.org/tup/build_system_rules_and_algorithms.pdf). Unfortunately, Tup's implementation uses FUSE and other systems, which we can't safely use on every platform. diff --git a/pages/docs/manual/v8.0.0/build-performance.mdx b/pages/docs/manual/v8.0.0/build-performance.mdx deleted file mode 100644 index 107a7f104..000000000 --- a/pages/docs/manual/v8.0.0/build-performance.mdx +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: "Build Performance" -description: "ReScript build performance and measuring tools" -canonical: "/docs/manual/latest/build-performance" ---- - -# Build Performance - -ReScript considers performance at install time, build time and run time as a serious feature. Here are some more info, and tips on keeping the build fast. **Feel free to skip this section** if you're just starting out. - -## Profile Your Build - -Sometime your build can be slow due to some confused infra setups. We provide an interactive visualization of your build's performance via `bstracing`: - -```sh -./node_modules/.bin/bstracing -``` - -Run the above command at your ReScript project's root; it'll spit out a JSON file you can drag and drop into `chrome://tracing`. - -import Image from "src/components/Image"; - - - -## Under the Hood - -Bsb itself uses a build system under the hood, called [Ninja](https://ninja-build.org). Ninja is like Make, but cross-platform, minimal, focuses in perf and destined to be more of a low-level building block than a full-blown build system. In this regard, Ninja's a great implementation detail for bsb. - -Bsb reads into `bsconfig.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level `bsc`-related commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build. - -## The JS Wrapper - -`bsb` itself is a Node.js wrapper which takes care of some miscellaneous tasks, plus the watcher. The lower-level, watcher-less, true `bsb` is called `bsb.exe`. It can be located in the same directory as where `bsb` is found: - -```sh -> bsb -where -/usr/local/lib/node_modules/bs-platform/lib -``` - -The path varies across systems. - -If you don't need the watcher, you can run said `bsb.exe`: `/usr/local/lib/node_modules/bs-platform/lib/bsb.exe`. This side-steps the node.js startup time, which can be big (in the order of `100ms`). - -## Numbers - -Raw `bsb.exe` build on a small project should be around `70ms`. This doubles when you use the more common `bsb` wrapper which comes with a watcher, which is practically faster since you don't manually run the build at every change (though you should opt for the raw `bsb.exe` for programmatic usage, e.g. inserting bsb into your existing JS build pipeline). - -No-op build (when no file's changed) should be around `15ms`. Incremental rebuild (described soon) of a single file in a project is around `70ms` too. - -Cleaning the artifacts should be instantaneous. - -### Extreme Test - -We've stress-tested bsb on a big project of 10,000 files (2 directories, 5000 files each, first 5000 no dependencies, last 5000 10 dependencies on files from the former directory) using https://github.com/ocaml-omake/omake/blob/perf-test/performance/generate.ml, on Retina Macbook Pro Early 2015 (3.1 GHz Intel Core i7). - - - -- No-op build of 10k files: `800ms` (the minimum amount of time required to check the mtimes of 10k files). -- Clean build: \<3 minutes. -- Incremental build: depends on the number of the dependents of the file. No dependent means `1s`. - -Note that bsb is a file-based build system. We don't do in-memory build, even if that speeds up the build a lot. In-memory builds risk memory leaks, out-of-memory errors and others. The bsb watcher, on the other hand, can stay open for days. - -## Incrementality - -Bsb doesn't take whole seconds to run every time. The bulk of the build performance comes from incremental build, aka re-building a previously built project when a few files changed. - -In short, thanks to our bsc compiler and bsb build system's architecture, we're able to **only build what's needed**. E.g. if `MyFile.res` isn't changed, then it's not recompiled. You can roughly emulate such incrementality in languages like JavaScript, but the degree of correctness is unfortunately low. For example, if you rename or move a JS file, then the watcher might get confused and not pick up the "new" file or fail to clean things up correctly, resulting in you needing to clean your build and restart anew, which defeats the purpose. - -## Speed Up Incremental Build - -ReScript uses the concept of interface files (`.rei`) (or, equivalently, [module signatures](module.md#signatures)). Exposing only what you need naturally speeds up incremental builds. E.g. if you change a `.re` file whose corresponding `.rei` file doesn't expose the changed part, then you've reduced the amount of dependent files you have to rebuild. - - - -## Programmatic Usage - -Unfortunately, JS build systems are usually the bottleneck for building a JS project nowadays. Having parts of the build blazingly fast doesn't matter much if the rest of the build takes seconds or literally minutes. Here are a few suggestions: - -- Convert more files into ReScript =). Fewer files going through fewer parts of the JS pipeline helps a ton. -- Careful with bringing in more dependencies: libraries, syntax transforms, build step loaders, etc. The bulk of these dragging down the editing & building experience might out-weight the API benefits they provide. -- Wait for us to create our own super fast linker (aka bundler). - -## Hot Reloading - -Hot reloading refers to maintaining a dev server and listening to file changes in a way that allows the server to pipe some delta changes right into the currently running browser page. This provides a relatively fast iteration workflow while working in specific frameworks. - -However, hot reloading is fragile by nature, and counts on the occasional inconsistencies (bad state, bad eval, etc.) and the heavy devserver setup/config being less of a hassle than the benefits it provides. We err on the side of caution and stability in general, and decided not to provide a built-in hot reloading _yet_. **Note**: you can still use the hot reloading facility provided by your JS build pipeline. diff --git a/pages/docs/manual/v8.0.0/control-flow.mdx b/pages/docs/manual/v8.0.0/control-flow.mdx deleted file mode 100644 index 195eb1a3e..000000000 --- a/pages/docs/manual/v8.0.0/control-flow.mdx +++ /dev/null @@ -1,287 +0,0 @@ ---- -title: "If-Else & Loops" -description: "If, else, ternary, for, and while" -canonical: "/docs/manual/latest/control-flow" ---- - -# If-Else & Loops - -ReScript supports `if`, `else`, ternary expression (`a ? b : c`), `for` and `while`. - -ReScript also supports our famous pattern matching, which will be covered in [its own section](pattern-matching-destructuring.md) - -## If-Else & Ternary - -Unlike its JavaScript counterpart, ReScript's `if` is an expression; they evaluate to their body's content: - - - -```re -let message = if (isMorning) { - "Good morning!" -} else { - "Hello!" -}; -``` - -```ml -let message = - if isMorning then - "Good morning!" - else - "Hello!" -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**Note:** an `if-else` expression without the final `else` branch implicitly gives `()` (aka the `unit` type). So this: - - - -```re -if (showMenu) { - displayMenu(); -}; -``` - -```ml -if showMenu then - displayMenu () -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -is basically the same as: - - - -```re -if (showMenu) { - displayMenu(); -} else { - (); -}; -``` - -```ml -if showMenu then - displayMenu () -else - () -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -Here's another way to look at it. This is clearly wrong: - -```re -let result = if (showMenu) { - 1 + 2; -}; -``` - -It'll give a type error, saying basically that the implicit `else` branch has the type `unit` while the `if` branch has type `int`. Intuitively, this makes sense: what would `result`'s value be, if `showMenu` was `false`? - -We also have ternary sugar, but **we encourage you to prefer if-else when possible**. - - - -```re -let message = isMorning ? "Good morning!" : "Hello!" -``` - -```ml -(* Doesn't exist in older ML syntax *) -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**`if-else` and ternary are much less used** in ReScript than in other languages; [Pattern-matching](pattern-matching-destructuring.md) kills a whole category of code that previously required conditionals. - -## For Loops - -For loops iterate from a starting value up to (and including) the ending value. - - - -```re -for (i in startValueInclusive to endValueInclusive) { - Js.log(i); -}; -``` - -```ml -for i = startValueInclusive to endValueInclusive do - Js.log i -done -``` - -```js -for (var i = startValueInclusive; i <= endValueInclusive; ++i) { - console.log(i); -} -``` - - - - - -```re -// prints: 1 2 3, one per line -for (x in 1 to 3) { - Js.log(x); -}; -``` - -```ml -(* prints: 1 2 3, one per line *) -for x = 1 to 3 do - Js.log x; -done -``` - -```js -for (var x = 1; x <= 3; ++x) { - console.log(x); -} -``` - - - -You can make the `for` loop count in the opposite direction by using `downto`. - - - -```re -for (i in startValueInclusive downto endValueInclusive) { - Js.log(i); -}; -``` - -```ml -for i = startValueInclusive downto endValueInclusive do - Js.log i -done -``` - -```js -for (var i = startValueInclusive; i >= endValueInclusive; --i) { - console.log(i); -} -``` - - - - - -```re -// prints: 3 2 1, one per line -for (x in 3 downto 1) { - Js.log(x); -}; -``` - -```ml -(* prints: 3 2 1, one per line) -for x = 3 downto 1 do - Js.log x; -done -``` - -```js -for (var x = 3; x >= 1; --x) { - console.log(x); -} -``` - - - -## While Loops - -While loops execute its body code block while its condition is true. - - - -```re -while (testCondition) { - // body here -}; -``` - -```ml -while testCondition do - (* body here *) -done -``` - -```js -while (testCondition) { - // body here -} -``` - - - -### Tips & Tricks - -There's no loop-breaking `break` keyword (nor early `return` from functions, for that matter) in ReScript. However, we can break out of a while loop easily through using a [mutable binding](mutation.md). - - - -```re -let break = ref(false); - -while (!break.contents) { - if (Js.Math.random() > 0.3) { - break := true; - } else { - Js.log("Still running"); - }; -}; -``` - -```ml -let () = break <- ref false -let () = while not break.contents do - if (Js.Math.random ()) > 0.3 then - break := true - else - Js.log "Still running" -done -``` - -```js -var $$break = { - contents: false, -}; - -while (!$$break.contents) { - if (Math.random() > 0.3) { - $$break.contents = true; - } else { - console.log("Still running"); - } -} -``` - - diff --git a/pages/docs/manual/v8.0.0/converting-from-js.mdx b/pages/docs/manual/v8.0.0/converting-from-js.mdx deleted file mode 100644 index 2cf6ca1bb..000000000 --- a/pages/docs/manual/v8.0.0/converting-from-js.mdx +++ /dev/null @@ -1,406 +0,0 @@ ---- -title: "Converting from JS" -description: "How to convert to ReScript with an existing JS codebase" -canonical: "/docs/manual/latest/converting-from-js" ---- - -# Converting from JS - -ReScript offers a unique project conversion methodology which: - -- Ensures minimal disruption to your teammates (very important!). -- Remove the typical friction of verifying conversion's correctness and performance guarantees. -- Doesn't force you to search for pre-made binding libraries made by others. **ReScript doesn't need the equivalent of TypeScript's `DefinitelyTyped`**. - -Enjoy! - -## Step 1: Install ReScript - -Run `npm install --save-dev bs-platform` on your project, then imitate our [New Project](installation#new-project) workflow by adding a `bsconfig.json` at the root. Then start `bsb -w`. - -## Step 2: Copy Paste the Entire JS File - -Let's work on converting a file called `src/main.js`. - -```js -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -``` - -First, copy the entire file content over to a new file called `src/Main.res` by using our [`%%raw` JS embedding trick](embed-raw-javascript): - - - -```re -[%%raw " -const school = require('school'); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -"] -``` - -```ml -[%%raw " -const school = require('school'); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -"] -``` - -```js -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -"use strict"; - -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} - -/* Not a pure module */ -``` - - - -Add this file to `bsconfig.json`: - -```json - "sources": { - "dir" : "src", - "subdirs" : true - }, -``` - -Open an editor tab for `src/Main.bs.js`. Do a command-line `diff -u src/main.js src/Main.bs.js`. Aside from whitespaces, you should see only minimal, trivial differences. You're already a third of the way done! - -**Always make sure** that at each step, you keep the ReScript output `.bs.js` file open to compare against the existing JavaScript file. Our compilation output is very close to your hand-written JavaScript; you can simply eye the difference to catch conversion bugs! - -## Step 3: Extract Parts into Idiomatic ReScript - -Let's turn the `defaultId` variable into a ReScript let-binding: - - - -```re -let defaultId = 10; - -[%%raw " -const school = require('school'); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -"] -``` - -```ml -let defaultId = 10 - -[%%raw " -const school = require('school'); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -"] -``` - -```js -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -const school = require('school'); - -function queryResult(usePayload, payload) { - if usePayload { - return payload.student - } else { - return school.getStudentById(defaultId) - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -/* Not a pure module */ -``` - - - -Check the output. Diff it. Code still works. Moving on! Extract the function: - - - -```re -[%%raw " -const school = require('school'); -"] - -let defaultId = 10; - -let queryResult = (usePayload, payload) => { - if (usePayload) { - payload.student; - } else { - school.getStudentById(defaultId); - } -}; -``` - -```ml -[%%raw " -const school = require('school'); -"] - -let defaultId = 10 - -let queryResult usePayload payload = - if usePayload then - payload.student - else - school.getStudentById(defaultId) -``` - -```js - -``` - - - -Format the code: `./node_modules/.bin/bsc -format src/Main.res`. - -We have a type error: "The record field student can't be found". That's fine! **Always ensure your code is syntactically valid first**. Fixing type errors comes later. - -## Step 4: Add `external`s, Fix Types - -The previous type error is caused by `payload`'s record declaration (which supposedly contains the field `student`) not being found. Since we're trying to convert as quickly as possible, let's use our [object](object) feature to avoid needing type declaration ceremonies: - - - -```re -[%%raw " -const school = require('school'); -"] - -let defaultId = 10; - -let queryResult = (usePayload, payload) => { - if (usePayload) { - payload##student; - } else { - school##getStudentById(defaultId); - } -} -``` - -```ml -[%%raw " -const school = require('school'); -"] - -let defaultId = 10 - -let queryResult usePayload payload = - if usePayload then - payload##student - else - school##getStudentById defaultId -``` - -```js - -``` - - - -Now this triggers the next type error, that `school` isn't found. Let's use [`external`](external) to bind to that module: - - - -```re -[@bs.module] external school: 'whatever = "school"; - -let defaultId = 10; - -let queryResult = (usePayload, payload) => { - if usePayload { - payload##student; - } else { - school##getStudentById(defaultId); - } -} -``` - -```ml -external school: 'whatever = "school" [@@bs.module] - -let defaultId = 10 - -let queryResult usePayload payload = - if usePayload then - payload##student - else - school##getStudentById defaultId -``` - -```js -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We hurrily typed `school` as a polymorphic `'whatever` and let its type be inferred by its usage below. The inference is technically correct, but within the context of bringing it a value from JavaScript, slightly dangerous. This is just the interop trick we've shown in the [`external`](external) page. - -Anyway, the file passes the type checker again. Check the `.bs.js` output, diff with the original `.js`; we've now converted a file over to ReScript! - -Now, you can delete the original, hand-written `main.js` file, and grep the files importing `main.js` and change them to importing `Main.bs.js`. - -## (Optional) Step 5: Cleanup - -If you prefer more advanced, rigidly typed `payload` and `school`, feel free to do so: - - - -```re -type school; -type student; -type payload = { - student: student -}; - -[@bs.module] external school: school = "school"; -[@bs.send] external getStudentById: (school, int) => student = "getStudentById"; - -let defaultId = 10; - -let queryResult = (usePayload, payload) => { - if (usePayload) { - payload.student; - } else { - school->getStudentById(defaultId); - } -} -``` - -```ml -type school -type student -type payload = { - student: student -} - -external school: school = "school" [@@bs.module] -external getStudentById: school -> int -> student = "getStudentById" [@@bs.send] - -let defaultId = 10 - -let queryResult usePayload payload = - if usePayload then - payload.student - else - school |. (getStudentById defaultId) -``` - -```js -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We've: - -- introduced an opaque types for `school` and `student` to prevent misusages their values -- typed the payload as a record with only the `student` field -- typed `getStudentById` as the sole method of `student` - -Check that the `.bs.js` output didn't change. How rigidly to type your JavaScript code is up to you; we recommend not typing them too elaborately; it's sometime an endless chase, and produces diminishing returns, especially considering that the elaborate-ness might turn off your potential teammates. - -## Tips & Tricks - -In the same vein of idea, **resist the urge to write your own wrapper functions for the JS code you're converting**. Use [`external`s](external), which are guaranteed to be erased in the output. And avoid trying to take the occasion to convert JS data structures into ReScript-specific data structures like variant or list. **This isn't the time for that**. - -The moment you produce extra conversion code in the output, your skeptical teammate's mental model might switch from "I recognize this output" to "this conversion might be introducing more problems than it solves. Why are we testing ReScript again?". Then you've lost. - -## Conclusion - -- Paste the JS code into a new ReScript file as embedded raw JS code. -- Compile and keep the output file open. Check and diff against original JS file. Free regression tests. -- Always make sure your file is syntactically valid. Don't worry about fixing types before that. -- (Ab)use [object](object.md) accesses to quickly convert things over. -- Optionally clean up the types for robustness. -- Don't go overboard and turn off your boss and fellow teammates. -- Proudly display that you've conserved the semantics and performance characteristics during the conversion by showing your teammates the eerily familiar output. -- Get promoted for introducing a new technology the safer, mature way. diff --git a/pages/docs/manual/v8.0.0/editor-plugins.mdx b/pages/docs/manual/v8.0.0/editor-plugins.mdx deleted file mode 100644 index e01314155..000000000 --- a/pages/docs/manual/v8.0.0/editor-plugins.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: "Editor Plugins" -description: "List of ReScript editor plugins" -canonical: "/docs/manual/latest/editor-plugins" ---- - -# Editor Plugins - -**Note**: the editor plugins below work with the old `.re` and `.ml` syntax (plus highlighting support for the new syntax for VSCode, Atom and Sublime Text). The new `v8.2.0` introduced a new syntax and several changes that required new editor plugins, listed on the newer version of this page. - -- [VSCode](https://marketplace.visualstudio.com/items?itemName=jaredly.reason-vscode) -- [Atom](https://github.com/reasonml-editor/atom-ide-reason) -- [Vim/Neovim](https://github.com/reasonml-editor/vim-reason-plus) -- [Sublime Text](https://github.com/reasonml-editor/sublime-reason) -- [IDEA](https://github.com/reasonml-editor/reasonml-idea-plugin) -- [Emacs](https://github.com/reasonml-editor/reason-mode) (currently unmaintained) diff --git a/pages/docs/manual/v8.0.0/embed-raw-javascript.mdx b/pages/docs/manual/v8.0.0/embed-raw-javascript.mdx deleted file mode 100644 index 433c71aef..000000000 --- a/pages/docs/manual/v8.0.0/embed-raw-javascript.mdx +++ /dev/null @@ -1,141 +0,0 @@ ---- -title: "Embed Raw JavaScript" -description: "Utility syntax to for raw JS usage in ReScript" -canonical: "/docs/manual/latest/embed-raw-javascript" ---- - -# Embed Raw JavaScript - -## Paste Raw JS Code - -First thing first. If you're ever stuck learning ReScript, remember that you can always just paste raw JavaScript code into our source file: - - - -```re -[%%raw {| -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m) -} -|}]; -``` - -```ml -[%%raw {| -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m) -} -|}] -``` - -```js -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m); -} -``` - - - -The `%%raw` special ReScript call takes your code string and pastes it as-is into the output. **You've now technically written your first ReScript file!** - -(The back tick syntax is a multiline string, similar to JavaScript's. Except for us, no escaping is needed inside the string. More on string in a later section.) - -While `%%raw` lets you embed top-level raw JS code, `%raw` lets you embed expression-level JS code: - - - -```re -let add = [%raw {| - function(a, b) { - console.log("hello from raw JavaScript!"); - return a + b - } -|}]; - -Js.log(add(1, 2)); -``` - -```ml -let add = [%raw {| - function(a, b) { - console.log("hello from raw JavaScript!"); - return a + b - } -|}] - -let () = Js.log (add 1 2) -``` - -```js -var add = function (a, b) { - console.log("hello from raw JavaScript!"); - return a + b; -}; - -console.log(add(1, 2)); -``` - - - -The above code: - -- declared a ReScript variable `add`, -- with the raw JavaScript value of a function declaration, -- then called that function in ReScript. - -If your boss is ever worried that your teammates can't adopt ReScript, just let them keep writing JavaScript inside ReScript files =). - -## Debugger - -You can also drop a `%debugger` expression in a body: - - - -```re -let f = (x, y) => { - [%debugger]; - x + y; -}; -``` - -```ml -let f x y = - [%debugger ]; - x + y -``` - -```js -function f(x, y) { - debugger; - return (x + y) | 0; -} -``` - - - -Output: - -```js -function f(x, y) { - debugger; // JavaScript developer tools will set an breakpoint and stop here - x + y; -} -``` - -## Tips & Tricks - -Embedding raw JS snippets isn't the best way to experience ReScript, though it's also highly useful if you're just starting out. As a matter of fact, the first few ReScript projects were converted through: - -- pasting raw JS snippets inside a file -- examining the JS output (identical to the old hand-written JS) -- gradually extract a few values and functions and making sure the output still looks OK - -At the end, we get a fully safe, converted ReScript file whose JS output is clean enough that we can confidently assert that no new bug has been introduced during the conversion process. - -We have a small guide on this iteration [here](converting-from-js.md). Feel free to peruse it later. diff --git a/pages/docs/manual/v8.0.0/exception.mdx b/pages/docs/manual/v8.0.0/exception.mdx deleted file mode 100644 index e26a20418..000000000 --- a/pages/docs/manual/v8.0.0/exception.mdx +++ /dev/null @@ -1,327 +0,0 @@ ---- -title: "Exception" -description: "Exceptions and exception handling in ReScript" -canonical: "/docs/manual/latest/exception" ---- - -# Exception - -Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!). - -## Usage - - - -```re -let getItem = (items) => - if (callSomeFunctionThatThrows()) { - // return the found item here - 1; - } else { - raise(Not_found); - }; - -let result = - try (getItem([|1, 2, 3|])) { - | Not_found => 0 /* Default value if getItem throws */ - }; -``` - -```ml -let getItem items = - if callSomeFunctionThatThrows () then - (* return the found item here *) - 1 - else - raise Not_found - -let result = - try getItem [|1; 2; 3|] with - | Not_found -> 0 (* Default value if getItem throws *) -``` - -```js -function getItem(items) { - if (callSomeFunctionThatThrows()) { - return 1; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error(), - }; -} - -var result; - -try { - result = getItem([1, 2, 3]); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - result = 0; - } else { - throw exn; - } -} -``` - - - -Note that the above is just for demonstration purposes; in reality, you'd return an `option(int)` directly from `getItem` and avoid the `try` altogether. - -You can directly match on exceptions _while_ getting another return value from a function: - - - -```re -switch (List.find(i => i === theItem, myItems)) { -| item => Js.log(item) -| exception Not_found => Js.log("No such item found!") -}; -``` - -```ml -let () = match List.find (fun i -> i == theItem) myItems with -| item -> Js.log item -| exception Not_found -> - Js.log "No such item found!" -``` - -```js -var exit = 0; - -var item; - -try { - item = List.find(function (i) { - return i === theItem; - }, myItems); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -You can also make your own exceptions like you'd make a variant (exceptions need to be capitalized too). - - - -```re -exception InputClosed(string); -// later on -raise(InputClosed("The stream has closed!")); -``` - -```ml -exception InputClosed of string -(* later on *) -raise(InputClosed "The stream has closed!") -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var InputClosed = Caml_exceptions.create("MyFile.InputClosed"); - -throw { - RE_EXN_ID: InputClosed, - _1: "The stream has closed!", - Error: new Error(), -}; -``` - - - -## Catching JS Exceptions - -To distinguish between JavaScript exceptions and ReScript exceptions, ReScript namespaces JS exceptions under the `Js.Exn.Error(payload)` variant. To catch an exception thrown from the JS side: - - - -```re -try (someJSFunctionThatThrows()) { -| Js.Exn.Error(obj) => - switch (Js.Exn.message(obj)) { - | Some(m) => Js.log("Caught a JS exception! Message: " ++ m) - | None => () - } -}; -``` - -```ml -let () = try someJSFunctionThatThrows () with -| Js.Exn.Error obj -> - match Js.Exn.message obj with - | Some m -> Js.log ("Caught a JS exception! Message: " ^ m) - | None -> () -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); -var Caml_js_exceptions = require("./stdlib/caml_js_exceptions.js"); - -try { - someJSFunctionThatThrows(); -} catch (raw_obj) { - var obj = Caml_js_exceptions.internalToOCamlException(raw_obj); - if (obj.RE_EXN_ID === Js_exn.$$Error) { - var m = obj._1.message; - if (m !== undefined) { - console.log("Caught a JS exception! Message: " + m); - } - } else { - throw obj; - } -} -``` - - - -The `obj` here is of type `Js.Exn.t`, intentionally opaque to disallow illegal operations. To operate on `obj`, do like the code above by using the standard library's [`Js.Exn`](api/js/exn) module's helpers. - -## Raise a JS Exception - -`raise(MyException)` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Js.Exn.raiseError`: - - - -```re -let myTest = () => { - Js.Exn.raiseError("Hello!"); -}; -``` - -```ml -let myTest () = - Js.Exn.raiseError "Hello!" -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); - -function myTest() { - return Js_exn.raiseError("Hello!"); -} -``` - - - -Then you can catch it from the JS side: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.message); // "Hello!" -} -``` - -## Catch ReScript Exceptions from JS - -The previous section is less useful than you think; to let your JS code work with your exception-throwing ReScript code, the latter doesn't actually need to throw a JS exception. ReScript exceptions can be used by JS code! - - - -```re -exception BadArgument({myMessage: string}); - -let myTest = () => { - raise(BadArgument({myMessage: "Oops!"})); -}; -``` - -```ml -exception BadArgument of {myMessage: string} - -let myTest () = - raise(BadArgument {myMessage = "Oops!"}) -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var BadArgument = Caml_exceptions.create("Playground.BadArgument"); - -function myTest() { - throw { - RE_EXN_ID: BadArgument, - myMessage: "Oops!", - Error: new Error(), - }; -} -``` - - - -Then, in your JS: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.myMessage); // "Oops!" - console.log(e.Error.stack); // the stack trace -} -``` - -> Note: `RE_EXN_ID` is an internal field for bookkeeping purposes. Don't use it on the JS side. Use the other fields. - -The above `BadArgument` exception takes an inline record type. We special-case compile the exception as `{RE_EXN_ID, myMessage, Error}` for good ergonomics. If the exception instead took ordinary positional arguments, l like the standard library's `Invalid_argument("Oops!")`, which takes a single argument, the argument is compiled to JS as the field `_1` instead. A second positional argument would compile to `_2`, etc. - -## Tips & Tricks - -When you have ordinary variants, you often don't **need** exceptions. For example, instead of throwing when `item` can't be found in a collection, try to return an `option(item)` (`None` in this case) instead. - -### Catch Both ReScript and JS Exceptions in the Same `catch` Clause - - - -```re -try (someOtherJSFunctionThatThrows()) { -| Not_found => ... // catch a ReScript exception -| Invalid_argument(_) => ... // catch a second ReScript exception -| Js.Exn.Error(obj) => ... // catch the JS exception -}; -``` - -```ml -try someOtherJSFunctionThatThrows() with -| Not_found -> ... (* catch a ReScript exception *) -| Invalid_argument _ -> ... (* catch a second ReScript exception *) -| Js.Exn.Error obj -> ... (* catch the JS exception *) -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); -var Caml_js_exceptions = require("./stdlib/caml_js_exceptions.js"); - -try { - someOtherJSFunctionThatThrows(); -} catch (raw_obj) { - var obj = Caml_js_exceptions.internalToOCamlException(raw_obj); - if ( - obj.RE_EXN_ID !== "Not_found" && - obj.RE_EXN_ID !== "Invalid_argument" && - obj.RE_EXN_ID !== Js_exn.$$Error - ) { - throw obj; - } -} -``` - - - -This technically works, but hopefully you don't ever have to work with such code... diff --git a/pages/docs/manual/v8.0.0/external.mdx b/pages/docs/manual/v8.0.0/external.mdx deleted file mode 100644 index 153fb7857..000000000 --- a/pages/docs/manual/v8.0.0/external.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -title: "External (Bind to Any JS Library)" -description: "The external keyword" -canonical: "/docs/manual/latest/external" ---- - -# External (Bind to Any JS Library) - -`external` is the primary ReScript feature for bringing in and using JavaScript values. - -`external` is like a let binding, but: - -- The right side of `=` isn't a value; it's the name of the JS value you're referring to. -- The type for the binding is mandatory, since we need to know what the type of that JS value is. -- Can only exist at the top level of a file or module. - - - -```re -[@bs.val] external setTimeout: (unit => unit, int) => float = "setTimeout"; -``` - -```ml -external setTimeout: (unit -> unit) -> int -> float = "setTimeout" [@@bs.val] -``` - -```js -// Empty output -``` - - - -There are several kinds of `external`s, differentiated and/or augmented through the `@bs` notation they carry. This page deals with the general, shared mechanism behind most `external`s. The different `@bs` annotations are documented in their respective pages later. A few notable ones: - -- `@bs.val`, `@bs.scope`: [bind to global JS values](bind-to-global-js-values). -- `@bs.module`: [bind to JS imported/exported values](import-from-export-to-js). -- `@bs.send`: [bind to JS methods](bind-to-js-function). - -## Usage - -Once declared, you can use an `external` as a normal value, just like a let binding. - -## Tips & Tricks - -`external` + ReScript objects are a wonderful combination for quick prototyping. Check the JS output tab: - - - -```re -// The type of document is just some random type 'a -// that we won't bother to specify -[@bs.val] external document: 'a = "document"; - -// call a method -document##addEventListener("mouseup", _event => { - Js.log("clicked!"); -}); - -// get a property -let loc = document##location; - -// set a property -document##location##href = "rescript-lang.org"; -``` - -```ml -(* The type of document is just some random type 'a *) -(* that we won't bother to specify *) -external document: 'a = "document" [@@bs.val] - -(* call a method *) -document##addEventListener "mouseup" (fun _event -> - Js.log "clicked!" -) - -(* get a property *) -let loc = document##location - -(* set a property *) -document##location##href = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); - -var loc = document.location; - -document.location.href = "rescript-lang.org"; -``` - - - -We've specified `document`'s type as `'a`, aka a placeholder type that's polymorphic. Any value can be passed there, so you're not getting much type safety (except the inferences at various call sites). However, this is excellent for quickly getting started using a JavaScript library in ReScript **without needing the equivalent of a repository of typed bindings** like TypeScript's `DefinitelyTyped` repo. - -However, if you want to more rigidly bind to the JavaScript library you want, keep reading the next few interop pages. - -## Performance & Output Readability - -`external`s declarations are inlined into their callers during compilation, **and completely disappear from the JS output**. This means any time you use one, you can be sure that you're not incurring extra JavaScript \<-> ReScript conversion cost. - -Additionally, no extra ReScript-specific runtime is better for output readability. - -## Design Decisions - -ReScript takes interoperating with existing code very seriously. Our type system has very strong guarantees. However, such strong feature also means that, without a great interop system, it'd be very hard to gradually convert a codebase over to ReScript. Fortunately, our interop are comprehensive and cooperate very well with most existing JavaScript code. - -The combination of a sound type system + great interop means that we get the benefits of a traditional gradual type system regarding incremental codebase coverage & conversion, without the downside of such gradual type system: complex features to support existing patterns, slow analysis, diminishing return in terms of type coverage, etc. diff --git a/pages/docs/manual/v8.0.0/faq.mdx b/pages/docs/manual/v8.0.0/faq.mdx deleted file mode 100644 index 0c4b8d947..000000000 --- a/pages/docs/manual/v8.0.0/faq.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: "FAQ" -description: "Frequently asked questions about ReScript and its ecosystem" -canonical: "/docs/manual/latest/faq" ---- - -# Frequently Asked Questions - -**What's the goal of this project?** - -We aim to provide the best typed language experience for the JavaScript platform. - -**What’s ReScript's relationship with OCaml?** - -We reuse the same excellent type system with OCaml, and lots of other high quality components. Additionally, ReScript provides its own syntax build system, JS interop, extra language features, etc. We do sync up those OCaml components from time to time, but it’s not our goal to be tied to the OCaml release cycle and its toolchain. - -**What’s the relationship with BuckleScript?** - -See [here](/blog/bucklescript-is-rebranding). BuckleScript is ReScript's old branding, with a sharper focus on proper JS support and familiarity which we previously couldn't achieve to the degree we wanted, due to us needing to cater to various different crowds. - -**What’s the relationship with Reason?** - -Reason is a syntax layer for OCaml that BuckleScript also adopted. The current ReScript compiler also supports the old Reason syntax v3.6 for backward compatibility. We will support it for a long time to make sure existing users do not get breaking changes. - -**I come from Reason/OCaml. Will ReScript keep supporting X?** - -Please see our [blog post](/blog/a-note-on-bucklescripts-future-commitments) on this matter. - -**Where can I see the docs in old Reason syntax?** - -Switch the doc version to `v8.0.0` in the sidebar on the left! - -**Will ReScript support native compilation eventually?** - -Our focus is a solid JS story right now. In the future, if there’s strong demand, we might consider it. - -**What’s the current state of ReScript?** - -Currently, we're actively working on the editor support. - -**Why create a new syntax?** - -The existing Reason syntax is owned by a different team with a different vision. Reason aims to be 100% compatible with OCaml syntax and to support all versions of OCaml. In the last few years, we've drawn the conclusion that it’s very hard to deliver such goal without sacrificing user experience. The other reason is that we feel it’s better to have the same vision as a team so that we can make more coherent decisions. - -**Who is behind the project?** - -The ReScript team (Hongbo, Cheng, Cristiano, Maxim, Patrick, Ricky). - -**We have a new forum; will we also have our own Discord?** - -Not now. We've found that too much important information get casually passed in Discord then lost within the noise. We prefer folks to communicate on the [forum](https://forum.rescript-lang.org). This is nicer to the less active members. - -We also will never announce important news in chat. diff --git a/pages/docs/manual/v8.0.0/function.mdx b/pages/docs/manual/v8.0.0/function.mdx deleted file mode 100644 index 4861bb1d4..000000000 --- a/pages/docs/manual/v8.0.0/function.mdx +++ /dev/null @@ -1,768 +0,0 @@ ---- -title: "Function" -description: "Function syntax in ReScript" -canonical: "/docs/manual/latest/function" ---- - -# Function - -_Cheat sheet for the full function syntax at the end_. - -ReScript functions are declared with an arrow and return an expression, just like JS functions. They compile to clean JS functions too. - - - -```re -let greet = (name) => "Hello " ++ name; -``` - -```ml -let greet name = "Hello " ^ name -``` - -```js -function greet(name) { - return "Hello " + name; -} -``` - - - -This declares a function and assigns to it the name `greet`, which you can call like so: - - - -```re -greet("world!"); // "Hello world!" -``` - -```ml -greet "world!" (* "Hello world!" *) -``` - -```js -greet("world!"); -``` - - - -Multi-arguments functions have arguments separated by comma: - - - -```re -let add = (x, y, z) => x + y + z; -add(1, 2, 3); // 6 -``` - -```ml -let add x y z = (x + y) + z -let () = add 1 2 3 -``` - -```js -function add(x, y, z) { - return (((x + y) | 0) + z) | 0; -} -``` - - - -For longer functions, you'd surround the body with a block: - - - -```re -let greetMore = (name) => { - let part1 = "Hello"; - part1 ++ " " ++ name; -}; -``` - -```ml -let greetMore name = - let part1 = "Hello" in - part1 ^ " " ^ name -``` - -```js -function greetMore(name) { - return "Hello " + name; -} -``` - - - -If your function has no argument, just write `let greetMore = () => {...}`. - -## Labeled Arguments - -Multi-arguments functions, especially those whose arguments are of the same type, can be confusing to call. - - - -```re -let addCoordinates = (x, y) => { - // use x and y here -}; -// ... -addCoordinates(5, 6); // which is x, which is y? -``` - -```ml -let addCoordinates x t = - (* use x and y here *) -(* ... *) -addCoordinates 5 6 (* which is x, which is y? *) -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can attach labels to an argument by prefixing the name with the `~` symbol: - - - -```re -let addCoordinates = (~x, ~y) => { - // use x and y here -}; -// ... -addCoordinates(~x=5, ~y=6); -``` - -```ml -let addCoordinates ~x ~y = - (* use x and y here *) -(* ... *) -addCoordinates ~x=5 ~y=6 -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can provide the arguments in **any order**: - - - -```re -addCoordinates(~y=6, ~x=5); -``` - -```ml -addCoordinates ~y=6 ~x=5 -``` - -```js -addCoordinates(5, 6); -``` - - - -The `~x` part in the declaration means the function accepts an argument labeled `x` and can refer to it in the function body by the same name. You can also refer to the arguments inside the function body by a different name for conciseness: - - - -```re -let drawCircle = (~radius as r, ~color as c) => { - setColor(c); - startAt(r, r); - // ... -}; - -drawCircle(~radius=10, ~color="red"); -``` - -```ml -let drawCircle ~radius:r ~color:c = - setColor c; - startAt r r; - (* ... *) - -let () = drawCircle ~radius:10 ~color:"red" -``` - -```js -function drawCircle(r, c) { - setColor(c); - return startAt(r, r); -} - -drawCircle(10, "red"); -``` - - - -As a matter of fact, `(~radius)` is just a shorthand for `(~radius as radius)`. - -Here's the syntax for typing the arguments: - - - -```re -let drawCircle = (~radius as r: int, ~color as c: string) => { - // code here -}; -``` - -```ml -let drawCircle ~radius:(r : int) ~color:(c : string) = - (* code *) -``` - -```js -function drawCircle(r, c) { - // code here -} -``` - - - -## Optional Labeled Arguments - -Labeled function arguments can be made optional during declaration. You can then omit them when calling the function. - - - -```re -// radius can be omitted -let drawCircle = (~color, ~radius=?, ()) => { - setColor(color); - switch (radius) { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - }; -}; -``` - -```ml -(* radius can be omitted *) -let drawCircle ~color ?radius () = - setColor color; - let () = match radius with - | None -> startAt 1 1 - | Some r_ -> startAt r_ r_ -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -function drawCircle(color, radius, param) { - setColor(color); - if (radius === undefined) { - return startAt(1, 1); - } - var r_ = Caml_option.valFromOption(radius); - return startAt(r_, r_); -} -``` - - - -When given in this syntax, `radius` is **wrapped** in the standard library's `option` type, defaulting to `None`. If provided, it'll be wrapped with a `Some`. So `radius`'s type value is `None | Some(int)` here. - -More on `option` type [here](null-undefined-option.md). - -**Note** for the sake of the type system, whenever you have an optional argument, you need to ensure that there's also at least one positional argument (aka non-labeled, non-optional argument) after it. If there's none, provide a dummy `unit` (aka `()`) argument. - -### Signatures and Type Annotations - -Functions with optional labeled arguments can be confusing when it comes to signature and type annotations. Indeed, the type of an optional labeled argument looks different depending on whether you're calling the function, or working inside the function body. Outside the function, a raw value is either passed in (`int`, for example), or left off entirely. Inside the function, the parameter is always there, but its value is an option (`option(int)`). This means that the type signature is different, depending on whether you're writing out the function type, or the parameter type annotation. The first being a raw value, and the second being an option. - -If we get back to our previous example and both add a signature and type annotations to its argument, we get this: - - - -```re -let drawCircle: (~color: color, ~radius: int=?, unit) => unit = - (~color: color, ~radius: option(int)=?, ()) => { - setColor(color); - switch (radius) { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - }; - }; -``` - -```ml -let drawCircle: color:color -> ?radius:int -> unit -> unit = - fun ~color:(color : color) ?radius:(radius : int option) () -> - setColor color; - let () = match radius with - | None -> startAt 1 1 - | Some r_ -> startAt r_ r_ -``` - -```js -function drawCircle(color, radius, param) { - setColor(color); - if (radius !== undefined) { - return startAt(radius, radius); - } else { - return startAt(1, 1); - } -} -``` - - - -The first line is the function's signature, we would define it like that in an interface file (see [Signatures](module.md#signatures)). The function's signature describes the types that the **outside world** interacts with, hence the type `int` for `radius` because it indeed expects an `int` when called. - -In the second line, we annotate the arguments to help us remember the types of the arguments when we use them **inside** the function's body, here indeed `radius` will be an `option(int)` inside the function. - -So if you happen to struggle when writing the signature of a function with optional labeled arguments, try to remember this! - -### Explicitly Passed Optional - -Sometimes, you might want to forward a value to a function without knowing whether the value is `None` or `Some(a)`. Naively, you'd do: - - - -```re -let result = - switch (payloadRadius) { - | None => drawCircle(~color, ()) - | Some(r) => drawCircle(~color, ~radius=r, ()) - }; -``` - -```ml -let result = - match payloadRadius with - | None -> drawCircle ~color () - | Some r -> drawCircle ~color ~radius:r () -``` - -```js -var r = payloadRadius; - -var result = - r !== undefined - ? drawCircle(color, Caml_option.valFromOption(r), undefined) - : drawCircle(color, undefined); -``` - - - -This quickly gets tedious. We provide a shortcut: - - - -```re -let result = drawCircle(~color, ~radius=?payloadRadius, ()); -``` - -```ml -let result = drawCircle ~color ?radius:payloadRadius () -``` - -```js -var result = drawCircle(1, undefined, undefined); -``` - - - -This means "I understand `radius` is optional, and that when I pass it a value it needs to be an `int`, but I don't know whether the value I'm passing is `None` or `Some(val)`, so I'll pass you the whole `option` wrapper". - -### Optional with Default Value - -Optional labeled arguments can also be provided a default value. In this case, they aren't wrapped in an `option` type. - - - -```re -let drawCircle = (~radius=1, ~color, ()) => { - setColor(color); - startAt(radius, radius); -}; -``` - -```ml -let drawCircle ?(radius=1) ~color () = - setColor color; - startAt radius radius -``` - -```js -function drawCircle(radiusOpt, color, param) { - var radius = radiusOpt !== undefined ? radiusOpt : 1; - setColor(color); - return startAt(radius, radius); -} -``` - - - -## Recursive Functions - -ReScript chooses the sane default of preventing a function to be called recursively within itself. To make a function recursive, add the `rec` keyword after the `let`: - - - -```re -let rec neverTerminate = () => neverTerminate() -``` - -```ml -let rec neverTerminate () = neverTerminate () -``` - -```js -function neverTerminate(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -A simple recursive function may look like this: - - - -```re -// Recursively check every item on the list until one equals the `item` -// argument. If a match is found, return `true`, otherwise return `false` -let rec listHas = (list, item) => - switch (list) { - | [] => false - | [a, ...rest] => a === item || listHas(rest, item) - }; -``` - -```ml -(* Recursively check every item on the list until one equals the `item` *) -(* argument. If a match is found, return `true`, otherwise return `false` *) - -let rec listHas list item = - match list with - | [] -> false - | a::rest -> (a == item) || (listHas rest item) -``` - -```js -function listHas(_list, item) { - while (true) { - var list = _list; - if (!list) { - return false; - } - if (list.hd === item) { - return true; - } - _list = list.tl; - continue; - } -} -``` - - - -Recursively calling a function is bad for performance and the call stack. However, ReScript intelligently compiles [tail recursion](https://stackoverflow.com/questions/33923/what-is-tail-recursion) into a fast JavaScript loop. Try checking the JS output of the above code! - -### Mutually Recursive Functions - -Mutually recursive functions start like a single recursive function using the -`rec` keyword, and then are chained together with `and`: - - - -```re -let rec callSecond = () => callFirst() -and callFirst = () => callSecond(); -``` - -```ml -let rec callSecond () = callFirst () -and callFirst () = callSecond () -``` - -```js -function callSecond(_param) { - while (true) { - _param = undefined; - continue; - } -} - -function callFirst(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -## Uncurried Function - -ReScript's functions are curried by default, which is one of the few performance penalties we pay in the compiled JS output. The compiler does a best-effort job at removing those currying whenever possible. However, in certain edge cases, you might want guaranteed uncurrying. In those cases, put a dot in the function's parameter list: - - - -```re -let add = (. x, y) => x + y; - -add(. 1, 2); -``` - -```ml -let add = (fun x y -> x + y) [@bs] -let () = add 1 2 [@bs] -``` - -```js -function add(x, y) { - return (x + y) | 0; -} - -add(1, 2); -``` - - - -If you write down the uncurried function's type, you'll add a dot there as well. - -**Note**: both the declaration site and the call site need to have the uncurry annotation. That's part of the guarantee/requirement. - -**This feature seems trivial**, but is actually one of our most important features, as a primarily functional language. We encourage you to use it if you'd like to remove any mention of `Curry` runtime in the JS output. - -## Tips & Tricks - -Cheat sheet for the function syntaxes: - -### Declaration - - - -```re -// anonymous function -(x, y) => 1; -// bind to a name -let add = (x, y) => 1; - -// labeled -let add = (~first as x, ~second as y) => x + y; -// with punning sugar -let add = (~first, ~second) => first + second; - -// labeled with default value -let add = (~first as x=1, ~second as y=2) => x + y; -// with punning -let add = (~first=1, ~second=2) => first + second; - -// optional -let add = (~first as x=?, ~second as y=?) => switch (x) {...}; -// with punning -let add = (~first=?, ~second=?) => switch (first) {...}; -``` - -```ml -(* anonymous function *) -fun x y -> 1 -(* bind to a name *) -let add x y = 1 - -(* labeled *) -let add ~first:x ~second:y = x + y -(* with punning sugar *) -let add ~first ~second = first + second - -(* labeled with default value *) -let add ?first:(x=1) ?second:(y=2) = x + y -(* with punning *) -let add ?(first=1) ?(second=2) = first + second - -(* optional *) -let add ?first:x ?second:y = match x with ... -(* with punning *) -let add ?first ?second = match x with ... -``` - - - -#### With Type Annotation - - - -```re -// anonymous function -(x: int, y: int): int => 1; -// bind to a name -let add = (x: int, y: int): int => 1; - -// labeled -let add = (~first as x: int, ~second as y: int) : int => x + y; -// with punning sugar -let add = (~first: int, ~second: int) : int => first + second; - -// labeled with default value -let add = (~first as x: int=1, ~second as y: int=2) : int => x + y; -// with punning sugar -let add = (~first: int=1, ~second: int=2) : int => first + second; - -// optional -let add = (~first as x: option(int)=?, ~second as y: option(int)=?) : int => switch (x) {...}; -// with punning sugar -// note that the caller would pass an `int`, not `option(int)` -// Inside the function, `first` and `second` are `option(int)`. -let add = (~first: option(int)=?, ~second: option(int)=?) : int => switch (first) {...}; -``` - -```ml -(* anonymous function *) -fun (x: int) (y: int) : int -> 1 -(* bind to a name *) -let add (x: int) (y: int) : int = 1 - -(* labeled *) -let add ~first:(x: int) ~second:(y: int) : int = x + y -(* no punning sugar *) - -(* labeled with default value *) -let add ?first:((x: int)=1) ?second:((y: int)=2) : int = x + y -(* no punning sugar *) -(* optional *) -let add ?first:(x: int option) ?second:(y: int option) : int = match x with ... -(* no punning sugar *) -``` - - - -### Application - - - -```re -add(x, y); - -// labeled -add(~first=1, ~second=2); -// with punning sugar -add(~first, ~second); - -// application with default value. Same as normal application -add(~first=1, ~second=2); - -// explicit optional application -add(~first=?Some(1), ~second=?Some(2)); -// with punning -add(~first?, ~second?); -``` - -```ml -add x y - -(* labeled *) -add ~first:1 ~second:2 -(* with punning sugar *) -add ~first ~second - -(* application with default value. Same as normal application *) -add ~first:1 ~second:2 - -(* explicit optional application *) -add ?first:(Some 1) ?second:(Some 2) -(* with punning *) -add ?first ?second -``` - - - -#### With Type Annotation - - - -```re -// labeled -add(~first=1: int, ~second=2: int); -// with punning sugar -add(~first: int, ~second: int); - -// application with default value. Same as normal application -add(~first=1: int, ~second=2: int); - -// explicit optional application -add(~first=?Some(1): option(int), ~second=?Some(2): option(int)); -// no punning sugar when you want to type annotate -``` - -```ml -(* labeled *) -add ~first:(1: int) ~second:(2: int) -(* no punning sugar *) - -(* application with default value. Same as normal application *) -add ~first:(1: int) ~second:(2: int) - -(* explicit optional application *) -add ?first:(Some 1: int option) ?second:(Some 2: int option) -(* no punning sugar when you want to type annotate *) -``` - - - -### Standalone Type Signature - - - -```re -// first arg type, second arg type, return type -type add = (int, int) => int; - -// labeled -type add = (~first: int, ~second: int) => int; - -// labeled -type add = (~first: int=?, ~second: int=?, unit) => int; -``` - -```ml -(* first arg type, second arg type, return type *) -type add = int -> int -> int - -(* labeled *) -type add = first:int -> second:int -> int - -(* labeled *) -type add = ?first:int -> ?second:int -> unit -> int -``` - - - -#### In Interface Files - -To annotate a function from the implementation file (`.re`) in your interface file (`.rei`): - - - -```re -let add: (int, int) => int; -``` - -```ml -val add: int -> int -> int -``` - - - -The type annotation part is the same as the previous section on With Type Annotation. - -**Don't** confuse `let add: myType` with `type add = myType`. When used in `.rei` interface files, the former exports the binding `add` while annotating it as type `myType`. The latter exports the type `add`, whose value is the type `myType`. diff --git a/pages/docs/manual/v8.0.0/generate-converters-accessors.mdx b/pages/docs/manual/v8.0.0/generate-converters-accessors.mdx deleted file mode 100644 index 418eb3e8e..000000000 --- a/pages/docs/manual/v8.0.0/generate-converters-accessors.mdx +++ /dev/null @@ -1,991 +0,0 @@ ---- -title: "Generate Converters & Helpers" -description: "All about the @bs.deriving decorator, and how to generate code from types" -canonical: "/docs/manual/latest/generate-converters-accessors" ---- - -# Generate Converters & Helpers - - - -When using ReScript, you will sometimes come into situations where you want to - -- Automatically generate functions that convert between ReScript's internal and JS runtime values (e.g. variants). -- Convert a record type into an abstract type with generated creation, accessor and method functions. -- Generate some other helper functions, such as functions from record attribute names. - -You can use the `@bs.deriving` decorator to trigger code generation. All different options and configurations will be discussed on this page. - -**Note:** Please be aware that extensive use of code generation might make it harder to understand your programs (since the code being generated is not visible in the source code, and you just need to know what kind of functions / values a decorator generates). - -**Another Note:** Since `v8.3` you can drop the `bs.` prefix for all our decorators (e.g. `@bs.deriving` => `@deriving`). - -## Generate Functions & Plain Values for Variants - -Use `[@bs.deriving accessors]` on a variant type to create accessor functions for its constructors. - - - -```reason -[@bs.deriving accessors] -type action = - | Click - | Submit(string) - | Cancel; -``` - -```ocaml -type action = - | Click - | Submit of string - | Cancel - [@@bs.deriving accessors] -``` - -```js -function submit(param_0) { - return /* Submit */ [param_0]; -} - -var click = /* Click */ 0; - -var cancel = /* Cancel */ 1; - -exports.click = click; -exports.submit = submit; -exports.cancel = cancel; -``` - - - -Variants constructors with payloads generate functions, payload-less constructors generate plain integers (the internal representation of variants). - -**Note**: - -- The generated accessors are lower-cased. -- You can now use these helpers on the JavaScript side! But don't rely on their actual values please. - -### Usage - - - -```reason -let s = submit("hello"); /* gives Submit("hello") */ -``` - -```ocaml -let s = submit "hello" (* gives Submit("hello") *) -``` - - - -This is useful: - -- When you're passing the accessor function as a higher-order function (which plain variant constructors aren't). -- When you'd like the JS side to use these values & functions opaquely and pass you back a variant constructor (since JS has no such thing). - -Please note that in case you just want to _pipe a payload into a constructor_, you don't need to generate functions for that. Use the `->` syntax instead, e.g. `"test"->Submit`. - -## Generate Field Accessors for Records - -Use `[@bs.deriving accessors]` on a record type to create accessors for its record field names. - - - -```reason -[@bs.deriving accessors] -type pet = { - name: string, -}; - -let pets = [|{name: "bob"}, {name: "bob2"}|]; - -pets - ->Belt.Array.map(name) - ->Js.Array2.joinWith("&") - ->Js.log; -``` - -```ocaml -type pet = { - name: string; -}[@@bs.deriving accessors] - -let pets = [|{ name = ("bob") }; { name = ("bob2") }|] - -let _ = - ((((pets |. Belt.Array.map) name) |. Js.Array2.joinWith) - ("&")) - |. Js.log -``` - -```js -function name(param) { - return param.name; -} - -var pets = [ - { - name: "bob", - }, - { - name: "bob2", - }, -]; - -console.log(Belt_Array.map(pets, name).join("&")); -``` - - - -## Generate Converters for JS Object and Record - -> **Note:** In ReScript >= v7 [records are already compiled to JS -> objects](bind-to-js-object#bind-to-record-like-js-objects). `[@bs.deriving jsConverter]` is therefore -> obsolete and will generate a no-op function for compatibility instead. - -Use `[@bs.deriving jsConverter]` on a record type to create convertion functions between records / JS object runtime values. - - - -```reason -[@bs.deriving jsConverter] -type coordinates = { - x: int, - y: int -}; -``` - -```ocaml -type coordinates = { - x: int; - y: int; -}[@@bs.deriving jsConverter] -``` - - - -Generates 2 functions of the following types: - - - -```reason -let coordinatesToJs: coordinates => {. "x": int, "y": int}; - -let coordinatesFromJs: {.. "x": int, "y": int} => coordinates; -``` - -```ocaml -val coordinatesToJs : coordinates -> < x: int; y: int> Js.t - -val coordinatesFromJs : < x: int; y: int ; .. > Js.t -> coordinates -``` - - - -**Note**: - -- `coordinatesFromJs` uses an open object type that accepts more fields, just to be more permissive. -- The converters are shallow. They don't recursively drill into the fields and convert them. This preserves the speed and simplicity of output while satisfying 80% of use-cases. - -### Usage - -This exports a `jsCoordinates` JS object (not a record!) for JS files to use: - - - -```reason -let jsCoordinates = coordinatesToJs({x: 1, y: 2}); -``` - -```ocaml -let jsCoordinates = coordinatesToJs { x = 1; y = 2 } -``` - - - -This binds to a `jsCoordinates` record (not a JS object!) that exists on the JS side, presumably created by JS calling the function `coordinatesFromJs`: - - - -```reason -[@bs.module "myGame"] external jsCoordinates : coordinates = "jsCoordinates"; -``` - -```ocaml -external jsCoordinates : coordinates = "jsCoordinates"[@@bs.module "myGame"] -``` - - - -### More Safety - -The above generated functions use `Js.t` object types. You can also hide this implementation detail by making the object type **abstract** by using the `newType` option with `[@bs.deriving jsConverter]`: - - - -```reason -[@bs.deriving {jsConverter: newType}] -type coordinates = { - x: int, - y: int -}; -``` - -```ocaml -type coordinates = { - x: int ; - y: int -} [@@bs.deriving { jsConverter = newType }] -``` - - - -Generates 2 functions of the following types: - - - -```reason -let coordinatesToJs: coordinates => abs_coordinates; - -let coordinatesFromJs: abs_coordinates => coordinates; -``` - -```ocaml -val coordinatesToJs : coordinates -> abs_coordinates - -val coordinatesFromJs : abs_coordinates -> coordinates -``` - - - -#### Usage - -Using `newType`, you've now prevented consumers from inadvertently doing the following: - - - -```reason -let myCoordinates = { - x: 10, - y: 20 -}; -let jsCoords = coordinatesToJs(myCoordinates); - -let x = jsCoords##x; /* disallowed! Don't access the object's internal details */ -``` - -```ocaml -let myCoordinates = { - x = 10; - y = 20 -} - -let jsCoords = coordinatesToJs myCoordinates - -let x = jsCoords ## x (* disallowed! Don't access the object's internal details *) -``` - - - -Same generated output. Isn't it great that types prevent invalid accesses you'd otherwise have to encode at runtime? - -## Generate Converters for JS Integer Enums and Variants - -Use `[@bs.deriving jsConverter]` on a variant type to create converter functions that allow back and forth conversion between JS integer enum and ReScript variant values. - - - -```reason -[@bs.deriving jsConverter] -type fruit = - | Apple - | Orange - | Kiwi - | Watermelon; -``` - -```ocaml -type fruit = - | Apple - | Orange - | Kiwi - | Watermelon [@@bs.deriving jsConverter] -``` - - - -This option causes `jsConverter` to, again, generate functions of the following types: - - - -```reason -let fruitToJs: fruit => int; - -let fruitFromJs: int => option(fruit); -``` - -```ocaml -val fruitToJs : fruit -> int - -val fruitFromJs : int -> fruit option -``` - - - -For `fruitToJs`, each fruit variant constructor would map into an integer, starting at 0, in the order they're declared. - -For `fruitFromJs`, the return value is an `option`, because not every int maps to a constructor. - -You can also attach a `[@bs.as alternativeIntValue]` to each constructor to customize their output. - -### Usage - - - -```reason -[@bs.deriving jsConverter] -type fruit = - | Apple - | [@bs.as 10] Orange - | [@bs.as 100] Kiwi - | Watermelon; - -let zero = fruitToJs(Apple); /* 0 */ - -switch (fruitFromJs(100)) { -| Some(Kiwi) => Js.log("this is Kiwi") -| _ => Js.log("received something wrong from the JS side") -}; -``` - -```ocaml -type fruit = - | Apple - | Orange [@bs.as 10] - | Kiwi [@bs.as 100] - | Watermelon [@@bs.deriving jsConverter] - -let zero = fruitToJs Apple;; - -match fruitFromJs 100 with - | ((Some (Kiwi))[@explicit_arity ]) -> Js.log "this is Kiwi" - | _ -> Js.log "received something wrong from the JS side" -``` - - - -**Note**: by using `bs.as` here, all subsequent number encoding changes. `Apple` is still `0`, `Orange` is `10`, `Kiwi` is `100` and `Watermelon` is **`101`**! - -### More Safety - -Similar to the JS object \<-> record deriving, you can hide the fact that the JS enum are ints by using the same `newType` option with `[@bs.deriving jsConverter]`: - - - -```reason -[@bs.deriving {jsConverter: newType}] -type fruit = - | Apple - | [@bs.as 100] Kiwi - | Watermelon; -``` - -```ocaml -type fruit = - | Apple - | Kiwi [@bs.as 100] - | Watermelon [@@bs.deriving { jsConverter = newType }] -``` - - - -This option causes `jsConverter` to generate functions of the following types: - - - -```reason -let fruitToJs: fruit => abs_fruit; - -let fruitFromJs: abs_fruit => fruit; -``` - -```ocaml -val fruitToJs : fruit -> abs_fruit - -val fruitFromJs : abs_fruit -> fruit -``` - - - -For `fruitFromJs`, the return value, unlike the previous non-abstract type case, doesn't contain an `option`, because there's no way a bad value can be passed into it; the only creator of `abs_fruit` values is `fruitToJs`! - -#### Usage - - - -```reason -[@bs.deriving {jsConverter: newType}] -type fruit = - | Apple - | [@bs.as 100] Kiwi - | Watermelon; - -let opaqueValue = fruitToJs(Apple); - -[@bs.module "myJSFruits"] external jsKiwi : abs_fruit = "iSwearThisIsAKiwi"; -let kiwi = fruitFromJs(jsKiwi); - -let error = fruitFromJs(100); /* nope, can't take a random int */ -``` - -```ocaml -type fruit = - | Apple - | Kiwi [@bs.as 100] - | Watermelon [@@bs.deriving { jsConverter = newType }] - -let opaqueValue = fruitToJs Apple - -external jsKiwi : abs_fruit = "iSwearThisIsAKiwi"[@@bs.module "myJSFruits"] - -let kiwi = fruitFromJs jsKiwi -let error = fruitFromJs 100 -``` - - - -## Generate Converters for JS String Enums and Polymorphic Variants - -> **Note**: Since ReScript 8.2, polymorphic variants are already compiled to strings, so this feature is getting deprecated at some point. It's currently still useful for aliasing JS output with `@bs.as`. - -Similarly as with [generating int converters](#generate-converters-between-js-integer-enums-and-variants), use `[@bs.deriving jsConverter]` on a polymorphic variant type to create converter functions for JS string and ReScript poly variant values. - -### Usage - - - -```reason -[@bs.deriving jsConverter] -type fruit = [ - | `Apple - | [@bs.as "miniCoconut"] `Kiwi - | `Watermelon -]; - -let appleString = fruitToJs(`Apple); /* "Apple" */ -let kiwiString = fruitToJs(`Kiwi); /* "miniCoconut" */ -``` - -```ocaml -type fruit = [ - | `Apple - | `Kiwi [@bs.as "miniCoconut"] - | `Watermelon -] [@@bs.deriving jsConverter] - -let appleString = fruitToJs `Apple -let kiwiString = fruitToJs `Kiwi -``` - - - -You can also use `[@bs.deriving {jsConverter: newType}]` to generate abstract types instead. - -## Convert Record Type to Abstract Record - -> **Note**: For ReScript >= v7, we recommend using [plain records to compile to JS objects](bind-to-js-object#bind-to-record-like-js-objects). -> This feature might still be useful for certain scenarios, but the ergonomics might be worse - -Use `[@bs.deriving abstract]` on a record type to expand the type into a creation, and a set of getter / setter functions for fields and methods. - -Usually you'd just use ReScript records to compile to JS objects of the same shape. There is still one particular use-case left where the `[@bs.deriving abstract]` convertion is still useful: Whenever you need compile a record with an optional field where the JS object attribute shouldn't show up in the resulting JS when undefined (e.g. `{name: "Carl", age: undefined}` vs `{name: "Carl"}`). Check the [Optional Labels](#optional-labels) section for more infos on this particular scenario. - -### Usage Example - - - -```reason -[@bs.deriving abstract] -type person = { - name: string, - age: int, - job: string, -}; - -[@bs.val] external john : person = "john"; -``` - -```ocaml -type person = { - name: string; - age: int; - job: string; -} [@@bs.deriving abstract] - -external john : person = "john" [@@bs.val] -``` - - - -**Note**: the `person` type is **not** a record! It's a record-looking type that uses the record's syntax and type-checking. The `[@bs.deriving abstract]` decorator turns it into an "abstract type" (aka you don't know what the actual value's shape). - -### Creation - -You don't have to bind to an existing `person` object from the JS side. You can also create such `person` JS object from ReScript's side. - -Since `[@bs.deriving abstract]` turns the above `person` record into an abstract type, you can't directly create a person record as you would usually. This doesn't work: `{name: "Joe", age: 20, job: "teacher"}`. - -Instead, you'd use the **creation function** of the same name as the record type, implicitly generated by the `[@bs.deriving abstract]` annotation: - - - -```reason -let joe = person(~name="Joe", ~age=20, ~job="teacher") -``` - -```ocaml -let joe = person ~name:"Joe" ~age:20 ~job:"teacher" -``` - -```js -var joe = { - name: "Joe", - age: 20, - job: "teacher", -}; -``` - - - -Note how in the example above there is no JS runtime overhead. - -#### Rename Fields - -Sometimes you might be binding to a JS object with field names that are invalid in ReScript/Reason. Two examples would be `{type: "foo"}` (reserved keyword in ReScript/Reason) and `{"aria-checked": true}`. Choose a valid field name then use `[@bs.as]` to circumvent this: - - - -```reason -[@bs.deriving abstract] -type data = { - [@bs.as "type"] type_: string, - [@bs.as "aria-label"] ariaLabel: string, -}; - -let d = data(~type_="message", ~ariaLabel="hello"); -``` - -```ocaml -type data = { - type_: string [@bs.as "type"]; - ariaLabel: string [@bs.as "aria-label"]; -} [@@bs.deriving abstract] - -let d = data ~type_:"message" ~ariaLabel:"hello" -``` - -```js -var d = { - type: "message", - "aria-label": "hello", -}; -``` - - - -#### Optional Labels - -You can omit fields during the creation of the object: - - - -```reason -[@bs.deriving abstract] -type person = { - [@bs.optional] name: string, - age: int, - job: string, -}; - -let joe = person(~age=20, ~job="teacher", ()); -``` - -```ocaml -type person = { - name: string [@bs.optional]; - age: int; - job: string; -} [@@bs.deriving abstract] - -let joe = person ~age:20 ~job:"teacher" () -``` - -```js -var joe = { - age: 20, - job: "teacher", -}; -``` - - - -Optional values that are not defined, will not show up as an attribute in the resulting JS object. In the example above, you will see that `name` was omitted. - -**Note** that the `[@bs.optional]` tag turned the `name` field optional. Merely typing `name` as `option(string)` wouldn't work. - -**Note**: now that your creation function contains optional fields, we mandate an unlabeled `()` at the end to indicate that [you've finished applying the function](function#optional-labeled-arguments). - -### Accessors - -Again, since `[@bs.deriving abstract]` hides the actual record shape, you can't access a field using e.g. `joe.age`. We remediate this by generating getter and setters. - -#### Read - -One getter function is generated per `bs.deriving abstract` record type field. In the above example, you'd get 3 functions: `nameGet`, `ageGet`, `jobGet`. They take in a `person` value and return `string`, `int`, `string` respectively: - - - -```reason -let twenty = ageGet(joe) -``` - -```ocaml -let twenty = ageGet joe -``` - - - -Alternatively, you can use the [Pipe](pipe) operator (`->`) for a nicer-looking access syntax: - - - -```reason -let twenty = joe->ageGet -``` - -```ocaml -let twenty = joe |. ageGet -``` - - - -If you prefer shorter names for the getter functions, we also support a `light` setting: - - - -```reason -[@bs.deriving {abstract: light}] -type person = { - name: string, - age: int, -}; - -let joe = person(~name="Joe", ~age=20); -let joeName = name(joe); -``` - -```ocaml -type person = { - name: string; - age: int; -} [@@bs.deriving {abstract = light}] - -let joe = person ~name:"Joe" ~age:20 -let joeName = name joe -``` - - - -The getter functions will now have the same names as the object fields themselves. - -#### Write - -A `[@bs.deriving abstract]` value is immutable by default. To mutate such value, you need to first mark one of the abstract record field as `mutable`, the same way you'd mark a normal record as mutable: - - - -```reason -[@bs.deriving abstract] -type person = { - name: string, - mutable age: int, - job: string, -}; -``` - -```ocaml -type person = { - name: string; - mutable age: int; - job: string; -} [@@bs.deriving abstract] -``` - - - -Then, a setter of the name `ageSet` will be generated. Use it like so: - - - -```reason -let joe = person(~name="Joe", ~age=20, ~job="teacher"); -ageSet(joe, 21); -``` - -```ocaml -let joe = person ~name:"Joe" ~age:20 ~job:"teacher" -let () = ageSet joe 21 -``` - - - -Alternatively, with the Pipe First syntax: - - - -```reason -joe->ageSet(21) -``` - -```ocaml -joe |. ageSet 21 -``` - - - -### Methods - -You can attach arbitrary methods onto a type (_any_ type, as a matter of fact. Not just `[@bs.deriving abstract]` record types). See [Object Method](bind-to-js-function#object-method) in the "Bind to JS Function" section for more infos. - -### Tips & Tricks - -You can leverage `[@bs.deriving abstract]` for finer-grained access control. - -#### Mutability - -You can mark a field as mutable in the implementation (`ml`/`re`) file, while _hiding_ such mutability in the interface file: - - - -```reason -/* test.re */ -[@bs.deriving abstract] -type cord = { - [@bs.optional] mutable x: int, - y: int, -}; -``` - -```ocaml -(* test.ml *) -type cord = { - mutable x: int [@bs.optional]; - y: int; -} [@@bs.deriving abstract] -``` - - - - - -```reason -/* test.rei */ -[@bs.deriving abstract] -type cord = { - [@bs.optional] x: int, - y: int, -}; -``` - -```ocaml -(* test.mli *) -type cord = { - x: int [@bs.optional]; - y: int; -} [@@bs.deriving abstract] -``` - - - -Tada! Now you can mutate inside your own file as much as you want, and prevent others from doing so! - -#### Hide the Creation Function - -Mark the record as `private` to disable the creation function: - - - -```reason -[@bs.deriving abstract] -type cord = pri { - [@bs.optional] x: int, - y: int, -}; -``` - -```ocaml -type cord = private { - x: int [@bs.optional]; - y: int -} [@@bs.deriving abstract] -``` - - - -The accessors are still there, but you can no longer create such data structure. Great for binding to a JS object while preventing others from creating more such object! - -#### Use submodules to prevent naming collisions and binding shadowing - -Oftentimes you will have multiple abstract types with similar attributes. Since -ReScript will expand all abstract getter, setter and creation functions in the -same scope where the type is defined, you will eventually run into value shadowing problems. - -**For example:** - - - -```reason -[@bs.deriving abstract] -type person = {name: string}; - -[@bs.deriving abstract] -type cat = { - name: string, - isLazy: bool, -}; - -let person = person(~name="Alice"); - -/* Error: This expression has type person but an expression was expected - of type cat */ -person->nameGet(); -``` - -```ocaml -type person = { name: string }[@@bs.deriving abstract] -type cat = { - name: string; - isLazy: bool -}[@@bs.deriving abstract] - -let person = person ~name:"Alice";; - -(person |. nameGet) () -``` - - - -To get around this issue, you can use modules to group a type with its related -functions and later use them via local open statements: - - - -```reason -module Person = { - [@bs.deriving abstract] - type t = {name: string}; -}; - -module Cat = { - [@bs.deriving abstract] - type t = { - name: string, - isLazy: bool, - }; -}; - -let person = Person.t(~name="Alice"); -let cat = Cat.t(~name="Snowball", ~isLazy=true); - -/* We can use each nameGet function separately now */ -let shoutPersonName = Person.(person->nameGet->Js.String.toUpperCase); - -/* Note how we use a local open Cat.([some expression]) to - get access to Cat's nameGet function */ -let whisperCatName = Cat.(cat->nameGet->Js.String.toLowerCase); -``` - -```ocaml -module Person = - struct type t = { name: string }[@@bs.deriving abstract] end - -module Cat = struct type t = { - name: string; - isLazy: bool -}[@@bs.deriving abstract] end - -let person = Person.t ~name:"Alice" -let cat = Cat.t ~name:"Snowball" ~isLazy:true - -let shoutPersonName = - let open Person in (person |. nameGet) |. Js.String.toUpperCase - -let whisperCatName = - let open Cat in (cat |. nameGet) |. Js.String.toLowerCase -``` - - - -## Convert External into JS Object Creation Function - -Use `@bs.obj` on an `external` binding to create a function that, when called, will evaluate to a `Js.t` object with fields corresponding to the function's parameter labels. - -This is very handy because you can make some of those labelled parameters optional and if you don't pass them in, the output object won't include the corresponding fields. Thus you can use it to dynamically create objects with the subset of fields you need at runtime. - -For example, suppose you need a JavaScript object like this: - -```js -var homeRoute = { - method: "GET", - path: "/", - action: () => console.log("Home"), - // options: ... -}; -``` - -But only the first three fields are required; the options field is optional. You can declare the binding function like so: - - - -```reason -[@bs.obj] external route: ( - ~_method:string, - ~path:string, - ~action:(list(string) => unit), - ~options:Js.t({..})=?, - unit -) => _ = ""; -``` - -```ocaml -external route : - _method:string -> - path:string -> - action:(string list -> unit) -> - ?options:< .. > Js.t -> - unit -> - _ = "" [@@bs.obj] -``` - - - -**Note**: the ` = ""` part at the end is just a dummy placeholder, due to syntactic limitations. It serves no purpose currently. - -This function has four labelled parameters (the fourth one optional), one unlabelled parameter at the end (which we mandate for functions with [optional parameters](function#optional-labeled-arguments), and one parameter (`_method`) that requires an underscore prefix to avoid confusion with the ReScript keyword `method`. - -Also of interest is the return type: `_`, which tells ReScript to automatically infer the full type of the `Js.t` object, sparing you the hassle of writing down the type manually! - -The function is called like so: - - - -```reason -let homeRoute = route(~_method="GET", ~path="/", ~action=(_ => Js.log("Home")), ()); -``` - -```ocaml -let homeRoute = route ~_method:"GET" ~path:"/" ~action:(fun _ -> Js.log "Home") () -``` - - diff --git a/pages/docs/manual/v8.0.0/import-export.mdx b/pages/docs/manual/v8.0.0/import-export.mdx deleted file mode 100644 index 2cb57673a..000000000 --- a/pages/docs/manual/v8.0.0/import-export.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: "Import & Export" -description: "Importing / exporting in ReScript modules" -canonical: "/docs/manual/latest/import-export" ---- - -# Import & Export - -## Import a Module/File - -Unlike JavaScript, ReScript doesn't have or need import statements: - - - -```re -// Inside School.re -let studentMessage = Student.message; -``` - -```ml -(* Inside School.re *) -let studentMessage = Student.message -``` - -```js -var Student = require("./Student.bs"); -var studentMessage = Student.message; -``` - - - -The above code refers to the `message` binding in the file `Student.re`. Every ReScript file is also a module, so accessing another file's content is the same as accessing another module's content! - -A ReScript project's file names need to be unique. - -## Export Stuff - -By default, every file's type declaration, binding and module is exported, aka publicly usable by another file. **This also means those values, once compiled into JS, are immediately usable by your JS code**. - -To only export a few selected things, use an [interface file](module.md#signatures). - -## Work with JavaScript Import & Export - -To see how to import JS modules and export stuff for JS consumption, see the JavaScript Interop section's [Import from/Export to JS](import-from-export-to-js.md). diff --git a/pages/docs/manual/v8.0.0/import-from-export-to-js.mdx b/pages/docs/manual/v8.0.0/import-from-export-to-js.mdx deleted file mode 100644 index 07af4500d..000000000 --- a/pages/docs/manual/v8.0.0/import-from-export-to-js.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -title: "Import from / Export to JS" -description: "Importing / exporting JS module content in ReScript" -canonical: "/docs/manual/latest/import-from-export-to-js" ---- - -# Import from/Export to JS - -You've seen how ReScript's idiomatic [Import & Export](import-export.md) works. This section describes how we work with importing stuff from JavaScript and exporting stuff for JavaScript consumption. - -## Import From JavaScript - -### Import a JavaScript Module's Content - -Use the `bs.module` [external](external.md): - - - -```re -// Import nodejs' path.dirname -[@bs.module "path"] external dirname: string => string = "dirname"; -let root = dirname("/User/github"); // returns "User" -``` - -```ml -(* Import nodejs' path.dirname *) -external dirname: string -> string = "dirname" [@@bs.module "path"] -let root = dirname "/User/github" (* returns "User" *) -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - - - -Here's what the `external` does: - -- `[@bs.module "path"]`: pass the name of the JS module as a string; in this case, `"path"`. The string can be anything: `"./src/myJsFile"`, `"@myNpmNamespace/myLib"`, etc. -- `external`: the general keyword for declaring a value that exists on the JS side. -- `dirname`: the binding name you'll use on the ReScript side. -- `string => string`: the type signature of `dirname`. -- `= "dirname"`: the name of the variable inside the `path` JS module. There's repetition in writing the first and second `dirname`, because sometime the binding name you want to use on the ReScript side is different than the variable name the JS module exported. - -### Import a JavaScript Module Itself (CommonJS) - -By omitting the string argument to `bs.module`, you bind to the whole JS module: - - - -```re -[@bs.module] external leftPad: string => int => string = "./leftPad"; -let paddedResult = leftPad("hi", 5); -``` - -```ml -external leftPad: string -> int -> string = "./leftPad" [@@bs.module] -let paddedResult = leftPad "hi" 5 -``` - -```js -var LeftPad = require("./leftPad"); -var paddedResult = LeftPad("hi", 5); -``` - - - -### Import a JavaScript Module Itself (ES6 Module Format) - -If your JS project is using ES6, you're likely using Babel to compile it to regular JavaScript. Babel's ES6 default export actually exports the default value under the name `default`. You'd bind to it like this: - - - -```re -[@bs.module "./student"] external studentName: string = "default"; -Js.log(studentName); -``` - -```ml -external studentName: string = "default" [@@bs.module "./student"] -let () = Js.log studentName -``` - -```js -var Student = require("./student"); -console.log(Student.default); -``` - - - -## Export To JavaScript - -As mentioned in ReScript's idiomatic [Import & Export](import-export.md), every let binding and module is exported by default to other ReScript modules. If you open up the compiled JS file, you'll see that these values can also directly be used by another _JavaScript_ file too. - -We support 2 JS export formats: - -- CommonJS (usable from JS as `require('myFile')`). -- ES6 modules (usable from JS as `import * from 'myFile'`). - -The output format is [configurable in bsb](build-configuration.md#package-specs). - -### Export an ES6 default value - -If your JS project is using ES6 modules, you're likely exporting & importing some default values: - -```js -// student.js -export default name = "Al"; -``` - -```js -// teacher.js -import studentName from "student.js"; -``` - -Technically, since a ReScript file maps to a module, there's no such thing as "default" export, only named ones. However, we've made an exception to support default module when you do the following: - - - -```re -/* FavoriteStudent.re */ -let default = "Bob"; -``` - -```re -(* FavoriteStudent.re *) -let default = "Bob" -``` - -```js -var $$default = "Bob"; - -exports.$$default = $$default; -exports.default = $$default; -exports.__esModule = true; -``` - - - -You can then require the default as normal JS side: - -```js -// teacher2.js -import studentName from "FavoriteStudent.js"; -``` - -**Note**: the above JS snippet _only_ works if you're using that ES6 import/export syntax in JS. If you're still using `require`, you'd need to do: - -```js -let studentName = require("FavoriteStudent").default; -``` diff --git a/pages/docs/manual/v8.0.0/installation.mdx b/pages/docs/manual/v8.0.0/installation.mdx deleted file mode 100644 index c92b34df2..000000000 --- a/pages/docs/manual/v8.0.0/installation.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: "Installation" -description: "ReScript installation and setup instructions" -canonical: "/docs/manual/latest/installation" ---- - -# Installation - -Prerequisite: NPM, which comes with [NodeJS](https://nodejs.org/en/). [Yarn](https://yarnpkg.com/en/) also works. - -To install ReScript globally: - -```sh -npm install -g bs-platform -``` - -## New Project - -**Note**: this starts a new project with the new syntax, not the old Reason syntax. - -```sh -git clone https://github.com/rescript-lang/rescript-project-template -cd rescript-project-template -npm install -npm run build -node src/Demo.bs.js -``` - - - -That compiles your ReScript into JavaScript, then uses NodeJS to run said JavaScript. **We recommend you use our highly unique workflow of keeping a tab open for the generated `.bs.js` file**, so that you can learn how ReScript transforms to JavaScript. Not many languages output clean JavaScript code you can manually inspect! - -During development, instead of running `npm run build` each time to compile, use `npm run start` to start a watcher that recompiles automatically after file changes. - -Alternatively, **to start a [ReasonReact](https://reasonml.github.io/reason-react/en/) app**, follow the instructions [here](https://reasonml.github.io/reason-react/docs/en/installation). - -## Integrate Into Existing JS Project - -You can install the toolchain locally to an existing JS project, through the familiar command: - -```sh -npm install --save-dev bs-platform -``` - -The rest is the same as above. Since we output clean `.bs.js` files, the rest of your existing toolchain (e.g. Babel and Webpack) should mostly just work. Nothing to learn on the bundling side! diff --git a/pages/docs/manual/v8.0.0/interop-cheatsheet.mdx b/pages/docs/manual/v8.0.0/interop-cheatsheet.mdx deleted file mode 100644 index 0dd7dbfff..000000000 --- a/pages/docs/manual/v8.0.0/interop-cheatsheet.mdx +++ /dev/null @@ -1,300 +0,0 @@ ---- -title: "Interop Cheatsheet" -description: "Cheatsheet for various interop scenarios in ReScript" -canonical: "/docs/manual/latest/interop-cheatsheet" ---- - -# Interop Cheatsheet - - - -## Raw JS - - - -```re -let add = [%raw "(a, b) => a + b"]; -[%%raw "const a = 1"]; -``` - -```ml -let add = [%raw "(a, b) => a + b"] -[%%raw "const a = 1"] -``` - -```js -var add = (a, b) => a + b; -const a = 1; -``` - - - -## Global Value - - - -```re -[@bs.val] external setTimeout: (unit => unit, int) => float = "setTimeout"; -``` - -```ml -external setTimeout: (unit -> unit) -> int -> float = "setTimeout" [@@bs.val] -``` - -```js -// Empty output -``` - - - -## Global Module's Value - - - -```re -[@bs.val] [@bs.scope "Math"] -external random: unit => float = "random"; - -let someNumber = random(); - -[@bs.val] [@bs.scope ("window", "location", "ancestorOrigins")] -external length: int = "length"; -``` - -```ml -external random: unit -> float = "random" -[@@bs.val][@@bs.scope "Math"] - -let someNumber = random () - -external length: int = "length" -[@@bs.val][@@bs.scope ("window", "location", "ancestorOrigins")] -``` - -```js -var someNumber = Math.random(); -``` - - - -## Nullable - - - -```re -let a = Some(5); // compiles to 5 -let b = None; // compiles to undefined -``` - -```ml -let a = Some 5 (* compiles to 5 *) -let b = None (* compiles to undefined *) -``` - -```js -var a = 5; -var b; -``` - - - -Handling a value that can be `undefined` and `null`, by ditching the `option` type and using `Js.Nullable.t`: - - - -```re -let jsNull = Js.Nullable.null; -let jsUndefined = Js.Nullable.undefined; -let result1: Js.Nullable.t(string) = Js.Nullable.return("hello"); -let result2: Js.Nullable.t(int) = Js.Nullable.fromOption(Some(10)); -let result3: option(int) = Js.Nullable.toOption(Js.Nullable.return(10)); -``` - -```ml -let jsNull = Js.Nullable.null -let jsUndefined = Js.Nullable.undefined -let result1: string Js.Nullable.t = Js.Nullable.return "hello" -let result2: int Js.Nullable.t = Js.Nullable.fromOption (Some 10) -let result3: int option = Js.Nullable.toOption (Js.Nullable.return 10) -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); -var Js_null_undefined = require("./stdlib/js_null_undefined.js"); - -var jsNull = null; -var jsUndefined; -var result1 = "hello"; -var result2 = Js_null_undefined.fromOption(10); -var result3 = Caml_option.nullable_to_opt(10); -``` - - - -## JS Object - -- [Bind to a JS object as a ReScript record](bind-to-js-object#bind-to-record-like-js-objects). -- [Bind to a JS object that acts like a hash map](bind-to-js-object#bind-to-hash-map-like-js-object). -- [Bind to a JS object that's a class](bind-to-js-object#bind-to-a-js-object-thats-a-class). - -## Function - -### Object Method & Chaining - - - -```re -[@bs.send] external map: (array('a), 'a => 'b) => array('b) = "map"; -[@bs.send] external filter: (array('a), 'a => 'b) => array('b) = "filter"; -[|1, 2, 3|] - ->map(a => a + 1) - ->filter(a => a mod 2 == 0) - ->Js.log; -``` - -```ml -external map: 'a array -> ('a -> 'b) -> 'b array = "map" [@@bs.send] -external filter: 'a array -> ('a -> 'b) -> 'b array = "filter" [@@bs.send] -[|1; 2; 3|] - |. map(fun a -> a + 1) - |. filter(fun a -> a mod 2 = 0) - |. Js.log -``` - -```js -console.log( - [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }), -); -``` - - - -### Variadic Arguments - - - -```re -[@bs.module "path"] [@bs.variadic] -external join: array(string) => string = "join"; -``` - -```ml -external join: string array -> string = "join" -[@@bs.module "path"][@@bs.variadic] -``` - -```js -// Empty output -``` - - - -### Polymorphic Function - - - -```re -[@bs.module "Drawing"] external drawCat: unit => unit = "draw"; -[@bs.module "Drawing"] external drawDog: (~giveName: string) => unit = "draw"; -``` - -```ml -external drawCat: unit -> unit = "draw" [@@bs.module "Drawing"] -external drawDog: giveName:string -> unit = "draw" [@@bs.module "Drawing"] -``` - -```js -// Empty output -``` - - - - - -```re -[@bs.val] -external padLeft: ( - string, - [@bs.unwrap] [ - | `Str(string) - | `Int(int) - ]) - => string = "padLeft"; - -padLeft("Hello World", `Int(4)); -padLeft("Hello World", `Str("Message from ReScript: ")); -``` - -```ml -external padLeft: - string -> - (([ - | `Str of string - | `Int of int - ]) [@bs.unwrap]) -> - string = "padLeft" [@@bs.val] - -let _ = padLeft "Hello World" (`Int 4) -let _ = padLeft "Hello World" (`Str "Message from ReScript: ") -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -## JS Module Interop - -[See here](import-from-export-to-js.md) - -## Dangerous Type Cast - -Final escape hatch converter. Do not abuse. - - - -```re -external convertToFloat: int => float = "%identity"; -let age = 10; -let gpa = 2.1 +. convertToFloat(age); -``` - -```ml -external convertToFloat: int => float = "%identity" -let age = 10 -let gpa = 2.1 +. (convertToFloat age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - - -## List of `@bs` Decorators - -- `@bs.as` -- `@bs.get` -- `@bs.inline` -- `@bs.int` -- `@bs.meth` -- `@bs.new` -- `@bs.return` -- `@bs.scope` -- `@bs.send` -- `@bs.set` -- `@bs.string` -- `@bs.this` -- `@bs.uncurry` -- `@bs.unwrap` -- `@bs.val` -- `@bs.variadic` diff --git a/pages/docs/manual/v8.0.0/interop-with-js-build-systems.mdx b/pages/docs/manual/v8.0.0/interop-with-js-build-systems.mdx deleted file mode 100644 index 0913040e2..000000000 --- a/pages/docs/manual/v8.0.0/interop-with-js-build-systems.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Interop with JS Build Systems" -description: "Documentation on how to interact with existing JS build systems" -canonical: "/docs/manual/latest/interop-with-js-build-systems" ---- - -# Interop with JS Build Systems - -If you come from JS, chances are that you already have a build system in your existing project. Here's an overview of the role bsb would play in your build pipeline, if you want to introduce some ReScript code into the codebase. - -> As much as possible, please try not to wrap bsb into your own incremental build framework. ReScript's compilation is very hard to get right, and you'll inevitably run into stale or badly performing builds (therefore erasing much of our value proposition) if you create your own meta layer on top. - -## Popular JS Build Systems - -The JS ecosystem uses a few build systems: [browserify](http://browserify.org/), [rollup](https://github.com/rollup/rollup), [webpack](https://webpack.js.org/), etc. The latter's probably the most popular of the three (as of 2019 =P). These build systems do both the compilation and the linking (aka, bundling many files into one or few files). - -ReScript and bsb only take care of the compilation step; it maps one `.re`/`.rei` file into one JS output file. As such, in theory, no build system integration is needed from our side. From e.g. the webpack watcher's perspective, the JS files ReScript generates are almost equivalent to your hand-written JS files. We also recommend that you initially check in those ReScript-generated JS files, as this workflow means: - -- You can introduce ReScript silently into your codebase without disturbing existing infra. -- You have a **visual** diff of the performance & correctness of your JS file when you update the `.re` files and the JS artifacts change. -- You can let teammates hot-patch the JS files in emergency situations, without needing to first start learning ReScript. -- You can remove ReScript completely from your codebase and things will still work (in case your company decides to stop using us for whatever reason). - -For what it's worth, you can also turn bsb into an automated step in your build pipeline, e.g. into a webpack loader; but such approach is error-prone and therefore discouraged. - -### Tips & Tricks - -You can make ReScript JS files look even more idiomatic through the in-source + bs suffix config in `bsconfig.json`: - -```json -{ - "package-specs": { - "module": "commonjs", // or whatever module system your project uses - "in-source": true - }, - "suffix": ".bs.js" -} -``` - -This will: - -- Generate the JS files alongside your ReScript source files. -- Use the file extension `.bs.js`, so that you can require these files on the JS side through `require('./MyFile.bs')`, without needing a loader. - -## Use Loaders on ReScript Side - -"What if my build system uses a CSS/png/whatever loader and I'd like to use it in ReScript?" - -Loaders are indeed troublesome; in the meantime, please use e.g. `%raw("require('./myStyles.css')")` at the top of your file. This just uses [`raw`](embed-raw-javascript.md) to compile the snippet into an actual JS require. - -## Getting Project's Dependencies - -`bsb` generates one `MyFile.mlast.d` file per `MyFile` source file; you'll find them in `lib/bs`. These are human readable, machine-friendly list of the dependencies of said `MyFile`. You can read into them for your purpose (though mind the IO overhead). Use these files instead of creating your own dependency graph; we did the hard work of tracking the dependencies as best as possible (including inner modules, `open`s, module names overlap, etc). - -## Run Script Per File Built - -See [js-post-build](build-configuration#js-post-build). Though please use it sparingly; if you hook up a node.js script after each file built, you'll incur the node startup time per file! diff --git a/pages/docs/manual/v8.0.0/introduction.mdx b/pages/docs/manual/v8.0.0/introduction.mdx deleted file mode 100644 index 654a991ce..000000000 --- a/pages/docs/manual/v8.0.0/introduction.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: "Introduction" -description: "The hows and whys of ReScript" -canonical: "/docs/manual/latest/introduction" ---- - -# ReScript - -Ever wanted a language like JavaScript, but without the warts, with a great type system, and with a lean build toolchain that doesn't waste your time? - -ReScript looks like JS, acts like JS, and compiles to the highest quality of clean, readable and performant JS, directly runnable in browsers and Node. - -**This means you can pick up ReScript and access the vast JavaScript ecosystem and tooling as if you've known ReScript for a long time**! - -**ReScript is the language for folks who don't necessarily love JavaScript, but who still acknowledge its importance**. - -## Difference vs TypeScript - -We respect TypeScript very much and think that it's a positive force in the JavaScript ecosystem. ReScript shares some of the same goals as TypeScript, but is different enough regarding some important nuances: - -- TypeScript's (admittedly noble) goal is to cover the entire JavaScript feature set and more. **ReScript covers only a curated subset of JavaScript**. For example, we emphasize plain data + functions over classes, clean [pattern matching](pattern-matching-destructuring.md) over fragile `if`s and dynamic object dispatches, [proper data modeling](variant.md) over string abuse, etc. JavaScript supersets will only grow larger over time; ReScript doesn't. \* - -- Consequently, TypeScript's type system is necessarily complex, pitfalls-ridden, potentially requires tweaking, sometime slow, and requires quite a bit of noisy annotations that often feel like manual bookkeeping rather than clear documentation. In contrast, ReScript's type system: - - Is deliberately curated to be a simple subset most folks will have an easier time to use. - - Has **no** pitfalls, aka the type system is "sound" (the types will always be correct). E.g. If a type isn't marked as nullable, its value will never lie and let through some `undefined` value silently. **ReScript code has no null/undefined errors**. - - Is the same for everyone. No knobs, no bikeshedding opportunity. - - Runs extremely fast precisely thanks to its simplicity and curation. We're one of the fastest compiler & build system for JavaScript development. - - **Doesn't need type annotations**. Annotate as much or as little as you'd like. The types are inferred by the language (and, again, are guaranteed correct). - -- Migrating to TypeScript is done "breadth-first", whereas migrating to ReScript is done "depth-first". You can convert your codebase to TypeScript by "turning it on" for all files and annotate here and there; but how much type safety did you gain? How do you measure it? Type errors can still slip in and out of the converted pieces. For ReScript, our interop features draws clear boundaries: there's pure ReScript code, and there's JS interop code. Every piece of converted ReScript code is 100% clean. You'd convert file by file and each conversion increases your safety monotonically. - -\* When you absolutely need to write or interoperate with free-for-all JavaScript, we expose enough escape hatches for you. - -## Other Highlights - -Aside from the aforementioned simple, robust and fast type system, ReScript presents a few more advantages. - -### Faster than JavaScript - -JavaScript's been aggressively optimized by talented engineers over a long span. Unfortunately, even for seasoned JS devs, it can be hard to know how to properly leverage JS' performance. ReScript's type system and compiler naturally guides you toward writing code that's very often performant by default, with good leverage of various Just-In-Time optimizations (hidden classes, inline caching, avoiding deopts, etc.). - -A widespread adage to write fast JavaScript code is to write as if there's a type system (in order to trigger JS engines' good optimization heuristics); ReScript gives you a real one and generates code that's friendly to optimizations by default. - -### High Quality Dead Code Elimination - -The JavaScript ecosystem is very reliant on dependencies. Shipping the final product inevitably drags in a huge amount of code, lots of which the project doesn't actually use. These regions of dead code impact loading, parsing and interpretation speed. ReScript provides powerful dead code elimination at all levels: - -- Function and module level code elimination is facilitated by the well-engineered type system and purity analysis. -- At the global level, ReScript generates code that are naturally friendly to dead code elimination done by bundling tools such as [Rollup](https://github.com/rollup/rollup) and [Closure Compiler](https://developers.google.com/closure/compiler/), after its own sophisticated elimination pass. -- The same applies for ReScript's own tiny runtime (which is written in ReScript itself). - -### Tiny JS Output - -A `Hello world` ReScript program generates **20 bytes** JS code. Additionally, the standard library pieces you require in are only include when needed. - -### Fast Iteration Loop - -ReScript's build time is **one or two orders of magnitude** faster than alternatives. In its watcher mode, the build system usually finishes before you switch screen from the editor to the terminal tab (two digits of milliseconds). A fast iteration cycle reduces need of keeping one's mental state around longer; this in turns allows one to stay in the flow longer and more often. - -### Readable Output & Great Interop - -Unreadable JavaScript code generated from other compiled-to-js languages makes it so that it could be, practically speaking: - -- Hard to debug (cryptic stack trace, mangled variable names) -- Hard to learn from (non-straightforward mapping of concepts from one language to another) -- Hard to profile for performance (unclear what runtime performance cost there is) -- Hard to integrate with existing hand-written JS code - -ReScript's JS output is very readable. This is especially important while learning, where users might want to understand how the code's compiled, and to audit for bugs. - -This characteristic, combined with a fully-featured JS interop system, allows ReScript code to be inserted into an existing JavaScript codebase almost unnoticed. - -### Preservation of Code Structure - -ReScript maps one source file to one JavaScript output file. This eases the integration of existing tools such as bundlers and test runners. You can even start writing a single file without much change your build setup. Each file's code structure is approximately preserved, too. - -## Conclusion - -We hope the above gave you enough of an idea of ReScript and its differentiators. Feel free to [try it online](/try) to get a feel! diff --git a/pages/docs/manual/v8.0.0/json.mdx b/pages/docs/manual/v8.0.0/json.mdx deleted file mode 100644 index 613df25a3..000000000 --- a/pages/docs/manual/v8.0.0/json.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: "JSON" -description: "Interacting with JSON in ReScript" -canonical: "/docs/manual/latest/json" ---- - -# JSON - -## Parse - -Bind to JavaScript's `JSON.parse` and type the return value as the type you're expecting: - - - -```re -// declare the shape of the json you're binding to -type data = {names: array(string)}; - -// bind to JS' JSON.parse -[@bs.scope "JSON"] [@bs.val] -external parseIntoMyData: string => data = "parse"; - -let result = parseIntoMyData({|{"names": ["Luke", "Christine"]}|}); -let name1 = result.names[0]; -``` - -```ml -(* declare the shape of the json you're binding to *) -type data = {names: string array} - -(* bind to JS' JSON.parse *) -external parseIntoMyData: string -> data = "parse" -[@@bs.scope "JSON"] [@@bs.val] - -let result = parseIntoMyData {|{"names": ["Luke", "Christine"]}|} -let name1 = (result.names).(0) -``` - -```js -var result = JSON.parse('{"names": ["Luke", "Christine"]}'); -var name1 = result.names[0]; -``` - - - -Where `data` can be any type you assume the JSON is. As you can see, this compiles to a straightforward `JSON.parse` call. As with regular JS, this is convenient, but has no guarantee that e.g. the data is correctly shaped, or even syntactically valid. Slightly dangerous. - -## Stringify - -Use `Js.Json.stringify`: - - - -```re -Js.log(Js.Json.stringifyAny([|"Amy", "Joe"|])); -``` - -```ml -Js.log (Js.Json.stringifyAny [|"Amy"; "Joe"|]) -``` - -```js -console.log(JSON.stringify(["Amy", "Joe"])); -``` - - - -## Advanced - -The [Js.Json](api/js/json) module provides slightly safer, low-level building blocks for power users who want to parse JSON on a per-field basis. See the examples in the API docs. diff --git a/pages/docs/manual/v8.0.0/jsx.mdx b/pages/docs/manual/v8.0.0/jsx.mdx deleted file mode 100644 index 7cf8b28f1..000000000 --- a/pages/docs/manual/v8.0.0/jsx.mdx +++ /dev/null @@ -1,354 +0,0 @@ ---- -title: "JSX" -description: "JSX syntax in ReScript and React" -canonical: "/docs/manual/latest/jsx" ---- - -# JSX - -Would you like some HTML syntax in your ReScript? If not, quickly skip over this section and pretend you didn't see anything! - -ReScript supports the JSX syntax, with some slight differences compared to the one in [ReactJS](https://facebook.github.io/react/docs/introducing-jsx.html). ReScript JSX isn't tied to ReactJS; they translate to normal function calls: - -**Note** for [ReasonReact](https://reasonml.github.io/reason-react/en/) readers: this isn't what ReasonReact turns JSX into, in the end. See Usage section for more info. - -## Capitalized Tag - - - -```re -; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps("ReScript", undefined), -); -``` - - - -becomes - - - -```re -[@JSX] MyComponent.createElement(~name="ReScript", ~children=[], ()); -``` - -```ml -MyComponent.createElement ~name:"ReScript" ~children:[] [@JSX] -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps("ReScript", undefined), -); -``` - - - -## Uncapitalized Tag - - - -```re -
child1 child2
; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - -
- -becomes - - - -```re -[@JSX] div(~onClick=handler, ~children=[child1, child2], ()); -``` - -```ml -div ~onClick:handler ~children:[child1; child2] () [@@JSX] -``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - - - -## Fragment - - - -```re -<> child1 child2 ; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -becomes - - - -```re -[@JSX] [child1, child2]; -``` - -```ml -[child1; child2] [@@JSX] -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -### Children - - - -```re - child1 child2 ; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(null, undefined), - child1, - child2, -); -``` - - - -This is the syntax for passing a list of two items, `child1` and `child2`, to the children position. It desugars to a list containing `child1` and `child2`: - - - -```re -[@JSX] MyComponent.createElement(~children=[child1, child2], ()); -``` - -```ml -MyComponent.createElement ~children:[child1; child2] () [@@JSX] -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(null, undefined), - child1, - child2, -); -``` - - - -**Note** again that this isn't the transform for ReasonReact; ReasonReact turns the final list into an array. But the idea still applies. - -So naturally, ` myChild ` desugars to `@JSX MyComponent.createElement(~children=[myChild], ())`. I.e. whatever you do, the arguments passed to the children position will be wrapped in a list. What if you don't want that? **What if you want to directly pass `myChild` without an extra wrapping**? - -#### Children Spread - -To solve the above problem, we've introduced - - - -```re - ...myChild ; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(myChild, undefined), -); -``` - - - -This passes the value `myChild` _without_ wrapping it in a list (or array, in the case of ReasonReact). Aka, this desugars to: - - - -```re -[@JSX] MyComponent.createElement(~children=myChild, ()); -``` - -```ml -MyComponent.createElement ~children:myChild () [@@JSX] -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(myChild, undefined), -); -``` - - - -This is extra useful in the cases where you are handled `myChild` that is already a list of things, and want to forward that without wrapping it an extra time (which would be a type error) \*. It also allows you to pass arbitrary data structures at `children` position (remember, JSX `children` is really just a totally normal prop): - - - -```re - ...((theClassName) =>
) ; - - ...("Hello", "Submit") ; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement( - make, - makeProps(function (theClassName) { - return React.createElement("div", { - className: theClassName, - }); - }, undefined), -); - -React.createElement( - MyForm.make, - MyForm.makeProps(["Hello", "Submit"], undefined), -); -``` - - - -## Usage - -See [ReasonReact JSX](https://reasonml.github.io/reason-react/docs/en/jsx) for an example application of JSX, which transforms the above calls into a ReasonReact-specific call. - -Here's a JSX tag that shows most of the features. - - - -```re - -
{React.string("hello")}
-
; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps( - true, - "string", - 1, - "hello", - handleClick, - React.createElement("div", undefined, "hello"), - undefined, - ), -); -``` - -
- -## Departures From JS JSX - -- Attributes and children don't mandate `{}`, but we show them anyway for ease of learning. Once you format your file, some of them go away and some turn into parentheses. -- There is no support for JSX prop spread: ``. Though somewhat related, we do have children spread, described above: ` ...children `. -- Punning! - -### Punning - -"Punning" refers to the syntax shorthand for when a label and a value are the same. For example, in JavaScript, instead of doing `return {name: name}`, you can do `return {name}`. - -Reason JSX supports punning. `` is just a shorthand for ``. The formatter will help you format to the punned syntax whenever possible. This is convenient in the cases where there are lots of props to pass down: - - - -```re -; -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(isLoading, text, onClick, undefined), -); -``` - - - -Consequently, a Reason JSX component can cram in a few more props before reaching for extra libraries solutions that avoids props passing. - -**Note** that this is a departure from ReactJS JSX, which does **not** have punning. ReactJS' `` desugars to ``, in order to conform to DOM's idioms and for backward compatibility. - -## Tip & Tricks - -For library authors wanting to take advantage of the JSX: the `@JSX` attribute above is a hook for potential ppx macros to spot a function wanting to format as JSX. Once you spot the function, you can turn it into any other expression. - -This way, everyone gets to benefit the JSX syntax without needing to opt into a specific library using it, e.g. ReasonReact. - -JSX calls supports the features of [labeled functions](function.md#labeled-arguments): optional, explicitly passed optional and optional with default. - -## Design Decisions - -\* You might wonder why you never needed such children spread in ReactJS; ReactJS uses some special runtime logic + special syntax transforms + variadic argument detection & marking to avoid most of these cases ([see here](https://github.com/facebook/react/blob/9b36df86c6ccecb73ca44899386e6a72a83ad445/packages/react/src/ReactElement.js#L207)). Such dynamic usage complexifies the type system detection _quite a bit_. Since we control the whole syntax and ReasonReact, we decided to introduce children spread to disambiguate between the case of wrapping vs not wrapping, without compile-time & runtime cost! diff --git a/pages/docs/manual/v8.0.0/lazy-values.mdx b/pages/docs/manual/v8.0.0/lazy-values.mdx deleted file mode 100644 index eb57e9934..000000000 --- a/pages/docs/manual/v8.0.0/lazy-values.mdx +++ /dev/null @@ -1,378 +0,0 @@ ---- -title: "Lazy Values" -description: "Data type for deferred computation in ReScript" -canonical: "/docs/manual/latest/lazy-values" ---- - -# Lazy Values - -A lazy value represents a deferred computation which will automatically memoize the result on the first run, and then return the memoized result on any repeated execution. - -This is useful for defining functions and expressions for complex procedures that always return the same value, for example: - -- Doing expensive DOM traversals over the same tree over and over again -- Doing file system operations on a static set of files that won't change -- Doing expensive requests to an API server that would always return the same data - -A lazy value has a type of `Lazy.t('a)`, where `'a` is the return value of the computation. All its functionality is encapsulated with the globally available `Lazy` module. - -## Creating a lazy value - -Lazy values are part of the language. You can either use the `lazy` keyword to create a lazy value from an expression... - - - -```re example -// We only want getFiles to read the file system once, -// so we wrap it in a lazy value -let getFiles = - lazy({ - Js.log("Reading dir"); - Node.Fs.readdirSync("./pages"); - }); - -// On the first call, the computation takes place -Lazy.force(getFiles)->Js.log; - -// The second call will just return the already calculated files -Lazy.force(getFiles)->Js.log; -``` - -```ml -(* We only want getFiles to read the file system once, *) -(* so we wrap it in a lazy value *) -let getFiles = lazy ( - Js.log "Reading dir"; - Node.Fs.readdirSync "./pages" -) - -(* On the first call, the computation takes place *) -let () = (Lazy.force getFiles) |. Js.log - -(* The second call will just return the already calculated files *) -let () = (Lazy.force getFiles) |. Js.log -``` - -```js -var Fs = require("fs"); -var CamlinternalLazy = require("./stdlib/camlinternalLazy.js"); - -var getFiles = { - LAZY_DONE: false, - VAL: function () { - console.log("Reading dir"); - return Fs.readdirSync("./pages"); - }, -}; - -console.log(CamlinternalLazy.force(getFiles)); -console.log(CamlinternalLazy.force(getFiles)); -``` - - - -...or you can also wrap an existing function to make it lazy: - - - -```re example -// Example for wrapping a function with 0 parameters -let getFiles = () => { - Node.Fs.readdirSync("./pages"); -}; - -// Here we wrap our function in the lazy value -let lazyGetFiles = Lazy.from_fun(getFiles); -``` - -```ml -(* Example for wrapping a function with 0 parameters *) -let getFiles () = - Node.Fs.readdirSync "./pages" - -(* Here we wrap our function in the lazy value *) -let lazyGetFiles = Lazy.from_fun getFiles -``` - -```js -var Fs = require("fs"); -var Lazy = require("./stdlib/lazy.js"); - -function getFiles(param) { - return Fs.readdirSync("./pages"); -} - -var lazyGetFiles = Lazy.from_fun(getFiles); -``` - - - - - -```re example -// Example for wrapping a function with parameters -let doesFileExist = name => { - Node.Fs.readdirSync("./pages")->Js.Array2.find(s => name === s); -}; - -// Here we use the lazy syntax again -// since we can't use Lazy.from_fun -let lazyDoesFileExist = lazy(doesFileExist("blog.re")); -``` - -```ml -(* Example for wrapping a function with parameters *) -let doesFileExist name = - Node.Fs.readdirSync "./pages" |. Js.Array2.find(fun s -> name == s) - -(* Here we use the lazy syntax again *) -(* since we can't use Lazy.from_fun *) -let lazyDoesFileExist = lazy(doesFileExist "blog.re") -``` - -```js -var Fs = require("fs"); -var Caml_option = require("./stdlib/caml_option.js"); - -function doesFileExist(name) { - return Caml_option.undefined_to_opt( - Fs.readdirSync("./pages").find(function (s) { - return name === s; - }), - ); -} - -var lazyDoesFileExist = { - LAZY_DONE: false, - VAL: function () { - return doesFileExist("blog.re"); - }, -}; -``` - - - -Whenever we want to wrap a function `unit => 'a`, we use `Lazy.from_fun`, otherwise we use the `lazy(expr)` keyword to wrap an expression or a function with 1 or more arguments. - -## Force a lazy computation - -Lazy values need to be explicitly executed to be able to return a value. Use the `Lazy.force`to start the execution: - - - -```re example -let computation = lazy(1); - -// Returns 1 -Lazy.force(computation); -``` - -```ml -let computation = lazy 1; - -(* Returns 1 *) -Lazy.force computation -``` - -```js -var CamlinternalLazy = require("./stdlib/camlinternalLazy.js"); - -var computation = { - LAZY_DONE: true, - VAL: 1, -}; - -CamlinternalLazy.force(computation); -``` - - - -It is also possible to use pattern matching to force a lazy value to compute, this includes `switch` expressions and similar syntax such as tuple destructuring: - - - -```re example -// Extract a lazy value via pattern matching -let computation = lazy("computed"); - -switch computation { -| lazy("computed") => Js.log("ok") -| _ => Js.log("not ok") -}; -``` - -```ml -(* Extract a lazy value via pattern matching *) -let computation = lazy "computed" - -let () = match computation with -| lazy "computed" -> Js.log "ok" -| _ -> Js.log "not ok" -``` - -```js -var CamlinternalLazy = require("./stdlib/camlinternalLazy.js"); - -var computation = { - LAZY_DONE: true, - VAL: "computed", -}; - -var match = CamlinternalLazy.force(computation); - -if (match === "computed") { - console.log("ok"); -} else { - console.log("not ok"); -} -``` - - - - - -```re example -// Destructuring a single value -// Note: currently the formatter will reprint this -// as `let lazy word = ...` -let lazy(word) = lazy("hello"); - -// Output: "hello" -Js.log(word); -``` - -```ml -let lazy word = lazy "hello" - -(* Output: "hello" *) -Js.log word -``` - -```js -var CamlinternalLazy = require("./stdlib/camlinternalLazy.js"); - -var match = { - LAZY_DONE: true, - VAL: "hello", -}; - -var word = CamlinternalLazy.force(match); - -console.log(word); -``` - - - - - -```re example -// Destructing a tuple -let lazyValues = (lazy("hello"), lazy("world")); -let (lazy(word1), lazy(word2)) = lazyValues; - -// Output: "hello world" -Js.log2(word1, word2); -let lazy(word) = lazy("hello"); -``` - -```ml -(* Destructing a tuple *) -let lazyValues = (lazy "hello", lazy "world") -let (lazy word1, lazy word2) = lazyValues - -(* Output: "hello world" *) -Js.log2(word1, word2) -let lazy word = lazy "hello" -``` - -```js -var CamlinternalLazy = require("./stdlib/camlinternalLazy.js"); - -var lazyValues_0 = { - LAZY_DONE: true, - VAL: "hello", -}; - -var lazyValues_1 = { - LAZY_DONE: true, - VAL: "world", -}; - -var lazyValues = [lazyValues_0, lazyValues_1]; - -var word1 = CamlinternalLazy.force(lazyValues_0); - -var word2 = CamlinternalLazy.force(lazyValues_1); - -console.log(word1, word2); - -var match = { - LAZY_DONE: true, - VAL: "hello", -}; - -var word = CamlinternalLazy.force(match); -``` - - - -As you can see, the `lazy` syntax is a really great way for creating and handling lazy computations! - -## Exception handling - -Whenever a lazy value computation raises an exception, the same exception will be thrown by `Lazy.force`. - - - -```re example -let readFile = - lazy({ - raise(Not_found) - }); - -try (Lazy.force(readFile)) { -| Not_found => Js.log("No file") -}; -``` - -```ml -let readFile = lazy (raise Not_found) -let () = try Lazy.force readFile with -| Not_found -> Js.log "No file" -``` - -```js -var CamlinternalLazy = require("./stdlib/camlinternalLazy.js"); -var Caml_js_exceptions = require("./stdlib/caml_js_exceptions.js"); - -var readFile = { - LAZY_DONE: false, - VAL: function () { - throw { - RE_EXN_ID: "Not_found", - Error: new Error(), - }; - }, -}; - -try { - CamlinternalLazy.force(readFile); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No file"); - } else { - throw exn; - } -} -``` - - - -Nothing new here, since we are using the `try` expression to match the exception raised in the lazy computation! - -Please remember: Exceptions should be used sparsely! - -## Notes - -A lazy value is **not** a [shared data type](shared-data-types.md). Don't rely on the runtime representation on the JS side. diff --git a/pages/docs/manual/v8.0.0/let-binding.mdx b/pages/docs/manual/v8.0.0/let-binding.mdx deleted file mode 100644 index fe4cfc8a1..000000000 --- a/pages/docs/manual/v8.0.0/let-binding.mdx +++ /dev/null @@ -1,232 +0,0 @@ ---- -title: "Let Binding" -description: "Let binding syntax for binding to values in ReScript" -canonical: "/docs/manual/latest/let-binding" ---- - -# Let Binding - -A "let binding", in other languages, might be called a "variable declaration". `let` _binds_ values to names. They can be seen and referenced by code that comes _after_ them. - - - -```re -let greeting = "hello!"; -let score = 10; -let newScore = 10 + score; -``` - -```ml -let greeting = "hello!" -let score = 10 -let newScore = 10 + score -``` - -```js -var greeting = "hello!"; -var score = 10; -var newScore = 20; -``` - - - -## Block Scope - -Bindings can be scoped through `{}`. - - - -```re -let message = { - let part1 = "hello"; - let part2 = "world"; - part1 ++ " " ++ part2; -}; -// `part1` and `part2` not accessible here! -``` - -```ml -let message = - let part1 = "hello" in - let part2 = "world" in - part1 ++ " " ++ part2 - -(* `part1` and `part2` not accessible here! *) -``` - -```js -var message = "hello world"; -``` - - - -The value of the last line of a scope is implicitly returned. - -### Design Decisions - -ReScript's `if`, `while` and functions all use the same block scoping mecanism. The code below works **not** because of some special "if scope"; but simply because it's the same scope syntax and feature you just saw: - - - -```re -if (displayGreeting) { - let message = "Enjoying the docs so far?"; - Js.log(message); -} -// `message` not accessible here! -``` - -```re -if displayGreeting then - let message = "Enjoying the docs so far?" in - Js.log message -(* `message` not accessible here! *) -``` - -```js -if (displayGreeting) { - console.log("Enjoying the docs so far?"); -} -``` - - - -## Bindings Are Immutable - -Let bindings are "immutable", aka "cannot change". This helps our type system deduce and optimize much more than other languages (and in turn, help you more). - -## Binding Shadowing - -The above restriction might sound unpractical at first. How would you change a value then? Usually, 2 ways: - -The first is to realize that many times, what you want isn't to mutate a variable's value. For example, this JavaScript pattern: - -```js -var result = 0; -result = calculate(result); -result = calculateSomeMore(result); -``` - -...is really just to comment on intermediate steps. You didn't need to mutate `result` at all! You could have just written this JS: - -```js -var result1 = 0; -var result2 = calculate(result1); -var result3 = calculateSomeMore(result2); -``` - -In ReScript, this obviously works too: - - - -```re -let result1 = 0; -let result2 = calculate(result1); -let result3 = calculateSomeMore(result2); -``` - -```ml -let result1 = 0 -let result2 = calculate result1 -let result3 = calculateSomeMore result2 -``` - -```js -var result1 = 0; -var result2 = calculate(0); -var result3 = calculateSomeMore(result2); -``` - - - -Additionally, reusing the same let binding name overshadows the previous bindings with the same name. So you can write this too: - - - -```re -let result = 0; -let result = calculate(result); -let result = calculateSomeMore(result); -``` - -```ml -let result = 0 -let result = calculate result -let result = calculateSomeMore result -``` - -```js -var result = calculate(0); -var result$1 = calculateSomeMore(result); -``` - - - -(Though for the sake of clarity, we don't recommend this). - -As a matter of fact, even this is valid code: - - - -```re -let result = "hello"; -Js.log(result); // prints "hello" -let result = 1; -Js.log(result); // prints 1 -``` - -```ml -let result = "hello" -let () = Js.log result (* prints "hello" *) -let result = 1 -let () = Js.log result (* prints 1 *) -``` - -```js -var result = 1; -console.log("hello"); -console.log(1); -``` - - - -The binding you refer to is whatever's the closest upward. No mutation here! -If you need _real_ mutation, e.g. passing a value around, have it modified by many pieces of code, we provide a slightly heavier [mutation feature](mutation.md). - -## Private let bindings - -Private let bindings are introduced in the release [7.2](https://rescript-lang.org/blog/bucklescript-release-7-2). - -In the module system, everything is public by default, -the only way to hide some values is by providing a separate signature to -list public fields and their types: - -```res -module A: { - let b: int -} = { - let a = 3 - let b = 4 -} -``` - -`%private` gives you an option to mark private fields directly - -```res -module A = { - %%private(let a = 3) - let b = 4 -} -``` - -`%private` also applies to file level modules, so in some cases, -users do not need to provide a separate interface file just to hide some particular values. - -Note interface files are still recommended as a general best practice since they give you better -separate compilation units and also they're better for documentation. - -Still, `%private` is useful in the following scenarios: - -- Code generators. Some code generators want to hide some values but it is sometimes very hard or time consuming for code generators to synthesize the types for public fields. - -- Quick prototyping. During prototyping, we still want to hide some values, but the interface file is not stable yet. `%private` provides you such convenience. diff --git a/pages/docs/manual/v8.0.0/libraries.mdx b/pages/docs/manual/v8.0.0/libraries.mdx deleted file mode 100644 index 2d5e3f9c6..000000000 --- a/pages/docs/manual/v8.0.0/libraries.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: "Libraries" -description: "ReScript libraries" -canonical: "/docs/manual/latest/libraries" ---- - -# Libraries - -ReScript libraries are just like JavaScript libraries: hosted on [NPM](http://npmjs.com). - -If you can't find what you're looking for: sometimes **you don't need a wrapper** to use a JS library: - -- Most JS data types, such as array and objects, [map over cleanly to ReScript and vice-versa](shared-data-types.md). -- You also have access to the familiar [JS API](api/js). -- You can use a JavaScript library without needing to bind to them first. Check the [`external`](external) page. diff --git a/pages/docs/manual/v8.0.0/migrate-from-bucklescript-reason.mdx b/pages/docs/manual/v8.0.0/migrate-from-bucklescript-reason.mdx deleted file mode 100644 index 44df12624..000000000 --- a/pages/docs/manual/v8.0.0/migrate-from-bucklescript-reason.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: "Migrate to ReScript Syntax" -description: "Instructions on upgrading from Reason to ReScript" -canonical: "/docs/manual/latest/migrate-to-new-syntax" ---- - -# Migrate to New Syntax - -Starting from `v8.2.0`, BuckleScript and the JS part of Reason are now fused into the new ReScript. We've also introduced a new syntax similar to the old Reason syntax, but [tremendously improved](https://reasonml.org/blog/bucklescript-8-1-new-syntax). - -The old ML and Reason syntax are still supported (see our support commitment [here](https://reasonml.org/blog/a-note-on-bucklescripts-future-commitments)). The gist is: this is mostly just a rebranding and shouldn't affect your existing code much. - -## Upgrade Your Codebase - -There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial, backward-compatible and can be done on a per-file basis: - -- Upgrade your project to `bs-platform 8.2.0` or later. -- `node_modules/.bin/bsc -format MyFile.re > MyFile.res` - -**That's it**! `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file. - -Enjoy the improved experience! - -## Difference With Old Reason - -- Complete removal of semicolon (you can still write them). -- No need for parentheses around `if`, `switch` and `try`. -- Type arguments: from `option(int)` to `option`. -- Old interpolated string: from `{j|hello ${name}|j}` to `` j`hello ${name}` ``. Now with proper unicode support! -- New interpolated string: `` `hello world` ``. Also supports multiline and unicode. `"hello world"` string is now singleline. -- Polymorphic variants: from `` `red`` to `#red`. -- Arrays: from `[|1,2,3|]` to `[1,2,3]`. In JS, arrays are the right default. -- Lists: from `[1,2,3]` to `list[1,2,3]` (_8.1.1 update_: now it is `list{1, 2, 3}`). This ties with upcoming plans to access containers in a uniform way: `set[...]` and `map[...]`. Maybe temporary. -- Exception: from `try (compute()) { | Not_found => Js.log("oops")}` to `try compute() catch { | Not_found => Js.log("oops")}`. -- First class module: from `(module S: Student)` to `module(S: Student)`. -- No custom infix operator for now (including `mod`). -- Object access: from `settings##visible #= true` to `settings["visible"] = true`. Rejoice! -- Object: from `Js.t({"age": int})` to just `{"age": int}`. The `Js.t` part is now implicit. -- Attribute: from `[@bs.deriving accessors]` to `@bs.deriving(accessors)`. From `[%re bla]` to `%re(bla)`. -- Removed dereference syntax `result^`. Just use `result.contents`. -- `fun` pattern matching syntax removed. -- Type declaration is non-recursive by default, consistent with let bindings. To have recursive types, use `type rec myList<'a> = Nil | Cons('a, myList<'a>)`. -- Use any words, including reserved keywords, as your identifier name: `let \"try" = true`. diff --git a/pages/docs/manual/v8.0.0/module.mdx b/pages/docs/manual/v8.0.0/module.mdx deleted file mode 100644 index 5e54d2bc5..000000000 --- a/pages/docs/manual/v8.0.0/module.mdx +++ /dev/null @@ -1,676 +0,0 @@ ---- -title: "Module" -description: "ReScript modules, module signatures and interface files" -canonical: "/docs/manual/latest/module" ---- - -# Module - -## Basics - -**Modules are like mini files**! They can contain type definitions, `let` -bindings, nested modules, etc. - -### Creation - -To create a module, use the `module` keyword. The module name must start with a -**capital letter**. Whatever you could place in a `.re` file, you may place -inside a module definition's `{}` block. - - - -```re -module School = { - type profession = Teacher | Director; - - let person1 = Teacher; - let getProfession = (person) => - switch person { - | Teacher => "A teacher" - | Director => "A director" - }; -}; -``` - -```ml -module School = struct - type profession = Teacher | Director - - let person1 = Teacher - let getProfession person = - match person with - | Teacher -> "A teacher" - | Director -> "A director" -end -``` - -```js -function getProfession(person) { - if (person) { - return "A director"; - } else { - return "A teacher"; - } -} - -var School = { - person1: /* Teacher */ 0, - getProfession: getProfession, -}; -``` - - - -A module's contents (including types!) can be accessed much like a record's, -using the `.` notation. This demonstrates modules' utility for namespacing. - - - -```re -let anotherPerson: School.profession = School.Teacher; -Js.log(School.getProfession(anotherPerson)); /* "A teacher" */ -``` - -```ml -let anotherPerson: School.profession = School.Teacher -Js.log (School.getProfession anotherPerson) (* "A teacher" *) -``` - -```js -var anotherPerson = /* Teacher */ 0; -console.log("A teacher"); -``` - - - -Nested modules work too. - - - -```re -module MyModule = { - module NestedModule = { - let message = "hello" - }; -}; - -let message = MyModule.NestedModule.message; -``` - -```ml -module MyModule = struct - module NestedModule = struct - let message = "hello" - end -end - -let message = MyModule.NestedModule.message -``` - -```js -var NestedModule = { - message: message, -}; - -var MyModule = { - NestedModule: NestedModule, -}; - -var message = MyModule.NestedModule.message; -``` - - - -### `open`ing a module - -Constantly referring to a value/type in a module can be tedious. Instead, we can "open" a module and refer to its contents without always prepending them with the -module's name. Instead of writing: - - - -```re -let p = School.getProfession(School.person1); -``` - -```ml -let p = School.getProfession School.person1 -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -We can write: - - - -```re -open School; -let p = getProfession(person1); -``` - -```ml -open School -let p = getProfession person1 -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -The content of `School` module are made visible (**not** copied into the file, but simply made visible!) in scope. `profession`, `getProfession` and `person1` will thus correctly be found. - -**Use `open` this sparingly, it's convenient, but makes it hard to know where some values come from**. You should usually use `open` in a local scope: - - - -```re -let p = { - open School; - getProfession(person1); -}; -/* School's content isn't visible here anymore */ -``` - -```ml -let p = - let open School in - getProfession person1 -(* School's content isn't visible here anymore *) -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -### Extending modules - -Using `include` in a module statically "spreads" a module's content into a new one, thus often fulfill the role of "inheritance" or "mixin". - -**Note**: this is equivalent to a compiler-level copy paste. **We heavily discourage `include`**. Use it as last resort! - - - -```re -module BaseComponent = { - let defaultGreeting = "Hello"; - let getAudience = (~excited) => excited ? "world!" : "world"; -}; - -module ActualComponent = { - /* the content is copied over */ - include BaseComponent; - /* overrides BaseComponent.defaultGreeting */ - let defaultGreeting = "Hey"; - let render = () => defaultGreeting ++ " " ++ getAudience(~excited=true); -}; -``` - -```ml -module BaseComponent = struct - let defaultGreeting = "Hello" - let getAudience ~excited = if excited then "world!" else "world" -end - -module ActualComponent = struct - (* the content is copied over *) - include BaseComponent - (* overrides BaseComponent.defaultGreeting *) - let defaultGreeting = "Hey" - let render () = defaultGreeting ^ " " ^ (getAudience ~excited:true) -end -``` - -```js -function getAudience(excited) { - if (excited) { - return "world!"; - } else { - return "world"; - } -} - -var BaseComponent = { - defaultGreeting: "Hello", - getAudience: getAudience, -}; - -var defaultGreeting = "Hey"; - -function render(param) { - return "Hey world!"; -} - -var ActualComponent = { - getAudience: getAudience, - defaultGreeting: defaultGreeting, - render: render, -}; -``` - - - -**Note**: `open` and `include` are very different! The former brings a module's content into your current scope, so that you don't have to refer to a value by prefixing it with the module's name every time. The latter **copies over** the definition of a module statically, then also do an `open`. - -### Every `.re` file is a module - -Every ReScript file is itself compiled to a module of the same name as the file name, capitalized. The file `React.re` implicitly forms a module `React`, which can be seen by other source files. - -**Note**: ReScript file names should, by convention, be capitalized so that their casing matches their module name. Uncapitalized file names are not invalid, but will be implicitly transformed into a capitalized module name. I.e. `file.res` will be compiled into the module `File`. To simplify and minimize the disconnect here, the convention is therefore to capitalize file names. - -## Signatures - -A module's type is called a "signature", and can be written explicitly. If a -module is like a `.re` (implementation) file, then a module's signature is like -a `.rei` (interface) file. - -### Creation - -To create a signature, use the `module type` keyword. The signature name must start with a -**capital letter**. Whatever you could place in a `.rei` file, you may place -inside a signature definition's `{}` block. - - - -```re -/* Picking up previous section's example */ -module type EstablishmentType = { - type profession; - let getProfession: profession => string; -}; -``` - -```ml -(* Picking up previous section's example *) -module type EstablishmentType = sig - type profession - val getProfession: profession -> string -end -``` - -```js -// Empty output -``` - - - -A signature defines the list of requirements that a module must satisfy in order -for that module to match the signature. Those requirements are of the form: - -- `let x: int` requires a `let` binding named `x`, of type `int`. -- `type t = someType` requires a type field `t` to be equal to `someType`. -- `type t` requires a type field `t`, but without imposing any requirements on the actual, concrete type of `t`. We'd use `t` in other entries in the signature to describe relationships, e.g. `let makePair: t => (t, t)` but we cannot, for example, assume that `t` is an `int`. This gives us great, enforced abstraction abilities. - -To illustrate the various kinds of type entries, consider the above signature -`EstablishmentType` which requires that a module: - -- Declare a type named `profession`. -- Must include a function that takes in a value of the type `profession` and returns a string. - -**Note**: - -Modules of the type `EstablishmentType` can contain more fields than the -signature declares, just like the module `School` in the previous section (if we -choose to assign it the type `EstablishmentType`. Otherwise, `School` exposes -every field). This effectively makes the `person1` field an enforced -implementation detail! Outsiders can't access it, since it's not present in the -signature; the signature **constrained** what others can access. - -The type `EstablishmentType.profession` is **abstract**: it doesn't have a -concrete type; it's saying "I don't care what the actual type is, but it's used -as input to `getProfession`". This is useful to fit many modules under the same -interface: - - - -```re -module Company: EstablishmentType = { - type profession = CEO | Designer | Engineer | ... - - let getProfession = (person) => ... - let person1 = ... - let person2 = ... -}; -``` - -```ml -module Company: EstablishmentType = struct - type profession = CEO | Designer | Engineer | ... - - let getProfession person = ... - let person1 = ... - let person2 = ... -end -``` - -```js -function getProfession(person) { - ... -} - -var person1 = ... - -var person2 = ... - -var Company = { - getProfession: getProfession, - person1: person1, - person2: person2 -}; -``` - - - -It's also useful to hide the underlying type as an implementation detail others -can't rely on. If you ask what the type of `Company.profession` is, instead of -exposing the variant, it'll only tell you "it's `Company.profession`". - -### Extending module signatures - -Like modules themselves, module signatures can also be extended by other module signatures using `include`. Again, **heavily discouraged**: - - - -```re -module type BaseComponent = { - let defaultGreeting: string; - let getAudience: (~excited: bool) => string; -}; - -module type ActualComponent = { - /* the BaseComponent signature is copied over */ - include BaseComponent; - let render: unit => string; -}; -``` - -```ml -module type BaseComponent = sig - val defaultGreeting: string - val getAudience: excited:bool -> string -end - -module type ActualComponent = sig - (* the BaseComponent signature is copied over *) - include BaseComponent - val render: unit -> string -end -``` - -```js -// Empty output -``` - - - -**Note**: `BaseComponent` is a module **type**, not an actual module itself! - -If you do not have a defined module type, you can extract it from an actual module -using `include (module type of ActualModuleName)`. For example, we can extend the -`List` module from the standard library, which does not define a module -type. - - - -```re -module type MyList = { - include (module type of List); - let myListFun: list('a) => list('a); -}; -``` - -```ml -module type MyList = sig - include module type of List - val myListFun: 'a list -> 'a list -end -``` - -```js -// Empty output -``` - - - -### Every `.rei` file is a signature - -Similar to how a `React.re` file implicitly defines a module `React`, a file -`React.rei` implicitly defines a signature for `React`. If `React.rei` isn't -provided, the signature of `React.re` defaults to exposing all the fields of the -module. Because they don't contain implementation files, `.rei` files are used -in the ecosystem to also document the public API of their corresponding modules. - - - -```re -/* file React.re (implementation. Compiles to module React) */ -type state = int; -let render = (str) => str; -``` - -```ml -(* file React.ml (implementation. Compiles to module React) *) -type state = int -let render str = str -``` - -```js -function render(str) { - return str; -} -``` - - - - - -```re -/* file React.rei (interface. Compiles to the signature of React.re) */ -type state = int; -let render: string => string; -``` - -```ml -(* file React.mli (interface. Compiles to the signature of React.re) *) -type state = int -val render: str -> str -``` - - - -## Module Functions (functors) - -Modules can be passed to functions! It would be the equivalent of passing a file -as a first-class item. However, modules are at a different "layer" of the -language than other common concepts, so we can't pass them to _regular_ -functions. Instead, we pass them to special functions called "functors". - -The syntax for defining and using functors is very much like the syntax -for defining and using regular functions. The primary differences are: - -- Functors use the `module` keyword instead of `let`. -- Functors take modules as arguments and return a module. -- Functors _require_ annotating arguments. -- Functors must start with a capital letter (just like modules/signatures). - -Here's an example `MakeSet` functor, that takes in a module of the type -`Comparable` and returns a new set that can contain such comparable items. - - - -```re -module type Comparable = { - type t; - let equal: (t, t) => bool; -} - -module MakeSet = (Item: Comparable) => { - // let's use a list as our naive backing data structure - type backingType = list(Item.t); - let empty = []; - let add = (currentSet: backingType, newItem: Item.t): backingType => - // if item exists - if (List.exists(x => Item.equal(x, newItem), currentSet)) { - currentSet; // return the same (immutable) set (a list really) - } else { - [ - newItem, - ...currentSet // prepend to the set and return it - ] - }; -}; -``` - -```ml -module type Comparable = sig - type t - val equal: t -> t -> bool -end - -module MakeSet (Item: Comparable) = struct - (* let's use a list as our naive backing data structure *) - type backingType = Item.t list - let empty = [] - let add (currentSet: backingType) (newItem: Item.t) : backingType = - (* if item exists *) - if List.exists (fun x -> Item.equal x newItem) currentSet then - currentSet (* return the same (immutable) set (a list really) *) - else - newItem::currentSet (* prepend to the set and return it *) -end -``` - -```js -var List = require("./stdlib/list.js"); - -function MakeSet(Item) { - var add = function (currentSet, newItem) { - if ( - List.exists(function (x) { - return Item.equal(x, newItem); - }, currentSet) - ) { - return currentSet; - } else { - return { - hd: newItem, - tl: currentSet, - }; - } - }; - return { - empty: /* [] */ 0, - add: add, - }; -} -``` - - - -Functors can be applied using function application syntax. In this case, we're -creating a set, whose items are pairs of integers. - - - -```re -module IntPair = { - type t = (int, int); - let equal = ((x1: int, y1: int), (x2, y2)) => x1 == x2 && y1 == y2; - let create = (x, y) => (x, y); -}; - -/* IntPair abides by the Comparable signature required by MakeSet */ -module SetOfIntPairs = MakeSet(IntPair); -``` - -```ml -module IntPair = struct - type t = int * int - let equal ((x1: int), (y1: int)) (x2,y2) = (x1 = x2) && (y1 = y2) - let create x y = (x, y) -end - -(* IntPair abides by the Comparable signature required by MakeSet *) -module SetOfIntPairs = MakeSet(IntPair) -``` - -```js -function equal(param, param$1) { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } -} - -function create(x, y) { - return [x, y]; -} - -var IntPair = { - equal: equal, - create: create, -}; - -var SetOfIntPairs = { - empty: /* [] */ 0, - add: add, -}; -``` - - - -### Module functions types - -Like with module types, functor types also act to constrain and hide what we may -assume about functors. The syntax for functor types are consistent with those -for function types, but with types capitalized to represent the signatures of -modules the functor accepts as arguments and return values. In the -previous example, we're exposing the backing type of a set; by giving `MakeSet` -a functor signature, we can hide the underlying data structure! - - - -```re -module type Comparable = ... - -module type MakeSetType = (Item: Comparable) => { - type backingType; - let empty: backingType; - let add: (backingType, Item.t) => backingType; -}; - -module MakeSet: MakeSetType = (Item: Comparable) => { - ... -}; -``` - -```ml -module type Comparable = ... - -module type MakeSetType = functor (Item : Comparable) -> sig - type backingType - val empty: backingType - val add: backingType -> Item.t -> backingType -end - -module MakeSet: MakeSetType = functor (Item: Comparable) -> struct - ... -end -``` - -```js -// Empty output -``` - - - -## Tips & Tricks - -Modules and functors are at a different "layer" of language than the rest (functions, let bindings, data structures, etc.). For example, you can't easily pass them into a tuple or record. Use them judiciously, if ever! Lots of times, just a record or a function is enough. diff --git a/pages/docs/manual/v8.0.0/mutation.mdx b/pages/docs/manual/v8.0.0/mutation.mdx deleted file mode 100644 index 02268505c..000000000 --- a/pages/docs/manual/v8.0.0/mutation.mdx +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: "Mutation" -description: "Imperative and mutative programming capabilities in ReScript" -canonical: "/docs/manual/latest/mutation" ---- - -# Mutation - -ReScript has great traditional imperative & mutative programming capabilities. You should use these features sparingly, but sometimes they allow your code to be more performant and written in a more familiar pattern. - -## Mutate Let-binding - -Let-bindings are immutable, but you can wrap it with a `ref`, exposed as a record with a single mutable field in the standard library: - - - -```re -let myValue = ref(5); -``` - -```ml -let myValue = ref 5 -``` - -```js -var myValue = { - contents: 5, -}; -``` - - - -## Usage - -You can get the actual value of a `ref` box through accessing its `contents` field: - - - -```re -let five = myValue.contents; // 5 -``` - -```ml -let five = myValue.contents (* 5 *) -``` - -```js -var five = myValue.contents; -``` - - - -We provide a syntax shortcut for `myValue.contents`: `myValue^`. Though we no longer encourage it. - -Assign a new value to `myValue` like so: - - - -```re -myValue.contents = 6; -``` - -```ml -myValue.contents = 6 -``` - -```js -myValue.contents = 6; -``` - - - -We provide a syntax sugar for this: - - - -```re -myValue := 6; -``` - -```ml -myValue := 6 -``` - -```js -myValue.contents = 6; -``` - - - -Note that the previous binding `five` stays `5`, since it got the underlying item on the `ref` box, not the `ref` itself. - -**Note**: you might see in the JS output tabs above that `ref` allocates an object. Worry not; local, non-exported `ref`s allocations are optimized away. - -## Tip & Tricks - -Before reaching for `ref`, know that you can achieve lightweight, local "mutations" through [overriding let bindings](let-binding.md#binding-shadowing). diff --git a/pages/docs/manual/v8.0.0/newcomer-examples.mdx b/pages/docs/manual/v8.0.0/newcomer-examples.mdx deleted file mode 100644 index bbf48af58..000000000 --- a/pages/docs/manual/v8.0.0/newcomer-examples.mdx +++ /dev/null @@ -1,183 +0,0 @@ ---- -title: "Newcomer Examples" -description: "Quick examples for users new to ReScript" -canonical: "/docs/manual/latest/newcomer-examples" ---- - -# Newcomer Examples - - - -An example is worth a thousand words. - -This section is dedicated to newcomers trying to figure out general idioms & conventions. If you're a beginner who's got a good idea for an example, please suggest an edit! - -## Use the [`option` type](null-undefined-option.md) - - - -```re -let possiblyNullValue1 = None; -let possiblyNullValue2 = Some("Hello"); - -switch (possiblyNullValue2) { -| None => Js.log("Nothing to see here.") -| Some(message) => Js.log(message) -}; -``` - -```ml -let possiblyNullValue1 = None -let possiblyNullValue2 = Some "Hello" - -let () = match possiblyNullValue2 with -| None -> Js.log "Nothing to see here." -| Some(message) -> Js.log message -``` - -```js -var possiblyNullValue1; -var possiblyNullValue2 = "Hello"; - -if (possiblyNullValue2 !== undefined) { - console.log(possiblyNullValue2); -} else { - console.log("Nothing to see here."); -} -``` - - - -## Create a Parametrized Type - - - -```re -type universityStudent = {gpa: float}; - -type response('studentType) = { - status: int, - student: 'studentType, -}; -``` - -```ml -type universityStudent = {gpa: float} - -type 'studentType response = { - status: int; - student: 'studentType; -} -``` - -```js -// Empty output -``` - - - -## Creating a JS Object - - - -```re -let student1 = { - "name": "John", - "age": 30, -}; -``` - -```ml -let student1 = [%bs.obj { - name = "John"; - age = 30 -}] -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -Or using [record](record.md): - - - -```re -type payload = { - name: string, - age: int, -}; - -let student1 = { - name: "John", - age: 30, -}; -``` - -```ml -type payload = { - name: string; - age: int; -} - -let student1 = { - name = "John"; - age = 30; -} -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -## Modeling a JS Module with Default Export - -See [here](import-from-export-to-js.md#import-a-javascript-module-itself-es6-module-format). - -## Checking for JS nullable types using the `option` type - -For a function whose argument is passed a JavaScript value that's potentially `null` or `undefined`, it's idiomatic to convert it to an `option`. The conversion is done through the helper functions in ReScript's [`Js.Nullable`](api/js/nullable#t) module. In this case, `toOption`: - - - -```re -let greetByName = (possiblyNullName) => { - let optionName = Js.Nullable.toOption(possiblyNullName); - switch (optionName) { - | None => "Hi" - | Some(name) => "Hello " ++ name - } -}; -``` - -```ml -let greetByName possiblyNullName = - let optionName = Js.Nullable.toOption possiblyNullName in - match optionName with - | None -> "Hi" - | Some name -> "Hello " ^ name -``` - -```js -function greetByName(possiblyNullName) { - if (possiblyNullName == null) { - return "Hi"; - } else { - return "Hello " + possiblyNullName; - } -} -``` - - - -This check compiles to `possiblyNullName == null` in JS, so checks for the presence of `null` or `undefined`. diff --git a/pages/docs/manual/v8.0.0/null-undefined-option.mdx b/pages/docs/manual/v8.0.0/null-undefined-option.mdx deleted file mode 100644 index 5d86a7452..000000000 --- a/pages/docs/manual/v8.0.0/null-undefined-option.mdx +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: "Null, Undefined and Option" -description: "JS interop with nullable and optional values in ReScript" -canonical: "/docs/manual/latest/null-undefined-option" ---- - -# Null, Undefined and Option - -ReScript itself doesn't have the notion of `null` or `undefined`. This is a _great_ thing, as it wipes out an entire category of bugs. No more `undefined is not a function`, and `cannot access someAttribute of undefined`! - -However, the **concept** of a potentially nonexistent value is still useful, and safely exists in our language. - -We represent the existence and nonexistence of a value by wrapping it with the `option` type. Here's its definition from the standard library: - - - -```re -type option('a) = None | Some('a); -``` - -type 'a option = | None | Some of 'a - -```` -```js -// Empty output -```` - - - -It means "a value of type option is either None (representing nothing) or that actual value wrapped in a Some". - -**Note** how the `option` type is just a regular [variant](variant.md). - -## Example - -Here's a normal value: - - - -```re -let licenseNumber = 5; -``` - -```ml -let licenseNumber = 5 -``` - -```js -var licenseNumber = 5; -``` - - - -To represent the concept of "maybe null", you'd turn this into an `option` type by wrapping it. For the sake of a more illustrative example, we'll put a condition around it: - - - -```re -let licenseNumber = - if (personHasACar) { - Some(5); - } else { - None; - }; -``` - -```ml -let licenseNumber = - if personHasACar then - Some 5 - else - None -``` - -```js -var licenseNumber = personHasACar ? 5 : undefined; -``` - - - -Later on, when another piece of code receives such value, it'd be forced to handle both cases through [pattern matching](pattern-matching-destructuring.md): - - - -```re -switch (licenseNumber) { -| None => - Js.log("The person doesn't have a car"); -| Some(number) => - Js.log("The person's license number is " ++ Js.Int.toString(number)); -}; -``` - -```ml -let () = match licenseNumber with -| None -> - Js.log "The person doesn't have a car" -| Some number -> - Js.log ("The person's license number is " ^ (Js.Int.toString number)) -``` - -```js -var number = licenseNumber; - -if (number !== undefined) { - console.log("The person's license number is " + number.toString()); -} else { - console.log("The person doesn't have a car"); -} -``` - - - -By turning your ordinary number into an `option` type, and by forcing you to handle the `None` case, the language effectively removed the possibility for you to mishandle, or forget to handle, a conceptual `null` value! **A pure ReScript program doesn't have null errors**. - -## Interoperate with JavaScript `undefined` and `null` - -The `option` type is common enough that we special-case it when compiling to JavaScript: - - - -```re -let x = Some(5); -``` - -```ml -let x = Some 5 -``` - -```js -var x = 5; -``` - - - -simply compiles down to `5`, and - - - -```re -let x = None; -``` - -```ml -let x = None -``` - -```js -var x; -``` - - - -compiles to `undefined`! If you've got e.g. a string in JavaScript that you know might be `undefined`, type it as `option(string)` and you're done! Likewise, you can send a `Some(5)` or `None` to the JS side and expect it to be interpreted correctly =) - -### Caveat 1 - -The option-to-undefined translation isn't perfect, because on our side, `option` values can be composed: - - - -```re -let x = Some(Some(Some(5))); -``` - -```ml -let x = Some (Some (Some 5)) -``` - -```js -var x = 5; -``` - - - -This still compiles to `5`, but this gets troublesome: - - - -```re -let x = Some(None); -``` - -```ml -let x = Some None -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -var x = Caml_option.some(undefined); -``` - -(See output tab). - - - -What's this `Caml_option.some` thing? Why can't this compile to `undefined`? Long story short, when dealing with a polymorphic `option` type (aka `option('a)`, for any `'a`), many operations become tricky if we don't mark the value with some special annotation. If this doesn't make sense, don't worry; just remember the following rule: - -- **Never, EVER, pass a nested `option` value (e.g. `Some(Some(Some(5)))`) into the JS side.** -- **Never, EVER, annotate a value coming from JS as `option('a)`. Always give the concrete, non-polymorphic type.** - -### Caveat 2 - -Unfortunately, lots of times, your JavaScript value might be _both_ `null` or `undefined`. In that case, you unfortunately can't type such value as e.g. `option(int)`, since our `option` type only checks for `undefined` and not `null` when dealing with a `None`. - -#### Solution: More Sophisticated `undefined` & `null` Interop - -To solve this, we provide access to more elaborate `null` and `undefined` helpers through the [`Js.Nullable`](api/js/nullable) module. This somewhat works like an `option` type, but is different from it. - -#### Examples - -To create a JS `null`, use the value `Js.Nullable.null`. To create a JS `undefined`, use `Js.Nullable.undefined` (you can naturally use `None` too, but that's not the point here; the `Js.Nullable.*` helpers wouldn't work with it). - -If you're receiving, for example, a JS string that can be `null` and `undefined`, type it as: - - - -```re -[@bs.module "MyConstant"] external myId: Js.Nullable.t(string) = "myId"; -``` - -```ml -external myId: string Js.Nullable.t = "myId" [@@bs.module "MyConstant"] -``` - -```js -// Empty output -``` - - - -To create such a nullable string from our side (presumably to pass it to the JS side, for interop purpose), do: - - - -```re -[@bs.module "MyIdValidator"] external validate: Js.Nullable.t(string) => bool = "validate"; -let personId: Js.Nullable.t(string) = Js.Nullable.return("abc123"); - -let result = validate(personId); -``` - -```ml -external validate: string Js.Nullable.t -> bool = "validate" [@@bs.module "MyIdValidator"] -let personId: string Js.Nullable.t = Js.Nullable.return "abc123" - -let result = validate personId -``` - -```js -var MyIdValidator = require("MyIdValidator"); -var personId = "abc123"; -var result = MyIdValidator.validate(personId); -``` - - - -The `return` part "wraps" a string into a nullable string, to make the type system understand and track the fact that, as you pass this value around, it's not just a string, but a string that can be `null` or `undefined`. - -#### Convert to/from `option` - -`Js.Nullable.fromOption` converts from a `option` to `Js.Nullable.t`. `Js.Nullable.toOption` does the opposite. diff --git a/pages/docs/manual/v8.0.0/object.mdx b/pages/docs/manual/v8.0.0/object.mdx deleted file mode 100644 index 25bbbc752..000000000 --- a/pages/docs/manual/v8.0.0/object.mdx +++ /dev/null @@ -1,231 +0,0 @@ ---- -title: "Object" -description: "Interoping with JS objects in ReScript" -canonical: "/docs/manual/latest/object" ---- - -# Object - -ReScript objects are like [records](record.md), but: - -- No type declaration needed. -- Structural and more polymorphic, [unlike records](record.md#record-types-are-found-by-field-name). -- Doesn't support updates unless the object comes from the JS side. -- Doesn't support [pattern matching](pattern-matching-destructuring.md). - - - -Although ReScript records compile to clean JavaScript objects, ReScript objects are a better candidate for emulating/binding to JS objects, as you'll see. - -## Type Declaration - -**Optional**, unlike for records. The type of an object is inferred from the value, so you never really need to write down is type definition. Nevertheless, here's its type declaration syntax: - - - -```re -type person = { - . - "age": int, - "name": string -}; -``` - -```re -type person = < - age :int; - name :string> Js.t -``` - -```js -// Empty output -``` - - - -Visually similar to record type's syntax, with the field names quoted. - -## Creation - -To create a new object: - - - -```re -let me = { - "age": 5, - "name": "Big ReScript" -}; -``` - -```ml -let me = [%bs.obj { - age = 5; - name = "Big ReScript"; -}] -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -**Note**: as said above, unlike for record, this `me` value does **not** try to find a conforming type declaration with the field `"age"` and `"name"`; rather, the type of `me` is inferred as `{"age": int, "name": string}`. This is convenient, but also means this code passes type checking without errors: - - - -```re -type person = { - . - "age": int -}; - -let me = { - "age": "hello!" // age is a string. No error. -}; -``` - -```ml -type person = < - age :int -> Js.t - -let me = [%bs.obj { - age = "hello!" (* age is a string. No error. *) -}] -``` - -```js -var me = { - age: "hello!", -}; -``` - - - -Since the type checker doesn't try to match `me` with the type `person`. If you ever want to force an object value to be of a predeclared object type, just annotate the value: - - - -```re -let me: person = { - "age": "hello!" -} -``` - -```ml -let me: person = [%bs.obj { - age = "hello!" -}] -``` - - - -Now the type system will error properly. - -## Access - - - -```re -let age = me##age; -``` - -```ml -let age = me##age -``` - -```js -var age = me["age"]; -``` - - - -## Update - -Disallowed unless the object is a binding that comes from the JavaScript side. In that case, use `=`: - - - -```re -type student = { - [@bs.set] "age": int, - [@bs.set] "name": string, -}; -[@bs.module "MyJSFile"] external student1: student = "student1"; - -student1##name = "Mary"; -``` - -```ml -type student = < - age: int [@bs.set]; - name: string [@bs.set]; -> Js.t -external student1: student = "student1" [@@bs.module "MyJSFile"] - -student1##name = "Mary" -``` - -```js -var MyJSFile = require("MyJSFile"); -MyJSFile.student1.name = "Mary"; -``` - - - -## Tips & Tricks - -Since objects don't require type declarations, and since ReScript infers all the types for you, you get to very quickly and easily (and dangerously) bind to any JavaScript API. Check the JS output tab: - - - -```re -// The type of document is just some random type 'a -// that we won't bother to specify -[@bs.val] external document: 'a = "document"; - -// call a method -document##addEventListener("mouseup", _event => { - Js.log("clicked!"); -}); - -// get a property -let loc = document##location; - -// set a property -document##location##href = "rescript-lang.org"; -``` - -```ml -// The type of document is just some random type 'a -// that we won't bother to specify -external document: 'a = "document" [@@bs.val] - -// call a method -let () = document##addEventListener "mouseup" (fun _event -> - Js.log "clicked!" -) - -// get a property -let loc = document##location - -// set a property -document##location##href = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); -var loc = document.location; -document.location.href = "rescript-lang.org"; -``` - - - -The `external` feature and the usage of this trick are also documented in the [external](external#tips--tricks) section later. It's an excellent way to start writing some ReScript code without worrying about whether bindings to a particular library exists. diff --git a/pages/docs/manual/v8.0.0/overview.mdx b/pages/docs/manual/v8.0.0/overview.mdx deleted file mode 100644 index 8d3a7f309..000000000 --- a/pages/docs/manual/v8.0.0/overview.mdx +++ /dev/null @@ -1,243 +0,0 @@ ---- -title: "Overview" -metaTitle: "Language Features Overview" -description: "A quick overview on ReScript's syntax" -canonical: "/docs/manual/latest/overview" ---- - -# Overview - -## Comparison to JS - -**Note**: the comparison is against our Reason syntax, not our ML syntax. - -### Semicolon - -| JavaScript | Us | -| ---------------------------------- | -------------------- | -| Rules enforced by linter/formatter | No semicolon needed! | - -### Comments - -| JavaScript | Us | -| ----------------- | ---- | -| `/* Comment */` | Same | -| `// Line comment` | Same | - -### Variable - -| JavaScript | Us | -| ----------------------- | ------------------------------------- | -| `const x = 5;` | `let x = 5` | -| `var x = y;` | No equivalent (thankfully) | -| `let x = 5; x = x + 1;` | `let x = ref(5); x := x.contents + 1` | - -### String & Character - -| JavaScript | Us | -| ------------------------ | --------------------- | ---------------- | --- | -| `"Hello world!"` | Same | -| `'Hello world!'` | Strings must use `"` | -| `"hello " + "world"` | `"hello " ++ "world"` | -| `` `hello ${message}` `` | `\{j | Hello $(message) | j}` | - -### Boolean - -| JavaScript | Us | -| ------------------------------------ | ---------------------------------------------- | -| `true`, `false` | Same | -| `!true` | Same | -| `\|\|`, `&&`, `<=`, `>=`, `<`, `>` | Same | -| `a === b`, `a !== b` | Same | -| No deep equality (recursive compare) | `a == b`, `a != b` | -| `a == b` | No equality with implicit casting (thankfully) | - -### Number - -| JavaScript | Us | -| ----------- | ------------ | -| `3` | Same \* | -| `3.1415` | Same | -| `3 + 4` | Same | -| `3.0 + 4.5` | `3.0 +. 4.5` | -| `5 % 3` | `5 mod 3` | - -\* JS has no distinction between integer and float. - -### Object/Record - -| JavaScript | Us | -| ------------------- | --------------------------------------- | -| no types | `type point = {x: int, mutable y: int}` | -| `{x: 30, y: 20}` | Same | -| `point.x` | Same | -| `point.y = 30;` | Same | -| `{...point, x: 30}` | Same | - -### Array - -| JavaScript | Us | -| ------------------ | ---------------------------------- | -| `[1, 2, 3]` | [|1, 2, 3|] | -| `myArray[1] = 10` | Same | -| `[1, "Bob", true]` | `(1, "Bob", true)` \* | - -\* Heterogenous arrays in JS are disallowed for us. Use tuple instead. - -### Null - -| JavaScript | Us | -| ------------------- | --------- | -| `null`, `undefined` | `None` \* | - -\* Again, only a spiritual equivalent; we don't have nulls, nor null bugs! But we do have an `option` type for when you actually need nullability. - -### Function - -| JavaScript | Us | -| ------------------------------- | ---------------------------- | -| `arg => retVal` | Same | -| `function named(arg) {...}` | `let named = (arg) => {...}` | -| `const f = function(arg) {...}` | `let f = (arg) => {...}` | -| `add(4, add(5, 6))` | Same | - -### Blocks - - - - - - - - - - - - - - -
JavaScriptUS
- ``` - const myFun = (x, y) => { - const doubleX = x + x; - const doubleY = y + y; - return doubleX + doubleY; - }; - ``` - - ``` - let myFun = (x, y) => { - let doubleX = x + x - let doubleY = y + y - doubleX + doubleY - } - ``` -
- -### If-else - -| JavaScript | Us | -| --------------------- | --------------------------------------------------------------------------------- | -| `if (a) {b} else {c}` | `if (a) {b} else {c}` \* | -| `a ? b : c` | Same | -| `switch` | `switch` but [super-powered pattern matching!](pattern-matching-destructuring.md) | - -\* Our conditionals are always expressions! You can write `let result = if (a) {"hello"} else {"bye"}` - -### Destructuring - -| JavaScript | Us | -| ----------------------------- | --------------------------------------------- | -| `const {a, b} = data` | `let {a, b} = data` | -| `const [a, b] = data` | let [|a, b|] = data \* | -| `const {a: aa, b: bb} = data` | `let {a: aa, b: bb} = data` | - -\* Gives good compiler warning that `data` might not be of length 2. - -### Loop - -| JavaScript | Us | -| ------------------------------------- | ------------------------------ | -| `for (let i = 0; i <= 10; i++) {...}` | `for (i in 0 to 10) {...}` | -| `for (let i = 10; i >= 0; i--) {...}` | `for (i in 10 downto 0) {...}` | -| `while (true) {...}` | `while (true) {...}` | - -### JSX - -| JavaScript | Us | -| ----------------------------------------- | -------------------------- | -| `` | Same | -| `` | `` \* | -| `` | `` | -| No children spread | `...children` | - -\* Argument punning! - -### Exception - -| JavaScript | Us | -| ----------------------------------------- | --------------------------------- | -| `throw new SomeError(...)` | `raise(SomeError(...))` | -| `try {a} catch (Err) {...} finally {...}` | `try a catch { \| Err => ...}` \* | - -\* No finally. - -### Blocks - -The last expression of a block delimited by `{}` implicitly returns (including function body). In JavaScript, this can only be simulated via an immediately-invoked function expression (since function bodies have their own local scope). - - - - - - - - - - - - - - -
JavaScriptUS
- ``` - let result = (function() { - const x = 23; - const y = 34; - return x + y; - })(); - ``` - - ``` - let result = { - let x = 23 - let y = 34 - x + y - } - ``` -
- -## Common Features' JS Output - -| Feature | Example | JavaScript Output | -| ------------------------------- | ------------------------------------ | ------------------------------------------ | --- | -------------------- | -| String | `"Hello"` | `"Hello"` | -| String Interpolation | `\{j | Hello $(message) | j}` | `"Hello " + message` | -| Character (disrecommended) | `'x'` | `120` (char code) | -| Integer | `23`, `-23` | `23`, `-23` | -| Float | `23.0`, `-23.0` | `23.0`, `-23.0` | -| Integer Addition | `23 + 1` | `23 + 1` | -| Float Addition | `23.0 +. 1.0` | `23.0 + 1.0` | -| Integer Division/Multiplication | `2 / 23 * 1` | `2 / 23 * 1` | -| Float Division/Multiplication | `2.0 /. 23.0 *. 1.0` | `2.0 / 23.0 * 1.0` | -| Float Exponentiation | `2.0 ** 3.0` | `Math.pow(2.0, 3.0)` | -| String Concatenation | `"Hello " ++ "World"` | `"Hello " + "World"` | -| Comparison | `>`, `<`, `>=`, `<=` | `>`, `<`, `>=`, `<=` | -| Boolean operation | `!`, `&&`, `\|\|` | `!`, `&&`, `\|\|` | -| Shallow and deep Equality | `===`, `==` | `===`, `==` | -| List (disrecommended) | `[1, 2, 3]` | `{hd: 1, tl: {hd: 2, tl: {hd: 3, tl: 0}}}` | -| List Prepend | `[a1, a2, ...oldList]` | `{hd: a1, tl: {hd: a2, tl: theRest}}` | -| Array | [|1, 2, 3|] | `[1, 2, 3]` | -| Record | `type t = {b: int}; let a = {b: 10}` | `var a = {b: 10}` | -| Multiline Comment | `/* Comment here */` | Not in output | -| Single line Comment | `// Comment here` | Not in output | diff --git a/pages/docs/manual/v8.0.0/pattern-matching-destructuring.mdx b/pages/docs/manual/v8.0.0/pattern-matching-destructuring.mdx deleted file mode 100644 index 07244c219..000000000 --- a/pages/docs/manual/v8.0.0/pattern-matching-destructuring.mdx +++ /dev/null @@ -1,913 +0,0 @@ ---- -title: "Pattern Matching / Destructuring" -description: "Pattern matching and destructuring complex data structures in ReScript" -canonical: "/docs/manual/latest/pattern-matching-destructuring" ---- - -# Pattern Matching / Destructuring - -One of ReScript's **best** feature is our pattern matching. Pattern matching combines 3 brilliant features into one: - -- Destructuring. -- `switch` based on shape of data. -- Exhaustiveness check. - -We'll dive into each aspect below. - -## Destructuring - -Even JavaScript has destructuring, which is "opening up" a data structure to extract the parts we want and assign variable names to them: - - - -```re -let coordinates = (10, 20, 30); -let (x, _, _) = coordinates; -Js.log(x); // 10 -``` - -```ml -let coordinates = (10, 20, 30) -let (x, _, _) = coordinates -Js.log x (* 10 *) -``` - -```js -var coordinates = [10, 20, 30]; -var x = 10; -console.log(10); -``` - - - -Destructuring works with most built-in data structures: - - - -```re -// Record -type student = {name: string, age: int}; -let student1 = {name: "John", age: 10}; -let {name} = student1; // "John" assigned to `name` - -// Variant -type result = - | Success(string); -let myResult = Success("You did it!"); -let Success(message) = myResult; // "You did it!" assigned to `message` - -// Array -let myArray = [|1, 2, 3|]; -let [|item1, item2, _|] = myArray; // 1 assigned to `item1`, 2 assigned to `item2`, 3rd item ignored - -// List -let myList = [1, 2, 3]; -let [head, ...tail] = myList; // 1 assigned to `head`, `[2, 3]` assigned to tail -``` - -```ml -// Record -type student = {name: string; age: int} -let student1 = {name = "John"; age = 10} -let {name} = student1; (* "John" assigned to `name` *) - -(* Variant *) -type result = - | Success of string -let myResult = Success "You did it!" -let Success message = myResult (* "You did it!" assigned to `message` *) - -(* Array *) -let myArray = [|1; 2; 3|] -let [|item1; item2; _|] = myArray (* 1 assigned to `item1`, 2 assigned to `item2`, 3rd item ignored *) - -(* List *) -let myList = [1; 2; 3] -let head::tail = myList (* 1 assigned to `head`, `[2, 3]` assigned to tail *) -``` - -```js -var student1 = { - name: "John", - age: 10, -}; -var name = "John"; - -var myResult = /* Success */ { - _0: "You did it!", -}; -var message = "You did it!"; - -var myArray = [1, 2, 3]; -if (myArray.length !== 2) { - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 14, 4], - Error: new Error(), - }; -} -var item1 = myArray[0]; -var item2 = myArray[1]; - -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */ 0, - }, - }, -}; -// ... -``` - - - -You can also use destructuring anywhere you'd usually put a binding: - - - -```re -type result = - | Success(string); -let displayMessage = (Success(m)) => { - // we've directly extracted the success message - // string by destructuring the parameter - Js.log(m); -} -displayMessage(Success("You did it!")); -``` - -```ml -type result = - | Success of string -let displayMessage (Success m) = - (* we've directly extracted the success message *) - (* string by destructuring the parameter *) - Js.log m - -let () = displayMessage (Success "You did it!") -``` - -```js -function displayMessage(m) { - console.log(m._0); -} - -displayMessage( - /* Success */ { - _0: "You did it!", - }, -); -``` - - - -For a record, you can rename the field while destructuring: - - - -```re -let {name: n} = student1; // "John" assigned to `n` -``` - -```ml -let {name = n} = student1 (* "John" assigned to `n` *) -``` - -```js -var n = "John"; -``` - - - -## `switch` Based on Shape of Data - -While the destructuring aspect of pattern matching is nice, it doesn't really change the way you think about structuring your code. One paradigm-changing way of thinking about your code is to execute some code based on the shape of the data. - -Consider a variant: - - - -```re -type payload = - | BadResult(int) - | GoodResult(string) - | NoResult; -``` - -```ml -type payload = - | BadResult of int - | GoodResult of string - | NoResult -``` - -```js -// Empty output -``` - - - -We'd like to handle each of the 3 cases differently. For example, print a success message if the value is `GoodResult(...)`, do something else when the value is `NoResult`, etc. - -In other languages, you'd end up with a series of if-elses that are hard to read and error-prone. In ReScript, you can instead use the supercharged `switch` pattern matching facility to destructure the value while calling the right code based on what you destructured: - - - -```re -let data = GoodResult("Product shipped!"); -switch (data) { -| GoodResult(theMessage) => - Js.log("Success! " ++ theMessage) -| BadResult(errorCode) => - Js.log("Something's wrong. The error code is: " ++ Js.Int.toString(errorCode)) -| NoResult => - Js.log("Bah.") -}; -``` - -```ml -let data = GoodResult ("Product shipped!") -let () = match data with -| GoodResult theMessage -> - Js.log ("Success! " ^ theMessage) -| BadResult errorCode -> - Js.log ("Something's wrong. The error code is: " ^ (Js.Int.toString errorCode)) -| NoResult -> Js.log "Bah." -``` - -```js -var data = { - TAG: /* GoodResult */ 1, - _0: "Product shipped!", -}; - -if (typeof data === "number") { - console.log("Bah."); -} else if (data.TAG) { - console.log("Success! Product shipped!"); -} else { - console.log( - "Something's wrong. The error code is: " + "Product shipped!".toString(), - ); -} -``` - - - -In this case, `message` will have the value `"Success! Product shipped!"`. - -Suddenly, your if-elses that messily checks some structure of the value got turned into a clean, compiler-verified, linear list of code to execute based on exactly the shape of the value. - -### Complex Examples - -Here's a real-world scenario that'd be a headache to code in other languages. Given this data structure: - - - -```re -type status = Vacations(int) | Sabbatical(int) | Sick | Present; -type reportCard = {passing: bool, gpa: float}; -type person = - | Teacher({ - name: string, - age: int, - }) - | Student({ - name: string, - status: status, - reportCard: reportCard, - }); -``` - -```ml -type status = Vacations of int | Sabbatical of int | Sick | Present -type reportCard = {passing: bool; gpa: float} -type person = - | Teacher of { - name: string; - age: int; - } - | Student of { - name: string; - status: status; - reportCard: reportCard; - } -``` - -```js -// Empty output -``` - - - -Imagine this requirement: - -- Informally greet a person who's a teacher and if his name is Mary or Joe. -- Greet other teachers formally. -- If the person's a student, congratulate him/her score if they passed the semester. -- If the student has a gpa of 0 and is on vacations or sabbatical, display a different message. -- A catch-all message for a student. - -ReScript can do this easily! - - - -```re -let message = switch (person1) { -| Teacher({name: "Mary" | "Joe"}) => - "Hey, still going to the party on Saturday?" -| Teacher({name}) => - // this is matched only if `name` isn't "Joe" - {j|Hello $(name).|j} -| Student({name, reportCard: {passing: true, gpa}}) => - "Congrats " ++ name + ", nice GPA of " ++ Js.Float.toString(gpa) ++ " you got there!" -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - "Come back in " ++ Js.Int.toString(daysLeft) ++ " days!" -| Student({status: Sick}) => - "How are you feeling?" -| Student({name}) => - {j|Good luck next semester $(name)!|j} -}; -``` - -```ml -let message = match person1 with -| Teacher {name = "Mary" | "Joe"} -> - "Hey, still going to the party on Saturday?" -| Teacher {name} -> - (* this is matched only if `name` isn't "Joe" *) - {j|Hello $(name).|j} -| Student {name; reportCard = {passing = true; gpa}} -> - "Congrats " ++ name + ", nice GPA of " ++ Js.Float.toString(gpa) ++ " you got there!" -| Student { - reportCard = {gpa = 0.0}; - status = (Vacations daysLeft) | (Sabbatical daysLeft) - } -> - "Come back in " ++ (Js.Int.toString daysLeft) ++ " days!" -| Student {status = Sick} -> - "How are you feeling?" -| Student {name} -> - {j|Good luck next semester $(name)!|j} -``` - -```js -var message; - -if (person1.TAG) { - var match$1 = person1.status; - var name = person1.name; - var match$2 = person1.reportCard; - message = match$2.passing - ? "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!" - : typeof match$1 === "number" - ? match$1 !== 0 - ? "Good luck next semester " + name + "!" - : "How are you feeling?" - : person1.reportCard.gpa !== 0.0 - ? "Good luck next semester " + name + "!" - : "Come back in " + match$1._0.toString() + " days!"; -} else { - var name$1 = person1.name; - switch (name$1) { - case "Joe": - case "Mary": - message = "Hey, still going to the party on Saturday?"; - break; - default: - message = "Hello " + name$1 + "."; - } -} -``` - - - -**Note** how we've: - -- drilled deep down into the value concisely -- using a nested pattern check `"Mary" | "Joe"` and `Vacations | Sabbatical` -- while extracting the `daysLeft` number from the latter case -- and assigned the greeting to the binding `message`. - -Here's another example of pattern matching, this time on an inline tuple. - - - -```re -type animal = Dog | Cat | Bird; -let categoryId = switch (isBig, myAnimal) { -| (true, Dog) => 1 -| (true, Cat) => 2 -| (true, Bird) => 3 -| (false, Dog | Cat) => 4 -| (false, Bird) => 5 -}; -``` - -```ml -type animal = Dog | Cat | Bird -let categoryId = match (isBig, myAnimal) with -| (true, Dog) -> 1 -| (true, Cat) -> 2 -| (true, Bird) -> 3 -| (false, (Dog | Cat)) -> 4 -| (false, Bird) -> 5 -``` - -```js -var categoryId = isBig ? (myAnimal + 1) | 0 : myAnimal >= 2 ? 5 : 4; -``` - - - -**Note** how pattern matching on a tuple is equivalent to a 2D table: - -| isBig \ myAnimal | Dog | Cat | Bird | -| ---------------- | --- | --- | ---- | -| true | 1 | 2 | 3 | -| false | 4 | 4 | 5 | - -### Ignore Part of a Value - -If you have a value like `Teacher(payload)` where you just want to pattern match on the `Teacher` part and ignore the `payload` completely, you can use the `_` wildcard like this: - - - -```re -switch (person) { -| Teacher(_) => Js.log("Hi teacher") -| Student(_) => Js.log("Hey student") -}; -``` - -```ml -let () = match person with -| Teacher _ -> Js.log "Hi teacher" -| Student _ -> Js.log "Hey student" -``` - -```js -if (person.TAG) { - console.log("Hey student"); -} else { - console.log("Hi teacher"); -} -``` - - - -`_` also works at the top level of the pattern like `| _ => ...` if you want to execute catch-all condition. - -### When Clause - -Sometime, you want to check more than the shape of a value. You want to also run some arbitrary check on it. You might be tempted to write this: - - - -```re -switch (person) { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) => - if (gpa < 0.5) { - Js.log("What's happening") - } else { - Js.log("Heyo") - } -}; -``` - -```ml -let () = match person with -| Teacher _ -> () (* do nothing *) -| Student {reportCard = {gpa}} -> - if gpa < 0.5 then - Js.log "What's happening" - else - Js.log "Heyo" -``` - -```js -if (person.TAG) { - if (person.reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -`switch` patterns support a shortcut for the arbitrary `if` check, to keep your pattern linear-looking: - - - -```re -switch (person) { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) when gpa < 0.5 => - Js.log("What's happening"); -| Student(_) => - // fall-through, catch-all case - Js.log("Heyo"); -} -``` - -```ml -let () = match person with -| Teacher _ -> () (* do nothing *) -| Student {reportCard = {gpa}} when gpa < 0.5 -> - Js.log "What's happening" -| Student _ -> - (* fall-through, catch-all case *) - Js.log "Heyo" -``` - -```js -if (person.TAG) { - if (person.reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -### Match on Exceptions - -If the function throws an exception (covered later), you can also match on _that_, in addition to the function's normally returned values. - - - -```re -switch (List.find(i => i === theItem, myItems)) { -| item => Js.log(item) -| exception Not_found => Js.log("No such item found!") -}; -``` - -```ml -let () = match List.find (fun i -> i == theItem) myItems with -| item -> Js.log item -| exception Not_found -> Js.log "No such item found!" -``` - -```js -var exit = 0; - -var item; - -try { - item = List.find(function (i) { - return i === theItem; - }, myItems); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -### Small Pitfall - -**Note**: you can only pass literals (i.e. concrete values) as a pattern, not let-binding names or other things. The following doesn't work as expected: - - - -```re -let coordinates = (10, 20, 30) -let centerY = 20 -switch (coordinates) { -| (x, centerY, _) => /* code */ -} -``` - -```ml -let coordinates = (10, 20, 30) -let centerY = 20 -let () = match coordinates with -| (x, centerY, _) => (* code *) -``` - -```js -var coordinates = [10, 20, 30]; -var centerY = 20; - -console.log(10); -``` - - - -A first time ReScript user might accidentally write that code, assuming that it's matching on `coordinates` when the second value is of the same value as `centerY`. In reality, this is interpreted as matching on coordinates and assigning the second value of the tuple to the name `centerY`, which isn't what's intended. - -## Exhaustiveness Check - -As if the above features aren't enough, ReScript also provides arguably the most important pattern matching feature: **compile-time check of missing patterns**. - -Let's revisit one of the above examples: - - - -```re -let message = switch (person) { -| Teacher({name: "Mary" | "Joe"}) => - "Hey, still going to the party on Saturday?" -| Student({name, reportCard: {passing: true, gpa}}) => - "Congrats " ++ name ++ ", nice GPA of " ++ Js.Float.toString(gpa) ++ " you got there!" -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - "Come back in " ++ Js.Int.toString(daysLeft) ++ " days!" -| Student({status: Sick}) => - "How are you feeling?" -| Student({name}) => - "Good luck next semester " ++ name ++ "!" -} -``` - -```ml -let message = match person with -| Teacher {name = "Mary" | "Joe"} -> - "Hey, still going to the party on Saturday?" -| Student {name; reportCard = {passing = true; gpa}} -> - "Congrats " ^ name ^ ", nice GPA of " ^ (Js.Float.toString gpa) ^ " you got there!" -| Student { - reportCard = {gpa = 0.0}; - status = (Vacations daysLeft) | (Sabbatical daysLeft) - } -> - "Come back in " ^ (Js.Int.toString daysLeft) ^ " days!" -| Student {status = Sick} -> - "How are you feeling?" -| Student {name} -> - "Good luck next semester "^ name ^ "!" -``` - -```js -if (person.TAG) { - var match$1 = person.status; - var name = person.name; - var match$2 = person.reportCard; - if (match$2.passing) { - "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!"; - } else if (typeof match$1 === "number") { - if (match$1 !== 0) { - "Good luck next semester " + name + "!"; - } else { - ("How are you feeling?"); - } - } else if (person.reportCard.gpa !== 0.0) { - "Good luck next semester " + name + "!"; - } else { - "Come back in " + match$1._0.toString() + " days!"; - } -} else { - switch (person.name) { - case "Joe": - case "Mary": - break; - default: - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 13, 0], - Error: new Error(), - }; - } -} -``` - - - -Did you see what we removed? This time, we've omitted the handling of the case where `person` is `Teacher({name})` when `name` isn't Mary or Joe. - -Failing to handle every scenario of a value likely constitutes the majority of program bugs out there. This happens very often when you refactor a piece of code someone else wrote. Fortunately for ReScript, the compiler will tell you so: - -``` -Warning 8: this pattern-matching is not exhaustive. -Here is an example of a value that is not matched: -Some({name: ""}) -``` - -**BAM**! You've just erased an entire category of important bugs before you even ran the code. In fact, this is how most of nullable values is handled: - - - -```re -switch (myNullableValue) { -| Some(v) => Js.log("value is present") -| None => Js.log("value is absent") -}; -``` - -```ml -match myNullableValue with -| Some v -> Js.log "value is present" -| None -> Js.log "value is absent" -``` - -```js -if (myNullableValue !== undefined) { - console.log("value is present"); -} else { - console.log("value is absent"); -} -``` - - - -If you don't handle the `None` case, the compiler warns. No more `undefined` bugs in your code! - -## Conclusion & Tips & Tricks - -Hopefully you can see how pattern matching is a game changer for writing correct code, through the concise destructuring syntax, the proper conditions handling of `switch`, and the static exhaustiveness check. - -Here are some advices. - -Do not abuse the wildcard `_` too much. This prevents the compiler from giving you better exhaustiveness check, which would be especially important after a refactoring where you add a new case to a variant. Try only using `_` against infinite possibilities, e.g. string, int, etc. - -Use `when` clause sparingly. - -**Flatten your pattern-match whenever you can**. This is a real bug remover. Here's a series of examples, from worst to best: - - - -```re -let optionBoolToBool = opt => { - if (opt == None) { - false - } else if (opt === Some(true)) { - true - } else { - false - } -} -``` - -```ml -let optionBoolToBool opt = - if opt = None - then false - else if opt == Some true then - true - else false -``` - -```js -function optionBoolToBool(opt) { - if (opt === undefined) { - return false; - } else { - return opt === true; - } -} -``` - - - -Now that's just silly =). Let's turn it into pattern-matching: - - - -```re -let optionBoolToBool = opt => { - switch (opt) { - | None => false - | Some(a) => a ? true : false - } -}; -``` - -```ml -let optionBoolToBool opt = - match opt with - | None -> false - | Some a -> if a then true else false -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Slightly better, but still nested. Pattern-matching allows you to do this: - - - -```re -let optionBoolToBool = opt => { - switch (opt) { - | None => false - | Some(true) => true - | Some(false) => false - } -}; -``` - -```ml -let optionBoolToBool opt = - match opt with - | None -> false - | Some true -> true - | Some false -> false -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Much more linear-looking! Now, you might be tempted to do this: - - - -```re -let optionBoolToBool = opt => { - switch (opt) { - | Some(true) => true - | _ => false - } -}; -``` - -```ml -let optionBoolToBool opt = - match opt with - | Some true -> true - | _ -> false -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Which is much more concise, but kills the exhaustiveness check mentioned above; refrain from using that. This is the best: - - - -```re -let optionBoolToBool opt = - match opt with - | Some trueOrFalse -> trueOrFalse - | None -> false -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined) { - return opt; - } else { - return false; - } -} -``` - - - -Pretty darn hard to make a mistake in this code at this point! Whenever you'd like to use an if-else with many branches, prefer pattern matching instead. It's more concise and [performant](variant#design-decisions) too. diff --git a/pages/docs/manual/v8.0.0/pipe.mdx b/pages/docs/manual/v8.0.0/pipe.mdx deleted file mode 100644 index 885ab0b48..000000000 --- a/pages/docs/manual/v8.0.0/pipe.mdx +++ /dev/null @@ -1,337 +0,0 @@ ---- -title: "Pipe" -description: "The Pipe operator (->)" -canonical: "/docs/manual/latest/pipe" ---- - -# Pipe - -ReScript provides a tiny but surprisingly useful operator `->`, called the "pipe", that allows you to "flip" your code inside-out. `a(b)` becomes `b->a`. It's a simple piece of syntax that doesn't have any runtime cost. - -Why would you use it? Imagine you have the following: - - - -```re -validateAge(getAge(parseData(person))); -``` - -```ml -validateAge (getAge (parseData person)) -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -This is slightly hard to read, since you need to read the code from the innermost part, to the outer parts. Use pipe to streamline it: - - - -```re -person - ->parseData - ->getAge - ->validateAge; -``` - -```ml -person - |. parseData - |. getAge - |. validateAge -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -Basically, `parseData(person)` is transformed into `person->parseData`, and `getAge(person->parseData)` is transformed into `person->parseData->getAge`, etc. - -**This works when the function takes more than one argument too**. - - - -```re -a(one, two, three); -``` - -```ml -a one two three -``` - -```js -a(one, two, three); -``` - - - -is the same as - - - -```re -one->a(two, three); -``` - -```ml -one |. a two three -``` - -```js -a(one, two, three); -``` - - - -This also works with labeled arguments. - -Pipes are used to emulate object-oriented programming, e.g. what's `myStudent.getName` in other languages like Java would be `myStudent->getName` in ReScript (aka `getName(myStudent)`). This allows us to have the readability of the good parts of OOP without its downside of dragging in a huge class system just to call a function on a piece of data. - -## Tips & Tricks - -Do **not** to abuse pipes; they're a means to an end. Inexperienced engineers sometimes shape a library's API to take advantage of the pipe. This is backward. - -## JS Method Chaining - -_This section requires understanding of [our binding API](bind-to-js-function.md#object-method)_. - -JavaScript's APIs are often attached to objects, and often chainable, like so: - -```js -const result = [|1, 2, 3|].map(a => a + 1).filter(a => a % 2 === 0); - -asyncRequest() - .setWaitDuration(4000) - .send(); -``` - -Assuming we don't need the chaining behavior above, we'd bind to each case this using `bs.send` from the previous section: - - - -```re -[@bs.send] external map: (array('a), 'a => 'b) => array('b) = "map"; -[@bs.send] external filter: (array('a), 'a => bool) => array('a) = "filter"; - -type request; -[@bs.val] external asyncRequest: unit => request = "asyncRequest"; -[@bs.send] external setWaitDuration: (request, int) => request = "setWaitDuration"; -[@bs.send] external send: request => unit = "send"; -``` - -```ml -external map: 'a array -> ('a -> 'b) -> 'b array = "map" [@@bs.send] -external filter: 'a array -> ('a -> bool) -> 'a array = "filter" [@@bs.send] - -type request -external asyncRequest: unit -> request = "asyncRequest" [@@bs.val] -external setWaitDuration: request -> int -> request = "setWaitDuration" [@@bs.send] -external send: request -> unit = "send" [@@bs.send] -``` - -```js -// Empty output -``` - - - -You'd use them like this: - - - -```re -let result = Js.Array2.filter( - Js.Array2.map([|1, 2, 3|], a => a + 1), - a => a mod 2 == 0 -); - -send(setWaitDuration(asyncRequest(), 4000)); -``` - -```ml -let result = Js.Array2.filter - (Js.Array2.map [|1; 2; 3|] (fun a -> a + 1)) - (fun a -> (a mod 2) = 0) - -let () = send (setWaitDuration (asyncRequest ()) 4000) -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -This looks much worse than the JS counterpart! Clean it up visually with pipe: - - - -```re -let result = [|1, 2, 3|] - ->map(a => a + 1) - ->filter(a => a mod 2 == 0) - -asyncRequest()->setWaitDuration(4000)->send -``` - -```ml -let result = [|1; 2; 3|] - |. map(fun a -> a + 1) - |. filter(fun a -> a mod 2 = 0) - -asyncRequest()->setWaitDuration(4000)->send -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -## Pipe Into Variants - -You can pipe into a variant's constructor as if it was a function: - - - -```re -let result = name->preprocess->Some; -``` - -```ml -let result = name |. preprocess |. Some -``` - -```js -var result = preprocess(name); -``` - - - -We turn this into: - - - -```re -let result = Some(preprocess(name)); -``` - -```ml -let result = Some (preprocess name) -``` - -```js -var result = preprocess(name); -``` - - - -**Note** that using a variant constructor as a function wouldn't work anywhere else beside here. - -## Pipe Placeholders - -A placeholder is written as an underscore and it tells ReScript that you want to fill in an argument of a function later. These two have equivalent meaning: - - - -```re -let addTo7 = (x) => add3(3, x, 4); -let addTo7 = add3(3, _, 4); -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - - - -Sometimes you don't want to pipe the value you have into the first position. In these cases you can mark a placeholder value to show which argument you would like to pipe into. - -Let's say you have a function `namePerson`, which takes a `person` then a `name` argument. If you are transforming a person then pipe will work as-is: - - - -```re -makePerson(~age=47, ()) - ->namePerson("Jane"); -``` - -```ml -makePerson ~age=47 () - |. namePerson("Jane") -``` - -```js -namePerson(makePerson(47), "Jane"); -``` - - - -If you have a name that you want to apply to a person object, you can use a placeholder: - - - -```re -getName(input) - ->namePerson(personDetails, _); -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -This allows you to pipe into any positional argument. It also works for named arguments: - - - -```re -getName(input) - ->namePerson(~person=personDetails, ~name=_); -``` - -```ml -(* doesn't exist in old ML syntax *) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -## Triangle Pipe (Deprecated) - -You might see usages of another pipe, `|>`, in some codebases. These are deprecated. - -Unlike `->` pipe, the `|>` pipe puts the subject as the last (not first) argument of the function. `a |> f(b)` turns into `f(b, a)`. - -For a more thorough discussion on the rationale and differences between the two operators, please refer to the [Data-first and Data-last comparison by Javier Chávarri](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/) diff --git a/pages/docs/manual/v8.0.0/primitive-types.mdx b/pages/docs/manual/v8.0.0/primitive-types.mdx deleted file mode 100644 index e8e5513f2..000000000 --- a/pages/docs/manual/v8.0.0/primitive-types.mdx +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: "Primitive Types" -description: "Primitive Data Types in ReScript" -canonical: "/docs/manual/latest/primitive-types" ---- - -# Primitive Types - -ReScript comes with the familiar primitive types like `string`, `int`, `float`, etc. - -## String - -ReScript `string`s are delimited using **double** quotes (single quotes are reserved for the character type below). - - - -```re -let greeting = "Hello world!"; -let multilineGreeting = "Hello - world!"; -``` - -```ml -let greeting = "Hello world!" -let multilineGreeting = "Hello - world!"; -``` - -```js -var greeting = "Hello world!"; -var multilineGreeting = "Hello\n world!"; -``` - - - -To concatenate strings, use `++`: - - - -```re -let greetings = "Hello " ++ "world!"; -``` - -```ml -let greetings = "Hello " ^ "world!" -``` - -```js -var greetings = "Hello world!"; -``` - - - -### String Interpolation - -There's a special syntax for string that allows - -- multiline string just like before -- Interpolation - - - -```re -let greeting = {j|Hello -World -$(name) -|j} -``` - -```ml -let greeting = {j|Hello -World -$(name) -|j} -``` - -```js -var greeting = "Hello\nWorld\n" + name + "\n"; -``` - - - -This is just like JavaScript's backtick string interpolation. - -### Usage - -See the familiar `Js.String` API in the [API docs](api/js/string). Since a ReScript string maps to a JavaScript string, you can mix & match the string operations in both standard libraries. - -### Tips & Tricks - -**You have a good type system now**! In an untyped language, you'd often overload the meaning of string by using it as: - -- a unique id: `var BLUE_COLOR = "blue"` -- an identifier into a data structure: `var BLUE = "blue" var RED = "red" var colors = [BLUE, RED]` -- the name of an object field: `person["age"] = 24` -- an enum: `if (audio.canPlayType() === 'probably') {...}` [(ಠ_ಠ)](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType#Return_value) -- other crazy patterns you'll soon find horrible, after getting used to ReScript's alternatives. - -The more you overload the poor string type, the less the type system (or a teammate) can help you! ReScript provides concise, fast and maintainable types & data structures alternatives to the use-cases above (e.g. variants, in a later section). - -## Char - -ReScript has a type for a string with a single letter: - - - -```re -let firstLetterOfAlphabet = 'a'; -``` - -```ml -let firstLetterOfAlphabet = 'a' -``` - -```js -var firstLetterOfAlphabet = /* "a" */ 97; -``` - - - -**Note**: Char doesn't support Unicode or UTF-8 and is therefore not recommended. - -To convert a String to a Char, use `"a".[0]`. To convert a Char to a String, use `String.make(1, 'a')`. - -## Regular Expression - -ReScript regular expressions compile cleanly to their JavaScript counterpart: - - - -```re -let r = [%re "/b/g"]; -``` - -```ml -let r = [%re "/b/g"] -``` - -```js -var r = /b/g; -``` - - - -A regular expression like the above has the type `Js.Re.t`. The [Js.Re](api/js/re) module contains the regular expression helpers you have seen in JS. - -## Boolean - -A ReScript boolean has the type `bool` and can be either `true` or `false`. Common operations: - -- `&&`: logical and. -- `||`: logical or. -- `!`: logical not. -- `<=`, `>=`, `<`, `>` -- `==`: structural equal, compares data structures deeply: `(1, 2) == (1, 2)` is `true`. Convenient, but use with caution. -- `===`: referential equal, compares shallowly. `(1, 2) === (1, 2)` is `false`. `let myTuple = (1, 2); myTuple === myTuple` is `true`. -- `!=`: structural unequal. -- `!==`: referential unequal. - -ReScript's `true/false` compiles into a JavaScript `true/false`. - -## Integers - -32-bits, truncated when necessary. We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [Js.Int](api/js/int) for helper functions. - -**Careful when you bind to JavaScript numbers**! Long ones might be truncated. Bind JS number (especially Dates) as **float** instead. - -## Floats - -Float requires other operators: `+.`, `-.`, `*.`, `/.`, etc. Like `0.5 +. 0.6`. See [Js.Float](api/js/float) for helper functions. - -## Unit - -The `unit` type has a single value, `()`. It compiles to JavaScrit's `undefined`. It's a dummy type used as a placeholder in various places. You won't need it until you see it. diff --git a/pages/docs/manual/v8.0.0/project-structure.mdx b/pages/docs/manual/v8.0.0/project-structure.mdx deleted file mode 100644 index 93e77f0f0..000000000 --- a/pages/docs/manual/v8.0.0/project-structure.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Project Structure" -description: "Notes on project structure and other rough ReScript guidelines" -canonical: "/docs/manual/latest/project-structure" ---- - -# Project Structure - -These are the existing, non-codified community practices that are currently propagated through informal agreement. We might remove some of them at one point, and enforce some others. Right now, they're just recommendations for ease of newcomers. - -## File Casing - -Capitalized file names (aka first letter upper-cased). - -**Justification**: Module names can only be capitalized. Newcomers often ask how a file maps to a module, and why `draw.res` maps to the module `Draw`, and sometimes try to refer to a module through uncapitalized identifiers. Using `Draw.res` makes this mapping more straightforward. It also helps certain file names that'd be awkward in uncapitalized form: `uRI.res`. - -## Ignore `.merlin` File - -This is generated by the build system and you should not have to manually edit it. Don't check it into the repo. - -**Justification**: `.merlin` is for editor tooling. The file contains absolute paths, which are also not cross-platform (e.g. Windows paths are different). - -## Folders - -Try not to have too many nested folders. Keep your project flat, and have fewer files (reminder: you can use nested modules). - -**Justification**: The file system is a _tree_, but your code's dependencies are a _graph_. Because of that, any file & folder organization is usually imperfect. While it's still valuable to group related files together in a folder, the time wasted debating & getting decision paralysis over these far outweight their benefits. We'll always recommend you to Get Work Done instead of debating about these issues. - -## Third-party Dependencies - -Keep them to a minimum. - -**Justification**: A compiled, statically typed language cannot model its dependencies easily by muddling along like in a dynamic language, especially when we're still piggy-backing on NPM/Yarn (to reduce learning overhead in the medium-term). Keeping dependencies simple & lean helps reduce possibility of conflicts (e.g. two diamond dependencies, or clashing interfaces). - -## Documentation - -Have them. Spend more effort making them great (examples, pitfalls) and professional rather than _just_ fancy-looking. Do use examples, and avoid using names such as `foo` and `bar`. There's always more concrete names (it's an example, no need to be abstract/generalized just yet. The API docs will do this plentily). For blog posts, don't repeat the docs themselves, describe the _transition_ from old to new, and why (e.g. "it was a component, now it's a function, because ..."). - -**Justification**: It's hard for newcomers to distinguish between a simple/decent library and one that's fancy-looking. For the sake of the community, don't try too hard to one-up each other's libraries. Do spread the words, but use your judgement too. - -## PPX & Other Meta-tools - -Keep them to a minimum. PPX, unless used in renown cases (printer, accessors and serializer/deserializer generation), can cause big learning churn for newcomers; on top of the syntax, semantics, types, build tool & FFI that they already have to learn, learning per-library custom transformations of the code is an extra step. More invasive macros makes the code itself less semantically meaningful too, since the essence would be hiding somewhere else. - -## Paradigm - -Don't abuse overly fancy features. Do leave some breathing room for future APIs but don't over-architect things. - -**Justification**: Simple code helps newcomers understand and potentially contribute to your code. Contributing is the best way for them to learn. The extra help you receive might also surpass the gain of using a slightly more clever language trick. But do try new language tricks in some of more casual projects! You might discover new ways of architecting code. - -## Publishing - -If it's a wrapper for a JS library, don't publish the JS artifacts. If it's a legit library, publish the artifacts in lib/js if you think JS consumers might use it. This is especially the case when you gradually convert a JS lib to ReScript while not breaking existing JS consumers. - -Do put the keywords `"rescript"` in your package.json `keywords` field. This allows us to find the library much more easily for future purposes. - -**Justification**: Be nice to JS consumers of your library. They're your future ReScripters. diff --git a/pages/docs/manual/v8.0.0/promise.mdx b/pages/docs/manual/v8.0.0/promise.mdx deleted file mode 100644 index d8fa52ec0..000000000 --- a/pages/docs/manual/v8.0.0/promise.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: "Promise" -description: "JS Promise handling in ReScript" -canonical: "/docs/manual/latest/promise" ---- - -# Promise - -ReScript has built-in support for [JavaScript promises](api/js/promise). The 3 functions you generally need are: - -- `Js.Promise.resolve: 'a => Js.Promise.t('a)` -- `Js.Promise.then_: ('a => Js.Promise.t('b), Js.Promise.t('a)) => Js.Promise.t('b)` -- `Js.Promise.catch: (Js.Promise.error => Js.Promise.t('a), Js.Promise.t('a)) => Js.Promise.t('a)` - -Additionally, here's the type signature for creating a promise on the ReScript side: - - - -```rei -Js.Promise.make: ( - ( - ~resolve: (. 'a) => unit, - ~reject: (. exn) => unit - ) => unit -) => Js.Promise.t('a); -``` - -```mli -Js.Promise.make: ( - resolve:(('a -> unit) [@bs]) -> - reject:((exn -> unit) [@bs]) -> - unit -) -> 'a Js.Promise.t -``` - - - -This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](function.md#uncurried-function) (with a dot). `make` returns the created promise. - -## Usage - -Using the [pipe operator](pipe.md): - - - -```re -let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2)); - -myPromise -|> Js.Promise.then_(value => { - Js.log(value); - Js.Promise.resolve(value + 2); - }) -|> Js.Promise.then_(value => { - Js.log(value); - Js.Promise.resolve(value + 3); - }) -|> Js.Promise.catch(err => { - Js.log2("Failure!!", err); - Js.Promise.resolve(-2); - }); -``` - -```ml -let myPromise = Js.Promise.make (fun ~resolve ~reject -> ((resolve 2) [@bs])) - -let () = myPromise -|> Js.Promise.then_(fun value -> - Js.log value; - Js.Promise.resolve (value + 2) - ) -|> Js.Promise.then_(fun value -> - Js.log value; - Js.Promise.resolve (value + 3) - ) -|> Js.Promise.catch(fun err -> - Js.log2 "Failure!!", err; - Js.Promise.resolve -2 - ) -``` - -```js -var myPromise = new Promise(function (resolve, reject) { - return resolve(2); -}); - -myPromise - .then(function (value) { - console.log(value); - return Promise.resolve((value + 2) | 0); - }) - .then(function (value) { - console.log(value); - return Promise.resolve((value + 3) | 0); - }) - .catch(function (err) { - console.log("Failure!!", err); - return Promise.resolve(-2); - }); -``` - - - -**Note**: we might offer a dedicated syntax for JS promises (async/await) in the future. Stay tuned! diff --git a/pages/docs/manual/v8.0.0/record.mdx b/pages/docs/manual/v8.0.0/record.mdx deleted file mode 100644 index 7ad957875..000000000 --- a/pages/docs/manual/v8.0.0/record.mdx +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: "Record" -description: "Record types in ReScript" -canonical: "/docs/manual/latest/record" ---- - -# Record - -Records are like JavaScript objects but: - -- are immutable by default -- have fixed fields (not extensible) - -## Type Declaration - -A record needs a mandatory type declaration: - - - -```re -type person = { - age: int, - name: string -}; -``` - -```ml -type person = { - age: int; - name: string; -} -``` - -```js -// Empty output -``` - - - -## Creation - -To create a `person` record (declared above): - - - -```re -let me = { - age: 5, - name: "Big ReScript" -}; -``` - -```ml -let me = { - age = 5; - name = "Big ReScript"; -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -When you create a new record value, ReScript tries to find a record type declaration that conforms to the shape of the value. So the `me` value here is inferred as of type `person`. - -The type is found by looking above the `me` value. **Note**: if the type instead resides in another file or module, you need to explicitly indicate which file or module it is: - - - -```re -// School.re -type person = {age: int, name: string}; -``` - -```ml -(* School.ml *) -type person = {age: int; name: string} -``` - -```js -// Empty output -``` - - - - - -```re -// Example.re - -let me: School.person = {age: 20, name: "Big ReScript"}; -/* or */ -let me2 = {School.age: 20, name: "Big ReScript"}; -``` - -```ml -(* Example.re *) - -let me: School.person = {age = 20; name = "Big ReScript"} -(* or *) -let me2 = {School.age = 20; name = "Big ReScript"} -``` - -```js -var me = { - age: 20, - name: "Big ReScript", -}; -var me2 = { - age: 20, - name: "Big ReScript", -}; -``` - - - -Either of the above 3 says "this record's definition is found in the School file". The first one, the regular type annotation, is preferred. - -## Access - -Use the familiar dot notation: - - - -```re -let name = me.name; -``` - -```ml -let name = me.name -``` - -```js -var name = "Big ReScript"; -``` - - - -## Immutable Update - -New records can be created from old records with the `...` spread operator. The original record isn't mutated. - - - -```re -let meNextYear = {...me, age: me.age + 1}; -``` - -```ml -let meNextYear = {me with age = me.age + 1} -``` - -```js -var meNextYear = { - age: 21, - name: "Big ReScript", -}; -``` - - - -**Note**: spread cannot add new fields to the record value, as a record's shape is fixed by its type. - -## Mutable Update - -Record fields can optionally be mutable. This allows you to efficiently update those fields in-place with the `=` operator. - - - -```re -type person = { - name: string, - mutable age: int -}; - -let baby = {name: "Baby ReScript", age: 5}; -baby.age = baby.age + 1; // `baby.age` is now 6. Happy birthday! -``` - -```ml -type person = { - name: string; - mutable age: int; -} - -let baby = {name = "Baby ReScript"; age = 5} -let () = baby.age <- baby.age + 1 (* `baby.age` is now 6. Happy birthday! *) -``` - -```js -var baby = { - name: "Baby ReScript", - age: 5, -}; - -baby.age = (baby.age + 1) | 0; -``` - - - -## Tips & Tricks - -**Record Types Are Found By Field Name**. With records, you **cannot** say "I'd like this function to take any record type, as long as they have the field `age`". The following **won't work as intended**: - - - -```re -type person = {age: int, name: string}; -type monster = {age: int, hasTentacles: bool}; - -let getAge = (entity) => entity.age; -``` - -```ml -type person = {age: int; name: string} -type monster = {age: int; hasTentacles: bool} - -let getAge entity = entity.age -``` - -```js -function getAge(entity) { - return entity.age; -} -``` - - - -Instead, `getAge` will infer that the parameter `entity` must be of type `monster`, the closest record type with the field `age`. The following code's last line fails: - - - -```re -let kraken = {age: 9999, hasTentacles: true}; -let me = {age: 5, name: "Baby ReScript"}; - -getAge(kraken); -getAge(me); // type error! -``` - -```ml -let kraken = {age = 9999; hasTentacles = true} -let me = {age = 5; name = "Baby ReScript"} - -let () = getAge kraken -let () = getAge me (* type error! *) -``` - - - -The type system will complain that `me` is a `person`, and that `getAge` only works on `monster`. If you need such capability, use ReScript objects, described [here](object.md). - -## Design Decisions - -After reading the constraints in the previous sections, and if you're coming from a dynamic language background, you might be wondering why one would bother with record in the first place instead of straight using object, since the former needs explicit typing and doesn't allow different records with the same field name to be passed to the same function, etc. - -1. The truth is that most of the times in your app, your data's shape is actually fixed, and if it's not, it can potentially be better represented as a combination of variant (introduced next) + record instead. -2. Since a record type is resolved through finding that single explicit type declaration (we call this "nominal typing"), the type error messages end up better than the counterpart ("structural typing", like for tuples). This makes refactoring easier; changing a record type's fields naturally allows the compiler to know that it's still the same record, just misused in some places. Otherwise, under structural typing, it might get hard to tell whether the definition site or the usage site is wrong. diff --git a/pages/docs/manual/v8.0.0/reserved-keywords.mdx b/pages/docs/manual/v8.0.0/reserved-keywords.mdx deleted file mode 100644 index e90946ff2..000000000 --- a/pages/docs/manual/v8.0.0/reserved-keywords.mdx +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: "Reserved Keyword" -description: "All reserved keywords in ReScript" -canonical: "/docs/manual/latest/reserved-keywords" ---- - -# Reserved Keywords - -> **Note**: Some of these words are reserved purely for backward compatibility. - -- `and` -- `as` -- `assert` - -- `begin` - -- `class` -- `constraint` - -- `do` -- `done` -- `downto` (also see `to`) - -- `else` (used with `if`) -- `end` -- `esfun` -- `exception` -- `external` - -- `false` (a `bool`, along with `true`) -- `for` -- `fun` -- `function` -- `functor` - -- `if` -- `in` -- `include` -- `inherit` -- `initializer` - -- `lazy` -- `let` - -- `module` -- `mutable` - -- `new` -- `nonrec` - -- `object` -- `of` -- `open` -- `or` - -- `pri` -- `pub` - -- `rec` - -- `sig` -- `struct` -- `switch` - -- `then` -- `to` -- `true` -- `try` -- `type` - -- `val` -- `virtual` - -- `when` -- `while` -- `with` diff --git a/pages/docs/manual/v8.0.0/shared-data-types.mdx b/pages/docs/manual/v8.0.0/shared-data-types.mdx deleted file mode 100644 index 8422611dc..000000000 --- a/pages/docs/manual/v8.0.0/shared-data-types.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: "Shared Data Types" -description: "Data types that share runtime presentation between JS and ReScript" -canonical: "/docs/manual/latest/shared-data-types" ---- - -# Shared Data Types - -ReScript's built-in values of type `string`, `float`, `array` and a few others have a rather interesting property: they compile to the exact same value in JavaScript! - -This means that if you're passing e.g. a ReScript string to the JavaScript side, the JS side can directly use it as a native JS string. It also means that you can import a JS string and pretend it's a native ReScript string. - -Unlike most compiled-to-js languages, in ReScript, **you don't need to write data converters back and forth for most of our values**! - -**Shared, bidirectionally usable types**: - -- String. Backtick strings like `` `hello $(personName)` `` (in old ML syntax: `{j|hello $(personName)|j}`) support interpolation. Normal `"hello"` strings don't. -- Float. ReScript floats are JS numbers, vice-versa. -- Array. In addition to the [JS Array API](api/js/array), we provide our own [Belt.Array](api/belt/array#set) API too. -- Tuple. Compiles to a JS array. You can treat a fixed-sized, heterogenous JS array as ReScript tuple too. -- Boolean. -- Record. Record compiles to JS object. Therefore you can also treat JS objects as records. If they're too dynamic, consider modeling them on the ReScript side as a hashmap/dictionary [`Js.Dict`](api/js/dict) or a ReScript object. -- Object. ReScript objects are JavaScript objects, vice-versa. -- Function. They compile to clean JS functions. -- Module. ReScript files are considered top-level modules, and are compiled to JS files 1 to 1. Nested modules are compiled to JavaScript objects. -- Unit. The `unit` type, which has a single value `()`, compiles to `undefined` too. Likewise, you can treat an incoming JS `undefined` as `()`. - - - -**Types that are slightly different than JS, but that you can still use from JS**: - -- Int. **Ints are 32-bits**! Be careful, you can potentially treat them as JS numbers and vice-versa, but if the number's large, then you better treat JS numbers as floats. For example, we bind to [`Js.Date`](api/js/date) using `float`s. -- Option. The `option` type's `None` value compiles into JS `undefined`. The `Some` value, e.g. `Some(5)`, compiles to `5`. Likewise, you can treat an incoming JS `undefined` as `None`. **JS `null` isn't handled here**. If your JS value can be `null`, use [Js.Nullable](api/js/nullable) helpers. -- Exception. - -**Non-shared types (aka internal types)**: - -- Variant. They don't exist in JS. -- List, which is just a regular variant. -- Character. -- Int64. -- Lazy values. -- Everything else. - -The non-shared types need your manual conversions if you want to export them for JS consumption. For a seamless JS / TypeScript / Flow integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand. diff --git a/pages/docs/manual/v8.0.0/try.mdx b/pages/docs/manual/v8.0.0/try.mdx deleted file mode 100644 index 0c44c192b..000000000 --- a/pages/docs/manual/v8.0.0/try.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: "Try" -description: "Try ReScript via CLI" -canonical: "/docs/manual/latest/try" ---- - -# Try via CLI - -You can compile a file directly via `bsc MyFile.re` (or `bsc MyFile.ml`): - - - -```re -// MyFile.re -let rec fib = n => { - switch (n) { - | 0 | 1 => n - | n => fib(n - 1) + fib(n - 2) - } -}; -Js.log(fib(0)); -``` - -```ml -// MyFile.ml -let rec fib n = - match n with - | 0 | 1 -> n - | n -> (fib (n - 1)) + (fib (n - 2)) -let _ = Js.log (fib 0) -``` - - - -```sh -❯ bsc MyFile.re -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; -function fib(n) { - if (n === 0 || n === 1) { - return 1; - } else { - return fib(n - 1 | 0) + fib(n - 2 | 0) | 0; - } -} -console.log(fib(0)); -exports.fib = fib; -/* Not a pure module */ -``` - -You can also get the inferred signature directly via `bsc -i MyFile.re` - - - -```rei -let fib: int => int; -``` - -```mli -val fib: int => int -``` - - diff --git a/pages/docs/manual/v8.0.0/tuple.mdx b/pages/docs/manual/v8.0.0/tuple.mdx deleted file mode 100644 index bab511fd9..000000000 --- a/pages/docs/manual/v8.0.0/tuple.mdx +++ /dev/null @@ -1,139 +0,0 @@ ---- -title: "Tuple" -description: "Tuple types and values in ReScript" -canonical: "/docs/manual/latest/tuple" ---- - -# Tuple - -Tuples are a ReScript-specific data structure that don't exist in JavaScript. They are: - -- immutable -- ordered -- fix-sized at creation time -- heterogeneous (can contain different types of values) - - - -```re -let ageAndName = (24, "Lil' ReScript"); -let my3dCoordinates = (20.0, 30.5, 100.0); -``` - -```ml -let ageAndName = (24, "Lil' ReScript") -let my3dCoordinates = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -Tuples' types can be used in type annotations as well. Tuple types visually resemble tuples values. - - - -```re -let ageAndName: (int, string) = (24, "Lil' ReScript"); -// a tuple type alias -type coord3d = (float, float, float); -let my3dCoordinates: coord3d = (20.0, 30.5, 100.0); -``` - -```ml -let ageAndName: (int * string) = (24, "Lil' ReScript") -(* a tuple type alias *) -type coord3d = (float * float * float) -let my3dCoordinates: coord3d = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -**Note**: there's no tuple of size 1. You'd just use the value itself. - -## Usage - -To get a specific member of a tuple, destructure it: - - - -```re -let (_, y, _) = my3dCoordinates; // now you've retrieved y -``` - -```ml -let (_, y, _) = my3dCoordinates; (* now you've retrieved y *) -``` - -```js -var y = 30.5; -``` - - - -The `_` means you're ignoring the indicated members of the tuple. - -Tuples aren't meant to be updated mutatively. You'd create new ones by destructuring the old ones: - - - -```re -let coordinates1 = (10, 20, 30); -let (c1x, _, _) = coordinates1; -let coordinates2 = (c1x + 50, 20, 30); -``` - -```ml -let coordinates1 = (10, 20, 30) -let (c1x, _, _) = coordinates1 -let coordinates2 = (c1x + 50, 20, 30) -``` - -```js -var coordinates1 = [10, 20, 30]; -var c1x = 10; -var coordinates2 = [60, 20, 30]; -``` - - - -## Tips & Tricks - -You'd use tuples in handy situations that pass around multiple values without too much ceremony. For example, to return many values: - - - -```re -let getCenterCoordinates = () => { - let x = doSomeOperationsHere(); - let y = doSomeMoreOperationsHere(); - (x, y) -}; -``` - -```ml -let getCenterCoordinates () = - let x = doSomeOperationsHere () in - let y = doSomeMoreOperationsHere () in - (x, y) -``` - -```js -function getCenterCoordinates(param) { - var x = doSomeOperationsHere(undefined); - var y = doSomeMoreOperationsHere(undefined); - return [x, y]; -} -``` - - - -Try to keep the usage of tuple **local**. For data structures that are long-living and passed around often, prefer a **record**, which has named fields. diff --git a/pages/docs/manual/v8.0.0/type.mdx b/pages/docs/manual/v8.0.0/type.mdx deleted file mode 100644 index 83822011f..000000000 --- a/pages/docs/manual/v8.0.0/type.mdx +++ /dev/null @@ -1,380 +0,0 @@ ---- -title: "Type" -description: "Types and type definitions in ReScript" -canonical: "/docs/manual/latest/type" ---- - -# Type - -Types are the highlight of ReScript! They are: - -- **Strong**. A type can't change into another type. In JavaScript, your variable's type might change when the code runs (aka at runtime). E.g. a `number` variable might change into a `string` sometimes. This is an anti-feature; it makes the code much harder to understand when reading or debugging. -- **Static**. ReScript types are erased after compilation and don't exist at runtime. Never worry about your types dragging down performance. You don't need type info during runtime; we report all the information (especially all the type errors) during compile time. Catch the bugs earlier! -- **Sound**. This is our biggest differentiator versus many other typed languages that compile to JavaScript. Our type system is guaranteed to **never** be wrong. Most type systems make a guess at the type of a value and show you a type in your editor that's sometime incorrect. We don't do that. We believe that a type system that is sometime incorrect can end up being dangerous due to expectation mismatches. -- **Fast**. Many developers underestimate how much of their project's build time goes into type checking. Our type checker is one of the fastest around. -- **Inferred**. You don't have to write down the types! ReScript can deduce them from their values. Yes, it might seem magical that we can deduce all of your program's types, without incorrectness, without your manual annotation, and do so quickly. Welcome to ReScript =). - -The following sections explore more of our type system. - -## Inference - -This let-binding doesn't contain any written type: - - - -```re -let score = 10; -let add = (a, b) => a + b; -``` - -```ml -let score = 10 -let add a b = a + b -``` - -```js -var score = 10; -function add(a, b) { - return (a + b) | 0; -} -``` - - - -ReScript knows that `score` is an `int`, judging by the value `10`. This is called **inference**. Likewise, it also knows that the `add` function takes 2 `int`s and returns an `int`, judging from the `+` operator, which works on ints. - -## Type Annotation - -But you can also optionally write down the type, aka annotate your value: - - - -```re -let score: int = 10; -``` - -```ml -let score: int = 10 -``` - -```js -var score = 10; -``` - - - -If the type annotation for `score` doesn't correspond to our inferred type for it, we'll show you an error during compilation time. We **won't** silently assume your type annotation is correct, unlike many other languages. - -You can also wrap any expression in parentheses and annotate it: - - - -```re -let myInt = 5; -let myInt: int = 5; -let myInt = (5: int) + (4: int); -let add = (x: int, y: int) : int => x + y; -let drawCircle = (~radius as r: int): circleType => /* code here */; -``` - -```ml -let myInt = 5 -let myInt: int = 5 -let myInt = (5 : int) + (4 : int) -let add (x : int) (y : int) = (x + y : int) -let drawCircle ~radius:(r : int) : circleType = (* code here *) -``` - -```js -var myInt = 9; -function add(x, y) { - return (x + y) | 0; -} -function drawCircle(r) { - /* code here */ -} -``` - - - -Note: in the last line, `(~radius as r: int)` is a labeled argument. More on this in the [function](function.md) page. - -## Type Alias - -You can refer to a type by a different name. They'll be equivalent: - - - -```re -type scoreType = int; -let x: scoreType = 10; -``` - -```ml -type scoreType = int -let x: scoreType = 10 -``` - -```js -var x = 10; -``` - - - -## Type Parameter (Aka Generic) - -Types can accept parameters, akin to generics in other languages. The parameters' names **need** to start with `'`. - -The use-case of a parameterized type is to kill duplications. Before: - - - -```re -// this is a tuple of 3 items, explained next -type intCoordinates = (int, int, int); -type floatCoordinates = (float, float, float); - -let a: intCoordinates = (10, 20, 20); -let b: floatCoordinates = (10.5, 20.5, 20.5); -``` - -```ml -(* this is a tuple of 3 items, explained next *) -type intCoordinates = (int, int, int) -type floatCoordinates = (float, float, float) - -let a: intCoordinates = (10, 20, 20) -let b: floatCoordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -After: - - - -```re -type coordinates('a) = ('a, 'a, 'a); - -let a: coordinates(int) = (10, 20, 20); -let b: coordinates(float) = (10.5, 20.5, 20.5); -``` - -```ml -type 'a coordinates = ('a * 'a * 'a) - -let a: int coordinates = (10, 20, 20) -let b: float coordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -Note that the above codes are just contrived examples for illustration purposes. Since the types are inferred, you could have just written: - - - -```re -let buddy = (10, 20, 20); -``` - -```ml -let buddy = (10, 20, 20) -``` - -```js -var buddy = [10, 20, 20]; -``` - - - -The type system infers that it's a `(int, int, int)`. Nothing else needed to be written down. - -Type arguments appear in many places. Our `array('a)` type is such a type that requires a type parameter - - - -```re -// inferred as `array(string)` -let greetings = [|"hello", "world", "how are you"|]; -``` - -```ml -(* inferred as `string array` *) -let greetings = [|"hello"; "world"; "how are you"|] -``` - -```js -var greetings = ["hello", "world", "how are you"]; -``` - - - -If types didn't accept parameters, the standard library would need to define the types `arrayOfString`, `arrayOfInt`, `arrayOfTuplesOfInt`, etc. That'd be tedious. - -Types can receive many arguments, and be composable. - - - - - -```re -type result('a, 'b) = - | Ok('a) - | Error('b); - -type myPayload = {data: string}; - -type myPayloadResults('errorType) = array(result(myPayload, 'errorType)); - -let payloadResults: myPayloadResults(string) = [| - Ok({data: "hi"}), - Ok({data: "bye"}), - Error("Something wrong happened!") -|]; -``` - -```ml -type ('a, 'b) result = - | Ok of 'a - | Error of 'b - -type myPayload = { - data: string; -} - -type 'errorType myPayloadResults = (myPayload, 'errorType) result array - -let payloadResults: string myPayloadResults = [| - Ok({data = "hi"}); - Ok({data = "bye"}); - Error("Something wrong happaned!"); -|] -``` - -```js -var payloadResults = [ - { - TAG: /* Ok */ 0, - _0: { data: "hi" }, - }, - { - TAG: /* Ok */ 0, - _0: { data: "bye" }, - }, - { - TAG: /* Error */ 1, - _0: "Something wrong happened!", - }, -]; -``` - - - -## Recursive Types - -Just like a functions, a type can reference itself within itself: - - - -```re -type person = { - name: string, - friends: array(person) -} -``` - -```ml -type person = { - name: string; - friends: person array; -} -``` - -```js -// Empty output -``` - - - -To opt out of resursive type, use `type nonrec person = ...`. - -## Mutually Recursive Types - -Types can also be _mutually_ recursive through `and`: - - - -```re -type student = {taughtBy: teacher} -and teacher = {students: array(student)}; -``` - -```ml -type student = {taughtBy: teacher} -and teacher = {students: student array} -``` - -```js -// Empty output -``` - - - -## Type Escape Hatch - -ReScript's type system is robust and does not allow dangerous, unsafe stuff like implicit type casting, randomly guessing a value's type, etc. However, out of pragmatism, we expose a single escape hatch for you to "lie" to the type system: - - - -```re -external myShadyConversion: myType1 => myType2 = "%identity"; -``` - -```ml -external myShadyConversion: myType1 -> myType2 = "%identity" -``` - -```js -// Empty output -``` - - - -This declaration converts a `myType1` of your choice to `myType2` of your choice. You can use it like so: - - - -```re -external convertToFloat : int => float = "%identity"; -let age = 10; -let gpa = 2.1 +. convertToFloat(age); -``` - -```ml -external convertToFloat : int -> float = "%identity" -let age = 10 -let gpa = 2.1 +. (convertToFloat age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - - -Obviously, do **not** abuse this feature. Use it tastefully when you're working with existing, overly dynamic JS code, for example. - -More on externals [here](external.md). - -**Note**: this particular `external` is the only one that isn't preceded by a `@bs` annotation. diff --git a/pages/docs/manual/v8.0.0/use-illegal-identifier-names.mdx b/pages/docs/manual/v8.0.0/use-illegal-identifier-names.mdx deleted file mode 100644 index 0c6200f53..000000000 --- a/pages/docs/manual/v8.0.0/use-illegal-identifier-names.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -title: "Use Illegal Identifier Names" -description: "Handling (JS) naming collisions in ReScript" -canonical: "/docs/manual/latest/use-illegal-identifier-names" ---- - -# Use Illegal Identifier Names - - - -This page is solely dedicated to Reason v3.6 related naming collisions and also highlights some name mangling rules the ReScript compiler implemented just for Reason purposes. - - - -JavaScript has different naming conventions and has only very few limitations when it comes to naming variables, classes, functions, JS object attributes etc. - -Reason on the contrary has more restrictive naming rules which need to be considered whenever you define a type, function, value, module, record attribute or similar. Here are a few typical naming restrictions which cause trouble with JS: - -- Every name needs to start with a lowercase letter (uppercase is reserved for module names) -- For the same reason, names can't be all caps (very common for JS constants: `const MY_CONSTANT = "my_constant"`) -- It's not possible to use [reserved keywords](/docs/manual/latest/reserved-keywords) for names -- Labeled arguments (for defining JSX attributes) can't be named after keywords and can't start with an uppercase letter -- etc. - -Of course, when doing interop, we still want to be able to map to the JS equivalent (preferably without any runtime overhead). In this section we describe some common scenarios on how to gracefully handle naming collisions. - -## Using reserved keywords as JSX props - -Many React components have a prop named `type` in JavaScript: - -```js -/* this won't work in Reason since `type` is a reserved keyword! */ - -``` - -If you're using a React component with a reserved keyword as a prop name, then simply prepend a underscore (so that it's a valid Reason name): - - - -```re -/* This works because `_type` is not a reserved keyword */ - -``` - -```ml -(* Doesn't exist in old ML syntax *) -``` - - - -The Reason compiler will remove the leading underscore when outputting JavaScript (so the JavaScript will have ``). - -The removal of the `_` is called "Name mangling". The ruleset for this behavior is discussed [further down below](#special-name-mangling-rules-for-js-object-attribute-names). - -## Accessing JavaScript object attributes that start with a capital letter - -Capital letters in Reason are used exclusively for module names, like `String` and `Belt`, and they cannot be used as record field names like in JavaScript. - -```js -const payload = { - PostTitle: "Welcome to Reason", -}; - -/* this won't work in Reason since `PostTitle` is capitalized, so `paylod.PostTitle` would break */ -const title = payload.PostTitle; -``` - -In this case, when writing bindings to the JavaScript object, you can use the `[@bs.as "whatever-name-you-want-in-javascript"]` to tell the compiler exactly what the JavaScript attribute name should be in the compiled output: - - - -```re -type payload = { - [@bs.as "PostTitle"] postTitle: string -}; - -let payload = { - postTitle: "Welcome to Reason" -}; - -/* ReScript is happy since we're using the valid `postTitle` field name */ -let title = payload.postTitle; -``` - -```ml -type payload = { - postTitle: string [@bs.as "PostTitle"] -} - -let payload = { - postTitle = "Welcome to Reason" -} - -(* ReScript is happy since we're using the valid `postTitle` field name *) -let title = payload.postTitle -``` - -```js -/* The correct capitalized field name is output in the JavaScript! */ -var title = payload.PostTitle; -``` - - - -## Accessing reserved keywords as JavaScript object attribute names - -Just like accessing attributes that start with a capital letter, we can use `[@bs.as "the-reserved-keyword-that-javascript-wants"]`. It's customary to append an underscore (unlike the JSX case, where we _prepend_ the underscore) to the reserved keyword name: - - - -```re -type payload = { - [@bs.as "type"] type_: string -} - -let payload = { - type_: "Documentation" -} - -/* ReScript is happy since we're using the valid `type_` field name */ -let payloadType = payload.type_; -``` - -```ml -type payload = { - type_: string [@bs.as "type"] -} - -let payload = { - type_ = "Documentation" -} - -(* ReScript is happy since we're using the valid `type_` field name *) -let payloadType = payload.type_ -``` - -```js -/* The reason compiler has correctly ouput `payload.type` even though *we* called the field `type_` */ -var payloadType = payload.type; -``` - - - -## Special name mangling rules for JS object attribute names - -> **Note:** This is special behavior partly implemented in the Reason syntax, partly in the ReScript compiler. This section is mostly useful for understanding how JS object attributes and labeled arguments of ReasonReact components are compiled. - -> **Another Note:** A JS object type is a structurally typed entity with special compilation behavior, so they act differently than records or plain Reason objects. They are encoded as `Js.t({...})` types, more details about that feature can be found [here](http://localhost:3000/docs/reason-compiler/latest/object-2#actual-solution). -> -> Labeled arguments used in `[@react.component]` functions (like `let make = (~name: string, ~age: int) => React.element`) are transformed into the `Js.t` representation (e.g. `let make = Js.t({."name": string, "age": int}) => React.element`), so they follow the same ruleset. - -When accessing a JavaScript object field in a structural way (e.g. `myJsObject##some`), the following rules apply: - -1. A single _leading_ underscore will be _dropped_ from the output: `myJsObject##_type` => `myJsObject.type` -1. Two (or more) _leading_ underscores will be _kept_ in the output: `myJsObject##__type` => `myJsObject.__type` -1. There is _no way_ to access e.g. `myJsObject##_type` structurally - use records and `[@bs.as "_type"]` instead -1. The _final trailing_ double underscores (and anything following them) will be dropped from the output: `myJsObject##this_is_kept__this_is_omitted` => `myJsObject.this_is_kept` diff --git a/pages/docs/manual/v8.0.0/variant.mdx b/pages/docs/manual/v8.0.0/variant.mdx deleted file mode 100644 index 0d359a44a..000000000 --- a/pages/docs/manual/v8.0.0/variant.mdx +++ /dev/null @@ -1,364 +0,0 @@ ---- -title: "Variant" -description: "Variant data structures in ReScript" -canonical: "/docs/manual/latest/variant" ---- - -# Variant - -So far, most of ReScript's data structures might look familiar to you. This section introduces an extremely important, and perhaps unfamiliar, data structure: variant. - -Most data structures in most languages are about "this **and** that". A variant allows us to express "this **or** that". - - - -```re -type myResponse = - | Yes - | No - | PrettyMuch; - -let areYouCrushingIt = Yes; -``` - -```ml -type myResponse = - | Yes - | No - | PrettyMuch - -let areYouCrushingIt = Yes -``` - -```js -var areYouCrushingIt = /* Yes */ 0; -``` - - - -`myResponse` is a variant type with the cases `Yes`, `No` and `PrettyMuch`, which are called "variant constructors" (or "variant tag"). The `|` bar separates each constructor. - -**Note**: a variant's constructors need to be capitalized. - -## Variant Needs an Explicit Definition - -If the variant you're using is in a different file, bring it into scope like you'd do [for a record](record.md#record-needs-an-explicit-definition): - - - -```re -// Zoo.re -type animal = Dog | Cat | Bird; -``` - -```ml -(* Zoo.re *) -type animal = Dog | Cat | Bird -``` - -```js -// Empty output -``` - - - - - -```re -// Example.re -let pet: Zoo.animal = Dog; // preferred -// or -let pet2 = Zoo.Dog; -``` - -```ml -(* Example.re *) -let pet: Zoo.animal = Dog (* preferred *) -(* or *) -let pet2 = Zoo.Dog -``` - -```js -var pet = /* Dog */ 0; -var pet2 = /* Dog */ 0; -``` - - - -## Constructor Arguments - -A variant's constructors can hold extra data separated by comma. - - - -```re -type account = - | None - | Instagram(string) - | Facebook(string, int); -``` - -```ml -type account = - | None - | Instagram of string - | Facebook of string * int -``` - -```js -// Empty output -``` - - - -Here, `Instagram` holds a `string`, and `Facebook` holds a `string` and an `int`. Usage: - - - -```re -let myAccount = Facebook("Josh", 26); -let friendAccount = Instagram("Jenny"); -``` - -```ml -let myAccount = - Facebook ("Josh", 26) -let friendAccount = - Instagram "Jenny" -``` - -```js -var myAccount = { - TAG: /* Facebook */ 1, - _0: "Josh", - _1: 26, -}; -var friendAccount = { - TAG: /* Instagram */ 0, - _0: "Jenny", -}; -``` - - - -### Records in Variants - -You can use a record type in a variant: - - - -```re -type idType = {name: string, password: string}; - -type user = - | Number(int) - | Id(idType); -``` - -```ml -type idType = {name: string; password: string} - -type user = - | Number of int - | Id of idType -``` - -```js -// Empty output -``` - - - -If the record type is used only in the variant definition, you may put it in line: - - - -```re -type user = - | Number(int) - | Id({name: string, password: string}); -``` - -```ml -type user = - | Number of int - | Id of {name: string; password: string} -``` - -```js -// Empty output -``` - - - -### Pattern Matching On Variant - -See the [Pattern Matching/Destructuring](pattern-matching-destructuring.md) section later. - -## Tips & Tricks - -**Be careful** not to confuse a constructor carrying 2 arguments with a constructor carrying a single tuple argument: - - - -```re -type account = - | Facebook(string, int); // 2 arguments -type account2 = - | Instagram((string, int)); // 1 argument - happens to be a 2-tuple -``` - -```ml -type account = - | Facebook of string * int (* 2 arguments *) -type account2 = - | Instagram of (string * int) (* 1 argument - happens to be a 2-tuple *) -``` - -```js -// Empty output -``` - -### Variants Must Have Constructors - - - -If you come from an untyped language, you might be tempted to try `type myType = int | string`. This isn't possible in ReScript; you'd have to give each branch a constructor: `type myType = Int(int) | String(string)`. The former looks nice, but causes lots of trouble down the line. - -### Interop with JavaScript - -_This section assumes knowledge about our JavaScript interop. Skip this if you haven't felt the itch to use variants for wrapping JS functions yet_. - -Quite a few JS libraries use functions that can accept many types of arguments. In these cases, it's very tempting to model them as variants. For example, suppose there's a `myLibrary.draw` JS function that takes in either a `number` or a `string`. You might be tempted to bind it like so: - - - -```re -// reserved for internal usage -[@bs.module "myLibrary"] external draw: 'a => unit = "draw"; - -type animal = - | MyFloat(float) - | MyString(string); - -let betterDraw = (animal) => - switch (animal) { - | MyFloat(f) => draw(f) - | MyString(s) => draw(s) - }; - -betterDraw(MyFloat(1.5)); -``` - -```ml -(* reserved for internal usage *) -external draw: 'a => unit = "draw" [@@bs.module "myLibrary"] - -type animal = - | MyFloat of float - | MyString of string - -let betterDraw animal = - match animal with - | MyFloat f -> draw f - | MyString s -> draw s - -let () = betterDraw (MyFloat 1.5) -``` - -```js -var MyLibrary = require("myLibrary"); - -function betterDraw(animal) { - MyLibrary.draw(animal._0); -} - -betterDraw({ - TAG: /* MyFloat */ 0, - _0: 1.5, -}); -``` - - - -You could definitely do that, but there are better ways! For example, define two `external`s that both compile to the same JS call: - - - -```re -[@bs.module "myLibrary"] external drawFloat: float => unit = "draw"; -[@bs.module "myLibrary"] external drawString: string => unit = "draw"; -``` - -```ml -external drawFloat: float -> unit = "draw" [@@bs.module "myLibrary"] -external drawString: string -> unit = "draw" [@@bs.module "myLibrary"] -``` - -```js -// Empty output -``` - - - -ReScript also provides [a few other ways](bind-to-js-function.md#modeling-polymorphic-function) to do this. - -### Variant Types Are Found By Field Name - -Please refer to this [record section](record#record-types-are-found-by-field-name). Variants are the same: a function can't accept an arbitrary constructor shared by two different variants. Again, such feature exists; it's called a polymorphic variant. We'll talk about this in the future =). - -## Design Decisions - -Variants, in their many forms (polymorphic variant, open variant, GADT, etc.), are likely _the_ feature of a type system such as ReScript's. The aforementioned `option` variant, for example, obliterates the need for nullable types, a major source of bugs in other languages. Philosophically speaking, a problem is composed of many possible branches/conditions. Mishandling these conditions is the majority of what we call bugs. **A type system doesn't magically eliminate bugs; it points out the unhandled conditions and asks you to cover them**\*. The ability to model "this or that" correctly is crucial. - -For example, some folks wonder how the type system can safely eliminate badly formatted JSON data from propagating into their program. They don't, not by themselves! But if the parser returns the `option` type `None | Some(actualData)`, then you'd have to handle the `None` case explicitly in later call sites. That's all there is. - -Performance-wise, a variant can potentially tremendously speed up your program's logic. Here's a piece of JavaScript: - -```js -let data = 'dog' -if (data === 'dog') { - ... -} else if (data === 'cat') { - ... -} else if (data === 'bird') { - ... -} -``` - -There's a linear amount of branch checking here (`O(n)`). Compare this to using a ReScript variant: - - - -```re -type animal = Dog | Cat | Bird; -let data = Dog -switch (data) { -| Dog => Js.log("Wof") -| Cat => Js.log("Meow") -| Bird => Js.log("Kashiiin") -} -``` - -```ml -type animal = Dog | Cat | Bird -let data = Dog -let () = - match data with - | Dog -> Js.log "Wof" - | Cat -> Js.log "Meow" - | Bird -> Js.log "Kashiiin" -``` - -```js -console.log("Wof"); - -var data = /* Dog */ 0; -``` - - - -The compiler sees the variant, then - -1. conceptually turns them into `type animal = 0 | 1 | 2` -2. compiles `switch` to a constant-time jump table (`O(1)`). diff --git a/pages/docs/manual/v9.0.0/api.mdx b/pages/docs/manual/v9.0.0/api.mdx deleted file mode 100644 index ce832115e..000000000 --- a/pages/docs/manual/v9.0.0/api.mdx +++ /dev/null @@ -1,15 +0,0 @@ -# Introduction - -ReScript ships 3 modules in its standard library. - -- [Js](api/js): bindings for all your familiar JavaScript APIs. -- [Belt](api/belt): extra collections and helpers not available in JavaScript. -- [Dom](api/dom): Dom related types and modules. - -Usage heuristics: - -- Default to using the `Js` module. Most of the APIs in it are runtime-free and compile down to clean, readable JavaScript, which is our priority. -- For other APIs that aren't available in regular JavaScript (and thus don't exist in our `Js` bindings), use Belt. For example, prefer `Js.Array2` over `Belt.Array`. -- The `Dom` module contains our standardized types used by various userland DOM bindings. Due to the complexity of DOM, we don't mind that you ignore this module and build your application-specific DOM bindings. - -**Note**: we do not recommend other userland standard library alternatives (unless it's DOM bindings). These cause confusion and split points for the community. diff --git a/pages/docs/manual/v9.0.0/api/belt.mdx b/pages/docs/manual/v9.0.0/api/belt.mdx deleted file mode 100644 index 1c5b8039a..000000000 --- a/pages/docs/manual/v9.0.0/api/belt.mdx +++ /dev/null @@ -1,179 +0,0 @@ -# Belt - -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. - -## Motivation - -Belt provides: - -- The **highest quality** immutable data structures in JavaScript. -- Safety by default: A Belt function will never throw exceptions, unless it is - indicated explicitly in the function name (suffix "Exn"). -- Better performance and smaller code size running on the JS platform. -- Ready for [Tree Shaking](https://webpack.js.org/guides/tree-shaking/). - -## Usage - -To use modules from Belt, either refer to them by their fully qualified name (`Belt.List`, `Belt.Array` etc.) or open the `Belt` module by putting - -```res -open Belt -``` - -at the top of your source files. After opening Belt this way, `Array` will refer to `Belt.Array`, `List` will refer to `Belt.List` etc. in the subsequent code. - -If you want to open Belt globally for all files in your project instead, you can put - -```json - "bsc-flags": ["-open Belt"], -``` - -into your `bsconfig.json`. - -**Note**: this is the **only** `open` we encourage. - -Example usage: - -```res -let someNumbers = [1, 1, 4, 2, 3, 6, 3, 4, 2] - -let greaterThan2UniqueAndSorted = - someNumbers - ->Belt.Array.keep(x => x > 2) - // convert to and from set to make values unique - ->Belt.Set.Int.fromArray - ->Belt.Set.Int.toArray // output is already sorted - -Js.log2("result", greaterThan2UniqueAndSorted) -``` - -## Curried vs. Uncurried Callbacks - -For functions taking a callback parameter, there are usually two versions -available: - -- curried (no suffix) -- uncurried (suffixed with `U`) - -E.g.: - -```res -let forEach: (t<'a>, 'a => unit) => unit - -let forEachU: (t<'a>, (. 'a) => unit) => unit -``` - -The uncurried version will be faster in some cases, but for simplicity we recommend to stick with the curried version unless you need the extra performance. - -The two versions can be invoked as follows: - -``` -["a", "b", "c"]->Belt.Array.forEach(x => Js.log(x)) - -["a", "b", "c"]->Belt.Array.forEachU((. x) => Js.log(x)) -``` - -## Specialized Collections - -For collections types like set or map, Belt provides both a generic module as well as specialized, more efficient implementations for string and int keys. - -For example, Belt has the following set modules: - -- [Belt.Set](belt/set) -- [Belt.Set.Int](belt/set-int) -- [Belt.Set.String](belt/set-string) - -## Implementation Details - -### Array access runtime safety - -One common confusion comes from the way Belt handles array access. It differs from than the default standard library's. - -```res -let letters = ["a", "b", "c"] -let a = letters[0] // a == "a" -let capitalA = Js.String.toUpperCase(a) -let k = letters[10] // Raises an exception! The 10th index doesn't exist. -``` - -Because Belt avoids exceptions and returns `options` instead, this code behaves differently: - -```res -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 k = letters[10] // k == None -``` - -Although we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here: - -- Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`. -- The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`. -- `Belt.Array.get` returns values wrapped in options, so `letters[0] == Some("a")`. - -Fortunately, this is easy to fix: - -```res example -open Belt -let letters = ["a", "b", "c"] -let a = letters[0] - -// Use a switch statement: -let capitalA = - switch a { - | Some(a) => Some(Js.String.toUpperCase(a)) - | None => None - } - -let k = letters[10] // k == None -``` - -With that little bit of tweaking, our code now compiles successfully and is 100% free of runtime errors! - -### A Special Encoding for Collection Safety - -When we create a collection library for a custom data type we need a way to provide a comparator function. Take Set for example, suppose its element type is a pair of ints, it needs a custom compare function that takes two tuples and returns their order. The Set could not just be typed as Set.t (int \* int) , its customized compare function needs to manifest itself in the signature, otherwise, if the user creates another customized compare function, the two collection could mix which would result in runtime error. - -We use a phantom type to solve the problem: - -```res -module Comparable1 = - Belt.Id.MakeComparable( - { - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - } - ) - -let mySet1 = Belt.Set.make(~id=module(Comparable1)) - -module Comparable2 = - Belt.Id.MakeComparable( - { - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - } - ) - -let mySet2 = Belt.Set.make(~id=module(Comparable2)) -``` - -Here, the compiler would infer `mySet1` and `mySet2` having different type, so e.g. a `merge` operation that tries to merge these two sets will correctly fail. - -```res -let mySet1: t<(int, int), Comparable1.identity> -let mySet2: t<(int, int), Comparable2.identity> -``` - -`Comparable1.identity` and `Comparable2.identity` are not the same using our encoding scheme. diff --git a/pages/docs/manual/v9.0.0/api/belt/array.mdx b/pages/docs/manual/v9.0.0/api/belt/array.mdx deleted file mode 100644 index f5483a892..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/array.mdx +++ /dev/null @@ -1,936 +0,0 @@ -# Array - - - -Utililites for `Array` functions. - - - -### Note about index syntax - -Code like `arr[0]` does _not_ compile to JavaScript `arr[0]`. ReScript transforms the `[]` index syntax into a function: `Array.get(arr, 0)`. By default, this uses the default standard library's `Array.get` function, which may raise an exception if the index isn't found. If you `open Belt`, it will use the `Belt.Array.get` function which returns options instead of raising exceptions. [See this for more information](../belt.mdx#array-access-runtime-safety). - -## length - -```res sig -let length: array<'a> => int -``` - -return the size of the array - -```res example -// Returns 1 -Belt.Array.length(["test"]) -``` - -## size - -```res sig -let size: array<'a> => int -``` - -See Belt_Array.length - -## get - -```res sig -let get: (array<'a>, int) => option<'a> -``` - -If `i <= 0 <= length(arr)` returns `Some(value)` where `value` is the item at index `i`. -If `i` is out of range returns `None` - -## getExn - -```res sig -let getExn: (array<'a>, int) => 'a -``` - -Raise an exception if `i` is out of range. -Otherwise return the value at index `i` in `arr`. - -## getUnsafe - -```res sig -let getUnsafe: (array<'a>, int) => 'a -``` - -Unsafe - -no bounds checking; this would cause type error if `i` does not stay within range - -## getUndefined - -```res sig -let getUndefined: (array<'a>, int) => Js.undefined<'a> -``` - -It does the samething in the runtime as `Belt_Array.getUnsafe` it is type safe since the return type still track whether it is in range or not - -## set - -```res sig -let set: (array<'a>, int, 'a) => bool -``` - -`set(arr, n, x)` modifies `arr` in place; it replaces the nth element of `arr` with `x`. - -Returns false means not updated due to out of range. - -## setExn - -```res sig -let setExn: (array<'a>, int, 'a) => unit -``` - -`setExn(arr, i, x)` raise an exception if `i` is out of range. - -## setUnsafe - -```res sig -let setUnsafe: (array<'a>, int, 'a) => unit -``` - -## shuffleInPlace - -```res sig -let shuffleInPlace: array<'a> => unit -``` - -`shuffleInPlace(arr)` randomly re-orders the items in `arr` - -## shuffle - -```res sig -let shuffle: array<'a> => array<'a> -``` - -Returns a fresh array with items in original array randomly shuffled. - -## reverseInPlace - -```res sig -let reverseInPlace: array<'a> => unit -``` - -`reverseInPlace(arr)` reverses items in `arr` in place. - -```res example -let arr = [10, 11, 12, 13, 14] - -let () = Belt.Array.reverseInPlace(arr) - -arr == [14, 13, 12, 11, 10] -``` - -## reverse - -```res sig -let reverse: array<'a> => array<'a> -``` - -`reverse(arr)` returns a fresh array with items in arr in reverse order. - -```res example -Belt.Array.reverse([10, 11, 12, 13, 14]) == [14, 13, 12, 11, 10] -``` - -## makeUninitialized - -```res sig -let makeUninitialized: int => array> -``` - -`makeUninitialized(n)` creates an array of length `n` filled with the undefined value. You must specify the type of data that will eventually fill the array. - -```res example -let arr: array> = Belt.Array.makeUninitialized(5) - -Belt.Array.getExn(arr, 0) == Js.undefined -``` - -## makeUninitializedUnsafe - -```res sig -let makeUninitializedUnsafe: int => array<'a> -``` - -Unsafe - -```res example -let arr = Belt.Array.makeUninitializedUnsafe(5) - -Js.log(Belt.Array.getExn(arr, 0)) // undefined - -Belt.Array.setExn(arr, 0, "example") - -Js.log(Belt.Array.getExn(arr, 0) == "example") -``` - -## make - -```res sig -let make: (int, 'a) => array<'a> -``` - -`make(n, e)` return an array of size `n` filled with value `e`. -Returns an empty array when `n` is negative. - -## range - -```res sig -let range: (int, int) => array -``` - -`range(start, finish)` create an inclusive array. - -```res example -Belt.Array.range(0, 3) == [0, 1, 2, 3] - -Belt.Array.range(3, 0) == [] - -Belt.Array.range(3, 3) == [3] -``` - -## rangeBy - -```res sig -let rangeBy: (int, int, ~step: int) => array -``` - -`rangeBy(start, finish, ~step)` - -Returns empty array when step is 0 or negative. It also return an empty array when `start > finish`. - -```res example -Belt.Array.rangeBy(0, 10, ~step=3) == [0, 3, 6, 9] - -Belt.Array.rangeBy(0, 12, ~step=3) == [0, 3, 6, 9, 12] - -Belt.Array.rangeBy(33, 0, ~step=1) == [] - -Belt.Array.rangeBy(33, 0, ~step=-1) == [] - -Belt.Array.rangeBy(3, 12, ~step=-1) == [] - -Belt.Array.rangeBy(3, 3, ~step=0) == [] - -Belt.Array.rangeBy(3, 3, ~step=1) == [3] -``` - -## makeByU - -```res sig -let makeByU: (int, (. int) => 'a) => array<'a> -``` - -## makeBy - -```res sig -let makeBy: (int, int => 'a) => array<'a> -``` - -`makeBy(n, f)` - -Return an empty array when n is negative return an array of size n populated by `f(i)` start from `0` to `n - 1`. - -```res example -Belt.Array.makeBy(5, (i) => i) == [0, 1, 2, 3, 4] - -Belt.Array.makeBy(5, (i) => i * i) == [0, 1, 4, 9, 16] -``` - -## makeByAndShuffleU - -```res sig -let makeByAndShuffleU: (int, (. int) => 'a) => array<'a> -``` - -## makeByAndShuffle - -```res sig -let makeByAndShuffle: (int, int => 'a) => array<'a> -``` - -`makeByAndShuffle(n, f)` - -Equivalent to `shuffle(makeBy(n, f))` - -## zip - -```res sig -let zip: (array<'a>, array<'b>) => array<('a, 'b)> -``` - -`zip(a, b)` - -Create an array of pairs from corresponding elements of a and b. Stop with the shorter array. - -```res example -Belt.Array.zip([1, 2], [3, 4, 5]) == [(1, 3), (2, 4)] -``` - -## zipByU - -```res sig -let zipByU: (array<'a>, array<'b>, (. 'a, 'b) => 'c) => array<'c> -``` - -## zipBy - -```res sig -let zipBy: (array<'a>, array<'b>, ('a, 'b) => 'c) => array<'c> -``` - -`zipBy(xs, ys, f)` - -Create an array by applying `f` to corresponding elements of `xs` and `ys`. Stops with shorter array. - -Equivalent to `map(zip(xs, ys), ((a, b)) => f(a, b))` - -```res example -Belt.Array.zipBy([1, 2, 3], [4, 5], (a, b) => 2 * a + b) == [6, 9] -``` - -## unzip - -```res sig -let unzip: array<('a, 'b)> => (array<'a>, array<'b>) -``` - -`unzip(a)` takes an array of pairs and creates a pair of arrays. The first array contains all the first items of the pairs; the second array contains all the second items. - -```res example -Belt.Array.unzip([(1, 2), (3, 4)]) == ([1, 3], [2, 4]) - -Belt.Array.unzip([(1, 2), (3, 4), (5, 6), (7, 8)]) == ([1, 3, 5, 7], [2, 4, 6, 8]) -``` - -## concat - -```res sig -let concat: (array<'a>, array<'a>) => array<'a> -``` - -`concat(xs, ys)` - -Returns a fresh array containing the concatenation of the arrays `v1` and `v2`;so even if `v1` or `v2` is empty; it can not be shared - -```res example -Belt.Array.concat([1, 2, 3], [4, 5]) == [1, 2, 3, 4, 5] - -Belt.Array.concat([], ["a", "b", "c"]) == ["a", "b", "c"] -``` - -## concatMany - -```res sig -let concatMany: array> => array<'a> -``` - -`concatMany(xss)` - -Returns a fresh array as the concatenation of `xss` (an array of arrays) - -```res example -Belt.Array.concatMany([[1, 2, 3], [4, 5, 6], [7, 8]]) == [1, 2, 3, 4, 5, 6, 7, 8] -``` - -## slice - -```res sig -let slice: (array<'a>, ~offset: int, ~len: int) => array<'a> -``` - -`slice(xs, offset, len)` creates a new array with the len elements of `xs` -starting at `offset` for `offset` can be negative;and is evaluated as -`length(xs) - offset(slice, xs) - 1(1)` means get the last element as a -singleton array `slice(xs, ~-len, len)` will return a copy of the array if the -array does not have enough data; `slice` extracts through the end of sequence. - -if `len` is negative; returns the empty array. - -```res example -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=2, ~len=3) == [12, 13, 14] - -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=-4, ~len=3) == [13, 14, 15] - -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=4, ~len=9) == [14, 15, 16] -``` - -## sliceToEnd - -```res sig -let sliceToEnd: (array<'a>, int) => array<'a> -``` - -`sliceToEnd(xs, offset)` creates a new array with the elements of `xs` starting at `offset` - -`offset` can be negative; and is evaluated as `length(xs) - offset(sliceToEnd, xs) - 1` means get the last element as a singleton array - -`sliceToEnd(xs, 0)` will return a copy of the array - -```res example -Belt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], 2) == [12, 13, 14, 15, 16] - -Belt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], -4) == [13, 14, 15, 16] -``` - -## copy - -```res sig -let copy: array<'a> => array<'a> -``` - -`copy(a)` - -Returns a copy of a; that is; a fresh array containing the same elements as a. - -## fill - -```res sig -let fill: (array<'a>, ~offset: int, ~len: int, 'a) => unit -``` - -`fill(arr, ~offset, ~len, x)` - -Modifies `arr` in place, storing `x` in elements number `offset` to `offset + len - 1`. -`offset` can be negative; and is evaluated as `length(arr - offset)` - -`fill(arr, ~offset=-1, ~len=1)` means fill the last element, if the array does not have enough data; `fill` will ignore it - -```res example -let arr = Belt.Array.makeBy(5, (i) => i) - -Belt.Array.fill(arr, ~offset=2, ~len=2, 9) - -arr == [0, 1, 9, 9, 4] - -Belt.Array.fill(arr, ~offset=7, ~len=2, 8) - -arr == [0, 1, 9, 9, 4] -``` - -## blit - -```res sig -let blit: - ( - ~src: array<'a>, - ~srcOffset: int, - ~dst: array<'a>, - ~dstOffset: int, - ~len: int - ) => - unit -``` - -`blit(~src=v1, ~srcOffset=o1, ~dst=v2, ~dstOffset=o2, ~len)` - -copies `len` elements from array `v1`;starting at element number `o1`;to array `v2`, starting at element number `o2`. - -It works correctly even if `v1` and `v2` are the same array;and the source and destination chunks overlap. - -`offset` can be negative; `-1` means `len - 1`; if `len + offset` is still negative;it will be set as 0 - -For each of the examples;presume that `v1 == [10, 11, 12, 13, 14, 15, 16, 17]` and `v2 == [20, 21, 22, 23, 24, 25, 26, 27]`. The result shown is the content of the destination array. - -```res example -let v1 = [10, 11, 12, 13, 14, 15, 16, 17] -let v2 = [20, 21, 22, 23, 24, 25, 26, 27] - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v2, ~dstOffset=2, ~len=3) -v2 == [20, 21, 14, 15, 16, 25, 26, 27] - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v1, ~dstOffset=2, ~len=3) -v1 == [10, 11, 14, 15, 16, 15, 16, 17] -``` - -## blitUnsafe - -```res sig -let blitUnsafe: (~src: array<'a>, ~srcOffset: int, ~dst: array<'a>, ~dstOffset: int, ~len: int) => unit -``` - -Unsafe blit without bounds checking. - -## forEachU - -```res sig -let forEachU: (array<'a>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (array<'a>, 'a => unit) => unit -``` - -`forEach(xs, f)` - -Call `f` on each element of `xs` from the beginning to end. `f` returns `unit`;so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects. - -```res example -Belt.Array.forEach(["a", "b", "c"], x => Js.log("Item: " ++ x)) - -/* - prints: - Item: a - Item: b - Item: c -*/ -let total = ref(0) - -Belt.Array.forEach([1, 2, 3, 4], x => total := total.contents + x) - -total.contents == 1 + 2 + 3 + 4 -``` - -## mapU - -```res sig -let mapU: (array<'a>, (. 'a) => 'b) => array<'b> -``` - -## map - -```res sig -let map: (array<'a>, 'a => 'b) => array<'b> -``` - -`map(xs, f)` - -Returns a new array by calling `f` for each element of `xs` from the beginning to end. - -```res example -Belt.Array.map([1, 2], (x) => x + 1) == [3, 4] -``` - -## getByU - -```res sig -let getByU: (array<'a>, (. 'a) => bool) => option<'a> -``` - -## getBy - -```res sig -let getBy: (array<'a>, 'a => bool) => option<'a> -``` - -`getBy(xs, p)` - -Returns `Some(value)` for the first value in `xs` that satisifies the predicate function `p`; returns `None` if no element satisifies the function. - -```res example -Belt.Array.getBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(4) -Belt.Array.getBy([15, 13, 11], (x) => mod(x, 2) == 0) == None -``` - -## getIndexByU - -```res sig -let getIndexByU: (array<'a>, (. 'a) => bool) => option -``` - -## getIndexBy - -```res sig -let getIndexBy: (array<'a>, 'a => bool) => option -``` - -`getIndexBy(xs, p)` - -returns `Some(index)` for the first value in `xs` that satisifies the predicate function `p`; -returns `None` if no element satisifies the function. - -```res example -Belt.Array.getIndexBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(1) -Belt.Array.getIndexBy([15, 13, 11], (x) => mod(x, 2) == 0) == None -``` - -## keepU - -```res sig -let keepU: (array<'a>, (. 'a) => bool) => array<'a> -``` - -## keep - -```res sig -let keep: (array<'a>, 'a => bool) => array<'a> -``` - -`keep(xs, p)` - -Returns a new array that keep all elements satisfy `p`. - -```res example -Belt.Array.keep([1, 2, 3], (x) => mod(x, 2) == 0) == [2] -``` - -## keepWithIndexU - -```res sig -let keepWithIndexU: (array<'a>, (. 'a, int) => bool) => array<'a> -``` - -## keepWithIndex - -```res sig -let keepWithIndex: (array<'a>, ('a, int) => bool) => array<'a> -``` - -`keepWithIndex(xs, p)` - -Returns a new array that keep all elements satisfy `p`. - -```res example -Belt.Array.keepWithIndex([1, 2, 3], (_x, i) => i == 1) == [2] -``` - -## keepMapU - -```res sig -let keepMapU: (array<'a>, (. 'a) => option<'b>) => array<'b> -``` - -## keepMap - -```res sig -let keepMap: (array<'a>, 'a => option<'b>) => array<'b> -``` - -`keepMap(xs, p)` - -Returns a new array that keep all elements that return a non-None applied `p`. - -```res example -Belt.Array.keepMap([1, 2, 3], x => - if mod(x, 2) == 0 { - Some(x) - } else { - None - } -) -== [2] -``` - -## forEachWithIndexU - -```res sig -let forEachWithIndexU: (array<'a>, (. int, 'a) => unit) => unit -``` - -## forEachWithIndex - -```res sig -let forEachWithIndex: (array<'a>, (int, 'a) => unit) => unit -``` - -`forEachWithIndex(xs, f)` - -The same as `Belt_Array.forEach`; -except that `f` is supplied two arguments: the index starting from 0 and the element from `xs`. - -```res example -Belt.Array.forEachWithIndex(["a", "b", "c"], (i, x) => Js.log("Item " ++ Belt.Int.toString(i) ++ " is " ++ x)) - -/* - prints: - Item 0 is a - Item 1 is b - Item 2 is cc -*/ -let total = ref(0) - -Belt.Array.forEachWithIndex([10, 11, 12, 13], (i, x) => total := total.contents + x + i) - -total.contents == 0 + 10 + 1 + 11 + 2 + 12 + 3 + 13 -``` - -## mapWithIndexU - -```res sig -let mapWithIndexU: (array<'a>, (. int, 'a) => 'b) => array<'b> -``` - -## mapWithIndex - -```res sig -let mapWithIndex: (array<'a>, (int, 'a) => 'b) => array<'b> -``` - -`mapWithIndex(xs, f)` - -`mapWithIndex(xs, f)` applies `f` to each element of `xs`. Function `f` takes two arguments: the index starting from 0 and the element from `xs`. - -```res example -Belt.Array.mapWithIndex([1, 2, 3], (i, x) => i + x) == [0 + 1, 1 + 2, 2 + 3] -``` - -## partitionU - -```res sig -let partitionU: (array<'a>, (. 'a) => bool) => (array<'a>, array<'a>) -``` - -## partition - -```res sig -let partition: (array<'a>, 'a => bool) => (array<'a>, array<'a>) -``` - -`partition(f, a)` split array into tuple of two arrays based on predicate `f`; first of tuple where predicate cause true, second where predicate cause false - -```res example -Belt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) == 0) == ([2, 4], [1, 3, 5]) - -Belt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) != 0) == ([1, 3, 5], [2, 4]) -``` - -## reduceU - -```res sig -let reduceU: (array<'b>, 'a, (. 'a, 'b) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (array<'b>, 'a, ('a, 'b) => 'a) => 'a -``` - -`reduce(xs, init, f)` - -Applies `f` to each element of `xs` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”; which starts with a value of `init`. `reduce` returns the final value of the accumulator. - -```res example -Belt.Array.reduce([2, 3, 4], 1, (a, b) => a + b) == 10 - -Belt.Array.reduce(["a", "b", "c", "d"], "", (a, b) => a ++ b) == "abcd" -``` - -## reduceReverseU - -```res sig -let reduceReverseU: (array<'b>, 'a, (. 'a, 'b) => 'a) => 'a -``` - -## reduceReverse - -```res sig -let reduceReverse: (array<'b>, 'a, ('a, 'b) => 'a) => 'a -``` - -`reduceReverse(xs, init, f)` - -Works like `Belt_Array.reduce`; except that function `f` is applied to each item of `xs` from the last back to the first. - -```res example -Belt.Array.reduceReverse(["a", "b", "c", "d"], "", (a, b) => a ++ b) == "dcba" -``` - -## reduceReverse2U - -```res sig -let reduceReverse2U: (array<'a>, array<'b>, 'c, (. 'c, 'a, 'b) => 'c) => 'c -``` - -## reduceReverse2 - -```res sig -let reduceReverse2: (array<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c -``` - -`reduceReverse2(xs, ys, init, f)` - -Reduces two arrays xs and ys;taking items starting at `min(length(xs), length(ys))` down to and including zero. - -```res example -Belt.Array.reduceReverse2([1, 2, 3], [1, 2], 0, (acc, x, y) => acc + x + y) == 6 -``` - -## reduceWithIndexU - -```res sig -let reduceWithIndexU: (array<'a>, 'b, (. 'b, 'a, int) => 'b) => 'b -``` - -## reduceWithIndex - -```res sig -let reduceWithIndex: (array<'a>, 'b, ('b, 'a, int) => 'b) => 'b -``` - -`reduceWithIndex(xs, f)` - -Applies `f` to each element of `xs` from beginning to end. Function `f` has three parameters: the item from the array and an “accumulator”, which starts with a value of `init` and the index of each element. `reduceWithIndex` returns the final value of the accumulator. - -```res example -Belt.Array.reduceWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i) == 16 -``` - -## someU - -```res sig -let someU: (array<'a>, (. 'a) => bool) => bool -``` - -## some - -```res sig -let some: (array<'a>, 'a => bool) => bool -``` - -`some(xs, p)` - -Returns true if at least one of the elements in `xs` satifies `p`; where `p` is a predicate: a function taking an element and returning a `bool`. - -```res example -Belt.Array.some([2, 3, 4], (x) => mod(x, 2) == 1) == true - -Belt.Array.some([(-1), (-3), (-5)], (x) => x > 0) == false -``` - -## everyU - -```res sig -let everyU: (array<'a>, (. 'a) => bool) => bool -``` - -## every - -```res sig -let every: (array<'a>, 'a => bool) => bool -``` - -`every(xs, p)` - -Returns `true` if all elements satisfy `p`; where `p` is a predicate: a function taking an element and returning a `bool`. - -```res example -Belt.Array.every([1, 3, 5], (x) => mod(x, 2) == 1) == true - -Belt.Array.every([1, (-3), 5], (x) => x > 0) == false -``` - -## every2U - -```res sig -let every2U: (array<'a>, array<'b>, (. 'a, 'b) => bool) => bool -``` - -## every2 - -```res sig -let every2: (array<'a>, array<'b>, ('a, 'b) => bool) => bool -``` - -`every2(xs, ys, p)` - -returns true if `p(xi, yi)` is true for all pairs of elements up to the shorter length (i.e. `min(length(xs), length(ys))`) - -```res example -Belt.Array.every2([1, 2, 3], [0, 1], (a, b) => a > b) == true - -Belt.Array.every2([], [1], (x, y) => x > y) == true - -Belt.Array.every2([2, 3], [1], (x, y) => x > y) == true - -Belt.Array.every2([0, 1], [5, 0], (x, y) => x > y) == false -``` - -## some2U - -```res sig -let some2U: (array<'a>, array<'b>, (. 'a, 'b) => bool) => bool -``` - -## some2 - -```res sig -let some2: (array<'a>, array<'b>, ('a, 'b) => bool) => bool -``` - -`some2(xs, ys, p)` - -returns true if `p(xi, yi)` is true for any pair of elements up to the shorter length (i.e. `min(length(xs), length(ys))`) - -```res example -Belt.Array.some2([0, 2], [1, 0, 3], (a, b) => a > b) == true - -Belt.Array.some2([], [1], (x, y) => x > y) == false - -Belt.Array.some2([2, 3], [1, 4], (x, y) => x > y) == true -``` - -## cmpU - -```res sig -let cmpU: (array<'a>, array<'a>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (array<'a>, array<'a>, ('a, 'a) => int) => int -``` - -`cmp(xs, ys, f)` - -Compared by length if `length(xs) != length(ys)`; returning -1 if `length(xs) < length(ys)` or 1 if `length(xs) > length(ys)` -Otherwise compare one by one `f(x, y)`. `f` returns -a negative number if `x` is “less than” `y` -zero if `x` is “equal to” `y` -a positive number if `x` is “greater than” `y` -The comparison returns the first non-zero result of `f`;or zero if `f` returns zero for all `x` and `y`. - -```res example -Belt.Array.cmp([1, 3, 5], [1, 4, 2], (a, b) => compare(a, b)) == -1 - -Belt.Array.cmp([1, 3, 5], [1, 2, 3], (a, b) => compare(a, b)) == 1 - -Belt.Array.cmp([1, 3, 5], [1, 3, 5], (a, b) => compare(a, b)) == 0 -``` - -## eqU - -```res sig -let eqU: (array<'a>, array<'a>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (array<'a>, array<'a>, ('a, 'a) => bool) => bool -``` - -`eq(xs, ys)` - -return false if length is not the same -otherwise compare items one by one using `f(xi, yi)`; and return true if all results are truefalse otherwise - -```res example -Belt.Array.eq([1, 2, 3], [(-1), (-2), (-3)], (a, b) => abs(a) == abs(b)) == true -``` - -## truncateToLengthUnsafe - -```res sig -let truncateToLengthUnsafe: (array<'a>, int) => unit -``` - -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`. - -If `n` is less than zero; raises a `RangeError`. - -```res example -let arr = ["ant", "bee", "cat", "dog", "elk"] - -Belt.Array.truncateToLengthUnsafe(arr, 3) - -arr == ["ant", "bee", "cat"] -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/debug.mdx b/pages/docs/manual/v9.0.0/api/belt/debug.mdx deleted file mode 100644 index 9fe40751f..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/debug.mdx +++ /dev/null @@ -1,7 +0,0 @@ -# Debug - -## setupChromeDebugger - -```res sig -let setupChromeDebugger: unit => unit -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/float.mdx b/pages/docs/manual/v9.0.0/api/belt/float.mdx deleted file mode 100644 index 9e316e24a..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/float.mdx +++ /dev/null @@ -1,107 +0,0 @@ -# Float - -This module includes convenience methods for handling `float` types. - -## toInt - -```res sig -let toInt: float => int -``` - -Converts a given `float` to an `int`. - -```res example -Js.log(Belt.Float.toInt(1.0) === 1) /* true */ -``` - -## fromInt - -```res sig -let fromInt: int => float -``` - -Converts a given `int` to a `float`. - -```res example -Js.log(Belt.Float.fromInt(1) === 1.0) /* true */ -``` - -## fromString - -```res sig -let fromString: string => option -``` - -Converts a given `string` to a `float`. Returns `Some(float)` when the input is a number, `None` otherwise. - -```res example -Js.log(Belt.Float.fromString("1.0") === Some(1.0)) /* true */ -``` - -## toString - -```res sig -let toString: float => string -``` - -Converts a given `float` to a `string`. Uses the JavaScript `String` constructor under the hood. - -```res example -Js.log(Belt.Float.toString(1.0) === "1.0") /* true */ -``` - -## + - -```re sig -let (+): (float, float) => float -``` - -Addition of two `float` values. -Can be opened in a module to avoid dot-notation (`+.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(2.0 + 2.0 === 4.0) /* true */ -``` - -## - - -```re sig -let (-): (float, float) => float -``` - -Subtraction of two `float` values. -Can be opened in a module to avoid dot-notation (`-.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(2.0 - 1.0 === 1.0) /* true */ -``` - -## \* - -```re sig -let (*): (float, float) => float -``` - -Multiplication of two `float` values. -Can be opened in a module to avoid dot-notation (`*.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(2.0 * 2.0 === 4.0) /* true */ -``` - -## / - -```re sig -let (/): (float, float) => float -``` - -Division of two `float` values. -Can be opened in a module to avoid dot-notation (`/.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -```res example -open Belt.Float -Js.log(4.0 / 2.0 === 2.0) /* true */ -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/hash-map-int.mdx b/pages/docs/manual/v9.0.0/api/belt/hash-map-int.mdx deleted file mode 100644 index c1376a511..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/hash-map-int.mdx +++ /dev/null @@ -1,325 +0,0 @@ -# HashMapInt - - - -Specalized when key type is `int`, more efficient than the generic type - - - -## key - -```res prelude -type key = int -``` - -Type of the `Belt.HashMap.Int` key. - -## t - -```res prelude -type t<'b> -``` - -Type of the `Belt.HashMap.Int` - -## make - -```res sig -let make: (~hintSize: int) => t<'b> -``` - -`make(~hintSize=10)` creates a new hash map by taking the `hintSize`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) - -Belt.HashMap.Int.set(hMap, 1, "a") -``` - -## clear - -```res sig -let clear: t<'b> => unit -``` - -Clears a hash table. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(1, "1")]) -Belt.HashMap.Int.clear(hMap) -Belt.HashMap.Int.isEmpty(hMap) == true -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(1, "1")]) -Belt.HashMap.Int.isEmpty(hMap) == false -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(2, "2")]) - -Belt.HashMap.Int.set(hMap, 1, "1") - -Belt.HashMap.Int.valuesToArray(hMap) == ["1", "2"] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -Creates copy of a hash map. - -```res example -let hMap1 = Belt.HashMap.Int.fromArray([(1, "1"), (2, "2")]) -let hMap2 = Belt.HashMap.Int.copy(hMap1) - -Belt.HashMap.Int.set(hMap2, 2, "3") - -Belt.HashMap.Int.get(hMap1, 2) != Belt.HashMap.Int.get(hMap2, 2) -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -## has - -```res sig -let has: (t<'b>, key) => bool -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") - -Belt.HashMap.Int.get(hMap, 1) == Some("value1") -Belt.HashMap.Int.get(hMap, 2) == None -``` - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -If bound exists, removes it from the hash map. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.remove(hMap, 1) -Belt.HashMap.Int.has(hMap, 1) == false -``` - -## forEachU - -```res sig -let forEachU: (t<'b>, (. key, 'b) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'b>, (key, 'b) => unit) => unit -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.forEach(hMap, (key, value) => Js.log2(key, value)) -// prints ("1", "value1") -``` - -## reduceU - -```res sig -let reduceU: (t<'b>, 'c, (. 'c, key, 'b) => 'c) => 'c -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```res sig -let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.reduce(hMap, "", (acc, key, value) => acc ++ (", " ++ value)) == "value1, value2" -``` - -## keepMapInPlaceU - -```res sig -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```res sig -let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit -``` - -Filters out values for which function `f` returned `None`. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.keepMapInPlace(hMap, (key, value) => mod(key, 1) == 0 ? None : Some(value)) -``` - -## size - -```res sig -let size: t<'a> => int -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.size(hMap) == 2 -``` - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -Returns array of key value pairs. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.toArray(hMap) == [(1, "value1"), (2, "value2")] -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -Returns array of keys. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.keysToArray(hMap) == [1, 2] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -Returns array of values. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "value1") -Belt.HashMap.Int.set(hMap, 2, "value2") - -Belt.HashMap.Int.valuesToArray(hMap) == ["value1", "value2"] -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```res example -let hMap = Belt.HashMap.Int.fromArray([(1, "value1"), (1, "value2")]) -Belt.HashMap.Int.toArray(hMap) == [(1, "value1"), (2, "value2")] -``` - -## mergeMany - -```res sig -let mergeMany: (t<'a>, array<(key, 'a)>) => unit -``` - -Merges many key value pairs into hash map. - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.mergeMany(hMap, [(1, "value1"), (2, "value2")]) -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a> => array -``` - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "1") - -Belt.HashMap.Int.getBucketHistogram(hMap) -``` - -## logStats - -```res sig -let logStats: t<'a> => unit -``` - -```res example -let hMap = Belt.HashMap.Int.make(~hintSize=10) -Belt.HashMap.Int.set(hMap, 1, "1") - -Belt.HashMap.Int.logStats(hMap) -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/hash-map-string.mdx b/pages/docs/manual/v9.0.0/api/belt/hash-map-string.mdx deleted file mode 100644 index 68e3809ec..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/hash-map-string.mdx +++ /dev/null @@ -1,337 +0,0 @@ -# HashMapString - - - -Specalized when key type is `string`, more efficient than the generic type - - - -## key - -```res prelude -type key = string -``` - -Type of the `Belt.HashMap.String` key. - -## t - -```res prelude -type t<'b> -``` - -Type of the `Belt.HashMap.String`. - -## make - -```res sig -let make: (~hintSize: int) => t<'b> -``` - -`make(~hintSize=10)` creates a new hash map by taking the `hintSize`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) - -Belt.HashMap.String.set(hMap, "key1", "a") -``` - -## clear - -```res sig -let clear: t<'b> => unit -``` - -Clears a hash table. - -```res example -let hMap = Belt.HashMap.String.fromArray([("1", "1")]) -Belt.HashMap.String.clear(hMap) -Belt.HashMap.String.isEmpty(hMap) == true -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```res example -let hMap = Belt.HashMap.String.fromArray([("1", "1")]) -Belt.HashMap.String.isEmpty(hMap) == false -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```res example -let hMap = Belt.HashMap.String.fromArray([("2", "2")]) - -Belt.HashMap.String.set(hMap, "1", "1") - -Belt.HashMap.String.valuesToArray(hMap) == ["1", "2"] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -Creates copy of a hash map. - -```res example -let hMap1 = Belt.HashMap.String.fromArray([("1", "1"), ("2", "2")]) -let hMap2 = Belt.HashMap.String.copy(hMap1) - -Belt.HashMap.String.set(hMap2, "2", "3") - -Belt.HashMap.String.get(hMap1, "2") != Belt.HashMap.String.get(hMap2, "2") -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") - -Belt.HashMap.String.get(hMap, "1") == Some("value1") -Belt.HashMap.String.get(hMap, "2") == None -``` - -## has - -```res sig -let has: (t<'b>, key) => bool -``` - -Checks if `x` is bound in `tbl`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") - -Belt.HashMap.String.has(hMap, "1") == true -Belt.HashMap.String.has(hMap, "2") == false -``` - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -If bound exists, removes it from the hash map. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.remove(hMap, "1") -Belt.HashMap.String.has(hMap, "1") == false -``` - -## forEachU - -```res sig -let forEachU: (t<'b>, (. key, 'b) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'b>, (key, 'b) => unit) => unit -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.forEach(hMap, (key, value) => Js.log2(key, value)) -// prints ("1", "value1") -``` - -## reduceU - -```res sig -let reduceU: (t<'b>, 'c, (. 'c, key, 'b) => 'c) => 'c -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```res sig -let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.reduce(hMap, "", (acc, key, value) => - acc ++ (", " ++ value) -) == "value1, value2" -``` - -## keepMapInPlaceU - -```res sig -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```res sig -let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit -``` - -Filters out values for which function `f` returned `None`. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.keepMapInPlace(hMap, (key, value) => key == "1" ? None : Some(value)) -``` - -## size - -```res sig -let size: t<'a> => int -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.size(hMap) == 2 -``` - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -Returns array of key value pairs. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.toArray(hMap) == [("1", "value1"), ("2", "value2")] -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -Returns array of keys. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.keysToArray(hMap) == ["1", "2"] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -Returns array of values. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "value1") -Belt.HashMap.String.set(hMap, "2", "value2") - -Belt.HashMap.String.valuesToArray(hMap) == ["value1", "value2"] -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```res example -let hMap = Belt.HashMap.String.fromArray([("1", "value1"), ("2", "value2")]) -Belt.HashMap.String.toArray(hMap) == [("1", "value1"), ("2", "value2")] -``` - -## mergeMany - -```res sig -let mergeMany: (t<'a>, array<(key, 'a)>) => unit -``` - -Merges many key value pairs into hash map. - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.mergeMany(hMap, [("1", "value1"), ("2", "value2")]) -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a> => array -``` - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "1") - -Belt.HashMap.String.getBucketHistogram(hMap) -``` - -## logStats - -```res sig -let logStats: t<'a> => unit -``` - -```res example -let hMap = Belt.HashMap.String.make(~hintSize=10) -Belt.HashMap.String.set(hMap, "1", "1") - -Belt.HashMap.String.logStats(hMap) -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/hash-map.mdx b/pages/docs/manual/v9.0.0/api/belt/hash-map.mdx deleted file mode 100644 index 36a8de539..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/hash-map.mdx +++ /dev/null @@ -1,444 +0,0 @@ -# HashMap - - - -The top level provides generic mutable hash map operations. - - - -## t - -```res prelude -type t<'key, 'value, 'id> -``` - -The type of hash tables from type `'key` to type `'value`. - -## id - -```res prelude -type id<'a, 'id> = Belt.Id.hashable<'a, 'id> -``` - -The identity needed for making an empty hash map. - -## make - -```res sig -let make: (~hintSize: int, ~id: id<'key, 'id>) => t<'key, 'value, 'id> -``` - -`make(~hintSize=10, ~id)` creates a new map by taking in the comparator and `hintSize`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) - -Belt.HashMap.set(hMap, 0, "a") -``` - -## clear - -```res sig -let clear: t<'key, 'value, 'id> => unit -``` - -Clears a hash table. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.fromArray([(1, "1")], ~id=module(IntHash)) -Belt.HashMap.clear(hMap) -Belt.HashMap.isEmpty(hMap) == true -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b, 'c> => bool -``` - -`isEmpty(m)` checks whether a hash map is empty. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -Belt.HashMap.isEmpty(Belt.HashMap.fromArray([(1, "1")], ~id=module(IntHash))) == false -``` - -## set - -```res sig -let set: (t<'key, 'value, 'id>, 'key, 'value) => unit -``` - -`set(hMap, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntHash)) - -Belt.HashMap.set(s0, 2, "3") - -Belt.HashMap.valuesToArray(s0) == ["1", "3", "3"] -``` - -## copy - -```res sig -let copy: t<'key, 'value, 'id> => t<'key, 'value, 'id> -``` - -Creates copy of a hash map. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntHash)) -let s1 = Belt.HashMap.copy(s0) - -Belt.HashMap.set(s0, 2, "3") - -Belt.HashMap.get(s0, 2) != Belt.HashMap.get(s1, 2) -``` - -## get - -```res sig -let get: (t<'key, 'value, 'id>, 'key) => option<'value> -``` - -Returns value bound under specific key. If values not exist returns `None`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") - -Belt.HashMap.get(s0, 1) == Some("value1") -Belt.HashMap.get(s0, 2) == None -``` - -## has - -```res sig -let has: (t<'key, 'value, 'id>, 'key) => bool -``` - -Checks if `x` is bound in `tbl`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") - -Belt.HashMap.has(s0, 1) == true -Belt.HashMap.has(s0, 2) == false -``` - -## remove - -```res sig -let remove: (t<'key, 'value, 'id>, 'key) => unit -``` - -If bound exists, removes it from the hash map. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.remove(s0, 1) -Belt.HashMap.has(s0, 1) == false -``` - -## forEachU - -```res sig -let forEachU: (t<'key, 'value, 'id>, (. 'key, 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit -``` - -`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -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)) -// prints (1, "value1") -``` - -## reduceU - -```res sig -let reduceU: (t<'key, 'value, 'id>, 'c, (. 'c, 'key, 'value) => 'c) => 'c -``` - -Same as [reduce](##reduce) but takes uncurried functon. - -## reduce - -```res sig -let reduce: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c -``` - -`reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.reduce(s0, "", (acc, key, value) => acc ++ (", " ++ value)) == "value1, value2" -``` - -## keepMapInPlaceU - -```res sig -let keepMapInPlaceU: (t<'key, 'value, 'id>, (. 'key, 'value) => option<'value>) => unit -``` - -Same as [keepMapInPlace](##keepMapInPlace) but takes uncurried functon. - -## keepMapInPlace - -```res sig -let keepMapInPlace: (t<'key, 'value, 'id>, ('key, 'value) => option<'value>) => unit -``` - -Filters out values for which function `f` returned `None`. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.keepMapInPlace(s0, (key, value) => key == 1 ? None : Some(value)) -``` - -## size - -```res sig -let size: t<'a, 'b, 'c> => int -``` - -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.size(s0) == 2 -``` - -## toArray - -```res sig -let toArray: t<'key, 'value, 'id> => array<('key, 'value)> -``` - -Returns array of key value pairs. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.toArray(s0) == [(1, "value1"), (2, "value2")] -``` - -## keysToArray - -```res sig -let keysToArray: t<'key, 'a, 'b> => array<'key> -``` - -Returns array of keys. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.keysToArray(s0) == [1, 2] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a, 'value, 'b> => array<'value> -``` - -Returns array of values. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.valuesToArray(s0) == ["value1", "value2"] -``` - -## fromArray - -```res sig -let fromArray: (array<('key, 'value)>, ~id: id<'key, 'id>) => t<'key, 'value, 'id> -``` - -Creates new hash map from array of pairs. - -Returns array of values. - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(1, "value1"), (2, "value2")], ~id=module(IntHash)) -Belt.HashMap.toArray(s0) == [(1, "value1"), (2, "value2")] -``` - -## mergeMany - -```res sig -let mergeMany: (t<'key, 'value, 'id>, array<('key, 'value)>) => unit -``` - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.mergeMany(hMap, [(1, "1"), (2, "2")]) -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a, 'b, 'c> => array -``` - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(hMap, 1, "1") - -Belt.HashMap.getBucketHistogram(hMap) -``` - -## logStats - -```res sig -let logStats: t<'a, 'b, 'c> => unit -``` - -```res example -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(hMap, 1, "1") - -Belt.HashMap.logStats(hMap) -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/hash-set-int.mdx b/pages/docs/manual/v9.0.0/api/belt/hash-set-int.mdx deleted file mode 100644 index d73d3f856..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/hash-set-int.mdx +++ /dev/null @@ -1,123 +0,0 @@ -# HashSetInt - - - -This module is `Belt.HashSet` specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with `Belt.HashSet` except its key type is fixed, and identity is not needed(using the built-in one). - - - -## key - -```res prelude -type key = int -``` - -## t - -```res prelude -type t -``` - -## make - -```res sig -let make: (~hintSize: int) => t -``` - -## clear - -```res sig -let clear: t => unit -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -## add - -```res sig -let add: (t, key) => unit -``` - -## copy - -```res sig -let copy: t => t -``` - -## has - -```res sig -let has: (t, key) => bool -``` - -## remove - -```res sig -let remove: (t, key) => unit -``` - -## forEachU - -```res sig -let forEachU: (t, (. key) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t, key => unit) => unit -``` - -## reduceU - -```res sig -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c -``` - -## reduce - -```res sig -let reduce: (t, 'c, ('c, key) => 'c) => 'c -``` - -## size - -```res sig -let size: t => int -``` - -## logStats - -```res sig -let logStats: t => unit -``` - -## toArray - -```res sig -let toArray: t => array -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t => array -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/hash-set-string.mdx b/pages/docs/manual/v9.0.0/api/belt/hash-set-string.mdx deleted file mode 100644 index 277d95228..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/hash-set-string.mdx +++ /dev/null @@ -1,123 +0,0 @@ -# HashSetString - - - -This module is `Belt.HashSet` specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with `Belt.HashSet` except its key type is fixed, and identity is not needed(using the built-in one). - - - -## key - -```res prelude -type key = string -``` - -## t - -```res prelude -type t -``` - -## make - -```res sig -let make: (~hintSize: int) => t -``` - -## clear - -```res sig -let clear: t => unit -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -## add - -```res sig -let add: (t, key) => unit -``` - -## copy - -```res sig -let copy: t => t -``` - -## has - -```res sig -let has: (t, key) => bool -``` - -## remove - -```res sig -let remove: (t, key) => unit -``` - -## forEachU - -```res sig -let forEachU: (t, (. key) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t, key => unit) => unit -``` - -## reduceU - -```res sig -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c -``` - -## reduce - -```res sig -let reduce: (t, 'c, ('c, key) => 'c) => 'c -``` - -## size - -```res sig -let size: t => int -``` - -## logStats - -```res sig -let logStats: t => unit -``` - -## toArray - -```res sig -let toArray: t => array -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t => array -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/hash-set.mdx b/pages/docs/manual/v9.0.0/api/belt/hash-set.mdx deleted file mode 100644 index d10a07ef2..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/hash-set.mdx +++ /dev/null @@ -1,160 +0,0 @@ -# HashSet - - - -A mutable Hash set which allows customized `hash` behavior. -All data are parameterized by not its only type but also a unique identity in the time of initialization, so that two HashSets of ints initialized with different hash functions will have different type. - - - -```res prelude -module I0 = unpack( - Belt.Id.hashableU( - ~hash=(. a: int) => land(a, 65535), - ~eq=(. a, b) => a == b, - ) -) - -let s0 = Belt.HashSet.make(~id=module(I0), ~hintSize=40) - -module I1 = unpack( - Belt.Id.hashableU( - ~hash=(. a: int) => land(a, 255), - ~eq=(. a, b) => a == b, - ) -) - -let s1 = Belt.HashSet.make(~id=module(I1), ~hintSize=40) - -Belt.HashSet.add(s1, 0) -Belt.HashSet.add(s1, 1) -``` - -The invariant must be held: for two elements who are equal, their hashed value should be the same. - -Here the compiler would infer `s0` and `s1` having different type so that it would not mix. - -```res sig -let s0: Belt.HashSet.t -let s1: Belt.HashSet.t -``` - -We can add elements to the collection (see last two lines in the example above). Since this is an mutable data structure, `s1` will contain two pairs. - -## t - -```res prelude -type t<'a, 'id> -``` - -## id - -```res prelude -type id<'a, 'id> = Belt.Id.hashable<'a, 'id> -``` - -## make - -```res sig -let make: (~hintSize: int, ~id: id<'a, 'id>) => t<'a, 'id> -``` - -## clear - -```res sig -let clear: t<'a, 'id> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -## add - -```res sig -let add: (t<'a, 'id>, 'a) => unit -``` - -## copy - -```res sig -let copy: t<'a, 'id> => t<'a, 'id> -``` - -## has - -```res sig -let has: (t<'a, 'id>, 'a) => bool -``` - -## remove - -```res sig -let remove: (t<'a, 'id>, 'a) => unit -``` - -## forEachU - -```res sig -let forEachU: (t<'a, 'id>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a, 'id>, 'a => unit) => unit -``` - -Order unspecified. - -## reduceU - -```res sig -let reduceU: (t<'a, 'id>, 'c, (. 'c, 'a) => 'c) => 'c -``` - -## reduce - -```res sig -let reduce: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c -``` - -Order unspecified. - -## size - -```res sig -let size: t<'a, 'id> => int -``` - -## logStats - -```res sig -let logStats: t<'a, 'b> => unit -``` - -## toArray - -```res sig -let toArray: t<'a, 'id> => array<'a> -``` - -## fromArray - -```res sig -let fromArray: (array<'a>, ~id: id<'a, 'id>) => t<'a, 'id> -``` - -## mergeMany - -```res sig -let mergeMany: (t<'a, 'id>, array<'a>) => unit -``` - -## getBucketHistogram - -```res sig -let getBucketHistogram: t<'a, 'b> => array -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/id.mdx b/pages/docs/manual/v9.0.0/api/belt/id.mdx deleted file mode 100644 index b8646dffe..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/id.mdx +++ /dev/null @@ -1,157 +0,0 @@ -# Id - - - -Provide utilities to create identified comparators or hashes for data -structures used below. - -It creates a unique identifier per module of functions so that different data -structures with slightly different comparison functions won't mix. - - - -## hash - -```res sig -type hash<'a, 'id> -``` - -Its runtime represenation is a hash function, but signed with a type parameter, so that different hash functions type mismatch. - -## eq - -```res sig -type eq<'a, 'id> -``` - -Its runtime represenation is an eq function, but signed with a type parameter, so that different hash functions type mismatch. - -## cmp - -```res sig -type cmp<'a, 'id> -``` - -Its runtime representation is a cmp function, but signed with a type parameter, so that different hash functions type mismatch. - -## Comparable - -```res prelude -module type Comparable = { - type identity - - type t - - let cmp: Belt.Id.cmp -} -``` - -## comparable - -```res sig -type comparable<'key,'id> = - module(Belt.Id.Comparable with type identity = 'id and type t = 'key) -``` - -is a module of functions, here it only includes cmp. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed by the type system). - -It can be created using function `Belt_Id.comparableU` or `Belt_Id.comparable`. - -The idea of a unique identity when created is that it makes sure two sets would type mismatch if they use different comparison function - -## MakeComparableU - -```res sig -module MakeComparableU: (M: { - type t - let cmp: (. t, t) => int -}) => Comparable with type t = M.t -``` - -## MakeComparable - -```res sig -module MakeComparable: (M: { - type t - let cmp: (t, t) => int -}) => Comparable with type t = M.t -``` - -## comparableU - -```res sig -let comparableU: (~cmp: (. 'a, 'a) => int) => - module(Belt.Id.Comparable with type t = 'a) -``` - -## comparable - -```res sig -type comparable<'key, 'id> = - module(Belt.Id.Comparable with type identity = 'id and type t = 'key) -``` - -## Hashable - -```res prelude -module type Hashable = { - type identity - - type t - - let hash: Belt.Id.hash - - let eq: Belt.Id.eq -} -``` - -## hashable - -```res sig -type hashable<'key, 'id> = - module(Belt.Id.Hashable with type identity = 'id and type t = 'key) -``` - -is a module of functions, here it only includes hash, eq. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed by the type system). - -It can be created using function `Belt_Id.hashableU` or `Belt_Id.hashable`. - -The idea of a unique identity when created is that it makes sure two hash sets would type mismatch if they use different comparison function. - -## MakeHashableU - -```res sig -module MakeHashableU: (M: { - type t - let hash: (. t) => int - let eq: (. t, t) => bool -}) => Hashable with type t = M.t -``` - -## MakeHashable - -```res sig -module MakeHashable: (M: { - type t - let hash: t => int - let eq: (t, t) => bool -}) => Hashable with type t = M.t -``` - -## hashableU - -```res sig -let hashableU: (~hash: (. 'a) => int, ~eq: (. 'a, 'a) => bool) => - module(Belt.Id.Hashable with type t = 'a) -``` - -## hashable - -```res sig -let hashable: (~hash: 'a => int, ~eq: ('a, 'a) => bool) => - module(Belt.Id.Hashable with type t = 'a) -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/int.mdx b/pages/docs/manual/v9.0.0/api/belt/int.mdx deleted file mode 100644 index 3e3a31c36..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/int.mdx +++ /dev/null @@ -1,103 +0,0 @@ -# Int - -This module includes convenience methods for handling `int` types. - -## toFloat - -```res sig -let toFloat: int => float -``` - -Converts a given `int` to a `float`. - -```res example -Js.log(Belt.Int.toFloat(1) === 1.0) /* true */ -``` - -## fromFloat - -```res sig -let fromFloat: float => int -``` - -Converts a given `float` to an `int`. - -```res example -Js.log(Belt.Int.fromFloat(1.0) === 1) /* true */ -``` - -## fromString - -```res sig -let fromString: string => option -``` - -Converts a given `string` to an `int`. Returns `Some(int)` when the input is a number, `None` otherwise. - -```res example -Js.log(Belt.Int.fromString("1") === Some(1)) /* true */ -``` - -## toString - -```res sig -let toString: int => string -``` - -Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood. - -```res example -Js.log(Belt.Int.toString(1) === "1") /* true */ -``` - -## + - -```re sig -let (+): (int, int) => int -``` - -Addition of two `int` values. Same as the addition from `Pervasives`. - -```res example -open Belt.Int -Js.log(2 + 2 === 4) /* true */ -``` - -## - - -```re sig -let (-): (int, int) => int -``` - -Subtraction of two `int` values. Same as the subtraction from `Pervasives`. - -```res example -open Belt.Int -Js.log(2 - 1 === 1) /* true */ -``` - -## \* - -```re sig -let (*): (int, int) => int -``` - -Multiplication of two `int` values. Same as the multiplication from `Pervasives`. - -```res example -open Belt.Int -Js.log(2 * 2 === 4) /* true */ -``` - -## / - -```re sig -let (/): (int, int) => int -``` - -Division of two `int` values. Same as the division from `Pervasives`. - -```res example -open Belt.Int -Js.log(4 / 2 === 2); /* true */ -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/list.mdx b/pages/docs/manual/v9.0.0/api/belt/list.mdx deleted file mode 100644 index d88f95805..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/list.mdx +++ /dev/null @@ -1,1124 +0,0 @@ -# List - - - -Collection functions for manipulating the `list` data structures, a singly-linked list. - -**Prefer Array** if you need any of the following: - -- Random access of element -- Better interop with JavaScript -- Better memory usage & performance. - - - -## t\<'a> - -```res prelude -type t<'a> = list<'a> -``` - -## length - -```res sig -let length: t<'a> => int -``` - -Returns the length of a list. - -```res example -Belt.List.length(list{1, 2, 3}) // 3 -``` - -## size - -```res sig -let size: t<'a> => int -``` - -**See:** list\{length}(#length) - -## head - -```res sig -let head: t<'a> => option<'a> -``` - -Returns `Some(value)` where `value` is the first element in the list, or `None` if `someList` is an empty list. - -```res example -Belt.List.head(list{}) // None -Belt.List.head(list{1, 2, 3}) // Some(1) -``` - -## headExn - -```res sig -let headExn: t<'a> => 'a -``` - -Same as [head](#head), but raises an exception if `someList` is empty. Use with care. - -```res example -Belt.List.headExn(list{1, 2, 3}) // 1 - -Belt.List.headExn(list{}) // Raises an Error -``` - -## tail - -```res sig -let tail: t<'a> => option> -``` - -Returns `None` if `someList` is empty, otherwise it returns `Some(tail)` where `tail` is everything except the first element of `someList`. - -```res example -Belt.List.tail(list{1, 2, 3}) // Some(list{2, 3}) - -Belt.List.tail(list{}) // None -``` - -## tailExn - -```res sig -let tailExn: t<'a> => t<'a> -``` - -Same as [tail](#tail), but raises an exception if `someList` is empty. Use with care. - -```res example -Belt.List.tailExn(list{1, 2, 3}) // list{2, 3} - -Belt.List.tailExn(list{}) // Raises an Error -``` - -## add - -```res sig -let add: (t<'a>, 'a) => t<'a> -``` - -Adds `value` to the beginning of `someList`. - -```res example -Belt.List.add(list{2, 3}, 1) // list{1, 2, 3} - -Belt.List.add(list{"World", "!"}, "Hello") // list{"Hello", "World", "!"} -``` - -## get - -```res sig -let get: (t<'a>, int) => option<'a> -``` - -Return the nth element in `someList`, or `None` if `index` is larger than the length. - -```res example -let abc = list{"A", "B", "C"} - -abc->Belt.List.get(1) // Some("B") - -abc->Belt.List.get(4) // None -``` - -## getExn - -```res sig -let getExn: (t<'a>, int) => 'a -``` - -Same as [get](#get), but raises an exception if `index` is larger than the length. Use with care. - -```res example -let abc = list{"A", "B", "C"} - -abc->Belt.List.getExn(1) // "B" - -abc->Belt.List.getExn(4) // Raises an Error -``` - -## make - -``` -let make: (int, 'a) => t<'a> -``` - -Returns a list of length `numItems` with each element filled with value `v`. Returns an empty list if `numItems` is negative. - -```res example -Belt.List.make(3, 1) // list{1, 1, 1} -``` - -## makeBy - -```res sig -let makeBy: (int, int => 'a) => t<'a> -``` - -Return a list of length `numItems` with element `i` initialized with `f(i)`. -Returns an empty list if `numItems` is negative. - -```res example -Belt.List.makeBy(5, i => i) // list{0, 1, 2, 3, 4} - -Belt.List.makeBy(5, i => i * i) // list{0, 1, 4, 9, 16} -``` - -## makeByU - -```res sig -let makeByU: (int, (. int) => 'a) => t<'a> -``` - -Uncurried version of [makeBy](#makeBy) - -## shuffle - -```res sig -let shuffle: t<'a> => t<'a> -``` - -Returns a new list in random order. - -```res example -Belt.List.shuffle(list{1, 2, 3}) // list{2, 1, 3} -``` - -## drop - -```res sig -let drop: (t<'a>, int) => option> -``` - -Return a new list, dropping the first `n` elements. Returns `None` if `someList` has fewer than `n` elements. - -```res example -list{1, 2, 3}->Belt.List.drop(2) // Some(list{3}) - -list{1, 2, 3}->Belt.List.drop(3) // Some(list{}) - -list{1, 2, 3}->Belt.List.drop(4) // None -``` - -## take - -```res sig -let take: (t<'a>, int) => option> -``` - -Returns a list with the first `n` elements from `someList`, or `None` if `someList` has fewer than `n` elements. - -```res example -list{1, 2, 3}->Belt.List.take(1) // Some(list{1}) - -list{1, 2, 3}->Belt.List.take(2) // Some(list{1, 2}) - -list{1, 2, 3}->Belt.List.take(4) // None -``` - -## splitAt - -```res sig -let splitAt: (t<'a>, int) => option<(list<'a>, list<'a>)> -``` - -Split the list `someList` at `index`. Returns `None` when the length of `someList` is less than `index`. - -```res example -list{"Hello", "World"}->Belt.List.splitAt(1) // Some((list{"Hello"}, list{"World"})) - -list{0, 1, 2, 3, 4}->Belt.List.splitAt(2) // Some((list{0, 1}, list{2, 3, 4})) -``` - -## concat - -```res sig -let concat: (t<'a>, t<'a>) => t<'a> -``` - -Returns the list obtained by adding `secondList` after `firstList`. - -```res example -Belt.List.concat(list{1, 2, 3}, list{4, 5}) // list{1, 2, 3, 4, 5} -``` - -## concatMany - -```res sig -let concatMany: array> => t<'a> -``` - -Returns the list obtained by concatenating all the lists in array `a`, in order. - -```res example -Belt.List.concatMany([list{1, 2, 3}, list{}, list{3}]) // list{1, 2, 3, 3} -``` - -## reverseConcat - -```res sig -let reverseConcat: (t<'a>, t<'a>) => t<'a> -``` - -Equivalent to writing: `concat(reverse(firstList, secondList)` - -```res example -Belt.List.reverseConcat(list{1, 2}, list{3, 4}) // list{2, 1, 3, 4} -``` - -## flatten - -```res sig -let flatten: t> => t<'a> -``` - -Return the list obtained by concatenating all the lists in list `ls`, in order. - -```res example -Belt.List.flatten(list{list{1, 2, 3}, list{}, list{3}}) // list{1, 2, 3, 3} -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -Returns a new list with `f` applied to each element of `someList`. - -```res example -list{1, 2}->Belt.List.map(x => x + 1) // list{3, 4} -``` - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -Uncurried version of [map](#map). - -## zip - -```res sig -let zip: (t<'a>, t<'b>) => t<('a, 'b)> -``` - -Returns a list of pairs from the two lists with the length of the shorter list. - -```res example -Belt.List.zip(list{1, 2}, list{3, 4, 5}) // list{(1, 3), (2, 4)} -``` - -## zipBy - -```res sig -let zipBy: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> -``` - -**See:** [zip](#zip) - -```res example -Belt.List.zipBy(list{1, 2, 3}, list{4, 5}, (a, b) => 2 * a + b) // list{6, 9} -``` - -## zipByU - -```res sig -let zipByU: (t<'a>, t<'b>, (. 'a, 'b) => 'c) => t<'c> -``` - -Uncurried version of [zipBy](#zipBy). - -## mapWithIndex - -```res sig -let mapWithIndex: (t<'a>, (int, 'a) => 'b) => t<'b> -``` - -Applies `f` to each element of `someList`. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`, in that order. - -```res example -list{1, 2, 3}->Belt.List.mapWithIndex((index, x) => index + x) // list{1, 3, 5} -``` - -## mapWithIndexU - -```res sig -let mapWithIndexU: (t<'a>, (. int, 'a) => 'b) => t<'b> -``` - -Uncurried version of [mapWithIndex](#mapWithIndex). - -## fromArray - -```res sig -let fromArray: array<'a> => t<'a> -``` - -Converts the given array to a list. - -```res example -Belt.List.fromArray([1, 2, 3]) // [1, 2, 3] -``` - -## toArray - -```res sig -let toArray: t<'a> => array<'a> -``` - -Converts the given list to an array. - -```res example -Belt.List.toArray(list{1, 2, 3}) // [1, 2, 3] -``` - -## reverse - -```res sig -let reverse: t<'a> => t<'a> -``` - -Returns a new list whose elements are those of `someList` in reversed order. - -```res example -Belt.List.reverse(list{1, 2, 3}) /* list{3, 2, 1} */ -``` - -## mapReverse - -```res sig -let mapReverse: (t<'a>, 'a => 'b) => t<'b> -``` - -Equivalent to: - -```res -map(someList, f)->reverse -``` - -```res example -list{3, 4, 5}->Belt.List.mapReverse(x => x * x) /* list{25, 16, 9} */ -``` - -## mapReverseU - -```res sig -let mapReverseU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -Uncurried version of [mapReverse](#mapReverse). - -## forEach - -```res sig -let forEach: (t<'a>, 'a => 'b) => unit -``` - -Call `f` on each element of `someList` from the beginning to end. -`f` returns `unit`, so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects. - -```res example -Belt.List.forEach(list{"a", "b", "c"}, x => Js.log("Item: " ++ x)) -/* - prints: - Item: a - Item: b - Item: c -*/ -``` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. 'a) => 'b) => unit -``` - -Uncurried version of [forEach](#forEach). - -## forEachWithIndex - -```res sig -let forEachWithIndex: (t<'a>, (int, 'a) => 'b) => unit -``` - -Call `f` on each element of `someList` from beginning to end. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`. `f` returns `unit`. - -```res example -Belt.List.forEachWithIndex(list{"a", "b", "c"}, (index, x) => { - Js.log("Item " ++ Belt.Int.toString(index) ++ " is " ++ x) -}) -/* - prints: - Item 0 is a - Item 1 is b - Item 2 is cc -*/ -``` - -## forEachWithIndexU - -```res sig -let forEachWithIndexU: (t<'a>, (. int, 'a) => 'b) => unit -``` - -Uncurried version of [forEachWithIndex](#forEachWithIndex). - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -Applies `f` to each element of `someList` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue`. reduce returns the final value of the accumulator. - -```res example -list{1, 2, 3, 4}->Belt.List.reduce(0, (a, b) => a + b) /* 10 */ - -/* same as */ - -list{1, 2, 3, 4}->Belt.List.reduce(0, (acc, item) => acc + item) /* 10 */ -``` - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b -``` - -Uncurried version of [reduce](#reduce). - -## reduceWithIndex - -```res sig -let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b -``` - -Applies `f` to each element of `someList` from beginning to end. Function `f` has three parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue` and the index of each element. `reduceWithIndex` returns the final value of the accumulator. - -```res example -list{1, 2, 3, 4}->Belt.List.reduceWithIndex(0, (acc, item, index) => acc + item + index) /* 16 */ -``` - -## reduceWithIndexU - -```res sig -let reduceWithIndexU: (t<'a>, 'b, (. 'b, 'a, int) => 'b) => 'b -``` - -Uncurried version of [reduceWithIndex](#reduceWithIndex). - -## reduceReverse - -```res sig -let reduceReverse: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -Works like [reduce](#reduce), except that function `f` is applied to each item of `someList` from the last back to the first. - -```res example -list{1, 2, 3, 4}->Belt.List.reduceReverse(0, (a, b) => a + b) /* 10 */ - -list{1, 2, 3, 4}->Belt.List.reduceReverse(10, (a, b) => a - b) /* 0 */ - -list{1, 2, 3, 4}->Belt.List.reduceReverse(list{}, Belt.List.add) // list{1, 2, 3, 4} -``` - -## reduceReverseU - -```res sig -let reduceReverseU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -Uncurried version of [reduceReverse](#reduceReverse). - -## mapReverse2 - -```res sig -let mapReverse2: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> -``` - -Equivalent to: `zipBy(xs, ys, f)->reverse` - -```res example - -Belt.List.mapReverse2(list{1, 2, 3}, list{1, 2}, (a, b) => a + b) // list{4, 2} -``` - -## mapReverse2U - -```res sig -let mapReverse2U: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> -``` - -Uncurried version of [mapReverse2](#mapReverse2). - -## forEach2 - -```res sig -let forEach2: (t<'a>, t<'b>, ('a, 'b) => 'c) => unit -``` - -Stops at the length of the shorter list. - -```res example -Belt.List.forEach2(list{"Z", "Y"}, list{"A", "B", "C"}, (x, y) => Js.log2(x, y)) - -/* - prints: - "Z" "A" - "Y" "B" -*/ -``` - -## forEach2U - -```res sig -let forEach2U: (t<'a>, t<'b>, (.'a, 'b) => 'c) => unit -``` - -Uncurried version of [forEach2](#forEach2). - -## reduce2 - -```res sig -let reduce2: (t<'b>, t<'c>, 'a, ('a, 'b, 'c) => 'a) => 'a -``` - -Applies `f` to each element of `firstList` and `secondList` from beginning to end. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of `initialValue`, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator. - -```res example -Belt.List.reduce2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* 0 + (1 * 1 + 4) + (2 * 2 + 5) */ -``` - -## reduce2U - -```res sig -let reduce2U: (t<'b>, t<'c>, 'a, (.'a, 'b, 'c) => 'a) => 'a -``` - -Uncurried version of [reduce2](#reduce2). - -## reduceReverse2 - -```res sig -let reduceReverse2: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c -``` - -Applies `f` to each element of `firstList` and `secondList` from end to beginning. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of init, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator. - -```res example -Belt.List.reduceReverse2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* + (1 * 1 + 4) + (2 * 2 + 5) */ -``` - -## reduceReverse2U - -```res sig -let reduceReverse2U: (t<'a>, t<'b>, 'c, (.'c, 'a, 'b) => 'c) => 'c -``` - -Uncurried version of [reduceReverse2](#reduceReverse2). - -## every - -```res sig -let every: (t<'a>, 'a => bool) => bool -``` - -Returns `true` if all elements satisfy `pred`, where `pred` is a predicate: a function taking an element and returning a bool. - -```res example -let isBelow10 = value => value < 10 - -list{1, 9, 8, 2}->Belt.List.every(isBelow10) /* true */ - -list{1, 99, 8, 2}->Belt.List.every(isBelow10) /* false */ -``` - -## everyU - -```res sig -let everyU: (t<'a>, (.'a) => bool) => bool -``` - -Uncurried version of [every](#every). - -## some - -```res sig -let some: (t<'a>, 'a => bool) => bool -``` - -Returns `true` if at least _one_ of the elements in `someList` satisfies `pred`, where `pred` is a predicate: a function taking an element and returning a bool. - -```res example -let isAbove100 = value => value > 100 - -list{101, 1, 2, 3}->Belt.List.some(isAbove100) /* true */ - -list{1, 2, 3, 4}->Belt.List.some(isAbove100) /* false */ -``` - -## someU - -```res sig -let someU: (t<'a>, (. 'a) => bool) => bool -``` - -Uncurried version of [some](#some). - -## every2 - -```res sig -let every2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool -``` - -Returns `true` if predicate `pred(a, b)` is `true` for all pairs of elements up to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -```res example -Belt.List.every2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{2, 3}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* false */ -``` - -## every2U - -```res sig -let every2U: (t<'a>, t<'b>, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [every2](#every2). - -## some2 - -```res sig -let some2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool -``` - -Returns `true` if predicate `pred(a, b)` is true for any pair of elements up to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -```res example -Belt.List.some2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */ - -Belt.List.some2(list{}, list{1}, (a, b) => a > b) /* false */ - -Belt.List.some2(list{2, 3}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.some2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* true */ -``` - -## some2U - -```res sig -let some2U: (t<'a>, t<'b>, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [some2](#some2). - -## cmpByLength - -```res sig -let cmpByLength: (t<'a>, t<'a>) => int -``` - -```res -cmpByLength(firstList, secondList) -``` - -Compare two lists solely by length. Returns `-1` if `length(firstList)` is less than `length(secondList)`, `0` if `length(firstList)` equals `length(secondList)`, and `1` if `length(firstList)` is greater than `length(secondList)`. - -```res example -Belt.List.cmpByLength(list{1, 2}, list{3, 4, 5, 6}) /* -1 */ - -Belt.List.cmpByLength(list{1, 2, 3}, list{4, 5, 6}) /* = 0 */ - -Belt.List.cmpByLength(list{1, 2, 3, 4}, list{5, 6}) /* = 1 */ -``` - -## cmp - -```res sig -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -``` - -Compare elements one by one `compareFn(a, b)`. `compareFn` returns a negative number if `a` is "less than" `b`, zero if `a` is "equal to" `b`, a positive number if `a` is "greater than" `b`. - -The comparison returns the first non-zero result of `compareFn`, or zero if `compareFn` returns zero for all `a` and `b`. - -If all items have compared equal, but `firstList` is exhausted first, return `-1`. (`firstList` is shorter). -If all items have compared equal, but `secondList` is exhausted first, return `1` (`firstList` is longer). - -```res example -Belt.List.cmp(list{3}, list{3, 7}, (a, b) => compare(a, b)) /* (-1) */ - -Belt.List.cmp(list{5, 3}, list{5}, (a, b) => compare(a, b)) /* 1 */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 4, 2}, (a, b) => compare(a, b)) /* (-1) */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 2, 3}, (a, b) => compare(a, b)) /* 1 */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 3, 5}, (a, b) => compare(a, b)) /* 0 */ -``` - -**Please note:** The total ordering of List is different from Array, -for Array, we compare the length first and, only if the lengths are equal, elements one by one. -For lists, we just compare elements one by one. - -## cmpU - -```res sig -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int -``` - -Uncurried version of [cmp](#cmp). - -## eq - -```res sig -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -``` - -Check equality of `firstList` and `secondList` using `eqElem` for equality on elements, where `eqElem` is a function that returns `true` if items `x` and `y` meet some criterion for equality, `false` otherwise. eq `false` if length of `firstList` and `secondList` are not the same. - -```res example -Belt.List.eq(list{1, 2, 3}, list{1, 2}, (a, b) => a == b) /* false */ - -Belt.List.eq(list{1, 2}, list{1, 2}, (a, b) => a == b) /* true */ - -Belt.List.eq(list{1, 2, 3}, list{(-1), (-2), (-3)}, (a, b) => abs(a) == abs(b)) /* true */ -``` - -## eqU - -```res sig -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool -``` - -Uncurried version of [eqU](#eqU). - -## has - -```res sig -let has: (t<'a>, 'b, ('a, 'b) => bool) => bool -``` - -Returns `true` if the list contains at least one element for which `eqFunction(x)` returns true. - -```res example -list{1, 2, 3}->Belt.List.has(2, (a, b) => a == b) /* true */ - -list{1, 2, 3}->Belt.List.has(4, (a, b) => a == b) /* false */ - -list{(-1), (-2), (-3)}->Belt.List.has(2, (a, b) => abs(a) == abs(b)) /* true */ -``` - -## hasU - -```res sig -let hasU: (t<'a>, 'b, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [has](#has). - -## getBy - -```res sig -let getBy: (t<'a>, 'a => bool) => option<'a> -``` - -Returns `Some(value)` for the first value in `someList` that satisfies the predicate function `pred`. Returns `None` if no element satisfies the function. - -```res example -Belt.List.getBy(list{1, 4, 3, 2}, x => x > 3) /* Some(4) */ - -Belt.List.getBy(list{1, 4, 3, 2}, x => x > 4) /* None */ -``` - -## getByU - -```res sig -let getByU: (t<'a>, (. 'a) => bool) => option<'a> -``` - -Uncurried version of [getBy](#getBy). - -## keep - -```res sig -let keep: (t<'a>, 'a => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.keep(list{1, 2, 3, 4}, isEven) /* list{2, 4} */ - -Belt.List.keep(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */ -``` - -## keepU - -```res sig -let keepU: (t<'a>, (. 'a) => bool) => t<'a> -``` - -Uncurried version of [keep](#keep). - -## filter - -```res sig -let filter: (t<'a>, 'a => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.filter(list{1, 2, 3, 4}, isEven) /* list{2, 4} */ - -Belt.List.filter(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */ -``` - -## keepWithIndex - -```res sig -let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.keepWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */ -``` - -## keepWithIndexU - -```res sig -let keepWithIndexU: (t<'a>, (. 'a, int) => bool) => t<'a> -``` - -Uncurried version of [keepWithIndex](#keepWithIndex). - -## filterWithIndex - -```res sig -let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a> -``` - -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -```res example -let isEven = x => mod(x, 2) == 0 - -Belt.List.filterWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */ -``` - -## keepMap - -```res sig -let keepMap: (t<'a>, 'a => option<'b>) => t<'b> -``` - -Applies `f` to each element of `someList`. If `f(x)` returns `Some(value)`, then `value` is _kept_ in the resulting list. -If `f(x)` returns `None`, the element is _not_ retained in the result. - -```res example -let isEven = x => mod(x, 2) == 0 - -list{1, 2, 3, 4} -->Belt.List.keepMap(x => - if (isEven(x)) { - Some(x) - } else { - None - } - ) /* list{2, 4} */ - -list{Some(1), Some(2), None}->Belt.List.keepMap(x => x) /* list{1, 2} */ -``` - -## keepMapU - -```res sig -let keepMapU: (t<'a>, (. 'a) => option<'b>) => t<'b> -``` - -Uncurried version of [keepMap](#keepMap). - -## partition - -```res sig -let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>) -``` - -Creates a pair of lists; the first list consists of all elements of `someList` that satisfy the predicate function `pred`; the second list consists of all elements of `someList` that _do not_ satisfy `pred. - -In other words: - -```res -(elementsThatSatisfies, elementsThatDoesNotSatisfy) -``` - -```res example -Belt.List.partition(list{1, 2, 3, 4}, x => x > 2) /* (list{3, 4}, list{1, 2}) */ -``` - -## partitionU - -```res sig -let partitionU: (t<'a>, (. 'a) => bool) => (t<'a>, t<'a>) -``` - -Uncurried version of [partition](#partition). - -## unzip - -```res sig -let unzip: t<('a, 'b)> => (t<'a>, t<'b>) -``` - -Takes a list of pairs and creates a pair of lists. The first list contains all the first items of the pairs; the second list contains all the second items. - -```res example -Belt.List.unzip(list{(1, 2), (3, 4)}) /* (list{1, 3}, list{2, 4}) */ - -Belt.List.unzip(list{("H", "W"), ("e", "o"), ("l", "r"), ("l", "l"), ("o", "d"), (" ", "!")}) -/* (list{"H", "e", "l", "l", "o", " "}, list{"W", "o", "r", "l", "d", "!"}) */ -``` - -## getAssoc - -```res sig -let getAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c> -``` - -Return the second element of a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`, or `None` if not found. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.getAssoc(3, (a, b) => a == b) /* Some("c") */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.getAssoc(15, (k, item) => k /* 15 */ == item /* 9, 5, 22 */) -/* Some("afternoon") */ -``` - -## getAssocU - -```res sig -let getAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => option<'c> -``` - -Uncurried version of [getAssoc](#getAssoc). - -## hasAssoc - -```res sig -let hasAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => bool -``` - -Returns `true` if there is a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.hasAssoc(1, (a, b) => a == b) /* true */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */) /* false */ -``` - -## hasAssocU - -```res sig -let hasAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => bool -``` - -Uncurried version of [hasAssoc](#hasAssoc). - -## removeAssoc - -```res sig -let removeAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => t<('a, 'c)> -``` - -Return a list after removing the first pair whose first value is `k` per the equality predicate `eqFunction`; if not found, return a new list identical to `someList`. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.removeAssoc(1, (a, b) => a == b) /* list{(2, "b"), (3, "c")} */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.removeAssoc(9, (k, item) => k /* 9 */ == item /* 9, 5, 22 */) -/* list{(15, "afternoon"), (22, "night")} */ -``` - -## removeAssocU - -```res sig -let removeAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => t<('a, 'c)> -``` - -Uncurried version of [removeAssoc](#removeAssoc). - -## setAssoc - -```res sig -let setAssoc: (t<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => t<('a, 'c)> -``` - -If `k` exists in `someList` by satisfying the `eqFunction` predicate, return a new list with the key and value replaced by the new `k` and `v`; otherwise, return a new list with the pair `k`, `v` added to the head of `someList`. - -```res example -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.setAssoc(2, "x", (a, b) => a == b) /* list{(1, "a"), (2, "x"), (3, "c")} */ - -list{(1, "a"), (3, "c")}->Belt.List.setAssoc(2, "b", (a, b) => a == b) /* list{(2, "b"), (1, "a"), (3, "c")} */ - -list{(9, "morning"), (3, "morning?!"), (22, "night")} -->Belt.List.setAssoc(15, "afternoon", (a, b) => mod(a, 12) == mod(b, 12)) -/* list{(9, "morning"), (15, "afternoon"), (22, "night")} */ -``` - -**Please note** - -In the last example, since: `15 mod 12` equals `3 mod 12` - -Both the key _and_ the value are replaced in the list. - -## setAssocU - -```res sig -let setAssocU: (t<('a, 'c)>, 'a, 'c, (. 'a, 'a) => bool) => t<('a, 'c)> -``` - -Uncurried version of [setAssoc](#setAssoc). - -## sort - -```res sig -let sort: (t<'a>, ('a, 'a) => int) => t<'a> -``` - -Returns a sorted list. - -```res example -Belt.List.sort(list{5, 4, 9, 3, 7}, (a, b) => a - b) // list{3, 4, 5, 7, 9} -``` - -## sortU - -```res sig -let sortU: (t<'a>, (. 'a, 'a) => int) => t<'a> -``` - -Uncurried version of [sort](#sort). diff --git a/pages/docs/manual/v9.0.0/api/belt/map-dict.mdx b/pages/docs/manual/v9.0.0/api/belt/map-dict.mdx deleted file mode 100644 index 4a9828f50..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/map-dict.mdx +++ /dev/null @@ -1,397 +0,0 @@ -# MapDict - - - -This module separates identity from data, it is a bit more verbose but slightly more efficient due to the fact that there is no need to pack identity and data back after each operation - -**_Advanced usage only_** - - - -## t - -```res prelude -type t<'key, 'value, 'id> -``` - -## cmp - -```res prelude -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> -``` - -## empty - -```res sig -let empty: t<'k, 'v, 'id> -``` - -## isEmpty - -```res sig -let isEmpty: t<'k, 'v, 'id> => bool -``` - -## has - -```res sig -let has: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int -``` - -## eqU - -```res sig -let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, cmp)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `cmp` is the equality predicate used to compare the data associated with the keys. - -## findFirstByU - -```res sig -let findFirstByU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => option<('k, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Map.Dict.fromArray([(4, "4"), (1, "1"), (2, "2"), (3, "3")], ~cmp=IntCmp.cmp) - -Belt.Map.Dict.findFirstBy(s0, (k, _) => k == 4) == Some((4, "4")) -``` - -## forEachU - -```res sig -let forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b -``` - -`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'k, 'a, 'id> => int -``` - -## toList - -```res sig -let toList: t<'k, 'a, 'id> => list<('k, 'a)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'k, 'a, 'id> => array<('k, 'a)> -``` - -## fromArray - -```res sig -let fromArray: (array<('k, 'a)>, ~cmp: cmp<'k, 'id>) => t<'k, 'a, 'id> -``` - -## keysToArray - -```res sig -let keysToArray: t<'k, 'a, 'id> => array<'k> -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'k, 'a, 'id> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'k, 'a, 'b> => option<'k> -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## maxKey - -```res sig -let maxKey: t<'k, 'a, 'b> => option<'k> -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## minimum - -```res sig -let minimum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## get - -```res sig -let get: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a, ~cmp: cmp<'k, 'id>) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b, 'c> => unit -``` - -## remove - -```res sig -let remove: (t<'a, 'b, 'id>, 'a, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```res sig -let removeMany: (t<'a, 'b, 'id>, array<'a>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -## set - -```res sig -let set: (t<'a, 'b, 'id>, 'a, 'b, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: ( - t<'a, 'b, 'id>, - 'a, - (. option<'b>) => option<'b>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'b, 'id> -``` - -## update - -```res sig -let update: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -## mergeU - -```res sig -let mergeU: ( - t<'a, 'b, 'id>, - t<'a, 'c, 'id>, - (. 'a, option<'b>, option<'c>) => option<'d>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'd, 'id> -``` - -## merge - -```res sig -let merge: ( - t<'a, 'b, 'id>, - t<'a, 'c, 'id>, - ('a, option<'b>, option<'c>) => option<'d>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'd, 'id> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```res sig -let mergeMany: (t<'a, 'b, 'id>, array<('a, 'b)>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -``` - -## keepU - -```res sig -let keepU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => t<'k, 'a, 'id> -``` - -## keep - -```res sig -let keep: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id> -``` - -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. - -## partitionU - -```res sig -let partitionU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) -``` - -## partition - -```res sig -let partition: (t<'k, 'a, 'id>, ('k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```res sig -let split: ( - t<'a, 'b, 'id>, - 'a, - ~cmp: cmp<'a, 'id>, -) => ((t<'a, 'b, 'id>, t<'a, 'b, 'id>), option<'b>) -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of `m` whose key is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id> -``` - -## map - -```res sig -let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/map-int.mdx b/pages/docs/manual/v9.0.0/api/belt/map-int.mdx deleted file mode 100644 index e7b4f3ff0..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/map-int.mdx +++ /dev/null @@ -1,373 +0,0 @@ -# MapInt - - - -Specalized when key type is `int`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison - - - -## key - -```res prelude -type key = int -``` - -## t - -```res prelude -type t<'value> -``` - -The type of maps from type `key` to type `'value`. - -## empty - -```res sig -let empty: t<'v> -``` - -## isEmpty - -```res sig -let isEmpty: t<'v> => bool -``` - -## has - -```res sig -let has: (t<'v>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'v>, t<'v>, (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int -``` - -## eqU - -```res sig -let eqU: (t<'v>, t<'v>, (. 'v, 'v) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool -``` - -`eq(m1,m2)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. - -## findFirstByU - -```res sig -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -let s0 = Belt.Map.Int.fromArray([(4, "4"), (1, "1"), (2, "2"), (3, "3")]) - -Belt.Map.Int.findFirstBy(s0, (k, v) => k == 4) == Some((4, "4")) -``` - -## forEachU - -```res sig -let forEachU: (t<'v>, (. key, 'v) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'v>, (key, 'v) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'v>, 'v2, (. 'v2, key, 'v) => 'v2) => 'v2 -``` - -## reduce - -```res sig -let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 -``` - -`reduce(m, a, f)` computes `f(kN, dN, ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## every - -```res sig -let every: (t<'v>, (key, 'v) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## some - -```res sig -let some: (t<'v>, (key, 'v) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'v> => int -``` - -## toList - -```res sig -let toList: t<'v> => list<(key, 'v)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'v> => array<(key, 'v)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'v)> => t<'v> -``` - -## keysToArray - -```res sig -let keysToArray: t<'v> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'v> => array<'v> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'v> => option<(key, 'v)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## maximum - -```res sig -let maximum: t<'v> => option<(key, 'v)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## get - -```res sig -let get: (t<'v>, key) => option<'v> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'v>, key) => Js.undefined<'v> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'v>, key, 'v) => 'v -``` - -## getExn - -```res sig -let getExn: (t<'v>, key) => 'v -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -**raise** when invariant is not held - -## remove - -```res sig -let remove: (t<'v>, key) => t<'v> -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```res sig -let removeMany: (t<'v>, array) => t<'v> -``` - -## set - -```res sig -let set: (t<'v>, key, 'v) => t<'v> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'v>, key, (. option<'v>) => option<'v>) => t<'v> -``` - -## update - -```res sig -let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> -``` - -## mergeU - -```res sig -let mergeU: (t<'v>, t<'v2>, (. key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -## merge - -```res sig -let merge: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```res sig -let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v> -``` - -## keepU - -```res sig -let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> -``` - -## keep - -```res sig -let keep: (t<'v>, (key, 'v) => bool) => t<'v> -``` - -## partitionU - -```res sig -let partitionU: (t<'v>, (. key, 'v) => bool) => (t<'v>, t<'v>) -``` - -## partition - -```res sig -let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```res sig -let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>) -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of `m` whose key is strictly greater than `x`; `data` is `None` if m contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'v>, (. 'v) => 'v2) => t<'v2> -``` - -## map - -```res sig -let map: (t<'v>, 'v => 'v2) => t<'v2> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'v>, (. key, 'v) => 'v2) => t<'v2> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/map-string.mdx b/pages/docs/manual/v9.0.0/api/belt/map-string.mdx deleted file mode 100644 index 545a38920..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/map-string.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# MapString - - - -Specalized when key type is `string`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison - - - -## key - -```res prelude -type key = string -``` - -## t - -```res prelude -type t<'value> -``` - -The type of maps from type `key` to type `'value`. - -## empty - -```res sig -let empty: t<'v> -``` - -## isEmpty - -```res sig -let isEmpty: t<'v> => bool -``` - -## has - -```res sig -let has: (t<'v>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'v>, t<'v>, (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int -``` - -## eqU - -```res sig -let eqU: (t<'v>, t<'v>, (. 'v, 'v) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool -``` - -`eq(m1, m2)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. - -## findFirstByU - -```res sig -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -let s0 = Belt.Map.String.fromArray([("4", 4), ("1", 1), ("2", 2), ("3", 3)]) - -Belt.Map.String.findFirstBy(s0, (k, _) => k == "4") == Some(("4", 4)) -``` - -## forEachU - -```res sig -let forEachU: (t<'v>, (. key, 'v) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'v>, (key, 'v) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'v>, 'v2, (. 'v2, key, 'v) => 'v2) => 'v2 -``` - -## reduce - -```res sig -let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 -``` - -`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...), where k1 ... kN)` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## every - -```res sig -let every: (t<'v>, (key, 'v) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'v>, (. key, 'v) => bool) => bool -``` - -## some - -```res sig -let some: (t<'v>, (key, 'v) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'v> => int -``` - -## toList - -```res sig -let toList: t<'v> => list<(key, 'v)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'v> => array<(key, 'v)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'v)> => t<'v> -``` - -## keysToArray - -```res sig -let keysToArray: t<'v> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'v> => array<'v> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'v> => option<(key, 'v)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## maximum - -```res sig -let maximum: t<'v> => option<(key, 'v)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'v> => Js.undefined<(key, 'v)> -``` - -## get - -```res sig -let get: (t<'v>, key) => option<'v> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'v>, key) => Js.undefined<'v> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'v>, key, 'v) => 'v -``` - -## getExn - -```res sig -let getExn: (t<'v>, key) => 'v -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -**raise** when invariant is not held - -## remove - -```res sig -let remove: (t<'v>, key) => t<'v> -``` - -`remove(m, x)` returns a map containing the same bindings as `m`, except for `x` which is unbound in the returned map. - -## removeMany - -```res sig -let removeMany: (t<'v>, array) => t<'v> -``` - -## set - -```res sig -let set: (t<'v>, key, 'v) => t<'v> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'v>, key, (. option<'v>) => option<'v>) => t<'v> -``` - -## update - -```res sig -let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> -``` - -## mergeU - -```res sig -let mergeU: (t<'v>, t<'v2>, (. key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -## merge - -```res sig -let merge: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## mergeMany - -```res sig -let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v> -``` - -## keepU - -```res sig -let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> -``` - -## keep - -```res sig -let keep: (t<'v>, (key, 'v) => bool) => t<'v> -``` - -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. - -## partitionU - -```res sig -let partitionU: (t<'v>, (. key, 'v) => bool) => (t<'v>, t<'v>) -``` - -## partition - -```res sig -let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of s that do not satisfy `p`. - -## split - -```res sig -let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>) -``` - -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the bindings of `m` whose key is strictly less than `x`; `r` is the map with all the bindings of m whose key is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'v>, (. 'v) => 'v2) => t<'v2> -``` - -## map - -```res sig -let map: (t<'v>, 'v => 'v2) => t<'v2> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'v>, (. key, 'v) => 'v2) => t<'v2> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/map.mdx b/pages/docs/manual/v9.0.0/api/belt/map.mdx deleted file mode 100644 index ba31ca263..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/map.mdx +++ /dev/null @@ -1,649 +0,0 @@ -# Map - -The top level provides generic immutable map operations. - -It also has three specialized inner modules `Belt.Map.Int`, `Belt.Map.String` and `Belt.Map.Dict`. - -## t - -```res prelude -type t<'key, 'value, 'identity> -``` - -`'key` is the field type - -`'value` is the element type - -`'identity` the identity of the collection - -## id - -```res prelude -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -``` - -The identity needed for making an empty map. - -## make - -```res sig -let make: (~id: id<'k, 'id>) => t<'k, 'v, 'id> -``` - -`make(~id)` creates a new map by taking in the comparator. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let m = Belt.Map.make(~id=module(IntCmp)) - -Belt.Map.set(m, 0, "a") -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b, 'c> => bool -``` - -`isEmpty(m)` checks whether a map m is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.isEmpty(Belt.Map.fromArray([(1, "1")], ~id=module(IntCmp))) == false -``` - -## has - -```res sig -let has: (t<'k, 'v, 'id>, 'k) => bool -``` - -`has(m, k)` checks whether `m` has the key `k`. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.has(Belt.Map.fromArray([(1, "1")], ~id=module(IntCmp)), 1) == true -``` - -## cmpU - -```res sig -let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, (. 'v, 'v) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int -``` - -`cmp(m0, m1, vcmp);` - -Total ordering of map given total ordering of value function. - -It will compare size first and each element following the order one by one. - -## eq - -```res sig -let eqU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, (. 'v, 'v) => bool) => bool -``` - -`eq(m1, m2, veq)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `veq` is the equality predicate used to compare the data associated with the keys. - -## eq - -```res sig -let eq: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool -``` - -## findFirstByU - -```res sig -let findFirstByU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => option<('k, 'v)> -``` - -## findFirstBy - -```res sig -let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> -``` - -`findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "")]) - -Belt.Map.findFirstBy(s0, (k, v) => k == 4) /* (4, "4") */ -``` - -## forEachU - -```res sig -let forEachU: (t<'k, 'v, 'id>, (. 'k, 'v) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "")]) - -let acc = ref(list{}) - -Belt.Map.forEach(s0, (k, v) => acc := list{(k, v), ...acc.contents}) - -acc.contents == list{(4, "4"), (3, "3"), (2, "2"), (1, "1")} -``` - -## reduceU - -```res sig -let reduceU: (t<'k, 'v, 'id>, 'acc, (. 'acc, 'k, 'v) => 'acc) => 'acc -``` - -## reduce - -```res sig -let reduce: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc -``` - -`reduce(m, a, f)` computes `(f(kN, dN) ... (f(k1, d1, a))...)`, where `k1 ... kN` are the keys of all bindings in m (in increasing order), and `d1 ... dN` are the associated data. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "3")]) - -Belt.Map.reduce(s0, list{}, (acc, k, v) => list{ - (k, v), - ...acc, -}) /* [(4, "4"), (3, "3"), (2, "2"), (1, "1"), 0] */ -``` - -## everyU - -```res sig -let everyU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => bool -``` - -## every - -```res sig -let every: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified - -## someU - -```res sig -let someU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => bool -``` - -## some - -```res sig -let some: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified - -## size - -```res sig -let size: t<'k, 'v, 'id> => int -``` - -`size(s)` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.size(Belt.Map.fromArray([(2, "2"), (2, "1"), (3, "3")], ~id=module(IntCmp))) == 2 -``` - -## toArray - -```res sig -let toArray: t<'k, 'v, 'id> => array<('k, 'v)> -``` - -`toArray(s)` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.toArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - (1, "1"), - (2, "2"), - (3, "3"), - ] -``` - -## toList - -```res sig -let toList: t<'k, 'v, 'id> => list<('k, 'v)> -``` - -In increasing order. - -See `Belt.Map.toArray` - -## fromArray - -```res sig -let fromArray: (array<('k, 'v)>, ~id: id<'k, 'id>) => t<'k, 'v, 'id> -``` - -`fromArray(kvs, ~id);` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.toArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - (1, "1"), - (2, "2"), - (3, "3"), - ] -``` - -## keysToArray - -```res sig -let keysToArray: t<'k, 'v, 'id> => array<'k> -``` - -`keysToArray(s);` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.keysToArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - 1, - 2, - 3, - ] -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'k, 'v, 'id> => array<'v> -``` - -`valuesToArray(s);` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.valuesToArray( - Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), -) == ["1", "2", "3"] -``` - -## minKey - -```res sig -let minKey: t<'k, 'a, 'b> => option<'k> -``` - -`minKey(s)` returns the minimum key, None if not exist. - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -See `Belt.Map.minKey` - -## maxKey - -```res sig -let maxKey: t<'k, 'a, 'b> => option<'k> -``` - -`maxKey(s)` returns the maximum key, None if not exist. - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -See `Belt.Map.maxKey` - -## minimum - -```res sig -let minimum: t<'k, 'v, 'a> => option<('k, 'v)> -``` - -`minimum(s)` returns the minimum key value pair, None if not exist - -## minUndefined - -```res sig -let minUndefined: t<'k, 'v, 'a> => Js.undefined<('k, 'v)> -``` - -See `Belt.Map.minimum` - -## maximum - -```res sig -let maximum: t<'k, 'v, 'a> => option<('k, 'v)> -``` - -`maximum(s)` returns the maximum key value pair, None if not exist. - -## maxUndefined - -```res sig -let maxUndefined: t<'k, 'v, 'a> => Js.undefined<('k, 'v)> -``` - -See `Belt.Map.maximum` - -## get - -```res sig -let get: (t<'k, 'v, 'id>, 'k) => option<'v> -``` - -`get(s, k)` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.get(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), 2) == - Some("2") - -Belt.Map.get(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), 2) == None -``` - -## getUndefined - -```res sig -let getUndefined: (t<'k, 'v, 'id>, 'k) => Js.undefined<'v> -``` - -See `Belt.Map.get` - -Returns `undefined` when not found - -## getWithDefault - -```res sig -let getWithDefault: (t<'k, 'v, 'id>, 'k, 'v) => 'v -``` - -`getWithDefault(s, k, default)` - -See `Belt.Map.get` - -Returns default when `k` is not found. - -## getExn - -```res sig -let getExn: (t<'k, 'v, 'id>, 'k) => 'v -``` - -`getExn(s, k)` - -See `Belt.Map.getExn` - -raise when `k` not exist - -## remove - -```res sig -let remove: (t<'k, 'v, 'id>, 'k) => t<'k, 'v, 'id> -``` - -`remove(m, x)` when `x` is not in `m`, `m` is returned reference unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)) - -let s1 = Belt.Map.remove(s0, 1) - -let s2 = Belt.Map.remove(s1, 1) - -s1 === s2 - -Belt.Map.keysToArray(s1) == [2, 3] -``` - -## removeMany - -```res sig -let removeMany: (t<'k, 'v, 'id>, array<'k>) => t<'k, 'v, 'id> -``` - -`removeMany(s, xs)` - -Removing each of `xs` to `s`, note unlike `Belt.Map.remove`, the reference of return value might be changed even if none in `xs` exists `s`. - -## set - -```res sig -let set: (t<'k, 'v, 'id>, 'k, 'v) => t<'k, 'v, 'id> -``` - -`set(m, x, y)` returns a map containing the same bindings as `m`, with a new binding of `x` to `y`. If `x` was already bound in `m`, its previous binding disappears. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)) - -let s1 = Belt.Map.set(s0, 2, "3") - -Belt.Map.valuesToArray(s1) == ["1", "3", "3"] -``` - -## updateU - -```res sig -let updateU: (t<'k, 'v, 'id>, 'k, (. option<'v>) => option<'v>) => t<'k, 'v, 'id> -``` - -## update - -```res sig -let update: (t<'k, 'v, 'id>, 'k, option<'v> => option<'v>) => t<'k, 'v, 'id> -``` - -`update(m, x, f)` returns a map containing the same bindings as `m`, except for the binding of `x`. Depending on the value of `y` where `y` is `f(get(m, x))`, the binding of `x` is added, removed or updated. If `y` is `None`, the binding is removed if it exists; otherwise, if `y` is `Some(z)` then `x` is associated to `z` in the resulting map. - -## mergeMany - -```res sig -let mergeMany: (t<'k, 'v, 'id>, array<('k, 'v)>) => t<'k, 'v, 'id> -``` - -`mergeMany(s, xs)` - -Adding each of `xs` to `s`, note unlike `add`, the reference of return value might be changed even if all values in `xs` exist `s`. - -## mergeU - -```res sig -let mergeU: ( - t<'k, 'v, 'id>, - t<'k, 'v2, 'id>, - (. 'k, option<'v>, option<'v2>) => option<'v3>, -) => t<'k, 'v3, 'id> -``` - -## merge - -```res sig -let merge: ( - t<'k, 'v, 'id>, - t<'k, 'v2, 'id>, - ('k, option<'v>, option<'v2>) => option<'v3>, -) => t<'k, 'v3, 'id> -``` - -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding value, is determined with the function `f`. - -## keepU - -```res sig -let keepU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => t<'k, 'v, 'id> -``` - -## keep - -```res sig -let keep: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id> -``` - -`keep(m, p)` returns the map with all the bindings in m that satisfy predicate `p`. - -## partitionU - -```res sig -let partitionU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) -``` - -## partition - -```res sig -let partition: (t<'k, 'v, 'id>, ('k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) -``` - -`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the bindings of `s` that do not satisfy `p`. - -## split - -```res sig -let split: (t<'k, 'v, 'id>, 'k) => ((t<'k, 'v, 'id>, t<'k, 'v, 'id>), option<'v>) -``` - -`split(x, m)` returns a tuple `(l, r)`, data, where `l` is the map with all the bindings of `m` whose 'k is strictly less than `x`; `r` is the map with all the bindings of m whose 'k is strictly greater than `x`; `data` is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. - -## mapU - -```res sig -let mapU: (t<'k, 'v, 'id>, (. 'v) => 'v2) => t<'k, 'v2, 'id> -``` - -## map - -```res sig -let map: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id> -``` - -`map(m, f) returns a map with same domain as`m`, where the associated value`a`of all bindings of`m`has been replaced by the result of the application of`f`to`a`. The bindings are passed to`f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'k, 'v, 'id>, (. 'k, 'v) => 'v2) => t<'k, 'v2, 'id> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'k, 'v, 'id>, ('k, 'v) => 'v2) => t<'k, 'v2, 'id> -``` - -`mapWithKey(m, f)` - -The same as `Belt.Map.map` except that `f` is supplied with one more argument: the key. - -## getData - -```res sig -let getData: t<'k, 'v, 'id> => Belt_MapDict.t<'k, 'v, 'id> -``` - -`getData(s0)` - -Advanced usage only - -Returns the raw data (detached from comparator), but its type is still manifested, so that user can pass identity directly without boxing. - -## getId - -```res sig -let getId: t<'k, 'v, 'id> => id<'k, 'id> -``` - -Advanced usage only - -Returns the identity of s0. - -## packIdData - -```res sig -let packIdData: (~id: id<'k, 'id>, ~data: Belt_MapDict.t<'k, 'v, 'id>) => t<'k, 'v, 'id> -``` - -`packIdData(~id, ~data)` - -Advanced usage only - -Returns the packed collection. diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-map-int.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-map-int.mdx deleted file mode 100644 index 73fbcaaab..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-map-int.mdx +++ /dev/null @@ -1,299 +0,0 @@ -# MutableMapInt - -## key - -```res prelude -type key = int -``` - -## t - -```res prelude -type t<'a> -``` - -## make - -```res sig -let make: unit => t<'a> -``` - -## clear - -```res sig -let clear: t<'a> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## has - -```res sig -let has: (t<'a>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```res sig -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, cmp)` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. key, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, (key, 'a) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The application order of `f` is in increasing order. - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, key, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'a>, (key, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## someU - -```res sig -let someU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'a>, (key, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## size - -```res sig -let size: t<'a> => int -``` - -## toList - -```res sig -let toList: t<'a> => list<(key, 'a)> -``` - -In increasing order - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'a> => option<(key, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'a> => option<(key, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'a>, key) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'a>, key, 'a) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'a>, key) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -Raise when invariant is not held. - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```res sig -let removeMany: (t<'a>, array) => unit -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'a>, key, (. option<'a>) => option<'a>) => unit -``` - -## update - -```res sig -let update: (t<'a>, key, option<'a> => option<'a>) => unit -``` - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'a>, (. key, 'a) => 'b) => t<'b> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-map-string.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-map-string.mdx deleted file mode 100644 index cfc1d228d..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-map-string.mdx +++ /dev/null @@ -1,299 +0,0 @@ -# MutableMapString - -## key - -```res prelude -type key = string -``` - -## t - -```res prelude -type t<'a> -``` - -## make - -```res sig -let make: unit => t<'a> -``` - -## clear - -```res sig -let clear: t<'a> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## has - -```res sig -let has: (t<'a>, key) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```res sig -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, cmp)` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. key, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, (key, 'a) => unit) => unit -``` - -`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The application order of `f` is in increasing order. - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, key, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'a>, (key, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## someU - -```res sig -let someU: (t<'a>, (. key, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'a>, (key, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. The application order of `p` is unspecified. - -## size - -```res sig -let size: t<'a> => int -``` - -## toList - -```res sig -let toList: t<'a> => list<(key, 'a)> -``` - -In increasing order - -## toArray - -```res sig -let toArray: t<'a> => array<(key, 'a)> -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -## keysToArray - -```res sig -let keysToArray: t<'a> => array -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'a> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'a> => option -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'a> => Js.undefined -``` - -## maxKey - -```res sig -let maxKey: t<'a> => option -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'a> => Js.undefined -``` - -## minimum - -```res sig -let minimum: t<'a> => option<(key, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'a> => option<(key, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'a> => Js.undefined<(key, 'a)> -``` - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'a>, key) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'a>, key, 'a) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'a>, key) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a> => unit -``` - -Raise when invariant is not held. - -## remove - -```res sig -let remove: (t<'a>, key) => unit -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```res sig -let removeMany: (t<'a>, array) => unit -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was already bound in `m`, its previous binding disappears. - -## updateU - -```res sig -let updateU: (t<'a>, key, (. option<'a>) => option<'a>) => unit -``` - -## update - -```res sig -let update: (t<'a>, key, option<'a> => option<'a>) => unit -``` - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'a>, (. key, 'a) => 'b) => t<'b> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-map.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-map.mdx deleted file mode 100644 index 21ed52d60..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-map.mdx +++ /dev/null @@ -1,313 +0,0 @@ -# MutableMap - - - -A mutable sorted map module which allows customize compare behavior. - - - -Same as `Belt.Map`, but mutable. - -## t - -```res prelude -type t<'k, 'v, 'id> -``` - -## id - -```res prelude -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -``` - -## make - -```res sig -let make: (~id: id<'k, 'id>) => t<'k, 'a, 'id> -``` - -## clear - -```res sig -let clear: t<'a, 'b, 'c> => unit -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b, 'c> => bool -``` - -## has - -```res sig -let has: (t<'k, 'a, 'b>, 'k) => bool -``` - -## cmpU - -```res sig -let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int -``` - -`cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. - -## eqU - -```res sig -let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool -``` - -`eq(m1, m2, eqf)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `eqf` is the equality predicate used to compare the data associated with the keys. - -## forEachU - -```res sig -let forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit -``` - -`forEach(m, f)` applies f to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## reduceU - -```res sig -let reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b -``` - -`reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` are the associated data. - -## everyU - -```res sig -let everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## every - -```res sig -let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. - -## someU - -```res sig -let someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool -``` - -## some - -```res sig -let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -``` - -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. - -## size - -```res sig -let size: t<'k, 'a, 'id> => int -``` - -## toList - -```res sig -let toList: t<'k, 'a, 'id> => list<('k, 'a)> -``` - -In increasing order. - -## toArray - -```res sig -let toArray: t<'k, 'a, 'id> => array<('k, 'a)> -``` - -## fromArray - -```res sig -let fromArray: (array<('k, 'a)>, ~id: id<'k, 'id>) => t<'k, 'a, 'id> -``` - -## keysToArray - -```res sig -let keysToArray: t<'k, 'a, 'b> => array<'k> -``` - -## valuesToArray - -```res sig -let valuesToArray: t<'b, 'a, 'c> => array<'a> -``` - -## minKey - -```res sig -let minKey: t<'k, 'a, 'b> => option<'k> -``` - -## minKeyUndefined - -```res sig -let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## maxKey - -```res sig -let maxKey: t<'k, 'a, 'b> => option<'k> -``` - -## maxKeyUndefined - -```res sig -let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k> -``` - -## minimum - -```res sig -let minimum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## minUndefined - -```res sig -let minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## maximum - -```res sig -let maximum: t<'k, 'a, 'b> => option<('k, 'a)> -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)> -``` - -## get - -```res sig -let get: (t<'k, 'a, 'id>, 'k) => option<'a> -``` - -## getUndefined - -```res sig -let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a> -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a -``` - -## getExn - -```res sig -let getExn: (t<'k, 'a, 'id>, 'k) => 'a -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b, 'c> => unit -``` - -Raise when invariant is not held. - -## remove - -```res sig -let remove: (t<'k, 'a, 'id>, 'k) => unit -``` - -`remove(m, x)` do the in-place modification. - -## removeMany - -```res sig -let removeMany: (t<'k, 'a, 'id>, array<'k>) => unit -``` - -## set - -```res sig -let set: (t<'k, 'a, 'id>, 'k, 'a) => unit -``` - -`set(m, x, y)` do the in-place modification - -## updateU - -```res sig -let updateU: (t<'k, 'a, 'id>, 'k, (. option<'a>) => option<'a>) => unit -``` - -## update - -```res sig -let update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit -``` - -## mergeMany - -```res sig -let mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unit -``` - -## mapU - -```res sig -let mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id> -``` - -## map - -```res sig -let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> -``` - -`map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the application of `f` to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. - -## mapWithKeyU - -```res sig -let mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id> -``` - -## mapWithKey - -```res sig -let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-queue.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-queue.mdx deleted file mode 100644 index 9efd21a4b..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-queue.mdx +++ /dev/null @@ -1,175 +0,0 @@ -# MutableQueue - - - -An FIFO(first in first out) queue data structure. - - - -## t - -```res prelude -type t<'a> -``` - -The type of queues containing elements of `type('a)`. - -## make - -```res sig -let make: unit => t<'a> -``` - -Returns a new queue, initially empty. - -## clear - -```res sig -let clear: t<'a> => unit -``` - -Discard all elements from the queue. - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -Returns `true` if the given queue is empty, `false` otherwise. - -## fromArray - -```res sig -let fromArray: array<'a> => t<'a> -``` - -`fromArray` a is equivalent to `Array.forEach(a, add(q, a));` - -## add - -```res sig -let add: (t<'a>, 'a) => unit -``` - -`add(q, x)` adds the element `x` at the end of the queue `q`. - -## peek - -```res sig -let peek: t<'a> => option<'a> -``` - -`peekOpt(q)` returns the first element in queue `q`, without removing it from the queue. - -## peekUndefined - -```res sig -let peekUndefined: t<'a> => Js.undefined<'a> -``` - -`peekUndefined(q)` returns `undefined` if not found. - -## peekExn - -```res sig -let peekExn: t<'a> => 'a -``` - -raise an exception if `q` is empty - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -`pop(q)` removes and returns the first element in queue `q`. - -## popUndefined - -```res sig -let popUndefined: t<'a> => Js.undefined<'a> -``` - -`popUndefined(q)` removes and returns the first element in queue `q`. it will return `undefined` if it is already empty. - -## popExn - -```res sig -let popExn: t<'a> => 'a -``` - -`popExn(q)` raise an exception if q is empty. - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -`copy(q)` returns a fresh queue. - -## size - -```res sig -let size: t<'a> => int -``` - -Returns the number of elements in a queue. - -## mapU - -```res sig -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, 'a => unit) => unit -``` - -`forEach(q, f) applies`f`in turn to all elements of`q`, from the least recently entered to the most recently entered. The queue itself is unchanged. - -## reduceU - -```res sig -let reduceU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b -``` - -## reduce - -```res sig -let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -``` - -`reduce(q, accu, f)` is equivalent to `List.reduce(l, accu, f)`, where `l` is the list of `q`'s elements. The queue remains unchanged. - -## transfer - -```res sig -let transfer: (t<'a>, t<'a>) => unit -``` - -`transfer(q1, q2)` adds all of `q1`'s elements at the end of the queue `q2`, then clears `q1`. It is equivalent to the sequence `forEach((x) => add(x, q2), q1);`; clear `q1`, but runs in constant time. - -## toArray - -```res sig -let toArray: t<'a> => array<'a> -``` - -First added will be in the beginning of the array. diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-set-int.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-set-int.mdx deleted file mode 100644 index f4fd5a6ce..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-set-int.mdx +++ /dev/null @@ -1,559 +0,0 @@ -# MutableSetInt - - - -This module is [Belt.MutableSet](mutable-set) specialized with key type to be a `int` type. -It is more efficient in general, the API is the same with [Belt.MutableSet](mutable-set) except its key type is fixed, and identity is not needed (using the built-in one). - - - -## value - -```res prelude -type value = int -``` - -The type of the set elements - -## t - -```res prelude -type t -``` - -Type of the sets. - -## make - -```res sig -let make: unit => t -``` - -Returns empty set. - -```res example -let set = Belt.MutableSet.Int.make() -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 3, 2, 4]) - -s0->Belt.MutableSet.Int.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```res sig -let copy: t => t -``` - -Returns copy of a set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 3, 2, 4]) - -let copied = s0->Belt.MutableSet.Int.copy -copied->Belt.MutableSet.Int.toArray /* [1, 2, 3, 4] */ -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.MutableSet.Int.fromArray([]) -let notEmpty = Belt.MutableSet.Int.fromArray([1]) - -Belt.MutableSet.Int.isEmpty(empty) /* true */ -Belt.MutableSet.Int.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.MutableSet.Int.fromArray([1, 4, 2, 5]) - -set->Belt.MutableSet.Int.has(3) /* false */ -set->Belt.MutableSet.Int.has(1) /* true */ -``` - -## add - -```res sig -let add: (t, value) => unit -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.Int.make() -s0->Belt.MutableSet.Int.add(1) -s0->Belt.MutableSet.Int.add(2) -s0->Belt.MutableSet.Int.add(2) - -s0->Belt.MutableSet.Int.toArray /* [1, 2] */ -``` - -## addCheck - -``` -let addCheck: (t, value) => bool; -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.MutableSet.Int.make() - -set->Belt.MutableSet.Int.mergeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.Int.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t, value) => unit -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([2, 3, 1, 4, 5]) -s0->Belt.MutableSet.Int.remove(1) -s0->Belt.MutableSet.Int.remove(3) -s0->Belt.MutableSet.Int.remove(3) - -s0->Belt.MutableSet.Int.toArray /* [2,4,5] */ -``` - -## removeCheck - -```res sig -let removeCheck: (t, value) => bool -``` - -## removeMany - -```res sig -let removeMany: (t, array) => unit -``` - -Removes each element of array from set. - -```res example -let set = Belt.MutableSet.Int.fromArray([1, 2, 3, 4]) - -set->Belt.MutableSet.Int.removeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.Int.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -let union = Belt.MutableSet.Int.union(s0, s1) -union->Belt.MutableSet.Int.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -let intersect = Belt.MutableSet.Int.intersect(s0, s1) -intersect->Belt.MutableSet.Int.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -Belt.MutableSet.Int.toArray(Belt.MutableSet.Int.diff(s0, s1)) /* [6] */ -Belt.MutableSet.Int.toArray(Belt.MutableSet.Int.diff(s1, s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.MutableSet.Int.fromArray([5, 2, 3, 1, 5, 4]) -let s2 = Belt.MutableSet.Int.intersect(s0, s1) -Belt.MutableSet.Int.subset(s2, s0) /* true */ -Belt.MutableSet.Int.subset(s2, s1) /* true */ -Belt.MutableSet.Int.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3]) -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 5]) - -Belt.MutableSet.Int.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -let acc = ref(list{}) -s0->Belt.MutableSet.Int.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -``` -let reduce: (t, 'a, ('a, value) => 'a) => 'a; -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([5, 2, 3, 5, 6]) -s0->Belt.MutableSet.Int.reduce(list{}, (acc, element) => - acc->Belt.List.add(element) -) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.Int.fromArray([2, 4, 6, 8]) -s0->Belt.MutableSet.Int.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 4, 6, 8]) -s0->Belt.MutableSet.Int.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) -let s1 = s0->Belt.MutableSet.Int.keep(isEven) - -s1->Belt.MutableSet.Int.toArray /* [2, 4] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) -let (s1, s2) = s0->Belt.MutableSet.Int.partition(isOdd) - -s1->Belt.MutableSet.Int.toArray /* [1,3,5] */ -s2->Belt.MutableSet.Int.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4]) - -s0->Belt.MutableSet.Int.size /* 4 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.minimum /* None */ -s1->Belt.MutableSet.Int.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.minUndefined /* undefined */ -s1->Belt.MutableSet.Int.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.maximum /* None */ -s1->Belt.MutableSet.Int.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.Int.make() -let s1 = Belt.MutableSet.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.MutableSet.Int.maxUndefined /* undefined */ -s1->Belt.MutableSet.Int.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) - -s0->Belt.MutableSet.Int.get(3) /* Some(3) */ -s0->Belt.MutableSet.Int.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -let s0 = Belt.MutableSet.Int.fromArray([1, 2, 3, 4, 5]) - -let ((smaller, larger), present) = s0->Belt.MutableSet.Int.split(3) - -present /* true */ -smaller->Belt.MutableSet.Int.toArray /* [1,2] */ -larger->Belt.MutableSet.Int.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-set-string.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-set-string.mdx deleted file mode 100644 index 2acd4467e..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-set-string.mdx +++ /dev/null @@ -1,561 +0,0 @@ -# MutableSetString - - - -This module is [Belt.MutableSet](mutable-set) specialized with key type to be a `string` type. -It is more efficient in general, the API is the same with [Belt.MutableSet](mutable-set) except its key type is fixed, and identity is not needed (using the built-in one) - - - -## value - -```res prelude -type value = string -``` - -The type of the set elements. - -## t - -```res prelude -type t -``` - -The type of sets. - -## make - -```res sig -let make: unit => t -``` - -Returns empty set. - -```res example -let set = Belt.MutableSet.String.make() -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange", "banana"]) - -s0->Belt.MutableSet.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```res sig -let copy: t => t -``` - -Returns copy of a set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["orange", "apple"]) - -let copied = s0->Belt.MutableSet.String.copy -copied->Belt.MutableSet.String.toArray /* ["apple", "orange"] */ -``` - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.MutableSet.String.fromArray([]) -let notEmpty = Belt.MutableSet.String.fromArray(["apple"]) - -Belt.MutableSet.String.isEmpty(empty) /* true */ -Belt.MutableSet.String.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.MutableSet.String.fromArray(["apple", "orange", "banana"]) - -set->Belt.MutableSet.String.has("strawberry") /* false */ -set->Belt.MutableSet.String.has("apple") /* true */ -``` - -## add - -```res sig -let add: (t, value) => unit -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.String.make() -s0->Belt.MutableSet.String.add("apple") -s0->Belt.MutableSet.String.add("banana") -s0->Belt.MutableSet.String.add("banana") - -s0->Belt.MutableSet.String.toArray /* ["apple", "banana"] */ -``` - -## addCheck - -```res sig -let addCheck: (t, value) => bool -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => unit -``` - -Adds each element of array to set. - -```res example -let set = Belt.MutableSet.String.make() - -set->Belt.MutableSet.String.mergeMany(["apple", "banana", "orange", "strawberry"]) -set->Belt.MutableSet.String.toArray /* ["apple", "banana", "orange", "strawberry"] */ -``` - -## remove - -```res sig -let remove: (t, value) => unit -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["orange", "banana", "apple"]) -s0->Belt.MutableSet.String.remove("apple") -s0->Belt.MutableSet.String.remove("banana") -s0->Belt.MutableSet.String.remove("banana") - -s0->Belt.MutableSet.String.toArray /* ["orange"] */ -``` - -## removeCheck - -```res sig -let removeCheck: (t, value) => bool -``` - -## removeMany - -```res sig -let removeMany: (t, array) => unit -``` - -Removes each element of array from set. - -```res example -let set = Belt.MutableSet.String.fromArray(["apple", "banana", "orange"]) - -set->Belt.MutableSet.String.removeMany(["strawberry", "apple", "banana", "orange"]) -set->Belt.MutableSet.String.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let union = Belt.MutableSet.String.union(s0, s1) -union->Belt.MutableSet.String.toArray /* ["apple", "banana", "carrot", "orange", "strawberry"] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let intersect = Belt.MutableSet.String.intersect(s0, s1) -intersect->Belt.MutableSet.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange", "strawberry"]) -Belt.MutableSet.String.toArray(Belt.MutableSet.String.diff(s0, s1)) /* ["carrot"] */ -Belt.MutableSet.String.toArray(Belt.MutableSet.String.diff(s1, s0)) /* ["strawberry"] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["5", "2", "3", "5", "6"]) -let s1 = Belt.MutableSet.String.fromArray(["5", "2", "3", "1", "5", "4"]) -let s2 = Belt.MutableSet.String.intersect(s0, s1) -Belt.MutableSet.String.subset(s2, s0) /* true */ -Belt.MutableSet.String.subset(s2, s1) /* true */ -Belt.MutableSet.String.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange"]) -let s1 = Belt.MutableSet.String.fromArray(["orange", "apple"]) - -Belt.MutableSet.String.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["banana", "orange", "apple"]) -let acc = ref(list{}) -s0->Belt.MutableSet.String.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* ["orange", "banana", "apple"] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange"]) -s0->Belt.MutableSet.String.reduce(0, (acc, element) => acc + String.length(element)) /* 11 */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let hasAtLeastFiveChars = x => String.length(x) >= 5 - -let s0 = Belt.MutableSet.String.fromArray(["apple", "carrot"]) -s0->Belt.MutableSet.String.every(hasAtLeastFiveChars) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.MutableSet.String.fromArray(["strawberry", "apple"]) -s0->Belt.MutableSet.String.some(hasFiveChars) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.MutableSet.String.fromArray(["apple", "orange", "banana"]) -let s1 = s0->Belt.MutableSet.String.keep(hasFiveChars) - -s1->Belt.MutableSet.String.toArray /* ["apple"] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.MutableSet.String.fromArray(["apple", "carrot"]) -let (s1, s2) = s0->Belt.MutableSet.String.partition(hasFiveChars) - -s1->Belt.MutableSet.String.toArray /* ["apple"] */ -s2->Belt.MutableSet.String.toArray /* ["carrot"] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple"]) - -s0->Belt.MutableSet.String.size /* 1 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "watermelon"]) - -s0->Belt.MutableSet.String.toList /* ["apple", "watermelon"] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "watermelon"]) - -s0->Belt.MutableSet.String.toArray /* ["apple", "watermelon"] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.minimum /* None */ -s1->Belt.MutableSet.String.minimum /* Some("apple") */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.minUndefined /* undefined */ -s1->Belt.MutableSet.String.minUndefined /* "apple" */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.maximum /* None */ -s1->Belt.MutableSet.String.maximum /* Some("orange") */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.MutableSet.String.make() -let s1 = Belt.MutableSet.String.fromArray(["apple", "orange"]) - -s0->Belt.MutableSet.String.maxUndefined /* undefined */ -s1->Belt.MutableSet.String.maxUndefined /* orange */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "carrot"]) - -s0->Belt.MutableSet.String.get("carrot") /* Some("carrot") */ -s0->Belt.MutableSet.String.get("watermelon") /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -let s0 = Belt.MutableSet.String.fromArray(["apple", "banana", "orange"]) - -let ((smaller, larger), present) = s0->Belt.MutableSet.String.split("banana") - -present /* true */ -smaller->Belt.MutableSet.String.toArray /* ["apple"] */ -larger->Belt.MutableSet.String.toArray /* ["orange"] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-set.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-set.mdx deleted file mode 100644 index 371f04de0..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-set.mdx +++ /dev/null @@ -1,711 +0,0 @@ -# MutableSet - - - -A **mutable** sorted set module which allows customize compare behavior. -The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map. - -It also has three specialized inner modules [Belt.MutableSet.Int](mutable-set-int) and [Belt.MutableSet.String](mutable-set-string) - This module separates data from function which is more verbose but slightly more efficient - - - -```res example -module PairComparator = Belt.Id.MakeComparable({ - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } -}) - -let mySet = Belt.MutableSet.make(~id=module(PairComparator)) -mySet->Belt.MutableSet.add((1, 2)) -``` - -## t - -```res prelude -type t<'value, 'id> -``` - -`'value` is the element type - -`'id` the identity of the collection - -## id - -```res prelude -type id<'value, 'id> = Belt_Id.comparable<'value, 'id> -``` - -The identity needed for making a set from scratch - -## make - -```res sig -let make: (~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates a new set by taking in the comparator - -## fromArray - -```res sig -let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates new set from array of elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## copy - -```res sig -let copy: t<'value, 'id> => t<'value, 'id> -``` - -Returns copy of a set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -let copied = s0->Belt.MutableSet.copy -copied->Belt.MutableSet.toArray /* [1, 2, 3, 4] */ -``` - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -Checks if set is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let empty = Belt.MutableSet.fromArray([], ~id=module(IntCmp)) -let notEmpty = Belt.MutableSet.fromArray([1], ~id=module(IntCmp)) - -Belt.MutableSet.isEmpty(empty) /* true */ -Belt.MutableSet.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t<'value, 'a>, 'value) => bool -``` - -Checks if element exists in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.fromArray([1, 4, 2, 5], ~id=module(IntCmp)) - -set->Belt.MutableSet.has(3) /* false */ -set->Belt.MutableSet.has(1) /* true */ -``` - -## add - -```res sig -let add: (t<'value, 'id>, 'value) => unit -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -s0->Belt.MutableSet.add(1) -s0->Belt.MutableSet.add(2) -s0->Belt.MutableSet.add(2) - -s0->Belt.MutableSet.toArray /* [1, 2] */ -``` - -## addCheck - -```res sig -let addCheck: (t<'value, 'id>, 'value) => bool -``` - -## mergeMany - -```res sig -let mergeMany: (t<'value, 'id>, array<'value>) => unit -``` - -Adds each element of array to set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.make(~id=module(IntCmp)) - -set->Belt.MutableSet.mergeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t<'value, 'id>, 'value) => unit -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([2, 3, 1, 4, 5], ~id=module(IntCmp)) -s0->Belt.MutableSet.remove(1) -s0->Belt.MutableSet.remove(3) -s0->Belt.MutableSet.remove(3) - -s0->Belt.MutableSet.toArray /* [2,4,5] */ -``` - -## removeCheck - -```res sig -let removeCheck: (t<'value, 'id>, 'value) => bool -``` - -## removeMany - -```res sig -let removeMany: (t<'value, 'id>, array<'value>) => unit -``` - -Removes each element of array from set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp)) - -set->Belt.MutableSet.removeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.toArray /* [] */ -``` - -## union - -```res sig -let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns union of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let union = Belt.MutableSet.union(s0, s1) -union->Belt.MutableSet.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns intersection of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let intersect = Belt.MutableSet.intersect(s0, s1) -intersect->Belt.MutableSet.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns elements from first set, not existing in second set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -Belt.MutableSet.toArray(Belt.MutableSet.diff(s0, s1)) /* [6] */ -Belt.MutableSet.toArray(Belt.MutableSet.diff(s1, s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if second set is subset of first set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let s2 = Belt.MutableSet.intersect(s0, s1) -Belt.MutableSet.subset(s2, s0) /* true */ -Belt.MutableSet.subset(s2, s1) /* true */ -Belt.MutableSet.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t<'value, 'id>, t<'value, 'id>) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if two sets are equal. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 5], ~id=module(IntCmp)) - -Belt.MutableSet.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'value, 'id>, 'value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let acc = ref(list{}) -s0->Belt.MutableSet.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -s0->Belt.MutableSet.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## every - -```res sig -let every: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.fromArray([2, 4, 6, 8], ~id=module(IntCmp)) -s0->Belt.MutableSet.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## some - -```res sig -let some: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 4, 6, 8], ~id=module(IntCmp)) -s0->Belt.MutableSet.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> -``` - -## keep - -```res sig -let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) -let s1 = s0->Belt.MutableSet.keep(isEven) - -s1->Belt.MutableSet.toArray /* [2, 4] */ -``` - -## partitionU - -```res sig -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -## partition - -```res sig -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) -let (s1, s2) = s0->Belt.MutableSet.partition(isOdd) - -s1->Belt.MutableSet.toArray /* [1,3,5] */ -s2->Belt.MutableSet.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t<'value, 'id> => int -``` - -Returns size of the set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp)) - -s0->Belt.MutableSet.size /* 4 */ -``` - -## toList - -```res sig -let toList: t<'value, 'id> => list<'value> -``` - -Returns list of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t<'value, 'id> => array<'value> -``` - -Returns array of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t<'value, 'id> => option<'value> -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.minimum /* None */ -s1->Belt.MutableSet.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.minUndefined /* undefined */ -s1->Belt.MutableSet.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t<'value, 'id> => option<'value> -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.maximum /* None */ -s1->Belt.MutableSet.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.maxUndefined /* undefined */ -s1->Belt.MutableSet.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t<'value, 'id>, 'value) => option<'value> -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.get(3) /* Some(3) */ -s0->Belt.MutableSet.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t<'value, 'id>, 'value) => 'value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) - -let ((smaller, larger), present) = s0->Belt.MutableSet.split(3) - -present /* true */ -smaller->Belt.MutableSet.toArray /* [1,2] */ -larger->Belt.MutableSet.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b> => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v9.0.0/api/belt/mutable-stack.mdx b/pages/docs/manual/v9.0.0/api/belt/mutable-stack.mdx deleted file mode 100644 index d8c51f494..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/mutable-stack.mdx +++ /dev/null @@ -1,105 +0,0 @@ -# MutableStack - - - -First in last out stack. This module implements stacks, with in-place modification. - - - -## t - -```res prelude -type t<'a> -``` - -## make - -```res sig -let make: unit => t<'a> -``` - -Returns a new stack, initially empty. - -## clear - -```res sig -let clear: t<'a> => unit -``` - -Discard all elements from the stack. - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -`copy(x)` O(1) operation, return a new stack. - -## push - -```res sig -let push: (t<'a>, 'a) => unit -``` - -## popUndefined - -```res sig -let popUndefined: t<'a> => Js.undefined<'a> -``` - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -## topUndefined - -```res sig -let topUndefined: t<'a> => Js.undefined<'a> -``` - -## top - -```res sig -let top: t<'a> => option<'a> -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## size - -```res sig -let size: t<'a> => int -``` - -## forEachU - -```res sig -let forEachU: (t<'a>, (. 'a) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (t<'a>, 'a => unit) => unit -``` - -## dynamicPopIterU - -```res sig -let dynamicPopIterU: (t<'a>, (. 'a) => unit) => unit -``` - -## dynamicPopIter - -```res sig -let dynamicPopIter: (t<'a>, 'a => unit) => unit -``` - -`dynamicPopIter(s, f)` apply `f` to each element of `s`. The item is poped before applying `f`, `s` will be empty after this opeartion. This function is useful for worklist algorithm. diff --git a/pages/docs/manual/v9.0.0/api/belt/option.mdx b/pages/docs/manual/v9.0.0/api/belt/option.mdx deleted file mode 100644 index 7cd48cca4..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/option.mdx +++ /dev/null @@ -1,256 +0,0 @@ -# Option - - - -In Belt we represent the existence and nonexistence of a value by wrapping it -with the `option` type. In order to make it a bit more convenient to work with -option-types, Belt provides utility-functions for it. - -The `option` type is a part of the Reason / OCaml standard library which is defined like this: - - - -```res sig -type option<'a> = None | Some('a) -``` - -```res example -let someString: option = Some("hello") -``` - -## getExn - -```res sig -let getExn: option<'a> => 'a -``` - -Raises an Error in case `None` is provided. Use with care. - -```res example -Belt.Option.getExn(Some(3)) /* 3 */ - -Belt.Option.getExn(None) /* Raises an Error */ -``` - -## mapWithDefault - -```res sig -let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b -``` - -If `optionValue` is of `Some(value)`, -this function returns that value applied with `f`, in other words `f(value)`. - -If `optionValue` is `None`, the default is returned. - -```res example -let someValue = Some(3) -someValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 8 */ - -let noneValue = None -noneValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 0 */ -``` - -## mapWithDefaultU - -```res sig -let mapWithDefaultU: (option<'a>, 'b, (. 'a) => 'b) => 'b -``` - -Uncurried version of [mapWithDefault](#mapWithDefault). - -## map - -```res sig -let map: (option<'a>, 'a => 'b) => option<'b> -``` - -If `optionValue` is `Some(value)` this returns `f(value)`, otherwise it returns `None`. - -```res example -Belt.Option.map(Some(3), x => x * x) /* Some(9) */ - -Belt.Option.map(None, x => x * x) /* None */ -``` - -## mapU - -```res sig -let mapU: (option<'a>, (. 'a) => 'b) => option<'b> -``` - -Uncurried version of [map](#map). - -## flatMap - -```res sig -let flatMap: (option<'a>, 'a => option<'b>) => option<'b> -``` - -If `optionValue` is `Some(value)`, returns `f(value)`, otherwise returns -`None`.
-The function `f` must have a return type of `option<'b>`. - -```res example -let addIfAboveOne = value => - if (value > 1) { - Some(value + 1) - } else { - None - } - -Belt.Option.flatMap(Some(2), addIfAboveOne) /* Some(3) */ - -Belt.Option.flatMap(Some(-4), addIfAboveOne) /* None */ - -Belt.Option.flatMap(None, addIfAboveOne) /* None */ -``` - -## flatMapU - -```res sig -let flatMapU: (option<'a>, (. 'a) => option<'b>) => option<'b> -``` - -Uncurried version of flatMap. - -## getWithDefault - -```res sig -let getWithDefault: (option<'a>, 'a) => 'a -``` - -If `optionalValue` is `Some(value)`, returns `value`, otherwise default. - -```res example -Belt.Option.getWithDefault(None, "Banana") /* Banana */ - -Belt.Option.getWithDefault(Some("Apple"), "Banana") /* Apple */ -``` - -```res example -let greet = (firstName: option) => - "Greetings " ++ firstName->Belt.Option.getWithDefault("Anonymous") - -Some("Jane")->greet /* "Greetings Jane" */ - -None->greet /* "Greetings Anonymous" */ -``` - -```res example -Belt.Option.getWithDefault(Some(1812), 1066) /* 1812 */ - -Belt.Option.getWithDefault(None, 1066) /* 1066 */ -``` - -## isSome - -```res sig -let isSome: option<'a> => bool -``` - -Returns `true` if the argument is `Some(value)`, `false` otherwise. - -```res example -Belt.Option.isSome(None) /* false */ - -Belt.Option.isSome(Some(1)) /* true */ -``` - -## isNone - -```res sig -let isNone: option<'a> => bool -``` - -Returns `true` if the argument is `None`, `false` otherwise. - -```res example -Belt.Option.isNone(None) /* true */ - -Belt.Option.isNone(Some(1)) /* false */ -``` - -## eq - -```res sig -let eq: (option<'a>, option<'b>, ('a, 'b) => bool) => bool -``` - -Evaluates two optional values for equality with respect to a predicate -function. If both `optValue1` and `optValue2` are `None`, returns `true`. -If one of the arguments is `Some(value)` and the other is `None`, returns -`false`. - -If arguments are `Some(value1)` and `Some(value2)`, returns the result of -`predicate(value1, value2)`; the predicate function must return a bool. - -```res example -let clockEqual = (a, b) => mod(a, 12) == mod(b, 12) - -open Belt.Option - -eq(Some(3), Some(15), clockEqual) /* true */ - -eq(Some(3), None, clockEqual) /* false */ - -eq(None, Some(3), clockEqual) /* false */ - -eq(None, None, clockEqual) /* true */ -``` - -## eqU - -```res sig -let eqU: (option<'a>, option<'b>, (.'a, 'b) => bool) => bool -``` - -Uncurried version of [eq](#eq). - -## cmp - -```res sig -let cmp: (option<'a>, option<'b>, ('a, 'b) => int) => int -``` - -`cmp(optValue1, optValue2, comparisonFunction)` compares two optional values -with respect to given `comparisonFunction`. - -If both `optValue1` and `optValue2` are `None`, it returns `0`. - -If the first argument is `Some(value1)` and the second is `None`, returns `1` -(something is greater than nothing). - -If the first argument is `None` and the second is `Some(value2)`, returns `-1` -(nothing is less than something). - -If the arguments are `Some(value1)` and `Some(value2)`, returns the result of -`comparisonFunction(value1, value2)`; comparisonFunction takes two arguments -and returns `-1` if the first argument is less than the second, `0` if the -arguments are equal, and `1` if the first argument is greater than the second. - -```res example -let clockCompare = (a, b) => compare(mod(a, 12), mod(b, 12)) - -open Belt.Option - -cmp(Some(3), Some(15), clockCompare) /* 0 */ - -cmp(Some(3), Some(14), clockCompare) /* 1 */ - -cmp(Some(2), Some(15), clockCompare) /* (-1) */ - -cmp(None, Some(15), clockCompare) /* (-1) */ - -cmp(Some(14), None, clockCompare) /* 1 */ - -cmp(None, None, clockCompare) /* 0 */ -``` - -## cmpU - -```res sig -let cmpU: (option<'a>, option<'b>, ((.'a, 'b) => int)) => int -``` - -Uncurried version of [cmp](#cmp). diff --git a/pages/docs/manual/v9.0.0/api/belt/range.mdx b/pages/docs/manual/v9.0.0/api/belt/range.mdx deleted file mode 100644 index d4e50bb87..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/range.mdx +++ /dev/null @@ -1,130 +0,0 @@ -# Range - - - -A small utility module to provide inclusive range operations for `[start, -finish]`. Internally it is relying on loops instead of creating new arrays, -which makes it pretty performant and memory friendly. - - - -## forEachU - -```res sig -let forEachU: (int, int, (. int) => unit) => unit -``` - -## forEach - -```res sig -let forEach: (int, int, int => unit) => unit -``` - -`forEach(start, finish, action)` - -equivalent to `Belt.Array.(forEach(range(start, finish), action))` - -```res example -Belt.Range.forEach(0, 4, (i) => Js.log(i)) - -/** - * prints: - * 0 - * 1 - * 2 - * 3 - * 4 - */ -``` - -## everyU - -```res sig -let everyU: (int, int, (. int) => bool) => bool -``` - -## every - -```res sig -let every: (int, int, int => bool) => bool -``` - -`every(start, finish, p)` - -equivalent to `Belt.Array.(every(range(start, finish), p))` - -```res example -Belt.Range.every(0, 4, (i) => i < 5) /* true */ - -Belt.Range.every(0, 4, (i) => i < 4) /* false */ -``` - -## everyByU - -```res sig -let everyByU: (int, int, ~step: int, (. int) => bool) => bool -``` - -## everyBy - -```res sig -let everyBy: (int, int, ~step: int, int => bool) => bool -``` - -`everyBy(start, finish, ~step, p)` - -See `Belt_Array.rangeBy` - -equivalent to `Belt.Array.(every(rangeBy(start, finish, ~step), p))` - -```res example -Belt.Range.everyBy(0, 4, ~step=1, (i) => mod(i, 2) === 0) /* false */ - -Belt.Range.everyBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */ -``` - -## someU - -```res sig -let someU: (int, int, (. int) => bool) => bool -``` - -## some - -```res sig -let some: (int, int, int => bool) => bool -``` - -`some(start, finish, p)` - -equivalent to `Belt.Array.(some(range(start, finish), p))` - -```res example -Belt.Range.some(0, 4, (i) => i > 5) /* false */ - -Belt.Range.some(0, 4, (i) => i > 2) /* true */ -``` - -## someByU - -```res sig -let someByU: (int, int, ~step: int, (. int) => bool) => bool -``` - -## someBy - -```res sig -let someBy: (int, int, ~step: int, int => bool) => bool -``` - -`someBy(start, finish, ~step, p)` - -See `Belt_Array.rangeBy` - -equivalent to `Belt.Array.(some(rangeBy(start, finish, ~step), p))` - -```res example -Belt.Range.someBy(1, 5, ~step=2, (i) => mod(i, 2) === 0) /* false */ - -Belt.Range.someBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */ -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/result.mdx b/pages/docs/manual/v9.0.0/api/belt/result.mdx deleted file mode 100644 index b2d12472b..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/result.mdx +++ /dev/null @@ -1,242 +0,0 @@ -# Result - - - -Result types are really useful to describe the result of a certain operation -without relying on exceptions or `option` types. - -This module gives you useful utilities to create and combine `Result` data. - - - -## t - -```res prelude -type t<'a, 'b> = - | Ok('a) - | Error('b) -``` - -The type `Result.t(result, err)` describes a variant of two states: -`Ok(someResult)` represents a successful operation, whereby -``Error(someError)` signals an erronous operation. - -In this concrete example, we are defining our own `Result` type to reflect an HTTP like -query operation: - -```res example -type responseError = NotAvailable | NotFound -type queryResult = t - -let failQueryUser = (username: string): queryResult => { - Error(NotAvailable) -} -``` - -## getExn - -```res sig -let getExn: t<'a, 'b> => 'a -``` - -`getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception - -```res example -Belt.Result.getExn(Belt.Result.Ok(42)) == 42 - -Belt.Result.getExn(Belt.Result.Error("Invalid data")) /* raises exception */ -``` - -## mapWithDefaultU - -```res sig -let mapWithDefaultU: (t<'a, 'c>, 'b, (. 'a) => 'b) => 'b -``` - -## mapWithDefault - -```res sig -let mapWithDefault: (t<'a, 'c>, 'b, 'a => 'b) => 'b -``` - -`mapWithDefault(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, -otherwise `default`. - -```res example -let ok = Belt.Result.Ok(42) -Belt.Result.mapWithDefault(ok, 0, (x) => x / 2) == 21 - -let error = Belt.Result.Error("Invalid data") -Belt.Result.mapWithDefault(error, 0, (x) => x / 2) == 0 -``` - -## mapU - -```res sig -let mapU: (t<'a, 'c>, (. 'a) => 'b) => t<'b, 'c> -``` - -## map - -```res sig -let map: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> -``` - -`map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res -unchanged. Function `f` takes a value of the same type as `n` and returns an -ordinary value. - -```res example -let f = (x) => sqrt(Belt.Int.toFloat(x)) - -Belt.Result.map(Ok(64), f) == Ok(8.0) - -Belt.Result.map(Error("Invalid data"), f) == Error("Invalid data") -``` - -## flatMapU - -```res sig -let flatMapU: (t<'a, 'c>, (. 'a) => t<'b, 'c>) => t<'b, 'c> -``` - -## flatMap - -```res sig -let flatMap: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c> -``` - -`flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res -unchanged. Function `f` takes a value of the same type as `n` and returns a -`Belt.Result`. - -```res example -let recip = (x) => - if (x !== 0.0) { - Belt.Result.Ok(1.0 /. x) - } else { - Belt.Result.Error("Divide by zero") - } - -Belt.Result.flatMap(Ok(2.0), recip) == Ok(0.5) - -Belt.Result.flatMap(Ok(0.0), recip) == Error("Divide by zero") - -Belt.Result.flatMap(Error("Already bad"), recip) == Error("Already bad") -``` - -## getWithDefault - -```res sig -let getWithDefault: (t<'a, 'b>, 'a) => 'a -``` - -`getWithDefault(res, defaultValue)`: If `res` is `Ok(n)`, returns `n`, -otherwise `default` - -```res example -Belt.Result.getWithDefault(Ok(42), 0) == 42 - -Belt.Result.getWithDefault(Error("Invalid Data"), 0) == 0 -``` - -## isOk - -```res sig -let isOk: t<'a, 'b> => bool -``` - -`isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is -the `Error(e)` variant. - -## isError - -```res sig -let isError: t<'a, 'b> => bool -``` - -`isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if -it is the `Ok(n)` variant. - -## eqU - -```res sig -let eqU: (t<'a, 'c>, t<'b, 'd>, (. 'a, 'b) => bool) => bool -``` - -## eq - -```res sig -let eq: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool -``` - -`eq(res1, res2, f)`: Determine if two `Belt.Result` variables are equal with -respect to an equality function. If `res1` and `res2` are of the form `Ok(n)` -and `Ok(m)`, return the result of `f(n, m)`. If one of `res1` and `res2` are of -the form `Error(e)`, return false If both `res1` and `res2` are of the form -`Error(e)`, return true - -```res example -let good1 = Belt.Result.Ok(42) - -let good2 = Belt.Result.Ok(32) - -let bad1 = Belt.Result.Error("invalid") - -let bad2 = Belt.Result.Error("really invalid") - -let mod10equal = (a, b) => mod(a, 10) === mod(b, 10) - -Belt.Result.eq(good1, good2, mod10equal) == true - -Belt.Result.eq(good1, bad1, mod10equal) == false - -Belt.Result.eq(bad2, good2, mod10equal) == false - -Belt.Result.eq(bad1, bad2, mod10equal) == true -``` - -## cmpU - -```res sig -let cmpU: (t<'a, 'c>, t<'b, 'd>, (. 'a, 'b) => int) => int -``` - -## cmp - -```res sig -let cmp: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => int) => int -``` - -`cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a -comparison function. The comparison function returns -1 if the first variable -is "less than" the second, 0 if the two variables are equal, and 1 if the first -is "greater than" the second. - -If `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of -`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`, -return -1 (nothing is less than something) If `res1` is of the form `Ok(n)` and -`res2` of the form `Error(e)`, return 1 (something is greater than nothing) If -both `res1` and `res2` are of the form `Error(e)`, return 0 (equal) - -```res example -let good1 = Belt.Result.Ok(59) - -let good2 = Belt.Result.Ok(37) - -let bad1 = Belt.Result.Error("invalid") - -let bad2 = Belt.Result.Error("really invalid") - -let mod10cmp = (a, b) => Pervasives.compare(mod(a, 10), mod(b, 10)) - -Belt.Result.cmp(Ok(39), Ok(57), mod10cmp) == 1 - -Belt.Result.cmp(Ok(57), Ok(39), mod10cmp) == (-1) - -Belt.Result.cmp(Ok(39), Error("y"), mod10cmp) == 1 - -Belt.Result.cmp(Error("x"), Ok(57), mod10cmp) == (-1) - -Belt.Result.cmp(Error("x"), Error("y"), mod10cmp) == 0 -``` diff --git a/pages/docs/manual/v9.0.0/api/belt/set-dict.mdx b/pages/docs/manual/v9.0.0/api/belt/set-dict.mdx deleted file mode 100644 index b1d87ef72..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/set-dict.mdx +++ /dev/null @@ -1,679 +0,0 @@ -# SetDict - - - -This module separates identity from data, it is a bit more verbose but slightly more efficient due to the fact that there is no need to pack identity and data back after each operation - - - -## t - -```res prelude -type t<'value, 'identity> -``` - -`'value` is the element type - -`'identity` the identity of the collection - -## cmp - -```res prelude -type cmp<'value, 'id> = Belt.Id.cmp<'value, 'id> -``` - -Type of compare function. - -## empty - -```res sig -let empty: t<'value, 'id> -``` - -```res example -let s0 = Belt.Set.Dict.empty -``` - -## fromArray - -```res sig -let fromArray: (array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Creates new set from array of elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 3, 2, 4], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array<'value> => t<'value, 'id> -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -Checks if set is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let empty = Belt.Set.Dict.fromArray([], ~cmp=IntCmp.cmp) -let notEmpty = Belt.Set.Dict.fromArray([1], ~cmp=IntCmp.cmp) - -Belt.Set.Dict.isEmpty(empty) /* true */ -Belt.Set.Dict.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => bool -``` - -Checks if element exists in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.fromArray([1, 4, 2, 5], ~cmp=IntCmp.cmp) - -set->Belt.Set.Dict.has(3) /* false */ -set->Belt.Set.Dict.has(1) /* true */ -``` - -## add - -```res sig -let add: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = s0->Belt.Set.Dict.add(1, ~cmp=IntCmp.cmp) -let s2 = s1->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp) -let s3 = s2->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.toArray /* [] */ -s1->Belt.Set.Dict.toArray /* [1] */ -s2->Belt.Set.Dict.toArray /* [1, 2] */ -s3->Belt.Set.Dict.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t<'value, 'id>, array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.empty - -let newSet = set->Belt.Set.Dict.mergeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp) -newSet->Belt.Set.Dict.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([2, 3, 1, 4, 5], ~cmp=IntCmp.cmp) -let s1 = s0->Belt.Set.Dict.remove(1, ~cmp=IntCmp.cmp) -let s2 = s1->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp) -let s3 = s2->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp) - -s1->Belt.Set.Dict.toArray /* [2,3,4,5] */ -s2->Belt.Set.Dict.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t<'value, 'id>, array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp) - -let newSet = set->Belt.Set.Dict.removeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp) -newSet->Belt.Set.Dict.toArray /* [] */ -``` - -## union - -```res sig -let union: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Returns union of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let union = Belt.Set.Dict.union(s0, s1, ~cmp=IntCmp.cmp) -union->Belt.Set.Dict.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Returns intersection of two sets. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let intersect = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp) -intersect->Belt.Set.Dict.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> -``` - -Returns elements from first set, not existing in second set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) - -let diff1 = Belt.Set.Dict.diff(s0, s1, ~cmp=IntCmp.cmp) -let diff2 = Belt.Set.Dict.diff(s1, s0, ~cmp=IntCmp.cmp) - -diff1->Belt.Set.Dict.toArray /* [6] */ -diff2->Belt.Set.Dict.toArray /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => bool -``` - -Checks if second set is subset of first set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let s2 = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp) -Belt.Set.Dict.subset(s2, s0, ~cmp=IntCmp.cmp) /* true */ -Belt.Set.Dict.subset(s2, s1, ~cmp=IntCmp.cmp) /* true */ -Belt.Set.Dict.subset(s1, s0, ~cmp=IntCmp.cmp) /* false */ -``` - -## cmp - -```res sig -let cmp: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => bool -``` - -Checks if two sets are equal. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([3, 2, 5], ~cmp=IntCmp.cmp) - -Belt.Set.Dict.eq(s0, s1, ~cmp=IntCmp.cmp) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'value, 'id>, 'value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let acc = ref(list{}) -s0->Belt.Set.Dict.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## every - -```res sig -let every: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Dict.fromArray([2, 4, 6, 8], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## some - -```res sig -let some: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 4, 6, 8], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> -``` - -## keep - -```res sig -let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) -let s1 = s0->Belt.Set.Dict.keep(isEven) - -s1->Belt.Set.Dict.toArray /* [2,4] */ -``` - -## partitionU - -```res sig -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -## partition - -```res sig -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) -let (s1, s2) = s0->Belt.Set.Dict.partition(isOdd) - -s1->Belt.Set.Dict.toArray /* [1,3,5] */ -s2->Belt.Set.Dict.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t<'value, 'id> => int -``` - -Returns size of the set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.size /* 4 */ -``` - -## toList - -```res sig -let toList: t<'value, 'id> => list<'value> -``` - -Returns list of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t<'value, 'id> => array<'value> -``` - -Returns array of ordered set elements. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t<'value, 'id> => option<'value> -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.minimum /* None */ -s1->Belt.Set.Dict.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.minUndefined /* undefined */ -s1->Belt.Set.Dict.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t<'value, 'id> => option<'value> -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.maximum /* None */ -s1->Belt.Set.Dict.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.maxUndefined /* undefined */ -s1->Belt.Set.Dict.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => option<'value> -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.get(3, ~cmp=IntCmp.cmp) /* Some(3) */ -s0->Belt.Set.Dict.get(20, ~cmp=IntCmp.cmp) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => Js.undefined<'value> -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => 'value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: ( - t<'value, 'id>, - 'value, - ~cmp: cmp<'value, 'id>, -) => ((t<'value, 'id>, t<'value, 'id>), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) - -let ((smaller, larger), present) = s0->Belt.Set.Dict.split(3, ~cmp=IntCmp.cmp) - -present /* true */ -smaller->Belt.Set.Dict.toArray /* [1,2] */ -larger->Belt.Set.Dict.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t<'a, 'b> => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v9.0.0/api/belt/set-int.mdx b/pages/docs/manual/v9.0.0/api/belt/set-int.mdx deleted file mode 100644 index 994a45772..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/set-int.mdx +++ /dev/null @@ -1,536 +0,0 @@ -# SetInt - - - -Specalized when value type is `int`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison. - - - -## value - -```res prelude -type value = int -``` - -The type of the set elements. - -## t - -```res prelude -type t -``` - -Type of the sets. - -## empty - -```res sig -let empty: t -``` - -Empty set - -```res example -let s0 = Belt.Set.Int.empty -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 3, 2, 4]) - -s0->Belt.Set.Int.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.Set.Int.fromArray([]) -let notEmpty = Belt.Set.Int.fromArray([1]) - -Belt.Set.Int.isEmpty(empty) /* true */ -Belt.Set.Int.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.Set.Int.fromArray([1, 4, 2, 5]) - -set->Belt.Set.Int.has(3) /* false */ -set->Belt.Set.Int.has(1) /* true */ -``` - -## add - -```res sig -let add: (t, value) => t -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = s0->Belt.Set.Int.add(1) -let s2 = s1->Belt.Set.Int.add(2) -let s3 = s2->Belt.Set.Int.add(2) -s0->Belt.Set.Int.toArray /* [] */ -s1->Belt.Set.Int.toArray /* [1] */ -s2->Belt.Set.Int.toArray /* [1, 2] */ -s3->Belt.Set.Int.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => t -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.Set.Int.empty - -let newSet = set->Belt.Set.Int.mergeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.Int.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t, value) => t -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.Int.fromArray([2, 3, 1, 4, 5]) -let s1 = s0->Belt.Set.Int.remove(1) -let s2 = s1->Belt.Set.Int.remove(3) -let s3 = s2->Belt.Set.Int.remove(3) - -s1->Belt.Set.Int.toArray /* [2,3,4,5] */ -s2->Belt.Set.Int.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t, array) => t -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -let set = Belt.Set.Int.fromArray([1, 2, 3, 4]) - -let newSet = set->Belt.Set.Int.removeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.Int.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -let union = Belt.Set.Int.union(s0, s1) -union->Belt.Set.Int.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -let intersect = Belt.Set.Int.intersect(s0, s1) -intersect->Belt.Set.Int.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -Belt.Set.Int.toArray(Belt.Set.Int.diff(s0, s1)) /* [6] */ -Belt.Set.Int.toArray(Belt.Set.Int.diff(s1, s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let s1 = Belt.Set.Int.fromArray([5, 2, 3, 1, 5, 4]) -let s2 = Belt.Set.Int.intersect(s0, s1) -Belt.Set.Int.subset(s2, s0) /* true */ -Belt.Set.Int.subset(s2, s1) /* true */ -Belt.Set.Int.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3]) -let s1 = Belt.Set.Int.fromArray([3, 2, 5]) - -Belt.Set.Int.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -let acc = ref(list{}) -s0->Belt.Set.Int.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.Set.Int.fromArray([5, 2, 3, 5, 6]) -s0->Belt.Set.Int.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Int.fromArray([2, 4, 6, 8]) -s0->Belt.Set.Int.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Int.fromArray([1, 2, 4, 6, 8]) -s0->Belt.Set.Int.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) -let s1 = s0->Belt.Set.Int.keep(isEven) - -s1->Belt.Set.Int.toArray /* [2,4] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) -let (s1, s2) = s0->Belt.Set.Int.partition(isOdd) - -s1->Belt.Set.Int.toArray /* [1,3,5] */ -s2->Belt.Set.Int.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4]) - -s0->Belt.Set.Int.size /* 4 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.toList /* [1,2,3,5] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.toArray /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.minimum /* None */ -s1->Belt.Set.Int.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.minUndefined /* undefined */ -s1->Belt.Set.Int.minUndefined /* 1 */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.maximum /* None */ -s1->Belt.Set.Int.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.Int.empty -let s1 = Belt.Set.Int.fromArray([3, 2, 1, 5]) - -s0->Belt.Set.Int.maxUndefined /* undefined */ -s1->Belt.Set.Int.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) - -s0->Belt.Set.Int.get(3) /* Some(3) */ -s0->Belt.Set.Int.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a tuple `((l, r), present)`, where `l` is the set of elements of set that are strictly less than value, `r` is the set of elements of set that are strictly greater than value, `present` is `false` if set contains no element equal to value, or `true` if set contains an element equal to value. - -```res example -let s0 = Belt.Set.Int.fromArray([1, 2, 3, 4, 5]) - -let ((smaller, larger), present) = s0->Belt.Set.Int.split(3) - -present /* true */ -smaller->Belt.Set.Int.toArray /* [1,2] */ -larger->Belt.Set.Int.toArray /* [4,5] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v9.0.0/api/belt/set-string.mdx b/pages/docs/manual/v9.0.0/api/belt/set-string.mdx deleted file mode 100644 index 1e2815f61..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/set-string.mdx +++ /dev/null @@ -1,537 +0,0 @@ -# SetString - - - -Specalized when value type is `string`, more efficient than the generic type, its compare behavior is fixed using the built-in comparison. - - - -## value - -```res prelude -type value = string -``` - -The type of the set elements. - -## t - -```res prelude -type t -``` - -The type of sets. - -## empty - -```res sig -let empty: t -``` - -Empty set - -```res example -let s0 = Belt.Set.String.empty -``` - -## fromArray - -```res sig -let fromArray: array => t -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "orange", "banana"]) - -s0->Belt.Set.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: array => t -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.Set.String.fromArray([]) -let notEmpty = Belt.Set.String.fromArray(["apple"]) - -Belt.Set.String.isEmpty(empty) /* true */ -Belt.Set.String.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t, value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.Set.String.fromArray(["apple", "orange", "banana"]) - -set->Belt.Set.String.has("strawberry") /* false */ -set->Belt.Set.String.has("apple") /* true */ -``` - -## add - -```res sig -let add: (t, value) => t -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.String.empty -let s1 = s0->Belt.Set.String.add("apple") -let s2 = s1->Belt.Set.String.add("banana") -let s3 = s2->Belt.Set.String.add("banana") -s0->Belt.Set.String.toArray /* [] */ -s1->Belt.Set.String.toArray /* ["apple"] */ -s2->Belt.Set.String.toArray /* ["apple", "banana"] */ -s3->Belt.Set.String.toArray /* ["apple", "banana"] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t, array) => t -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.Set.String.empty - -let newSet = set->Belt.Set.String.mergeMany(["apple", "banana", "orange", "strawberry"]) - -newSet->Belt.Set.String.toArray /* ["apple", "banana", "orange", "strawberry"] */ -``` - -## remove - -```res sig -let remove: (t, value) => t -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.String.fromArray(["orange", "banana", "apple"]) -let s1 = s0->Belt.Set.String.remove("apple") -let s2 = s1->Belt.Set.String.remove("banana") -let s3 = s2->Belt.Set.String.remove("banana") - -s1->Belt.Set.String.toArray /* ["orange", "banana"] */ -s2->Belt.Set.String.toArray /* ["orange"] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t, array) => t -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -let set = Belt.Set.String.fromArray(["apple", "banana", "orange"]) - -let newSet = set->Belt.Set.String.removeMany(["strawberry", "apple", "banana", "orange"]) -newSet->Belt.Set.String.toArray /* [] */ -``` - -## union - -```res sig -let union: (t, t) => t -``` - -Returns union of two sets. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.Set.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let union = Belt.Set.String.union(s0, s1) -union->Belt.Set.String.toArray /* ["apple", "banana", "carrot", "orange", "strawberry"] */ -``` - -## intersect - -```res sig -let intersect: (t, t) => t -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.Set.String.fromArray(["apple", "banana", "orange", "strawberry"]) -let intersect = Belt.Set.String.intersect(s0, s1) -intersect->Belt.Set.String.toArray /* ["apple", "banana", "orange"] */ -``` - -## diff - -```res sig -let diff: (t, t) => t -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange", "carrot"]) -let s1 = Belt.Set.String.fromArray(["apple", "banana", "orange", "strawberry"]) -Belt.Set.String.toArray(Belt.Set.String.diff(s0, s1)) /* ["carrot"] */ -Belt.Set.String.toArray(Belt.Set.String.diff(s1, s0)) /* ["strawberry"] */ -``` - -## subset - -```res sig -let subset: (t, t) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.Set.String.fromArray(["5", "2", "3", "5", "6"]) -let s1 = Belt.Set.String.fromArray(["5", "2", "3", "1", "5", "4"]) -let s2 = Belt.Set.String.intersect(s0, s1) -Belt.Set.String.subset(s2, s0) /* true */ -Belt.Set.String.subset(s2, s1) /* true */ -Belt.Set.String.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t, t) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t, t) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "orange"]) -let s1 = Belt.Set.String.fromArray(["orange", "apple"]) - -Belt.Set.String.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t, (. value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t, value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.Set.String.fromArray(["banana", "orange", "apple"]) -let acc = ref(list{}) -s0->Belt.Set.String.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* ["orange", "banana", "apple"] */ -``` - -## reduceU - -```res sig -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t, 'a, ('a, value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "orange"]) -s0->Belt.Set.String.reduce(0, (acc, element) => acc + String.length(element)) /* 11 */ -``` - -## everyU - -```res sig -let everyU: (t, (. value) => bool) => bool -``` - -## every - -```res sig -let every: (t, value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let hasAtLeastFiveChars = x => String.length(x) >= 5 - -let s0 = Belt.Set.String.fromArray(["apple", "carrot"]) -s0->Belt.Set.String.every(hasAtLeastFiveChars) /* true */ -``` - -## someU - -```res sig -let someU: (t, (. value) => bool) => bool -``` - -## some - -```res sig -let some: (t, value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.Set.String.fromArray(["strawberry", "apple"]) -s0->Belt.Set.String.some(hasFiveChars) /* true */ -``` - -## keepU - -```res sig -let keepU: (t, (. value) => bool) => t -``` - -## keep - -```res sig -let keep: (t, value => bool) => t -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.Set.String.fromArray(["apple", "orange", "banana"]) -let s1 = s0->Belt.Set.String.keep(hasFiveChars) - -s1->Belt.Set.String.toArray /* ["apple"] */ -``` - -## partitionU - -```res sig -let partitionU: (t, (. value) => bool) => (t, t) -``` - -## partition - -```res sig -let partition: (t, value => bool) => (t, t) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let hasFiveChars = x => String.length(x) == 5 - -let s0 = Belt.Set.String.fromArray(["apple", "carrot"]) -let (s1, s2) = s0->Belt.Set.String.partition(hasFiveChars) - -s1->Belt.Set.String.toArray /* ["apple"] */ -s2->Belt.Set.String.toArray /* ["carrot"] */ -``` - -## size - -```res sig -let size: t => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.Set.String.fromArray(["apple"]) - -s0->Belt.Set.String.size /* 1 */ -``` - -## toList - -```res sig -let toList: t => list -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "watermelon"]) - -s0->Belt.Set.String.toList /* ["apple", "watermelon"] */ -``` - -## toArray - -```res sig -let toArray: t => array -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "watermelon"]) - -s0->Belt.Set.String.toArray /* ["apple", "watermelon"] */ -``` - -## minimum - -```res sig -let minimum: t => option -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.minimum /* None */ -s1->Belt.Set.String.minimum /* Some("apple") */ -``` - -## minUndefined - -```res sig -let minUndefined: t => Js.undefined -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.minUndefined /* undefined */ -s1->Belt.Set.String.minUndefined /* "apple" */ -``` - -## maximum - -```res sig -let maximum: t => option -``` - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.maximum /* None */ -s1->Belt.Set.String.maximum /* Some("orange") */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t => Js.undefined -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.String.empty -let s1 = Belt.Set.String.fromArray(["apple", "orange"]) - -s0->Belt.Set.String.maxUndefined /* undefined */ -s1->Belt.Set.String.maxUndefined /* orange */ -``` - -## get - -```res sig -let get: (t, value) => option -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "carrot"]) - -s0->Belt.Set.String.get("carrot") /* Some("carrot") */ -s0->Belt.Set.String.get("watermelon") /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t, value) => Js.undefined -``` - -See [get](#get) - returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t, value) => value -``` - -See [get](#get) - raise when element does not exist. - -## split - -```res sig -let split: (t, value) => ((t, t), bool) -``` - -Returns a triple `((l, r), present)`, where `l` is the set of elements of set that are strictly less than value, `r` is the set of elements of set that are strictly greater than value, `present` is `false` if set contains no element equal to value, or `true` if set contains an element equal to value. - -```res example -let s0 = Belt.Set.String.fromArray(["apple", "banana", "orange"]) - -let ((smaller, larger), present) = s0->Belt.Set.String.split("banana") - -present /* true */ -smaller->Belt.Set.String.toArray /* ["apple"] */ -larger->Belt.Set.String.toArray /* ["orange"] */ -``` - -## checkInvariantInternal - -```res sig -let checkInvariantInternal: t => unit -``` - -**raise** when invariant is not held diff --git a/pages/docs/manual/v9.0.0/api/belt/set.mdx b/pages/docs/manual/v9.0.0/api/belt/set.mdx deleted file mode 100644 index 173cdd865..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/set.mdx +++ /dev/null @@ -1,590 +0,0 @@ -# Set - - - -A **immutable** sorted set module which allows customize compare behavior. -The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map. - -It also has three specialized inner modules [Belt.Set.Int](set-int), [Belt.Set.String](set-string) and [Belt.Set.Dict](set-dict) - This module separates data from function which is more verbose but slightly more efficient - - - -```res example -module PairComparator = - Belt.Id.MakeComparable({ - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch (Pervasives.compare(a0, b0)) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - }) - -let mySet = Belt.Set.make(~id=module(PairComparator)) -let mySet2 = Belt.Set.add(mySet, (1, 2)) -``` - -**Note:** This module's examples will assume a predeclared module for integers -called `IntCmp`. It is declared like this: - -```res prelude -module IntCmp = - Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare - }) -``` - -## t - -```res prelude -type t<'value, 'identity> -``` - -`'value` is the element type - -`'identity` the identity of the collection - -## id - -```res prelude -type id<'value, 'id> = Belt_Id.comparable<'value, 'id> -``` - -The identity needed for making a set from scratch - -## make - -```res sig -let make: (~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates a new set by taking in the comparator - -```res example -let set = Belt.Set.make(~id=module(IntCmp)) -``` - -## fromArray - -```res sig -let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -Creates new set from array of elements. - -```res example -let s0 = Belt.Set.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -s0->Belt.Set.toArray /* [1, 2, 3, 4] */ -``` - -## fromSortedArrayUnsafe - -```res sig -let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> -``` - -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. - -## isEmpty - -```res sig -let isEmpty: t<'a, 'b> => bool -``` - -Checks if set is empty. - -```res example -let empty = Belt.Set.fromArray([], ~id=module(IntCmp)) -let notEmpty = Belt.Set.fromArray([1],~id=module(IntCmp)) - -Belt.Set.isEmpty(empty) /* true */ -Belt.Set.isEmpty(notEmpty) /* false */ -``` - -## has - -```res sig -let has: (t<'value, 'id>, 'value) => bool -``` - -Checks if element exists in set. - -```res example -let set = Belt.Set.fromArray([1, 4, 2, 5], ~id=module(IntCmp)) - -set->Belt.Set.has(3) /* false */ -set->Belt.Set.has(1) /* true */ -``` - -## add - -```res sig -let add: (t<'value, 'id>, 'value) => t<'value, 'id> -``` - -Adds element to set. If element existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = s0->Belt.Set.add(1) -let s2 = s1->Belt.Set.add(2) -let s3 = s2->Belt.Set.add(2) -s0->Belt.Set.toArray /* [] */ -s1->Belt.Set.toArray /* [1] */ -s2->Belt.Set.toArray /* [1, 2] */ -s3->Belt.Set.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` - -## mergeMany - -```res sig -let mergeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id> -``` - -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -```res example -let set = Belt.Set.make(~id=module(IntCmp)) - -let newSet = set->Belt.Set.mergeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.toArray /* [1, 2, 3, 4, 5] */ -``` - -## remove - -```res sig -let remove: (t<'value, 'id>, 'value) => t<'value, 'id> -``` - -Removes element from set. If element wasn't existed in set, value is unchanged. - -```res example -let s0 = Belt.Set.fromArray([2,3,1,4,5], ~id=module(IntCmp)) -let s1 = s0->Belt.Set.remove(1) -let s2 = s1->Belt.Set.remove(3) -let s3 = s2->Belt.Set.remove(3) - -s1->Belt.Set.toArray /* [2,3,4,5] */ -s2->Belt.Set.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` - -## removeMany - -```res sig -let removeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id> -``` - -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -```res example -let set = Belt.Set.fromArray([1, 2, 3, 4],~id=module(IntCmp)) - -let newSet = set->Belt.Set.removeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.toArray /* [] */ -``` - -## union - -```res sig -let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns union of two sets. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let union = Belt.Set.union(s0, s1) -union->Belt.Set.toArray /* [1,2,3,4,5,6] */ -``` - -## intersect - -```res sig -let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns intersection of two sets. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let intersect = Belt.Set.intersect(s0, s1) -intersect->Belt.Set.toArray /* [2,3,5] */ -``` - -## diff - -```res sig -let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> -``` - -Returns elements from first set, not existing in second set. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -Belt.Set.toArray(Belt.Set.diff(s0, s1)) /* [6] */ -Belt.Set.toArray(Belt.Set.diff(s1,s0)) /* [1,4] */ -``` - -## subset - -```res sig -let subset: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if second set is subset of first set. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let s2 = Belt.Set.intersect(s0, s1) -Belt.Set.subset(s2, s0) /* true */ -Belt.Set.subset(s2, s1) /* true */ -Belt.Set.subset(s1, s0) /* false */ -``` - -## cmp - -```res sig -let cmp: (t<'value, 'id>, t<'value, 'id>) => int -``` - -Total ordering between sets. Can be used as the ordering function for doing sets of sets. It compares size first and then iterates over each element following the order of elements. - -## eq - -```res sig -let eq: (t<'value, 'id>, t<'value, 'id>) => bool -``` - -Checks if two sets are equal. - -```res example -let s0 = Belt.Set.fromArray([5,2,3], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,5], ~id=module(IntCmp)) - -Belt.Set.eq(s0, s1) /* true */ -``` - -## forEachU - -```res sig -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit -``` - -Same as [forEach](##forEach) but takes uncurried functon. - -## forEach - -```res sig -let forEach: (t<'value, 'id>, 'value => unit) => unit -``` - -Applies function `f` in turn to all elements of set in increasing order. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let acc = ref(list{}) -s0->Belt.Set.forEach(x => { - acc := Belt.List.add(acc.contents, x) -}) -acc /* [6,5,3,2] */ -``` - -## reduceU - -```res sig -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a -``` - -## reduce - -```res sig -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -``` - -Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. - -```res example -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -s0->Belt.Set.reduce(list{}, (acc, element) => - acc->Belt.List.add(element) -) /* [6,5,3,2] */ -``` - -## everyU - -```res sig -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## every - -```res sig -let every: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if all elements of the set satisfy the predicate. Order unspecified. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.fromArray([2,4,6,8], ~id=module(IntCmp)) -s0->Belt.Set.every(isEven) /* true */ -``` - -## someU - -```res sig -let someU: (t<'value, 'id>, (. 'value) => bool) => bool -``` - -## some - -```res sig -let some: (t<'value, 'id>, 'value => bool) => bool -``` - -Checks if at least one element of the set satisfies the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.fromArray([1,2,4,6,8], ~id=module(IntCmp)) -s0->Belt.Set.some(isOdd) /* true */ -``` - -## keepU - -```res sig -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> -``` - -## keep - -```res sig -let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -``` - -Returns the set of all elements that satisfy the predicate. - -```res example -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) -let s1 = s0->Belt.Set.keep(isEven) - -s1->Belt.Set.toArray /* [2,4] */ -``` - -## partitionU - -```res sig -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -## partition - -```res sig -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) -``` - -Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. - -```res example -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) -let (s1, s2) = s0->Belt.Set.partition(isOdd) - -s1->Belt.Set.toArray /* [1,3,5] */ -s2->Belt.Set.toArray /* [2,4] */ -``` - -## size - -```res sig -let size: t<'value, 'id> => int -``` - -Returns size of the set. - -```res example -let s0 = Belt.Set.fromArray([1,2,3,4], ~id=module(IntCmp)) - -s0->Belt.Set.size /* 4 */ -``` - -## toArray - -```res sig -let toArray: t<'value, 'id> => array<'value> -``` - -Returns array of ordered set elements. - -```res example -let s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.toArray /* [1,2,3,5] */ -``` - -## toList - -```res sig -let toList: t<'value, 'id> => list<'value> -``` - -Returns list of ordered set elements. - -```res example -let s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.toList /* [1,2,3,5] */ -``` - -## minimum - -```res sig -let minimum: t<'value, 'id> => option<'value> -``` - -Returns minimum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.minimum /* None */ -s1->Belt.Set.minimum /* Some(1) */ -``` - -## minUndefined - -```res sig -let minUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns minimum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.minUndefined /* undefined */ -s1->Belt.Set.minUndefined /* 1 */ -``` - -## maximum - -Returns maximum value of the collection. `None` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.maximum /* None */ -s1->Belt.Set.maximum /* Some(5) */ -``` - -## maxUndefined - -```res sig -let maxUndefined: t<'value, 'id> => Js.undefined<'value> -``` - -Returns maximum value of the collection. `undefined` if collection is empty. - -```res example -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.maxUndefined /* undefined */ -s1->Belt.Set.maxUndefined /* 5 */ -``` - -## get - -```res sig -let get: (t<'value, 'id>, 'value) => option<'value> -``` - -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -```res example -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) - -s0->Belt.Set.get(3) /* Some(3) */ -s0->Belt.Set.get(20) /* None */ -``` - -## getUndefined - -```res sig -let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> -``` - -Same as [get](#get) but returns `undefined` when element does not exist. - -## getExn - -```res sig -let getExn: (t<'value, 'id>, 'value) => 'value -``` - -Same as [get](#get) but raise when element does not exist. - -## split - -```res sig -let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) -``` - -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -```res example -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) - -let ((smaller, larger), present) = s0->Belt.Set.split(3) - -present /* true */ -smaller->Belt.Set.toArray /* [1,2] */ -larger->Belt.Set.toArray /* [4,5] */ - -``` - -## getData - -```res sig -let getData: t<'value, 'id> => Belt_SetDict.t<'value, 'id> -``` - -**Advanced usage only** - -Returns the raw data (detached from comparator), but its type is still manifested, so that user can pass identity directly without boxing. - -## getId - -```res sig -let getId: t<'value, 'id> => id<'value, 'id> -``` - -**Advanced usage only** - -Returns the identity of set. - -## packIdData - -```res sig -let packIdData: (~id: id<'value, 'id>, ~data: Belt_SetDict.t<'value, 'id>) => t<'value, 'id> -``` - -**Advanced usage only** - -Returns the packed collection. diff --git a/pages/docs/manual/v9.0.0/api/belt/sort-array-int.mdx b/pages/docs/manual/v9.0.0/api/belt/sort-array-int.mdx deleted file mode 100644 index 15fc2dc4c..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/sort-array-int.mdx +++ /dev/null @@ -1,59 +0,0 @@ -# SortArrayInt - - - -This is a specialized module for `Belt.SortArray`, the docs in that module also applies here, except the comparator is fixed and inlined. - - - -## element - -```res prelude -type element = int -``` - -## strictlySortedLength - -```res sig -let strictlySortedLength: array => int -``` - -The same as `Belt.SortArray.strictlySortedLength` except the comparator is fixed. - -Returns `+n` means increasing order `-n` means negative order. - -## isSorted - -```res sig -let isSorted: array => bool -``` - -`sorted(xs)` return true if `xs` is in non strict increasing order. - -## stableSortInPlace - -```res sig -let stableSortInPlace: array => unit -``` - -The same as `Belt.SortArray.stableSortInPlaceBy` except the comparator is fixed. - -## stableSort - -```res sig -let stableSort: array => array -``` - -The same as `Belt.SortArray.stableSortBy` except the comparator is fixed. - -## binarySearch - -```res sig -let binarySearch: (array, element) => int -``` - -If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value. - -If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot(-1) = 0` if `key` is larger than all elements return `- (len + 1)` since `lnot(-(len+1)) = len`. diff --git a/pages/docs/manual/v9.0.0/api/belt/sort-array-string.mdx b/pages/docs/manual/v9.0.0/api/belt/sort-array-string.mdx deleted file mode 100644 index 3016c1903..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/sort-array-string.mdx +++ /dev/null @@ -1,59 +0,0 @@ -# SortArrayString - - - -This is a specialized module for `Belt.SortArray`, the docs in that module also applies here, except the comparator is fixed and inlined. - - - -## element - -```res prelude -type element = string -``` - -## strictlySortedLength - -```res sig -let strictlySortedLength: array => int -``` - -The same as `Belt.SortArray.strictlySortedLength` except the comparator is fixed. - -Returns `+n` means increasing order `-n` means negative order. - -## isSorted - -```res sig -let isSorted: array => bool -``` - -`sorted(xs)` return true if `xs` is in non strict increasing order. - -## stableSortInPlace - -```res sig -let stableSortInPlace: array => unit -``` - -The same as `Belt.SortArray.stableSortInPlaceBy` except the comparator is fixed. - -## stableSort - -```res sig -let stableSort: array => array -``` - -The same as `Belt.SortArray.stableSortBy` except the comparator is fixed. - -## binarySearch - -```res sig -let binarySearch: (array, element) => int -``` - -If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value. - -If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot(-1) = 0` if `key` is larger than all elements return `- (len + 1)` since `lnot(-(len+1)) = len`. diff --git a/pages/docs/manual/v9.0.0/api/belt/sort-array.mdx b/pages/docs/manual/v9.0.0/api/belt/sort-array.mdx deleted file mode 100644 index 7ea25b672..000000000 --- a/pages/docs/manual/v9.0.0/api/belt/sort-array.mdx +++ /dev/null @@ -1,111 +0,0 @@ -# SortArray - -## SortArrayInt - -```res example -module Int = Belt.SortArray.Int -``` - -Specalized when key type is `int`, more efficient than the generic type - -## SortArrayString - -```res example -module String = Belt.SortArray.String -``` - -Specalized when key type is `string`, more efficient than the generic type - -## strictlySortedLengthU - -```res sig -let strictlySortedLengthU: (array<'a>, (. 'a, 'a) => bool) => int -``` - -## strictlySortedLength - -```res sig -let strictlySortedLength: (array<'a>, ('a, 'a) => bool) => int -``` - -`strictlySortedLenght(xs, cmp);` return `+n` means increasing order `-n` means negative order - -```res example -Belt.SortArray.strictlySortedLength([1, 2, 3, 4, 3], (x, y) => x < y) == 4 - -Belt.SortArray.strictlySortedLength([], (x, y) => x < y) == 0 - -Belt.SortArray.strictlySortedLength([1], (x, y) => x < y) == 1 - -Belt.SortArray.strictlySortedLength([4, 3, 2, 1], (x, y) => x < y) == -4 -``` - -## isSortedU - -```res sig -let isSortedU: (array<'a>, (. 'a, 'a) => int) => bool -``` - -## isSorted - -```res sig -let isSorted: (array<'a>, ('a, 'a) => int) => bool -``` - -`isSorted(arr, cmp)`: Returns true if array is increasingly sorted (equal is okay) - -## stableSortInPlaceByU - -```res sig -let stableSortInPlaceByU: (array<'a>, (. 'a, 'a) => int) => unit -``` - -## stableSortInPlaceBy - -```res sig -let stableSortInPlaceBy: (array<'a>, ('a, 'a) => int) => unit -``` - -## stableSortByU - -```res sig -let stableSortByU: (array<'a>, (. 'a, 'a) => int) => array<'a> -``` - -## stableSortBy - -```res sig -let stableSortBy: (array<'a>, ('a, 'a) => int) => array<'a> -``` - -`stableSortBy(xs, cmp)`: Returns a fresh array Sort `xs` in place using -comparator `cmp`, the stable means if the elements are equal, their order will -be preserved - -## binarySearchByU - -```res sig -let binarySearchByU: (array<'a>, 'a, (. 'a, 'a) => int) => int -``` - -## binarySearchBy - -```res sig -let binarySearchBy: (array<'a>, 'a, ('a, 'a) => int) => int -``` - -If value is not found and value is less than one or more elements in array, the -negative number returned is the bitwise complement of the index of the first -element that is larger than value. - -If value is not found and value is greater -than all elements in array, the negative number returned is the bitwise -complement of (the index of the last element plus 1)for example, if `key` is -smaller than all elements return `-1` since `lnot(-1) == 0` if `key` is larger -than all elements return `lnot(-1) == 0` since `lnot(- (len + 1)) == len` - -```res example -Belt.SortArray.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 33, Pervasives.compare) == 4 - -lnot(Belt.SortArray.binarySearchBy([1, 3, 5, 7], 4, Pervasives.compare)) == 2 -``` diff --git a/pages/docs/manual/v9.0.0/api/dom.mdx b/pages/docs/manual/v9.0.0/api/dom.mdx deleted file mode 100644 index b74050f73..000000000 --- a/pages/docs/manual/v9.0.0/api/dom.mdx +++ /dev/null @@ -1,855 +0,0 @@ -# Dom - - - -The Dom module offers a canonical set of dom related types that third party libraries can depend on. It only provides types, no functions to manipulate the values of certain types whatsoever. - - - -## animation - -```res sig -type animation -``` - -## cssStyleDeclaration - -```res sig -type cssStyleDeclaration -``` - -## cssStyleSheet - -```res sig -type cssStyleSheet -``` - -## node - -```res sig -type node -``` - -## characterData - -```res sig -type characterData -``` - -## cdataSection - -```res sig -type cdataSection -``` - -## comment - -```res sig -type comment -``` - -## document - -```res sig -type document -``` - -## documentType - -```res sig -type documentType -``` - -## domImplementation - -```res sig -type domImplementation -``` - -## element - -```res sig -type element -``` - -## htmlCollection - -```res sig -type htmlCollection -``` - -## htmlFormControlsCollection - -```res sig -type htmlFormControlsCollection -``` - -## htmlOptionsCollection - -```res sig -type htmlOptionsCollection -``` - -## intersectionObserver - -```res sig -type intersectionObserver -``` - -## intersectionObserverEntry - -```res sig -type intersectionObserverEntry -``` - -## mutationObserver - -```res sig -type mutationObserver -``` - -## mutationRecord - -```res sig -type mutationRecord -``` - -## performanceObserver - -```res sig -type performanceObserver -``` - -## performanceObserverEntryList - -```res sig -type performanceObserverEntryList -``` - -## reportingObserver - -```res sig -type reportingObserver -``` - -## reportingObserverOptions - -```res sig -type reportingObserverOptions -``` - -## resizeObserver - -```res sig -type resizeObserver -``` - -## resizeObserverEntry - -```res sig -type resizeObserverEntry -``` - -## namedNodeMap - -```res sig -type namedNodeMap -``` - -## nodeList - -```res sig -type nodeList -``` - -## radioNodeList - -```res sig -type radioNodeList -``` - -## processingInstruction - -```res sig -type processingInstruction -``` - -## shadowRoot - -```res sig -type shadowRoot -``` - -## text - -```res sig -type text -``` - -## domRect - -```res sig -type domRect -``` - -## dataTransfer - -```res sig -type dataTransfer -``` - -## domStringMap - -```res sig -type domStringMap -``` - -## history - -```res sig -type history -``` - -## htmlDocument - -```res sig -type htmlDocument -``` - -## htmlElement - -```res sig -type htmlElement -``` - -## htmlAnchorElement - -```res sig -type htmlAnchorElement -``` - -## htmlAreaElement - -```res sig -type htmlAreaElement -``` - -## htmlAudioElement - -```res sig -type htmlAudioElement -``` - -## htmlBaseElement - -```res sig -type htmlBaseElement -``` - -## htmlBodyElement - -```res sig -type htmlBodyElement -``` - -## htmlBrElement - -```res sig -type htmlBrElement -``` - -## htmlButtonElement - -```res sig -type htmlButtonElement -``` - -## htmlCanvasElement - -```res sig -type htmlCanvasElement -``` - -## htmlDataElement - -```res sig -type htmlDataElement -``` - -## htmlDataListElement - -```res sig -type htmlDataListElement -``` - -## htmlDialogElement - -```res sig -type htmlDialogElement -``` - -## htmlDivElement - -```res sig -type htmlDivElement -``` - -## htmlDlistElement - -```res sig -type htmlDlistElement -``` - -## htmlEmbedElement - -```res sig -type htmlEmbedElement -``` - -## htmlFieldSetElement - -```res sig -type htmlFieldSetElement -``` - -## htmlFormElement - -```res sig -type htmlFormElement -``` - -## htmlHeadElement - -```res sig -type htmlHeadElement -``` - -## htmlHeadingElement - -```res sig -type htmlHeadingElement -``` - -## htmlHrElement - -```res sig -type htmlHrElement -``` - -## htmlHtmlElement - -```res sig -type htmlHtmElement -``` - -## htmlIframeElement - -```res sig -type htmlIframeElement -``` - -## htmlImageElement - -```res sig -type htmlImageElement -``` - -## htmlInputElement - -```res sig -type htmlInputElement -``` - -## htmlLabelElement - -```res sig -type htmlLabelElement -``` - -## htmlLegendElement - -```res sig -type htmlLegendElement -``` - -## htmlLiElement - -```res sig -type htmlLiElement -``` - -## htmlLinkElement - -```res sig -type htmlLinkElement -``` - -## htmlMapElement - -```res sig -type htmlMapElement -``` - -## htmlMediaElement - -```res sig -type htmlMediaElement -``` - -## htmlMenuElement - -```res sig -type htmlMenuElement -``` - -## htmlMetaElement - -```res sig -type htmlMetaElement -``` - -## htmlMeterElement - -```res sig -type htmlMeterElement -``` - -## htmlModElement - -```res sig -type htmlModElement -``` - -## htmlOListElement - -```res sig -type htmlOListElement -``` - -## htmlObjectElement - -```res sig -type htmlObjectElement -``` - -## htmlOptGroupElement - -```res sig -type htmlOptGroupElement -``` - -## htmlOptionElement - -```res sig -type htmlOptionElement -``` - -## htmlOutputElement - -```res sig -type htmlOutputElement -``` - -## htmlParagraphElement - -```res sig -type htmlParagraphElement -``` - -## htmlParamElement - -```res sig -type htmlParamElement -``` - -## htmlPreElement - -```res sig -type htmlPreElement -``` - -## htmlProgressElement - -```res sig -type htmlProgressElement -``` - -## htmlQuoteElement - -```res sig -type htmlQuoteElement -``` - -## htmlScriptElement - -```res sig -type htmlScriptElement -``` - -## htmlSelectElement - -```res sig -type htmlSelectElement -``` - -## htmlSlotElement - -```res sig -type htmlSlotElement -``` - -## htmlSourceElement - -```res sig -type htmlSourceElement -``` - -## htmlSpanElement - -```res sig -type htmlSpanElement -``` - -## htmlStyleElement - -```res sig -type htmlStyleElement -``` - -## htmlTableCaptionElement - -```res sig -type htmlTableCaptionElement -``` - -## htmlTableCellElement - -```res sig -type htmlTableCellElement -``` - -## htmlTableColElement - -```res sig -type htmlTableColElement -``` - -## htmlTableDataCellElement - -```res sig -type htmlTableDataCellElement -``` - -## htmlTableElement - -```res sig -type htmlTableElement -``` - -## htmlTableHeaderCellElement - -```res sig -type htmlTableHeaderCellElement -``` - -## htmlTableRowElement - -```res sig -type htmlTableRowElement -``` - -## htmlTableSectionElement - -```res sig -type htmlTableSectionElement -``` - -## htmlTextAreaElement - -```res sig -type htmlTextAreaElement -``` - -## htmlTimeElement - -```res sig -type htmlTimeElement -``` - -## htmlTitleElement - -```res sig -type htmlTitleElement -``` - -## htmlTrackElement - -```res sig -type htmlTrackElement -``` - -## htmlUlistElement - -```res sig -type htmlUlistElement -``` - -## htmlUnknownElement - -```res sig -type htmlUnknownElement -``` - -## htmlVideoElement - -```res sig -type htmlVideoElement -``` - -## location - -```res sig -type location -``` - -## window - -```res sig -type window -``` - -## xmlDocument - -```res sig -type xmlDocument -``` - -## event - -```res sig -type event -``` - -## uiEvent - -```res sig -type uiEvent -``` - -## animationEvent - -```res sig -type animationEvent -``` - -## beforeUnloadEvent - -```res sig -type beforeUnloadEvent -``` - -## clipboardEvent - -```res sig -type clipboardEvent -``` - -## closeEvent - -```res sig -type closeEvent -``` - -## compositionEvent - -```res sig -type compositionEvent -``` - -## customEvent - -```res sig -type customEvent -``` - -## dragEvent - -```res sig -type dragEvent -``` - -## errorEvent - -```res sig -type errorEvent -``` - -## focusEvent - -```res sig -type focusEvent -``` - -## idbVersionChangeEvent - -```res sig -type idbVersionChangeEvent -``` - -## inputEvent - -```res sig -type inputEvent -``` - -## keyboardEvent - -```res sig -type keyboardEvent -``` - -## mouseEvent - -```res sig -type mouseEvent -``` - -## pageTransitionEvent - -```res sig -type pageTransitionEvent -``` - -## pointerEvent - -```res sig -type pointerEvent -``` - -## popStateEvent - -```res sig -type popStateEvent -``` - -## progressEvent - -```res sig -type progressEvent -``` - -## relatedEvent - -```res sig -type relatedEvent -``` - -## storageEvent - -```res sig -type storageEvent -``` - -## svgZoomEvent - -```res sig -type svgZoomEvent -``` - -## timeEvent - -```res sig -type timeEvent -``` - -## touchEvent - -```res sig -type touchEvent -``` - -## trackEvent - -```res sig -type trackEvent -``` - -## transitionEvent - -```res sig -type transitionEvent -``` - -## webGlContextEvent - -```res sig -type webGlContextEvent -``` - -## wheelEvent - -```res sig -type wheelEvent -``` - -## range - -```res sig -type range -``` - -## selection - -```res sig -type selection -``` - -## domTokenList - -```res sig -type domTokenList -``` - -## domSettableTokenList - -```res sig -type domSettableTokenList -``` - -## nodeFilter - -```res sig -type nodeFilter = { - acceptNode: (Dom.element) => int -} -``` - -## nodeIterator - -```res sig -type nodeIterator -``` - -## treeWalker - -```res sig -type treeWalker -``` - -## svgRect - -```res sig -type svgRect -``` - -## svgPoint - -```res sig -type svgPoint -``` - -## eventPointerId - -```res sig -type eventPointerId -``` diff --git a/pages/docs/manual/v9.0.0/api/dom/storage.mdx b/pages/docs/manual/v9.0.0/api/dom/storage.mdx deleted file mode 100644 index 412cae405..000000000 --- a/pages/docs/manual/v9.0.0/api/dom/storage.mdx +++ /dev/null @@ -1,55 +0,0 @@ -# Storage - -## t - -```res prelude sig -type t -``` - -## getItem - -```res sig -external getItem: (string, t) => option = "getItem" -``` - -## setItem - -```res sig -external setItem: (string, string, t) => unit = "setItem" -``` - -## removeItem - -```res sig -external removeItem: (string, t) => unit = "removeItem" -``` - -## clear - -```res sig -external clear: t => unit = "clear" -``` - -## key - -```res sig -external key: (int, t) => option = "key" -``` - -## length - -```res sig -external length: t => int = "length" -``` - -## localStorage - -```res sig -@bs.val external localStorage: t = "localStorage" -``` - -## sessionStorage - -```res sig -@bs.val external sessionStorage: t = "sessionStorage" -``` diff --git a/pages/docs/manual/v9.0.0/api/dom/storage2.mdx b/pages/docs/manual/v9.0.0/api/dom/storage2.mdx deleted file mode 100644 index a126b6c14..000000000 --- a/pages/docs/manual/v9.0.0/api/dom/storage2.mdx +++ /dev/null @@ -1,61 +0,0 @@ -# Storage2 - - - -The same as [Dom.Storage](./storage2), but with `t` on first argument position for proper `->` usage. - - - -## t - -```res prelude sig -type t -``` - -## getItem - -```res sig -external getItem: (t, string) => option = "getItem" -``` - -## setItem - -```res sig -external setItem: (t, string, string) => unit = "setItem" -``` - -## removeItem - -```res sig -external removeItem: (t, string) => unit = "removeItem" -``` - -## clear - -```res sig -external clear: t => unit = "clear" -``` - -## key - -```res sig -external key: (t, int) => option = "key" -``` - -## length - -```res sig -external length: t => int = "length" -``` - -## localStorage - -```res sig -@bs.val external localStorage: t = "localStorage" -``` - -## sessionStorage - -```res sig -@bs.val external sessionStorage: t = "sessionStorage" -``` diff --git a/pages/docs/manual/v9.0.0/api/js.mdx b/pages/docs/manual/v9.0.0/api/js.mdx deleted file mode 100644 index c8f023802..000000000 --- a/pages/docs/manual/v9.0.0/api/js.mdx +++ /dev/null @@ -1,179 +0,0 @@ -# Js - -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/array-2) 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._ - -In the meantime, there are several options for dealing with the data-last APIs: - -```res example -/* Js.String (data-last API used with pipe last operator) */ -Js.log("2019-11-10" |> Js.String.split("-")) -Js.log("ReScript" |> Js.String.startsWith("Re")) - -/* Js.String (data-last API used with pipe first operator) */ -Js.log("2019-11-10"->Js.String.split("-", _)) -Js.log("ReScript"->Js.String.startsWith("Re", _)) - -/* Js.String (data-last API used without any piping) */ -Js.log(Js.String.split("-", "2019-11-10")) -Js.log(Js.String.startsWith("Re", "ReScript")) -``` - -## Js.Xxx2 Modules - -Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latters are old modules. - -## Object - -```res sig -type t<+'a> -``` - -Js object type. - -```res example -let x: {"x": int, "y": int} = {"x": 1, "y": 2} -``` - -## Nullable and Undefined - -```res prelude -type null<+'a> -``` - -nullable, value of this type can be either null or 'a this type is the same as type t in Js.Null - -```res prelude -type undefined<+'a> -``` - -value of this type can be either undefined or 'a this type is the same as type t in Js.Undefined - -```res prelude -type nullable<+'a> -``` - -value of this type can be undefined, null or 'a this type is the same as type t n Js.Null_undefined - -```res prelude -type null_undefined<'a> = Js.nullable<'a> -``` - -```res sig -let toOption: Js.nullable<'a> => option<'a> -``` - -```res sig -let undefinedToOption: Js.undefined<'a> => option<'a> -``` - -```res sig -let nullToOption: Js.null<'a> => option<'a> -``` - -```res sig -let test: Js.nullable<'a> => bool -``` - -```res sig -let isNullable: Js.nullable<'a> => bool -``` - -```res sig -let testAny: 'a => bool -``` - -The same as `Js.test` except that it is more permissive on the types of input. - -```res sig -type promise<+'a, +'e> -``` - -Deprecated. please use `Js.Promise`. -The promise type, defined here for interoperation across packages. - -```res sig -let null: Js.null<'a> -``` - -The same as empty in `Js.Null`. Will be compiled as `null`. - -```res sig -let undefined: Js.undefined<'a> -``` - -The same as empty `Js.Undefined`. Will be compiled as `undefined`. - -## TypeOf - -```res sig -let typeof: 'a => string -``` - -`typeof x` will be compiled as `typeof x` in JS. Please consider functions in `Js.Types` for a type safe way of reflection. - -## Logging - -```res sig -let log: 'a => unit -let log2: ('a, 'b) => unit -let log3: ('a, 'b, 'c) => unit -let log4: ('a, 'b, 'c, 'd) => unit -``` - -A convenience function to log everything. - -```res sig -let logMany: array<'a> => unit -``` - -A convenience function to log more than 4 arguments - -## Comparison - -```res sig -let eqNull: ('a, null<'a>) => bool -let eqUndefined: ('a, undefined<'a>) => bool -let eqNullable: ('a, nullable<'a>) => bool -``` - -```res sig -let unsafe_lt: ('a, 'a) => bool -``` - -`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. - -```res sig -let unsafe_le: ('a, 'a) => bool -``` - -`unsafe_le a b` will be compiled as `a <= b`. See also `Js.unsafe_lt`. - -```res sig -let unsafe_gt: ('a, 'a) => bool -``` - -`unsafe_gt a b` will be compiled as `a > b`. See also `Js.unsafe_lt`. - -```res sig -let unsafe_ge: ('a, 'a) => bool -``` - -`unsafe_ge a b` will be compiled as `a >= b`. See also `Js.unsafe_lt`. diff --git a/pages/docs/manual/v9.0.0/api/js/array-2.mdx b/pages/docs/manual/v9.0.0/api/js/array-2.mdx deleted file mode 100644 index ad627fab9..000000000 --- a/pages/docs/manual/v9.0.0/api/js/array-2.mdx +++ /dev/null @@ -1,900 +0,0 @@ -# Array2 - - - -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: - -```res example -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: - -```res example -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) -} -``` - - - -## t - -```res prelude -type t<'a> = array<'a> -``` - -The type used to describe a JavaScript array. - -## array_like - -```res prelude -type array_like<'a> -``` - -A type used to describe JavaScript objects that are like an array or are iterable. - -## from - -```res sig -let from: array_like<'a> => array<'a> -``` - -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. - -```res example -let strArr = Js.String.castToArrayLike("abcd") -Js.Array2.from(strArr) == ["a", "b", "c", "d"] -``` - -## fromMap - -```res sig -let fromMap: (array_like<'a>, 'a => 'b) => array<'b> -``` - -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. - -```res example -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] -``` - -## isArray - -```res sig -let isArray: 'a => bool -``` - -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. - -```res example -Js.Array2.isArray([5, 2, 3, 1, 4]) == true -Js.Array2.isArray(list{5, 2, 3, 1, 4}) == true -Js.Array2.isArray("abcd") == false -``` - -## length - -```res sig -let length: array<'a> => int -``` - -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. - -## copyWithin - -```res sig -let copyWithin: (t<'a>, ~to_: int) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array2.copyWithin(arr, ~to_=2) == [100, 101, 100, 101, 102] -arr == [100, 101, 100, 101, 102] -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (t<'a>, ~to_: int, ~from: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (t<'a>, ~to_: int, ~start: int, ~end_: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillInPlace - -```res sig -let fillInPlace: (t<'a>, 'a) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array2.fillInPlace(arr, 99) == [99, 99, 99, 99, 99] -arr == [99, 99, 99, 99, 99] -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (t<'a>, 'a, ~from: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (t<'a>, 'a, ~start: int, ~end_: int) => t<'a> -``` - -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. - -```res example -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] -``` - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## push - -```res sig -let push: (t<'a>, 'a) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array2.push(arr, "dog") == 4 -arr == ["ant", "bee", "cat", "dog"] -``` - -## pushMany - -```res sig -let pushMany: (t<'a>, array<'a>) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array2.pushMany(arr, ["dog", "elk"]) == 5 -arr == ["ant", "bee", "cat", "dog", "elk"] -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t<'a> => t<'a> -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array2.reverseInPlace(arr) == ["cat", "bee", "ant"] -arr == ["cat", "bee", "ant"] -``` - -## shift - -```res sig -let shift: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## sortInPlace - -```res sig -let sortInPlace: t<'a> => t<'a> -``` - -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. - -```res example -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] -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: (t<'a>, ('a, 'a) => int) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## spliceInPlace - -```res sig -let spliceInPlace: (t<'a>, ~pos: int, ~remove: int, ~add: array<'a>) => t<'a> -``` - -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. - -```res example -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"] -``` - -## removeFromInPlace - -```res sig -let removeFromInPlace: (t<'a>, ~pos: int) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array2.removeFromInPlace(arr, ~pos=4) == ["e", "f"] -arr == ["a", "b", "c", "d"] -``` - -## removeCountInPlace - -```res sig -let removeCountInPlace: (t<'a>, ~pos: int, ~count: int) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array2.removeCountInPlace(arr, ~pos=2, ~count=3) == ["c", "d", "e"] -arr == ["a", "b", "f"] -``` - -## unshift - -```res sig -let unshift: (t<'a>, 'a) => int -``` - -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. - -```res example -let arr = ["b", "c", "d"] -Js.Array2.unshift(arr, "a") == 4 -arr == ["a", "b", "c", "d"] -``` - -## unshiftMany - -```res sig -let unshiftMany: (t<'a>, array<'a>) => int -``` - -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. - -```res example -let arr = ["d", "e"] -Js.Array2.unshiftMany(arr, ["a", "b", "c"]) == 5 -arr == ["a", "b", "c", "d", "e"] -``` - -## append - -```res sig -let append: (t<'a>, 'a) => t<'a> -``` - -Deprecated. `append()` is not type-safe. Use `concat()` instead. - -## concat - -```res sig -let concat: (t<'a>, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array2.concat(["a", "b"], ["c", "d", "e"]) == ["a", "b", "c", "d", "e"] -``` - -## concatMany - -```res sig -let concatMany: (t<'a>, array>) => t<'a> -``` - -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. - -```res example -Js.Array2.concatMany(["a", "b", "c"], [["d", "e"], ["f", "g", "h"]]) == [ - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - ] -``` - -## includes - -```res sig -let includes: (t<'a>, 'a) => bool -``` - -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. - -```res example -Js.Array2.includes(["a", "b", "c"], "b") == true -Js.Array2.includes(["a", "b", "c"], "x") == false -``` - -## indexOf - -```res sig -let indexOf: (t<'a>, 'a) => int -``` - -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. - -```res example -Js.Array2.indexOf([100, 101, 102, 103], 102) == 2 -Js.Array2.indexOf([100, 101, 102, 103], 999) == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (t<'a>, 'a, ~from: int) => int -``` - -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. - -```res example -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 -``` - -## joinWith - -```res sig -let joinWith: (t<'a>, string) => string -``` - -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. - -```res example -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" -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (t<'a>, 'a) => int -``` - -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. - -```res example -Js.Array2.lastIndexOf(["a", "b", "a", "c"], "a") == 2 -Js.Array2.lastIndexOf(["a", "b", "a", "c"], "x") == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (t<'a>, 'a, ~from: int) => int -``` - -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. - -```res example -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 -``` - -## slice - -```res sig -let slice: (t<'a>, ~start: int, ~end_: int) => t<'a> -``` - -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. - -```res example -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) == [] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -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. - -## sliceFrom - -```res sig -let sliceFrom: (t<'a>, int) => t<'a> -``` - -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. - -```res example -Js.Array2.sliceFrom([100, 101, 102, 103, 104], 2) == [102, 103, 104] -``` - -## toString - -```res sig -let toString: t<'a> => string -``` - -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. - -```res example -Js.Array2.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8" -Js.Array2.toString(["a", "b", "c"]) == "a,b,c" -``` - -## toLocaleString - -```res sig -let toLocaleString: t<'a> => string -``` - -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. - -```res example -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 -``` - -## every - -```res sig -let every: (t<'a>, 'a => bool) => bool -``` - -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. - -```res example -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 -``` - -## everyi - -```res sig -let everyi: (t<'a>, ('a, int) => bool) => bool -``` - -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. - -```res example -// 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 -``` - -## filter - -```res sig -let filter: (t<'a>, 'a => bool) => t<'a> -``` - -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. - -```res example -let nonEmpty = s => s != "" -Js.Array2.filter(["abc", "", "", "def", "ghi"], nonEmpty) == ["abc", "def", "ghi"] -``` - -## filteri - -```res sig -let filteri: (t<'a>, ('a, int) => bool) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## find - -```res sig -let find: (t<'a>, 'a => bool) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findi - -```res sig -let findi: (t<'a>, ('a, int) => bool) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findIndex - -```res sig -let findIndex: (t<'a>, 'a => bool) => int -``` - -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. - -```res example -Js.Array2.findIndex([33, 22, -55, 77, -44], x => x < 0) == 2 -Js.Array2.findIndex([33, 22, 55, 77, 44], x => x < 0) == -1 -``` - -## findIndexi - -```res sig -let findIndexi: (t<'a>, ('a, int) => bool) => int -``` - -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. - -```res example -// 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 -``` - -## forEach - -```res sig -let forEach: (t<'a>, 'a => unit) => unit -``` - -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. - -```res example -// display all elements in an array -Js.Array2.forEach(["a", "b", "c"], x => Js.log(x)) == () -``` - -## forEachi - -```res sig -let forEachi: (t<'a>, ('a, int) => unit) => unit -``` - -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. - -```res example -// display all elements in an array as a numbered list -Js.Array2.forEachi(["a", "b", "c"], (item, index) => Js.log2(index + 1, item)) == () -``` - -## map - -```res sig -let map: (t<'a>, 'a => 'b) => t<'b> -``` - -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. - -```res example -Js.Array2.map([12, 4, 8], x => x * x) == [144, 16, 64] -Js.Array2.map(["animal", "vegetable", "mineral"], Js.String.length) == [6, 9, 7] -``` - -## mapi - -```res sig -let mapi: (t<'a>, ('a, int) => 'b) => t<'b> -``` - -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. - -```res example -// multiply each item in array by its position -let product = (item, index) => item * index -Js.Array2.mapi([10, 11, 12], product) == [0, 11, 24] -``` - -## reduce - -```res sig -let reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b -``` - -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. - -```res example -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) -``` - -## reducei - -```res sig -let reducei: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b -``` - -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. - -```res example -// 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 -``` - -## reduceRight - -```res sig -let reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b -``` - -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. - -```res example -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) -``` - -## reduceRighti - -```res sig -let reduceRighti: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b -``` - -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. - -```res example -// 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 -``` - -## some - -```res sig -let some: (t<'a>, 'a => bool) => bool -``` - -Returns `true` if the predicate function given as the second argument to `some()` returns `true` for any element in the array; `false` otherwise. - -```res example -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 -``` - -## somei - -```res sig -let somei: (t<'a>, ('a, int) => bool) => bool -``` - -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 - -```res example -// 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 -``` - -## unsafe_get - -```res sig -let unsafe_get: (array<'a>, int) => 'a -``` - -Returns the value at the given position in the array if the position is in bounds; returns the JavaScript value `undefined` otherwise. - -```res example -let arr = [100, 101, 102, 103] -Js.Array2.unsafe_get(arr, 3) == 103 -Js.Array2.unsafe_get(arr, 4) // returns undefined -``` - -## unsafe_set - -```res sig -let unsafe_set: (array<'a>, int, 'a) => unit -``` - -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._ - -```res example -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. -``` diff --git a/pages/docs/manual/v9.0.0/api/js/array.mdx b/pages/docs/manual/v9.0.0/api/js/array.mdx deleted file mode 100644 index 4c55ae32d..000000000 --- a/pages/docs/manual/v9.0.0/api/js/array.mdx +++ /dev/null @@ -1,934 +0,0 @@ -# Array - - - -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. - -Here is an example to find the sum of squares of all even numbers in an array. -Without pipe last, we must call the functions in reverse order: - -```res example -let isEven = x => mod(x, 2) == 0 -let square = x => x * x -let result = { - open Js.Array - reduce(\"+", 0, map(square, filter(isEven, [5, 2, 3, 4, 1]))) -} -``` - -With pipe last, we call the functions in the “natural” order: - -```res example -let isEven = x => mod(x, 2) == 0 -let square = x => x * x -let result = { - open Js.Array - [5, 2, 3, 4, 1] |> filter(isEven) |> map(square) |> reduce(\"+", 0) -} -``` - - - -## t - -```res prelude -type t<'a> = array<'a> -``` - -The type used to describe a JavaScript array. - -## array_like - -```res prelude -type array_like<'a> = Js_array2.array_like<'a> -``` - -A type used to describe JavaScript objects that are like an array or are iterable. - -## from - -```res sig -let from: array_like<'a> => array<'a> -``` - -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. - -```res example -let strArr = Js.String.castToArrayLike("abcd") -Js.Array.from(strArr) == ["a", "b", "c", "d"] -``` - -## fromMap - -```res sig -let fromMap: (array_like<'a>, 'a => 'b) => array<'b> -``` - -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. - -```res example -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] -``` - -## isArray - -```res sig -let isArray: 'a => bool -``` - -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. - -```res example -Js.Array.isArray([5, 2, 3, 1, 4]) == true -Js.Array.isArray(list{5, 2, 3, 1, 4}) == true -Js.Array.isArray("abcd") == false -``` - -## length - -```res sig -let length: array<'a> => int -``` - -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. - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array.copyWithin(~to_=2, arr) == [100, 101, 100, 101, 102] -arr == [100, 101, 100, 101, 102] -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillInPlace - -```res sig -let fillInPlace: ('a, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = [100, 101, 102, 103, 104] -Js.Array.fillInPlace(99, arr) == [99, 99, 99, 99, 99] -arr == [99, 99, 99, 99, 99] -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: ('a, ~from: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: ('a, ~start: int, ~end_: int, t<'a>) => t<'a> -``` - -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. - -```res example -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] -``` - -## pop - -```res sig -let pop: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## push - -```res sig -let push: ('a, t<'a>) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array.push("dog", arr) == 4 -arr == ["ant", "bee", "cat", "dog"] -``` - -## pushMany - -```res sig -let pushMany: (array<'a>, t<'a>) => int -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array.pushMany(["dog", "elk"], arr) == 5 -arr == ["ant", "bee", "cat", "dog", "elk"] -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t<'a> => t<'a> -``` - -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. - -```res example -let arr = ["ant", "bee", "cat"] -Js.Array.reverseInPlace(arr) == ["cat", "bee", "ant"] -arr == ["cat", "bee", "ant"] -``` - -## shift - -```res sig -let shift: t<'a> => option<'a> -``` - -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. - -```res example -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 -``` - -## sortInPlace - -```res sig -let sortInPlace: t<'a> => t<'a> -``` - -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. - -```res example -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] -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: (('a, 'a) => int, t<'a>) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## spliceInPlace - -```res sig -let spliceInPlace: (~pos: int, ~remove: int, ~add: array<'a>, t<'a>) => t<'a> -``` - -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. - -```res example -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"] -``` - -## removeFromInPlace - -```res sig -let removeFromInPlace: (~pos: int, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array.removeFromInPlace(~pos=4, arr) == ["e", "f"] -arr == ["a", "b", "c", "d"] -``` - -## removeCountInPlace - -```res sig -let removeCountInPlace: (~pos: int, ~count: int, t<'a>) => t<'a> -``` - -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. - -```res example -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array.removeCountInPlace(~pos=2, ~count=3, arr) == ["c", "d", "e"] -arr == ["a", "b", "f"] -``` - -## unshift - -```res sig -let unshift: ('a, t<'a>) => int -``` - -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. - -```res example -let arr = ["b", "c", "d"] -Js.Array.unshift("a", arr) == 4 -arr == ["a", "b", "c", "d"] -``` - -## unshiftMany - -```res sig -let unshiftMany: (array<'a>, t<'a>) => int -``` - -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. - -```res example -let arr = ["d", "e"] -Js.Array.unshiftMany(["a", "b", "c"], arr) == 5 -arr == ["a", "b", "c", "d", "e"] -``` - -## append - -```res sig -let append: ('a, t<'a>) => t<'a> -``` - -Deprecated. `append()` is not type-safe. Use `concat()` instead. - -## concat - -```res sig -let concat: (t<'a>, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array.concat(["c", "d", "e"], ["a", "b"]) == ["a", "b", "c", "d", "e"] -``` - -## concatMany - -```res sig -let concatMany: (array>, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array.concatMany([["d", "e"], ["f", "g", "h"]], ["a", "b", "c"]) == [ - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - ] -``` - -## includes - -```res sig -let includes: ('a, t<'a>) => bool -``` - -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. - -```res example -Js.Array.includes("b", ["a", "b", "c"]) == true -Js.Array.includes("x", ["a", "b", "c"]) == false -``` - -## indexOf - -```res sig -let indexOf: ('a, t<'a>) => int -``` - -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. - -```res example -Js.Array.indexOf(102, [100, 101, 102, 103]) == 2 -Js.Array.indexOf(999, [100, 101, 102, 103]) == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: ('a, ~from: int, t<'a>) => int -``` - -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. - -```res example -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 -``` - -## join - -```res sig -let join: t<'a> => string -``` - -Deprecated. Use `joinWith` instead. - -## joinWith - -```res sig -let joinWith: (string, t<'a>) => string -``` - -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. - -```res example -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" -``` - -## lastIndexOf - -```res sig -let lastIndexOf: ('a, t<'a>) => int -``` - -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. - -```res example -Js.Array.lastIndexOf("a", ["a", "b", "a", "c"]) == 2 -Js.Array.lastIndexOf("x", ["a", "b", "a", "c"]) == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: ('a, ~from: int, t<'a>) => int -``` - -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. - -```res example -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 -``` - -## lastIndexOf_start - -```res sig -let lastIndexOf_start: ('a, t<'a>) => int -``` - -Deprecated. Please use `lastIndexOf`. - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t<'a>) => t<'a> -``` - -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. - -```res example -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) == [] -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -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. - -## slice_copy - -```res sig -let slice_copy: (unit, t<'a>) => t<'a> -``` - -Deprecated. Please use `copy`. - -## sliceFrom - -```res sig -let sliceFrom: (int, t<'a>) => t<'a> -``` - -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. - -```res example -Js.Array.sliceFrom(2, [100, 101, 102, 103, 104]) == [102, 103, 104] -``` - -## slice_start - -```res sig -let slice_start: (int, t<'a>) => t<'a> -``` - -Deprecated. Please `sliceFrom`. - -## toString - -```res sig -let toString: t<'a> => string -``` - -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. - -```res example -Js.Array.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8" -Js.Array.toString(["a", "b", "c"]) == "a,b,c" -``` - -## toLocaleString - -```res sig -let toLocaleString: t<'a> => string -``` - -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. - -```res example -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 -``` - -## every - -```res sig -let every: ('a => bool, t<'a>) => bool -``` - -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. - -```res example -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 -``` - -## everyi - -```res sig -let everyi: (('a, int) => bool, t<'a>) => bool -``` - -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. - -```res example -// 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 -``` - -## filter - -```res sig -let filter: ('a => bool, t<'a>) => t<'a> -``` - -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. - -```res example -let nonEmpty = s => s != "" -Js.Array.filter(nonEmpty, ["abc", "", "", "def", "ghi"]) == ["abc", "def", "ghi"] -``` - -## filteri - -```res sig -let filteri: (('a, int) => bool, t<'a>) => t<'a> -``` - -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. - -```res example -// 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] -``` - -## find - -```res sig -let find: ('a => bool, t<'a>) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findi - -```res sig -let findi: (('a, int) => bool, t<'a>) => option<'a> -``` - -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. - -```res example -// 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 -``` - -## findIndex - -```res sig -let findIndex: ('a => bool, t<'a>) => int -``` - -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. - -```res example -Js.Array.findIndex(x => x < 0, [33, 22, -55, 77, -44]) == 2 -Js.Array.findIndex(x => x < 0, [33, 22, 55, 77, 44]) == -1 -``` - -## findIndexi - -```res sig -let findIndexi: (('a, int) => bool, t<'a>) => int -``` - -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. - -```res example -// 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 -``` - -## forEach - -```res sig -let forEach: ('a => unit, t<'a>) => unit -``` - -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. - -```res example -// display all elements in an array -Js.Array.forEach(x => Js.log(x), ["a", "b", "c"]) == () -``` - -## forEachi - -```res sig -let forEachi: (('a, int) => unit, t<'a>) => unit -``` - -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. - -```res example -// display all elements in an array as a numbered list -Js.Array.forEachi((item, index) => Js.log2(index + 1, item), ["a", "b", "c"]) == () -``` - -## map - -```res sig -let map: ('a => 'b, t<'a>) => t<'b> -``` - -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. - -```res example -Js.Array.map(x => x * x, [12, 4, 8]) == [144, 16, 64] -Js.Array.map(Js.String.length, ["animal", "vegetable", "mineral"]) == [6, 9, 7] -``` - -## mapi - -```res sig -let mapi: (('a, int) => 'b, t<'a>) => t<'b> -``` - -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. - -```res example -// multiply each item in array by its position -let product = (item, index) => item * index -Js.Array.mapi(product, [10, 11, 12]) == [0, 11, 24] -``` - -## reduce - -```res sig -let reduce: (('b, 'a) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -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) -``` - -## reducei - -```res sig -let reducei: (('b, 'a, int) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -// 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 -``` - -## reduceRight - -```res sig -let reduceRight: (('b, 'a) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -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) -``` - -## reduceRighti - -```res sig -let reduceRighti: (('b, 'a, int) => 'b, 'b, t<'a>) => 'b -``` - -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. - -```res example -// 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 -``` - -## some - -```res sig -let some: ('a => bool, t<'a>) => bool -``` - -Returns `true` if the predicate function given as the first argument to `some()` returns `true` for any element in the array; `false` otherwise. - -```res example -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 -``` - -## somei - -```res sig -let somei: (('a, int) => bool, t<'a>) => bool -``` - -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 - -```res example -// 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 -``` - -## unsafe_get - -```res sig -let unsafe_get: (array<'a>, int) => 'a -``` - -Returns the value at the given position in the array if the position is in bounds; returns -the JavaScript value `undefined` otherwise. - -```res example -let arr = [100, 101, 102, 103] -Js.Array.unsafe_get(arr, 3) == 103 -Js.Array.unsafe_get(arr, 4) // returns undefined -``` - -## unsafe_set - -```res sig -let unsafe_set: (array<'a>, int, 'a) => unit -``` - -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._ - -```res example -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. -``` diff --git a/pages/docs/manual/v9.0.0/api/js/console.mdx b/pages/docs/manual/v9.0.0/api/js/console.mdx deleted file mode 100644 index c7d83a8ed..000000000 --- a/pages/docs/manual/v9.0.0/api/js/console.mdx +++ /dev/null @@ -1,113 +0,0 @@ -# Console - - - -Provide console (logging) utilities. - - - -## log - -```res sig -let log: 'a => unit -``` - -```res sig -let log2: ('a, 'b) => unit -``` - -```res sig -let log3: ('a, 'b, 'c) => unit -``` - -```res sig -let log4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let logMany: array<'a> => unit -``` - -## info - -```res sig -let info: 'a => unit -``` - -```res sig -let info2: ('a, 'b) => unit -``` - -```res sig -let info3: ('a, 'b, 'c) => unit -``` - -```res sig -let info4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let infoMany: array<'a> => unit -``` - -## warn - -```res sig -let warn: 'a => unit -``` - -```res sig -let warn2: ('a, 'b) => unit -``` - -```res sig -let warn3: ('a, 'b, 'c) => unit -``` - -```res sig -let warn4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let warnMany: array<'a> => unit -``` - -## error - -```res sig -let error: 'a => unit -``` - -```res sig -let error2: ('a, 'b) => unit -``` - -```res sig -let error3: ('a, 'b, 'c) => unit -``` - -```res sig -let error4: ('a, 'b, 'c, 'd) => unit -``` - -```res sig -let errorMany: array<'a> => unit -``` - -## trace - -```res sig -let trace: unit => unit -``` - -## timeStart - -```res sig -let timeStart: string => unit -``` - -## timeEnd - -```res sig -let timeEnd: string => unit -``` diff --git a/pages/docs/manual/v9.0.0/api/js/date.mdx b/pages/docs/manual/v9.0.0/api/js/date.mdx deleted file mode 100644 index a381d68e5..000000000 --- a/pages/docs/manual/v9.0.0/api/js/date.mdx +++ /dev/null @@ -1,1134 +0,0 @@ -# Date - - - -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. - - - -In these examples, we will be using this date: - -```res prelude -let exampleDate = Js.Date.fromFloat(123456654321.0) -``` - -which is Thu, 29 Nov 1973 21:30:54 GMT. There is no particular significance to this date. -The code used to access this date is running in the Europe/Austria time zone with the `en_US.utf8` locale. - -In all of these functions, month values are in the range 0-11, where January is month zero. - -## t - -```res prelude -type t -``` - -## valueOf - -```res sig -let valueOf: t => float -``` - -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.) - -```res example -Js.Date.valueOf(exampleDate) == 123456654321.0 -``` - -## make - -```res sig -let make: unit => t -``` - -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. - -```res example -let now = Js.Date.make() -``` - -## fromFloat - -```res sig -let fromFloat: float => t -``` - -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. - -```res example -Js.Date.fromFloat(123456654321.0) == exampleDate -``` - -## fromString - -```res sig -let fromString: string => t -``` - -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. - -```res example -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 -``` - -## makeWithYM - -```res sig -let makeWithYM: (~year: float, ~month: float, unit) => t -``` - -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. - -```res example -let november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ()) -``` - -## makeWithYMD - -```res sig -let makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t -``` - -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. - -## makeWithYMDH - -```res sig -let makeWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => t -``` - -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. - -## makeWithYMDHM - -```res sig -let makeWithYMDHM: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - unit, -) => t -``` - -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. - -## makeWithYMDHMS - -```res sig -let makeWithYMDHMS: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - ~seconds: float, - unit, -) => t -``` - -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. - -```res example -Js.Date.makeWithYMDHMS( - ~year=1973.0, - ~month=11.0, - ~date=29.0, - ~hours=21.0, - ~minutes=30.0, - ~seconds=54.321, - (), -) == exampleDate -``` - -## utcWithYM - -```res sig -let utcWithYM: (~year: float, ~month: float, unit) => float -``` - -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. - -```res example -let november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ()) -``` - -## utcWithYMD - -```res sig -let 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 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. - -## utcWithYMDH - -```res sig -let 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 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. - -## utcWithYMDHM - -```res sig -let 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 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. - -## utcWithYMDHMS - -```res sig -let utcWithYMDHMS: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - ~seconds: 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. - -## now - -```res sig -let now: unit => float -``` - -Returns the current time as number of milliseconds since Unix epoch. - -## parse - -```res sig -let parse: string => t -``` - -Deprecated. Use [`fromString()`](#fromstring). - -## parseAsFloat - -```res sig -let parseAsFloat: string => float -``` - -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. - -## getDate - -```res sig -let getDate: t => 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. - -```res example -Js.Date.getDate(exampleDate) == 29.0 -``` - -## getDay - -```res sig -let getDay: t => float -``` - -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. - -```res example -Js.Date.getDay(exampleDate) == 4.0 -``` - -## getFullYear - -```res sig -let getFullYear: t => float -``` - -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. - -```res example -Js.Date.getFullYear(exampleDate) == 1973.0 -``` - -## getHours - -```res sig -let getHours: t => float -``` - -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. - -```res example -Js.Date.getHours(exampleDate) == 22.0 // Vienna is in GMT+01:00 -``` - -## getMilliseconds - -```res sig -let getMilliseconds: t => float -``` - -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. - -```res example -Js.Date.getMilliseconds(exampleDate) == 321.0 -``` - -## getMinutes - -```res sig -let getMinutes: t => float -``` - -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. - -```res example -Js.Date.getMinutes(exampleDate) == 30.0 -``` - -## getMonth - -```res sig -let getMonth: t => float -``` - -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. - -```res example -Js.Date.getMonth(exampleDate) == 10.0 -``` - -## getSeconds - -```res sig -let getSeconds: t => float -``` - -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. - -```res example -Js.Date.getSeconds(exampleDate) == 54.0 -``` - -## getTime - -```res sig -let getTime: t => float -``` - -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. - -```res example -Js.Date.getTime(exampleDate) == 123456654321.0 -``` - -## getTimezoneOffset - -```res sig -let getTimezoneOffset: t => float -``` - -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. - -```res example -Js.Date.getTimezoneOffset(exampleDate) == -60.0 -``` - -## getUTCDate - -```res sig -let getUTCDate: t => float -``` - -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. - -```res example -Js.Date.getUTCDate(exampleDate) == 29.0 -``` - -## getUTCDay - -```res sig -let getUTCDay: t => float -``` - -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. - -```res example -Js.Date.getUTCDay(exampleDate) == 4.0 -``` - -## getUTCFullYear - -```res sig -let getUTCFullYear: t => float -``` - -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. - -```res example -Js.Date.getUTCFullYear(exampleDate) == 1973.0 -``` - -## getUTCHours - -```res sig -let getUTCHours: t => float -``` - -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. - -```res example -Js.Date.getUTCHours(exampleDate) == 21.0 -``` - -## getUTCMilliseconds - -```res sig -let getUTCMilliseconds: t => float -``` - -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. - -```res example -Js.Date.getUTCMilliseconds(exampleDate) == 321.0 -``` - -## getUTCMinutes - -```res sig -let getUTCMinutes: t => float -``` - -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. - -```res example -Js.Date.getUTCMinutes(exampleDate) == 30.0 -``` - -## getUTCMonth - -```res sig -let getUTCMonth: t => float -``` - -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. - -```res example -Js.Date.getUTCMonth(exampleDate) == 10.0 -``` - -## getUTCSeconds - -```res sig -let getUTCSeconds: t => float -``` - -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. - -```res example -Js.Date.getUTCSeconds(exampleDate) == 54.0 -``` - -## getYear - -```res sig -let getYear: t => float -``` - -Deprecated. Use `getFullYear()` instead. - -## setDate - -```res sig -let setDate: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setFullYear - -```res sig -let setFullYear: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setFullYearM - -```res sig -let setFullYearM: (t, ~year: float, ~month: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setFullYearMD - -```res sig -let setFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setHours - -```res sig -let setHours: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setHoursM - -```res sig -let setHoursM: (t, ~hours: float, ~minutes: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setHoursMS - -```res sig -let setHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setHoursMSMs - -```res sig -let setHoursMSMs: ( - t, - ~hours: float, - ~minutes: float, - ~seconds: float, - ~milliseconds: float, - unit, -) => float -``` - -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. - -```res example -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) -``` - -## setMilliseconds - -```res sig -let setMilliseconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setMinutes - -```res sig -let setMinutes: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setMinutesS - -```res sig -let setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setMinutesSMs - -```res sig -let setMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setMonth - -```res sig -let setMonth: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setMonthD - -```res sig -let setMonthD: (t, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setSeconds - -```res sig -let setSeconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setSecondsMs - -```res sig -let setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setTime - -```res sig -let setTime: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCDate - -```res sig -let setUTCDate: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCFullYear - -```res sig -let setUTCFullYear: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCFullYearM - -```res sig -let setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCFullYearMD - -```res sig -let setUTCFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCHours - -```res sig -let setUTCHours: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCHoursM - -```res sig -let setUTCHoursM: (t, ~hours: float, ~minutes: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCHoursMS - -```res sig -let setUTCHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCHoursMSMs - -```res sig -let setUTCHoursMSMs: ( - t, - ~hours: float, - ~minutes: float, - ~seconds: float, - ~milliseconds: float, - unit, -) => float -``` - -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. - -```res example -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) -``` - -## setUTCMilliseconds - -```res sig -let setUTCMilliseconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCMinutes - -```res sig -let setUTCMinutes: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCMinutesS - -```res sig -let setUTCMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCMinutesSMs - -```res sig -let setUTCMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCMonth - -```res sig -let setUTCMonth: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCMonthD - -```res sig -let setUTCMonthD: (t, ~month: float, ~date: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCSeconds - -```res sig -let setUTCSeconds: (t, float) => float -``` - -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. - -```res example -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) -``` - -## setUTCSecondsMs - -```res sig -let setUTCSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float -``` - -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. - -```res example -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) -``` - -## setUTCTime - -```res sig -let setUTCTime: (t, float) => float -``` - -Same as [`setTime()`](#settime). - -## setYear - -```res sig -let setYear: (t, float) => float -``` - -Deprecated. Use [`setFullYear()`](#setfullyear) instead. - -## toDateString - -```res sig -let toDateString: t => string -``` - -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. - -```res example -Js.Date.toDateString(exampleDate) == "Thu Nov 29 1973" -``` - -## toGMTString - -```res sig -let toGMTString: t => string -``` - -Deprecated. Use [`toUTCString()`](#toutcstring) instead. - -## toISOString - -```res sig -let toISOString: t => string -``` - -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. - -```res example -Js.Date.toISOString(exampleDate) == "1973-11-29T21:30:54.321Z" -``` - -## toJSON - -```res sig -let toJSON: t => string -``` - -Deprecated. This method is unsafe. It will be changed to return `option` in a future release. Please use `toJSONUnsafe()` instead. - -## toJSONUnsafe - -```res sig -let toJSONUnsafe: t => string -``` - -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. - -```res example -Js.Date.toJSONUnsafe(exampleDate) == "1973-11-29T21:30:54.321Z" -``` - -## toLocaleDateString - -```res sig -let toLocaleDateString: t => string -``` - -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. - -```res example -Js.Date.toLocaleDateString(exampleDate) == "11/29/1973" // for en_US.utf8 -Js.Date.toLocaleDateString(exampleDate) == "29.11.73" // for de_DE.utf8 -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -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. - -```res example -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 -``` - -## toLocaleTimeString - -```res sig -let toLocaleTimeString: t => string -``` - -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. - -```res example -Js.Date.toLocaleString(exampleDate) == "10:30:54 PM" // for en_US.utf8 -Js.Date.toLocaleString(exampleDate) == "22:30:54" // for de_DE.utf8 -``` - -## toString - -```res sig -let toString: t => string -``` - -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. - -```res example -Js.Date.toString( - exampleDate, -) == "Thu Nov 29 1973 22:30:54 GMT+0100 (Central European Standard Time)" -``` - -## toTimeString - -```res sig -let toTimeString: t => string -``` - -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. - -```res example -Js.Date.toTimeString(exampleDate) == "22:30:54 GMT+0100 (Central European Standard Time)" -``` - -## toUTCString - -```res sig -let toUTCString: t => string -``` - -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. - -```res example -Js.Date.toUTCString(exampleDate) == "Thu, 29 Nov 1973 21:30:54 GMT" -``` diff --git a/pages/docs/manual/v9.0.0/api/js/dict.mdx b/pages/docs/manual/v9.0.0/api/js/dict.mdx deleted file mode 100644 index 0758932ae..000000000 --- a/pages/docs/manual/v9.0.0/api/js/dict.mdx +++ /dev/null @@ -1,165 +0,0 @@ -# Dict - - - -Provide utilities for JS dictionary object. - -**Note:** This module's examples will assume this predeclared dictionary: - -```res prelude -let ages = Js.Dict.fromList(list{("Maria", 30), ("Vinh", 22), ("Fred", 49)}) -``` - - - -## t - -```res prelude -type t<'a> -``` - -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. - -## key - -```res prelude -type key = string -``` - -The type for dictionary keys. This means that dictionaries _must_ use `string`s as their keys. - -## get - -```res sig -let get: (t<'a>, key) => option<'a> -``` - -`Js.Dict.get(key)` returns `None` if the key is not found in the dictionary, `Some(value)` otherwise. - -```res example -Js.Dict.get(ages, "Vinh") == Some(22) -Js.Dict.get(ages, "Paul") == None -``` - -## unsafeGet - -```res sig -let unsafeGet: (t<'a>, key) => '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). - -```res example -Js.Dict.unsafeGet(ages, "Fred") == 49 -Js.Dict.unsafeGet(ages, "Paul") // returns undefined -``` - -## set - -```res sig -let set: (t<'a>, key, 'a) => unit -``` - -`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._ - -```res example -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)})) -``` - -## keys - -```res sig -let keys: t<'a> => array -``` - -Returns all the keys in the dictionary `dict`. - -```res example -Js.Dict.keys(ages) == ["Maria", "Vinh", "Fred"] -``` - -## empty - -```res sig -let empty: unit => t<'a> -``` - -Returns an empty dictionary. - -## unsafeDeleteKey - -```res sig -let unsafeDeleteKey: (. t, string) => unit -``` - -Experimental internal function - -## entries - -```res sig -let entries: t<'a> => array<(key, 'a)> -``` - -Returns an array of key/value pairs in the given dictionary (ES2017). - -```res example -Js.Dict.entries(ages) == [("Maria", 30), ("Vinh", 22), ("Fred", 49)] -``` - -## values - -```res sig -let values: t<'a> => array<'a> -``` - -Returns the values in the given dictionary (ES2017). - -```res example -Js.Dict.values(ages) == [30, 22, 49] -``` - -## fromList - -```res sig -let fromList: list<(key, 'a)> => t<'a> -``` - -Creates a new dictionary containing each (key, value) pair in its list argument. - -```res example -let capitals = Js.Dict.fromList(list{("Japan", "Tokyo"), ("France", "Paris"), ("Egypt", "Cairo")}) -``` - -## fromArray - -```res sig -let fromArray: array<(key, 'a)> => t<'a> -``` - -Creates a new dictionary containing each (key, value) pair in its array argument. - -```res example -let capitals2 = Js.Dict.fromArray([("Germany", "Berlin"), ("Burkina Faso", "Ouagadougou")]) -``` - -## map - -```res sig -let map: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -`map(f, dict)` maps `dict` to a new dictionary with the same keys, using the function `f` to map each value. - -```res example -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)}) -``` diff --git a/pages/docs/manual/v9.0.0/api/js/exn.mdx b/pages/docs/manual/v9.0.0/api/js/exn.mdx deleted file mode 100644 index 730a4b2ed..000000000 --- a/pages/docs/manual/v9.0.0/api/js/exn.mdx +++ /dev/null @@ -1,103 +0,0 @@ -# Exn - - - -Provide utilities for dealing with JS exceptions. - - - -## t - -```res prelude -type t -``` - -## exn - -```res sig -type exn += - private - | Error(t) -``` - -## asJsExn - -```res sig -let asJsExn: exn => option -``` - -## stack - -```res sig -let stack: t => option -``` - -## message - -```res sig -let message: t => option -``` - -## name - -```res sig -let name: t => option -``` - -## fileName - -```res sig -let fileName: t => option -``` - -## isCamlExceptionOrOpenVariant - -```res sig -let isCamlExceptionOrOpenVariant: 'a => bool -``` - -Internal use only. - -## raiseError - -```res sig -let raiseError: string => 'a -``` - -Raise Js exception Error object with stacktrace. - -## raiseEvalError - -```res sig -let raiseEvalError: string => 'a -``` - -## raiseRangeError - -```res sig -let raiseRangeError: string => 'a -``` - -## raiseReferenceError - -```res sig -let raiseReferenceError: string => 'a -``` - -## raiseSyntaxError - -```res sig -let raiseSyntaxError: string => 'a -``` - -## raiseTypeError - -```res sig -let raiseTypeError: string => 'a -``` - -## raiseUriError - -```res sig -let raiseUriError: string => 'a -``` diff --git a/pages/docs/manual/v9.0.0/api/js/float.mdx b/pages/docs/manual/v9.0.0/api/js/float.mdx deleted file mode 100644 index 13f375ad5..000000000 --- a/pages/docs/manual/v9.0.0/api/js/float.mdx +++ /dev/null @@ -1,283 +0,0 @@ -# Float - - - -Provide utilities for JS float. - - - -## \_NaN - -```res sig -let _NaN: float -``` - -The special value "Not a Number". - -## isNaN - -```res sig -let isNaN: float => bool -``` - -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`. - -Returns true if the given value is `_NaN`, false otherwise. - -## isFinite - -```res sig -let isFinite: float => bool -``` - -Tests if the given value is finite. -Returns true if the given value is a finite number, false otherwise. - -```res example -/* returns [false] */ -Js.Float.isFinite(infinity) -``` - -```res example -/* returns [false] */ -Js.Float.isFinite(neg_infinity) -``` - -```res example -/* returns [false] */ -Js.Float.isFinite(Js.Float._NaN) -``` - -```res example -/* returns [true] */ -Js.Float.isFinite(1234.) -``` - -## toExponential - -```res sig -let toExponential: float => string -``` - -Formats a float using exponential (scientific) notation. -Returns a string representing the given value in exponential notation. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.71234e+1" */ -Js.Float.toExponential(77.1234)->Js.log -``` - -```res example -/* prints "7.7e+1" */ -Js.Float.toExponential(77.)->Js.log -``` - -## toExponentialWithPrecision - -```res sig -let toExponentialWithPrecision: (float, ~digits: int) => string -``` - -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). - -Returns a `string` representing the given value in exponential notation. - -The output will be rounded or padded with zeroes if necessary. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.71e+1" */ -Js.Float.toExponentialWithPrecision(77.1234, ~digits=2)->Js.log -``` - -## toFixed - -```res sig -let toFixed: float => string -``` - -Formats a `float` using fixed point notation. -Returns a `string` representing the given value in fixed-point notation (usually). -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "12346" (note the rounding) */ -Js.Float.toFixed(12345.6789)->Js.log -``` - -```res example -/* print "1.2e+21" */ -Js.Float.toFixed(1.2e21)->Js.log -``` - -## toFixedWithPrecision - -```res sig -let toFixedWithPrecision: (float, ~digits: int) => string -``` - -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. - -Returns a `string` representing the given value in fixed-point notation (usually). - -The output will be rounded or padded with zeroes if necessary. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "12345.7" (note the rounding) */ -Js.Float.toFixedWithPrecision(12345.6789, ~digits=1)->Js.log -``` - -```res example -/* prints "0.00" (note the added zeroes) */ -Js.Float.toFixedWithPrecision(0., ~digits=2)->Js.log -``` - -## toPrecision - -```res sig -let toPrecision: float => string -``` - -Formats a `float` 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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "12345.6789" */ -Js.Float.toPrecision(12345.6789)->Js.log -``` - -```res example -/* print "1.2e+21" */ -Js.Float.toPrecision(1.2e21)->Js.log -``` - -## toPrecisionWithPrecision - -```res sig -let toPrecisionWithPrecision: (float, ~digits: int) => string -``` - -Formats a `float` using some fairly arbitrary rules. -`digits` specifies how many digits should appear in total. The value must be 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 for digits before the decimal point. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "1e+4" */ -Js.Float.toPrecisionWithPrecision(12345.6789, ~digits=1)->Js.log -``` - -```res example -/* prints "0.0" */ -Js.Float.toPrecisionWithPrecision(0., ~digits=2)->Js.log -``` - -## toString - -```res sig -let toString: float => string -``` - -Formats a `float` as a `string`. -Returns a `string` representing the given value in fixed-point (usually). - -```res example -/* prints "12345.6789" */ -Js.Float.toString(12345.6789)->Js.log -``` - -## toStringWithRadix - -```res sig -let toStringWithRadix: (float, ~radix: int) => string -``` - -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). - -Returns a `string` representing the given value in fixed-point (usually). -Raises `RangeError` if `radix` is not in the range \[2, 36\] (inclusive). - -```res example -/* prints "110" */ -Js.Float.toStringWithRadix(6., ~radix=2)->Js.log -``` - -```res example -/* prints "11.001000111101011100001010001111010111000010100011111" */ -Js.Float.toStringWithRadix(3.14, ~radix=2)->Js.log -``` - -```res example -/* prints "deadbeef" */ -Js.Float.toStringWithRadix(3735928559., ~radix=16)->Js.log - -``` - -```res example -/* prints "3f.gez4w97ry0a18ymf6qadcxr" */ -Js.Float.toStringWithRadix(123.456, ~radix=36)->Js.log -``` - -## fromString - -```res sig -let fromString: string => float -``` - -Parses the given `string` into a `float` using JavaScript semantics. -Returns the number as a `float` if successfully parsed, `_NaN` otherwise. - -```res example -/* returns 123 */ -Js.Float.fromString("123") -``` - -```res example -/* returns 12.3 */ -Js.Float.fromString("12.3") -``` - -```res example -/* returns 0 */ -Js.Float.fromString("") -``` - -```res example -/* returns 17 */ -Js.Float.fromString("0x11") -``` - -```res example -/* returns 3 */ -Js.Float.fromString("0b11") -``` - -```res example -/* returns 9 */ -Js.Float.fromString("0o11") -``` - -```res example -/* returns [_NaN] */ -Js.Float.fromString("hello") -``` - -```res example -/* returns [_NaN] */ -Js.Float.fromString("100a") -``` diff --git a/pages/docs/manual/v9.0.0/api/js/global.mdx b/pages/docs/manual/v9.0.0/api/js/global.mdx deleted file mode 100644 index 7bba67610..000000000 --- a/pages/docs/manual/v9.0.0/api/js/global.mdx +++ /dev/null @@ -1,179 +0,0 @@ -# Global - - - -Provide bindings to JS global functions in global namespace. - - - -```res prelude -type intervalId -``` - -Identify an interval started by `Js.Global.setInterval`. - -```res prelude -type timeoutId -``` - -Identify timeout started by `Js.Global.setTimeout`. - -## clearInterval - -```res sig -let clearInterval: intervalId => unit -``` - -Clear an interval started by `Js.Global.setInterval` - -```res example -/* 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)) -``` - -## clearTimeout - -```res sig -let clearTimeout: timeoutId => unit -``` - -Clear a timeout started by `Js.Global.setTimeout`. - -```res example -/* 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)) -} -``` - -## setInterval - -```res sig -let setInterval: (unit => unit, int) => intervalId -``` - -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. - -```res example -/* 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) -``` - -## setIntervalFloat - -```res sig -let setIntervalFloat: (unit => unit, float) => intervalId -``` - -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. - -```res example -/* 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) -``` - -## setTimeout - -```res sig -let setTimeout: (unit => unit, int) => timeoutId -``` - -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. - -```res example -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!" - -Js.Global.setTimeout(() => Js.log(message), 1000) -``` - -## setTimeoutFloat - -```res sig -let setTimeoutFloat: (unit => unit, float) => timeoutId -``` - -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. - -```res example -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!" - -Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0) -``` - -## encodeURI - -```res sig -let encodeURI: string => string -``` - -URL-encodes a string. - -## decodeURI - -```res sig -let decodeURI: string => string -``` - -Decodes a URL-enmcoded string produced by encodeURI. - -## encodeURIComponent - -```res sig -let encodeURIComponent: string => string -``` - -URL-encodes a string, including characters with special meaning in a URI. - -## decodeURIComponent - -```res sig -let decodeURIComponent: string => string -``` - -Decodes a URL-enmcoded string produced by encodeURIComponent diff --git a/pages/docs/manual/v9.0.0/api/js/int.mdx b/pages/docs/manual/v9.0.0/api/js/int.mdx deleted file mode 100644 index 1fc48b47a..000000000 --- a/pages/docs/manual/v9.0.0/api/js/int.mdx +++ /dev/null @@ -1,146 +0,0 @@ -# Int - - - -Provide utilities for handling `int`. - - - -## toExponential - -```res sig -let toExponential: int => string -``` - -Formats an `int` using exponential (scientific) notation. -Returns a `string` representing the given value in exponential notation. -Raises `RangeError` if digits is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.7e+1" */ -Js.log(Js.Int.toExponential(77)) -``` - -## toExponentialWithPrecision - -```res sig -let toExponentialWithPrecision: (int, ~digits: int) => string -``` - -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. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -```res example -/* prints "7.70e+1" */ -Js.log(Js.Int.toExponentialWithPrecision(77, ~digits=2)) - -/* prints "5.68e+3" */ -Js.log(Js.Int.toExponentialWithPrecision(5678, ~digits=2)) -``` - -## toPrecision - -```res sig -let toPrecision: int => string -``` - -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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "123456789" */ -Js.log(Js.Int.toPrecision(123456789)) -``` - -## toPrecisionWithPrecision - -```res sig -let toPrecisionWithPrecision: (int, ~digits: int) => string -``` - -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. -Raises `RangeError` if `digits` is not in the range accepted by this function. - -```res example -/* prints "1.2e+8" */ -Js.log(Js.Int.toPrecisionWithPrecision(123456789, ~digits=2)) - -/* prints "0.0" */ -Js.log(Js.Int.toPrecisionWithPrecision(0, ~digits=2)) -``` - -## toString - -```res sig -let toString: int => string -``` - -Formats an `int` as a `string`. -Returns a `string` representing the given value in fixed-point (usually). - -```res example -/* prints "123456789" */ -Js.log(Js.Int.toString(123456789)) -``` - -## toStringWithRadix - -```res sig -let toStringWithRadix: (int, ~radix: int) => string -``` - -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). -Raises `RangeError` if `radix` is not in the range \[2, 36\] (inclusive). - -```res example -/* 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)) -``` - -## toFloat - -```res sig -let toFloat: int => float -``` - -## equal - -```res sig -let equal: (int, int) => bool -``` - -## max - -```res sig -let max: int -``` - -## min - -```res sig -let min: int -``` diff --git a/pages/docs/manual/v9.0.0/api/js/json.mdx b/pages/docs/manual/v9.0.0/api/js/json.mdx deleted file mode 100644 index 99c970894..000000000 --- a/pages/docs/manual/v9.0.0/api/js/json.mdx +++ /dev/null @@ -1,292 +0,0 @@ -# Json - - - -Provide utilities for JSON. - - - -## t - -```res prelude -type t -``` - -The JSON data structure. - -## kind - -```res prelude -type rec kind<'a> = - | String: kind - | Number: kind - | Object: kind> - | Array: kind> - | Boolean: kind - | Null: kind -``` - -Underlying type of a JSON value. - -## tagged_t - -```res prelude -type tagged_t = - | JSONFalse - | JSONTrue - | JSONNull - | JSONString(string) - | JSONNumber(float) - | JSONObject(Js_dict.t) - | JSONArray(array) -``` - -## classify - -```res sig -let classify: t => tagged_t -``` - -## test - -```res sig -let test: ('a, kind<'b>) => bool -``` - -`test(v, kind)` returns `true` if `v` is of `kind`. - -## decodeString - -```res sig -let decodeString: t => option -``` - -`decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise. - -## decodeNumber - -```res sig -let decodeNumber: t => option -``` - -`decodeNumber(json)` returns `Some(n)` if `json` is a `number`, `None` otherwise. - -## decodeObject - -```res sig -let decodeObject: t => option> -``` - -`decodeObject(json)` returns `Some(o)` if `json` is an `object`, `None` otherwise. - -## decodeArray - -```res sig -let decodeArray: t => option> -``` - -`decodeArray(json)` returns `Some(a)` if `json` is an `array`, `None` otherwise. - -## decodeBoolean - -```res sig -let decodeBoolean: t => option -``` - -`decodeBoolean(json)` returns `Some(b)` if `json` is a `boolean`, `None` otherwise. - -## decodeNull - -```res sig -let decodeNull: t => option> -``` - -`decodeNull(json)` returns `Some(null)` if `json` is a `null`, `None` otherwise. - -## null - -```res sig -let null: t -``` - -`null` is the singleton null JSON value. - -## string - -```res sig -let string: string => t -``` - -`string(s)` makes a JSON string of the `string` `s`. - -## number - -```res sig -let number: float => t -``` - -`number(n)` makes a JSON number of the `float` `n`. - -## boolean - -```res sig -let boolean: bool => t -``` - -`boolean(b)` makes a JSON boolean of the `bool` `b`. - -## object\_ - -```res sig -let object_: Js_dict.t => t -``` - -`object_(dict)` makes a JSON object of the `Js.Dict.t` `dict`. - -## array - -```res sig -let array: array => t -``` - -`array_(a)` makes a JSON array of the `Js.Json.t` array `a`. - -## stringArray - -```res sig -let stringArray: array => t -``` - -`stringArray(a)` makes a JSON array of the `string` array `a`. - -## numberArray - -```res sig -let numberArray: array => t -``` - -`numberArray(a)` makes a JSON array of the `float` array `a`. - -## booleanArray - -```res sig -let booleanArray: array => t -``` - -`booleanArray(a)` makes a JSON array of the `bool` array `a`. - -## objectArray - -```res sig -let objectArray: array> => t -``` - -`objectArray(a) makes a JSON array of the `JsDict.t`array`a`. - -## parseExn - -```res sig -let parseExn: string => t -``` - -`parseExn(s)` parses the `string` `s` into a JSON data structure. -Returns a JSON data structure. -Raises `SyntaxError` if the given string is not a valid JSON. Note: `SyntaxError` is a JavaScript exception. - -```res example -/* 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") -} -``` - -```res example -/* 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 Js.Dict.t */ - 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 ] } `)) -``` - -## stringify - -```res sig -let stringify: t => string -``` - -`stringify(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure. - -```res example -/* 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(["bucklescript", "ocaml", "js"])) - - Js.log(Js.Json.stringify(Js.Json.object_(dict))) -} -``` - -## stringifyWithSpace - -```res sig -let stringifyWithSpace: (t, int) => string -``` - -`stringify(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure with spacing. - -```res example -/* 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(["bucklescript", "ocaml", "js"])) - - Js.log(Js.Json.stringifyWithSpace(Js.Json.object_(dict), 2)) -} -``` - -## stringifyAny - -```res sig -let stringifyAny: 'a => option -``` - -`stringifyAny(value)` formats any value into a JSON string. - -```res example -/* prints `["hello", "world"]` */ -Js.log(Js.Json.stringifyAny(["hello", "world"])) -``` diff --git a/pages/docs/manual/v9.0.0/api/js/list.mdx b/pages/docs/manual/v9.0.0/api/js/list.mdx deleted file mode 100644 index 72b908489..000000000 --- a/pages/docs/manual/v9.0.0/api/js/list.mdx +++ /dev/null @@ -1,143 +0,0 @@ -# List - - - -Provide utilities for list. - - - -## t - -```res prelude -type t<'a> = list<'a> -``` - -## length - -```res sig -let length: t<'a> => int -``` - -## cons - -```res sig -let cons: ('a, t<'a>) => t<'a> -``` - -## isEmpty - -```res sig -let isEmpty: t<'a> => bool -``` - -## hd - -```res sig -let hd: t<'a> => option<'a> -``` - -## tl - -```res sig -let tl: t<'a> => option> -``` - -## nth - -```res sig -let nth: (t<'a>, int) => option<'a> -``` - -## revAppend - -```res sig -let revAppend: (t<'a>, t<'a>) => t<'a> -``` - -## rev - -```res sig -let rev: t<'a> => t<'a> -``` - -## mapRev - -```res sig -let mapRev: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -## map - -```res sig -let map: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -## iter - -```res sig -let iter: ((. 'a) => unit, t<'a>) => unit -``` - -## iteri - -```res sig -let iteri: ((. int, 'a) => unit, t<'a>) => unit -``` - -## foldLeft - -```res sig -let foldLeft: ((. 'a, 'b) => 'a, 'a, list<'b>) => 'a -``` - -Application order is left to right, tail-recurisve. - -## foldRight - -```res sig -let foldRight: ((. 'a, 'b) => 'b, list<'a>, 'b) => 'b -``` - -Application order is right to left, tail-recursive. - -## flatten - -```res sig -let flatten: t> => t<'a> -``` - -## filter - -```res sig -let filter: ((. 'a) => bool, t<'a>) => t<'a> -``` - -## filterMap - -```res sig -let filterMap: ((. 'a) => option<'b>, t<'a>) => t<'b> -``` - -## countBy - -```res sig -let countBy: ((. 'a) => bool, list<'a>) => int -``` - -## init - -```res sig -let init: (int, (. int) => 'a) => t<'a> -``` - -## toVector - -```res sig -let toVector: t<'a> => Js_vector.t<'a> -``` - -## equal - -```res sig -let equal: ((. 'a, 'a) => bool, list<'a>, list<'a>) => bool -``` diff --git a/pages/docs/manual/v9.0.0/api/js/math.mdx b/pages/docs/manual/v9.0.0/api/js/math.mdx deleted file mode 100644 index 69cd10d4d..000000000 --- a/pages/docs/manual/v9.0.0/api/js/math.mdx +++ /dev/null @@ -1,626 +0,0 @@ -# Math - - - -Provide utilities for JS Math. Note: The constants `_E`, `_LN10`, `_LN2`, `_LOG10E`, `_LOG2E`, `_PI`, `_SQRT1_2`, and `_SQRT2` begin with an underscore because ReasonML variable names cannot begin with a capital letter. (Module names begin with upper case.) - - - -## \_E - -```res sig -let _E: float -``` - -Euler's number; ≈ 2.718281828459045. See [`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) on MDN. - -## \_LN2 - -```res sig -let _LN2: float -``` - -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. - -## \_LN10 - -```res sig -let _LN10: float -``` - -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. - -## \_LOG2E - -```res sig -let _LOG2E: float -``` - -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. - -## \_LOG10E - -```res sig -let _LOG10E: float -``` - -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. - -## \_PI - -```res sig -let _PI: float -``` - -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. - -## \_SQRT1_2 - -```res sig -let _SQRT1_2: float -``` - -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. - -## \_SQRT2 - -```res sig -let _SQRT2: float -``` - -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. - -## abs_int - -```res sig -let abs_int: int => int -``` - -Absolute value for integer argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. - -## abs_float - -```res sig -let abs_float: float => float -``` - -Absolute value for float argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. - -## acos - -```res sig -let acos: float => float -``` - -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. - -## acosh - -```res sig -let acosh: float => float -``` - -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. - -## asin - -```res sig -let asin: float => float -``` - -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. - -## asinh - -```res sig -let asinh: float => float -``` - -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. - -## atan - -```res sig -let atan: float => float -``` - -Arctangent (in radians) of argument. See [`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) on MDN. - -## atanh - -```res sig -let atanh: float => float -``` - -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. - -## atan2 - -```res sig -let atan2: (~y: float, ~x: float, unit) => float -``` - -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. - -```res example -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 -``` - -## cbrt - -```res sig -let cbrt: float => float -``` - -Cube root. See [`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) on MDN - -## unsafe_ceil_int - -```res sig -let unsafe_ceil_int: float => int -``` - -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. - -```res example -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 -``` - -## unsafe_ceil - -```res sig -let unsafe_ceil: float => int -``` - -Deprecated; please use [`unsafe_ceil_int`](#unsafe_ceil_int) instead. - -## ceil_int - -```res sig -let ceil_int: float => 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. - -```res example -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 -``` - -## ceil - -```res sig -let ceil: float => int -``` - -Deprecated; please use [`ceil_int`](#ceil_int) instead. - -## ceil_float - -```res sig -let ceil_float: float => float -``` - -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. - -```res example -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 -``` - -## clz32 - -```res sig -let clz32: int => int -``` - -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. - -```res example -Js.Math.clz32(0) == 32 -Js.Math.clz32(-1) == 0 -Js.Math.clz32(255) == 24 -``` - -## cos - -```res sig -let cos: float => float -``` - -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. - -## cosh - -```res sig -let cosh: float => float -``` - -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. - -## exp - -```res sig -let exp: float => float -``` - -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. - -## expm1 - -```res sig -let expm1: float => float -``` - -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. - -## unsafe_floor_int - -```res sig -let unsafe_floor_int: float => int -``` - -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. - -```res example -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 -``` - -## unsafe_floor - -```res sig -let unsafe_floor: float => int -``` - -Deprecated; please use [`unsafe_floor_int`](#unsafe_floor_int) instead. - -## floor_int - -```res sig -let floor_int: float => 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. - -```res example -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 -``` - -## floor - -```res sig -let floor: float => int -``` - -Deprecated; please use [`floor_int`](#floor_int) instead. - -## floor_float - -```res sig -let floor_float: float => float -``` - -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. - -```res example -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 -``` - -## fround - -```res sig -let fround: float => float -``` - -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. - -```res example -Js.Math.fround(5.5) == 5.5 -Js.Math.fround(5.05) == 5.050000190734863 -``` - -## hypot - -```res sig -let hypot: (float, float) => float -``` - -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. - -## hypotMany - -```res sig -let hypotMany: array => float -``` - -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. - -```res example -Js.Math.hypotMany([3.0, 4.0, 12.0]) == 13.0 -``` - -## imul - -```res sig -let imul: (int, int) => int -``` - -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. - -## log - -```res sig -let log: float => float -``` - -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. - -```res example -Js.Math.log(Js.Math._E) == 1.0 -Js.Math.log(100.0) == 4.605170185988092 -``` - -## log1p - -```res sig -let log1p: float => float -``` - -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. - -```res example -Js.Math.log1p(Js.Math._E -. 1.0) == 1.0 -Js.Math.log1p(99.0) == 4.605170185988092 -``` - -## log10 - -```res sig -let log10: float => float -``` - -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. - -```res example -Js.Math.log10(1000.0) == 3.0 -Js.Math.log10(0.01) == -2.0 -Js.Math.log10(Js.Math.sqrt(10.0)) == 0.5 -``` - -## log2 - -```res sig -let log2: float => float -``` - -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. - -```res example -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 -``` - -## max_int - -```res sig -let max_int: (int, int) => int -``` - -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. - -## maxMany_int - -```res sig -let maxMany_int: array => int -``` - -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. - -## max_float - -```res sig -let max_float: (float, float) => float -``` - -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. - -## maxMany_float - -```res sig -let maxMany_float: array => float -``` - -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. - -## min_int - -```res sig -let min_int: (int, int) => int -``` - -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. - -## minMany_int - -```res sig -let minMany_int: array => int -``` - -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. - -## min_float - -```res sig -let min_float: (float, float) => float -``` - -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. - -## minMany_float - -```res sig -let minMany_float: array => float -``` - -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. - -## pow_int - -```res sig -let pow_int: (~base: int, ~exp: int) => int -``` - -Raises 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. - -```res example -Js.Math.pow_int(~base=3, ~exp=4) == 81 -``` - -## pow_float - -```res sig -let pow_float: (~base: float, ~exp: float) => float -``` - -Raises 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. - -```res example -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 -``` - -## random - -```res sig -let random: unit => float -``` - -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. - -## random_int - -```res sig -let random_int: (int, int) => int -``` - -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. - -## unsafe_round - -```res sig -let unsafe_round: float => int -``` - -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. - -```res example -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 -``` - -## round - -```res sig -let round: float => float -``` - -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. - -## sign_int - -```res sig -let sign_int: int => int -``` - -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. - -## sign_float - -```res sig -let sign_float: float => float -``` - -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. - -## sin - -```res sig -let sin: float => float -``` - -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. - -## sinh - -```res sig -let sinh: float => float -``` - -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. - -## sqrt - -```res sig -let sqrt: float => float -``` - -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. - -## tan - -```res sig -let tan: float => float -``` - -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. - -## tanh - -```res sig -let tanh: float => float -``` - -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. - -## unsafe_trunc - -```res sig -let unsafe_trunc: float => int -``` - -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. - -## trunc - -```res sig -let trunc: float => float -``` - -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. diff --git a/pages/docs/manual/v9.0.0/api/js/null-undefined.mdx b/pages/docs/manual/v9.0.0/api/js/null-undefined.mdx deleted file mode 100644 index ad7c1a3fe..000000000 --- a/pages/docs/manual/v9.0.0/api/js/null-undefined.mdx +++ /dev/null @@ -1,114 +0,0 @@ -# Null_undefined - - - -Provide utilities around `Js.null_undefined`. - - - -## t - -```res prelude -type t<'a> = Js.null_undefined<'a> -``` - -Local alias for `Js.null_undefined('a)`. - -## return - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.null_undefined('a)` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -## isNullable - -```res sig -let isNullable: t<'a> => bool -``` - -Returns `true` if the given value is null or undefined, `false` otherwise. - -## null - -```res sig -let null: t<'a> -``` - -The null value of type `Js.null_undefined('a)`. - -## undefined - -```res sig -let undefined: t<'a> -``` - -The undefined value of type `Js.null_undefined('a)`. - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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)`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.null_undefined) => - Js.Null_undefined.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.null_undefined) => - Js.Null_undefined.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option('a)` to `Js.null_undefined('a)`. -`Some(a)` => `a` -`None` => `undefined` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.null_undefined('a)` to `option('a)`. -`a` => `Some(a)` -`undefined` => `None` -`null` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v9.0.0/api/js/null.mdx b/pages/docs/manual/v9.0.0/api/js/null.mdx deleted file mode 100644 index 79cae6737..000000000 --- a/pages/docs/manual/v9.0.0/api/js/null.mdx +++ /dev/null @@ -1,107 +0,0 @@ -# Null - - - -Provide utilities around `null('a)`. - - - -```res prelude -type t<'a> = Js.null<'a> -``` - -Local alias for `Js.null('a)`. - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.null('a)` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -Returns `true` if the given value is empty (`null`), `false` otherwise. - -## empty - -```res sig -let empty: t<'a> -``` - -The empty value, `null`. - -## getUnsafe - -```res sig -let getUnsafe: t<'a> => 'a -``` - -## getExn - -```res sig -let getExn: t<'a> => 'a -``` - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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)`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.null) => - Js.Null.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.null) => - Js.Null.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option('a)` to `Js.null('a)`. -`Some(a)` => `a` -`None` => `empty` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.null('a)` to `option('a)`. -`a` => `Some(a)` -`empty` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v9.0.0/api/js/nullable.mdx b/pages/docs/manual/v9.0.0/api/js/nullable.mdx deleted file mode 100644 index 0c9976668..000000000 --- a/pages/docs/manual/v9.0.0/api/js/nullable.mdx +++ /dev/null @@ -1,114 +0,0 @@ -# Nullable - - - -Provide utilities around `Js.null_undefined`. - - - -## t - -```res prelude -type t<'a> = Js.null_undefined<'a> -``` - -Local alias for `Js.null_undefined('a)`. - -## return - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.null_undefined('a)` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -## isNullable - -```res sig -let isNullable: t<'a> => bool -``` - -Returns `true` if the given value is null or undefined, `false` otherwise. - -## null - -```res sig -let null: t<'a> -``` - -The null value of type `Js.null_undefined('a)`. - -## undefined - -```res sig -let undefined: t<'a> -``` - -The undefined value of type `Js.null_undefined('a)`. - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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)`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.null_undefined) => - Js.Nullable.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.null_undefined) => - Js.Nullable.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option('a)` to `Js.null_undefined('a)`. -`Some(a)` => `a` -`None` => `undefined` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.null_undefined('a)` to `option('a)`. -`a` => `Some(a)` -`undefined` => `None` -`null` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v9.0.0/api/js/obj.mdx b/pages/docs/manual/v9.0.0/api/js/obj.mdx deleted file mode 100644 index 8c1ce8a54..000000000 --- a/pages/docs/manual/v9.0.0/api/js/obj.mdx +++ /dev/null @@ -1,57 +0,0 @@ -# Obj - - - -Provide utilities for Js.t. - - - -## empty - -```res sig -let empty: unit => {..} -``` - -`empty()` returns the empty object `{}`. - -## assign - -```res sig -let assign: ({..}, {..}) => {..} -``` - -`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`. - -```res example -/* 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) -``` - -## keys - -```res sig -let keys: Js.t<'a> => array -``` - -`keys(obj)` returns an `array` of the keys of `obj`'s own enumerable properties. diff --git a/pages/docs/manual/v9.0.0/api/js/option.mdx b/pages/docs/manual/v9.0.0/api/js/option.mdx deleted file mode 100644 index 61e3700c8..000000000 --- a/pages/docs/manual/v9.0.0/api/js/option.mdx +++ /dev/null @@ -1,171 +0,0 @@ -# Option - - - -Provide utilities for handling `option`. - - - -## t - -```res sig -type t<'a> = option<'a> -``` - -## some - -```res sig -let some: 'a => option<'a> -``` - -Wraps the given value in `Some()` - -```res example -Js.Option.some(1066) == Some(1066) -``` - -## isSome - -```res sig -let isSome: option<'a> => bool -``` - -Returns `true` if the argument is `Some(value)`; `false` if the argument is `None`. - -## isSomeValue - -```res sig -let isSomeValue: ((. 'a, 'a) => bool, 'a, option<'a>) => bool -``` - -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)`. - -```res example -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 -``` - -## isNone - -```res sig -let isNone: option<'a> => bool -``` - -Returns `true` if the argument is `None`; `false` otherwise. - -## getExn - -```res sig -let getExn: option<'a> => 'a -``` - -If the argument to `getExn()` is of the form `Some(value)`, returns `value`. If given `None`, it throws a `getExn` exception. - -## equal - -```res sig -let equal: ((. 'a, 'b) => bool, option<'a>, option<'b>) => bool -``` - -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` - -```res example -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 -``` - -## andThen - -```res sig -let andThen: ((. 'a) => option<'b>, option<'a>) => option<'b> -``` - -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)`. - -```res example -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 -``` - -## map - -```res sig -let map: ((. 'a) => 'b, option<'a>) => option<'b> -``` - -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. - -```res example -let square = (. x) => x * x -Js.Option.map(square, Some(3)) == Some(9) -Js.Option.map(square, None) == None -``` - -## getWithDefault - -```res sig -let getWithDefault: ('a, option<'a>) => 'a -``` - -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. - -```res example -Js.Option.getWithDefault(1066, Some(15)) == 15 -Js.Option.getWithDefault(1066, None) == 1066 -``` - -## default - -```res sig -let default: ('a, option<'a>) => 'a -``` - -**See:** [getWithDefault](#getWithDefault) - -## filter - -```res sig -let filter: ((. 'a) => bool, option<'a>) => option<'a> -``` - -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`. - -```res example -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 -``` - -## firstSome - -```res sig -let firstSome: (option<'a>, option<'a>) => option<'a> -``` - -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. - -```res example -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 -``` diff --git a/pages/docs/manual/v9.0.0/api/js/promise.mdx b/pages/docs/manual/v9.0.0/api/js/promise.mdx deleted file mode 100644 index df1331769..000000000 --- a/pages/docs/manual/v9.0.0/api/js/promise.mdx +++ /dev/null @@ -1,91 +0,0 @@ -# Promise - - - -Provide bindings to JS promise. - - - -## t - -```res prelude -type t<+'a> -``` - -## error - -```res prelude -type error -``` - -## make - -```res sig -let make: ((~resolve: (. 'a) => unit, ~reject: (. exn) => unit) => unit) => t<'a> -``` - -## resolve - -```res sig -let resolve: 'a => t<'a> -``` - -## reject - -```res sig -let reject: exn => t<'a> -``` - -## all - -```res sig -let all: array> => t> -``` - -## all2 - -```res sig -let all2: ((t<'a0>, t<'a1>)) => t<('a0, 'a1)> -``` - -## all3 - -```res sig -let all3: ((t<'a0>, t<'a1>, t<'a2>)) => t<('a0, 'a1, 'a2)> -``` - -## all4 - -```res sig -let all4: ((t<'a0>, t<'a1>, t<'a2>, t<'a3>)) => t<('a0, 'a1, 'a2, 'a3)> -``` - -## all5 - -```res sig -let all5: ((t<'a0>, t<'a1>, t<'a2>, t<'a3>, t<'a4>)) => t<('a0, 'a1, 'a2, 'a3, 'a4)> -``` - -## all6 - -```res sig -let all6: ((t<'a0>, t<'a1>, t<'a2>, t<'a3>, t<'a4>, t<'a5>)) => t<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)> -``` - -## race - -```res sig -let race: array> => t<'a> -``` - -## then\_ - -```res sig -let then_: ('a => t<'b>, t<'a>) => t<'b> -``` - -## catch - -```res sig -let catch: (error => t<'a>, t<'a>) => t<'a> -``` diff --git a/pages/docs/manual/v9.0.0/api/js/re.mdx b/pages/docs/manual/v9.0.0/api/js/re.mdx deleted file mode 100644 index 665eb7a2d..000000000 --- a/pages/docs/manual/v9.0.0/api/js/re.mdx +++ /dev/null @@ -1,238 +0,0 @@ -# Re - - - -Provide bindings to JS regular expressions (RegExp). - - - -## t - -```res prelude -type t -``` - -The RegExp object. - -## result - -```res prelude -type result -``` - -The result of a executing a RegExp on a string. - -## captures - -```res sig -let captures: result => array> -``` - -An `array` of the match and captures, the first is the full match and the remaining are the substring captures. - -## matches - -```res sig -let matches: result => array -``` - -Deprecated. Use captures instead. -An `array` of the matches, the first is the full match and the remaining are the substring matches. - -## index - -```res sig -let index: result => int -``` - -0-based index of the match in the input string. - -## input - -```res sig -let input: result => string -``` - -The original input string. - -## fromString - -```res sig -let fromString: string => t -``` - -Constructs a RegExp object (Js.Re.t) from a `string`. -Regex literals `%re("/.../")` 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. - -```res example -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") -``` - -## fromStringWithFlags - -```res sig -let fromStringWithFlags: (string, ~flags: string) => t -``` - -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) - -## flags - -```res sig -let flags: t => string -``` - -Returns the enabled flags as a string. - -## global - -```res sig -let global: t => bool -``` - -Returns a `bool` indicating whether the global flag is set. - -## ignoreCase - -```res sig -let ignoreCase: t => bool -``` - -Returns a `bool` indicating whether the ignoreCase flag is set. - -## lastIndex - -```res sig -let lastIndex: t => int -``` - -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. - -```res example -let re = %re("/ab*/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 - } -} -``` - -## setLastIndex - -```res sig -let setLastIndex: (t, int) => unit -``` - -Sets the index at which the next match will start its search from. - -## multiline - -```res sig -let multiline: t => bool -``` - -Returns a `bool` indicating whether the multiline flag is set. - -## source - -```res sig -let source: t => string -``` - -Returns the pattern as a `string`. - -## sticky - -```res sig -let sticky: t => bool -``` - -Returns a `bool` indicating whether the sticky flag is set. - -## unicode - -```res sig -let unicode: t => bool -``` - -Returns a `bool` indicating whether the unicode flag is set. - -## exec\_ - -```res sig -let exec_: (t, string) => option -``` - -Executes a search on a given string using the given RegExp object. -Returns `Some(Js.Re.result)` if a match is found, `None` otherwise. - -```res example -/* Match "quick brown" followed by "jumps", ignoring characters in between - * Remember "brown" and "jumps" - * Ignore case - */ - -let re = %re("/quick\s(brown).+?(jumps)/ig") -let result = Js.Re.exec_(re, "The Quick Brown Fox Jumps Over The Lazy Dog") -``` - -## exec - -```res sig -let exec: (string, t) => option -``` - -Deprecated. please use `Js.Re.exec_` instead. - -## test\_ - -```res sig -let test_: (t, string) => bool -``` - -Tests whether the given RegExp object will match a given `string`. -Returns true if a match is found, false otherwise. - -```res example -/* 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" */ -``` - -## test - -```res sig -let test: (string, t) => bool -``` - -Deprecated. please use `Js.Re.test_` instead. diff --git a/pages/docs/manual/v9.0.0/api/js/result.mdx b/pages/docs/manual/v9.0.0/api/js/result.mdx deleted file mode 100644 index b9a747f95..000000000 --- a/pages/docs/manual/v9.0.0/api/js/result.mdx +++ /dev/null @@ -1,15 +0,0 @@ -# Result - - - -Define the interface for result. - - - -## t - -```res sig -type t<'good, 'bad> = - | Ok('good) - | Error('bad) -``` diff --git a/pages/docs/manual/v9.0.0/api/js/string-2.mdx b/pages/docs/manual/v9.0.0/api/js/string-2.mdx deleted file mode 100644 index c38ec4b85..000000000 --- a/pages/docs/manual/v9.0.0/api/js/string-2.mdx +++ /dev/null @@ -1,803 +0,0 @@ -# String2 - - - -Provide bindings to JS string. Optimized for pipe-first. - - - -## t - -```res prelude -type t = string -``` - -## make - -```res sig -let make: 'a => t -``` - -`make(value)` converts the given value to a `string`. - -```res example -Js.String2.make(3.5) == "3.5" -Js.String2.make([1, 2, 3]) == "1,2,3" -``` - -## fromCharCode - -```res sig -let fromCharCode: int => t -``` - -`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. - -```res example -Js.String2.fromCharCode(65) == "A" -Js.String2.fromCharCode(0x3c8) == `ψ` -Js.String2.fromCharCode(0xd55c) == `한` -Js.String2.fromCharCode(-64568) == `ψ` -``` - -## fromCharCodeMany - -```res sig -let fromCharCodeMany: array => t -``` - -`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. - -## fromCodePoint - -```res sig -let fromCodePoint: int => t -``` - -`fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. -If the number is not a valid code point, it raises `RangeError`. -Thus, `fromCodePoint(0x1F63A)` will produce a correct value, unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN. - -```res example -Js.String2.fromCodePoint(65) == "A" -Js.String2.fromCodePoint(0x3c8) == `ψ` -Js.String2.fromCodePoint(0xd55c) == `한` -Js.String2.fromCodePoint(0x1f63a) == `😺` -``` - -## fromCodePointMany - -```res sig -let fromCodePointMany: array => t -``` - -`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. - -```res example -Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` -``` - -## length - -```res sig -let length: t => int -``` - -`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. - -```res example -Js.String2.length("abcd") == 4 -``` - -## get - -```res sig -let get: (t, int) => t -``` - -`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(string)`. - -```res example -Js.String2.get("Reason", 0) == "R" -Js.String2.get("Reason", 4) == "o" -Js.String2.get(`Rẽasöń`, 5) == `ń` -``` - -## charAt - -```res sig -let charAt: (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. - -```res example -Js.String2.charAt("Reason", 0) == "R" -Js.String2.charAt("Reason", 12) == "" -Js.String2.charAt(`Rẽasöń`, 5) == `ń` -``` - -## charCodeAt - -```res sig -let charCodeAt: (t, int) => float -``` - -`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. - -```res example -Js.String2.charCodeAt(`😺`, 0) == 0xd83d->Belt.Int.toFloat -Js.String2.codePointAt(`😺`, 0) == Some(0x1f63a) -``` - -## codePointAt - -```res sig -let codePointAt: (t, int) => option -``` - -`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. - -```res example -Js.String2.codePointAt(`¿😺?`, 1) == Some(0x1f63a) -Js.String2.codePointAt("abc", 5) == None -``` - -## concat - -```res sig -let concat: (t, t) => t -``` - -`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. - -```res example -Js.String2.concat("cow", "bell") == "cowbell" -``` - -## concatMany - -```res sig -let concatMany: (t, array) => t -``` - -`concat(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. - -```res example -Js.String2.concatMany("1st", ["2nd", "3rd", "4th"]) == "1st2nd3rd4th" -``` - -## endsWith - -```res sig -let endsWith: (t, t) => bool -``` - -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. - -```res example -Js.String2.endsWith("BuckleScript", "Script") == true -Js.String2.endsWith("BuckleShoes", "Script") == false -``` - -## endsWithFrom - -```res sig -let endsWithFrom: (t, t, int) => bool -``` - -`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. - -```res example -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 -``` - -## includes - -```res sig -let includes: (t, t) => bool -``` - -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. - -```res example -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 -``` - -## includesFrom - -```res sig -let includesFrom: (t, t, int) => bool -``` - -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. - -```res example -Js.String2.includesFrom("programmer", "gram", 1) == true -Js.String2.includesFrom("programmer", "gram", 4) == false -Js.String2.includesFrom(`대한민국`, `한`, 1) == true -``` - -## indexOf - -```res sig -let indexOf: (t, t) => int -``` - -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. - -```res example -Js.String2.indexOf("bookseller", "ok") == 2 -Js.String2.indexOf("bookseller", "sell") == 4 -Js.String2.indexOf("beekeeper", "ee") == 1 -Js.String2.indexOf("bookseller", "xyz") == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (t, t, int) => int -``` - -`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. - -```res example -Js.String2.indexOfFrom("bookseller", "ok", 1) == 2 -Js.String2.indexOfFrom("bookseller", "sell", 2) == 4 -Js.String2.indexOfFrom("bookseller", "sell", 5) == -1 -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (t, t) => int -``` - -`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. - -```res example -Js.String2.lastIndexOf("bookseller", "ok") == 2 -Js.String2.lastIndexOf("beekeeper", "ee") == 4 -Js.String2.lastIndexOf("abcdefg", "xyz") == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (t, t, int) => int -``` - -`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. - -```res example -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 -``` - -## localeCompare - -```res sig -let localeCompare: (t, t) => float -``` - -`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. - -```res example -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 -``` - -## match - -```res sig -let match_: (t, Js_re.t) => option> -``` - -`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. - -```res example -Js.String2.match_("The better bats", %re("/b[aeiou]t/")) == Some(["bet"]) -Js.String2.match_("The better bats", %re("/b[aeiou]t/g")) == Some(["bet", "bat"]) -Js.String2.match_("Today is 2018-04-05.", %re("/(\d+)-(\d+)-(\d+)/")) == - Some(["2018-04-05", "2018", "04", "05"]) -Js.String2.match_("The large container.", %re("/b[aeiou]g/")) == None -``` - -## normalize - -```res sig -let normalize: t => t -``` - -`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. - -## normalizeByForm - -```res sig -let normalizeByForm: (t, t) => t -``` - -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.. - -## repeat - -```res sig -let repeat: (t, int) => t -``` - -`repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`. Raises `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. - -```res example -Js.String2.repeat("ha", 3) == "hahaha" -Js.String2.repeat("empty", 0) == "" -``` - -## replace - -```res sig -let replace: (t, t, t) => t -``` - -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. - -```res example -Js.String2.replace("old string", "old", "new") == "new string" -Js.String2.replace("the cat and the dog", "the", "this") == "this cat and the dog" -``` - -## replaceByRe - -```res sig -let replaceByRe: (t, Js_re.t, t) => t -``` - -`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. - -```res example -Js.String2.replaceByRe("vowels be gone", %re("/[aeiou]/g"), "x") == "vxwxls bx gxnx" -Js.String2.replaceByRe("Juan Fulano", %re("/(\w+) (\w+)/"), "$2, $1") == "Fulano, Juan" -``` - -## unsafeReplaceBy0 - -```res sig -let unsafeReplaceBy0: (t, Js_re.t, (t, int, t) => t) => t -``` - -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. - -```res example -let str = "beautiful vowels" -let re = %re("/[aeiou]/g") -let matchFn = (matchPart, _offset, _wholeString) => Js.String2.toUpperCase(matchPart) - -Js.String2.unsafeReplaceBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" -``` - -## unsafeReplaceBy1 - -```res sig -let unsafeReplaceBy1: (t, Js_re.t, (t, t, int, t) => t) => t -``` - -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. - -```res example -let str = "Jony is 40" -let re = %re("/(Jony is )\d+/g") -let matchFn = (_match, part1, _offset, _wholeString) => { - part1 ++ "41" -} - -Js.String2.unsafeReplaceBy1(str, re, matchFn) == "Jony is 41" -``` - -## unsafeReplaceBy2 - -```res sig -let unsafeReplaceBy2: (t, Js_re.t, (t, t, t, int, t) => t) => t -``` - -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. - -```res example -let str = "7 times 6" -let re = %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" -``` - -## unsafeReplaceBy3 - -```res sig -let unsafeReplaceBy3: (t, Js_re.t, (t, t, t, t, int, t) => t) => t -``` - -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. - -## search - -```res sig -let search: (t, Js_re.t) => int -``` - -`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. - -```res example -Js.String2.search("testing 1 2 3", %re("/\d+/")) == 8 -Js.String2.search("no numbers", %re("/\d+/")) == -1 -``` - -## slice - -```res sig -let slice: (t, ~from: int, ~to_: int) => t -``` - -`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. - -```res example -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) == "" -``` - -## sliceToEnd - -```res sig -let sliceToEnd: (t, ~from: int) => t -``` - -`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. - -```res example -Js.String2.sliceToEnd("abcdefg", ~from=4) == "efg" -Js.String2.sliceToEnd("abcdefg", ~from=-2) == "fg" -Js.String2.sliceToEnd("abcdefg", ~from=7) == "" -``` - -## split - -```res sig -let split: (t, t) => array -``` - -`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. - -```res example -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"] -``` - -## splitAtMost - -```res sig -let splitAtMost: (t, t, ~limit: int) => array -``` - -`splitAtMost(str, delimiter, ~limit:n)` 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. - -```res example -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=3) == ["ant", "bee", "cat"] -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=0) == [] -Js.String2.splitAtMost("ant/bee/cat/dog/elk", "/", ~limit=9) == [ - "ant", - "bee", - "cat", - "dog", - "elk", - ] -``` - -## splitByRe - -```res sig -let splitByRe: (t, Js_re.t) => array> -``` - -`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. - -```res example -Js.String2.splitByRe("art; bed , cog ;dad", %re("/\s*[,;]\s*/")) == [ - Some("art"), - Some("bed"), - Some("cog"), - Some("dad"), - ] -``` - -## splitByReAtMost - -```res sig -let splitByReAtMost: (t, Js_re.t, ~limit: int) => array> -``` - -`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. - -```res example -Js.String2.splitByReAtMost("one: two: three: four", %re("/\s*:\s*/"), ~limit=3) == [ - Some("one"), - Some("two"), - Some("three"), - ] - -Js.String2.splitByReAtMost("one: two: three: four", %re("/\s*:\s*/"), ~limit=0) == [] - -Js.String2.splitByReAtMost("one: two: three: four", %re("/\s*:\s*/"), ~limit=8) == [ - Some("one"), - Some("two"), - Some("three"), - Some("four"), - ] -``` - -## startsWith - -```res sig -let startsWith: (t, t) => bool -``` - -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. - -```res example -Js.String2.startsWith("BuckleScript", "Buckle") == true -Js.String2.startsWith("BuckleScript", "") == true -Js.String2.startsWith("JavaScript", "Buckle") == false -``` - -## startsWithFrom - -```res sig -let startsWithFrom: (t, t, int) => bool -``` - -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. - -```res example -Js.String2.startsWithFrom("BuckleScript", "kle", 3) == true -Js.String2.startsWithFrom("BuckleScript", "", 3) == true -Js.String2.startsWithFrom("JavaScript", "Buckle", 2) == false -``` - -## substr - -```res sig -let substr: (t, ~from: int) => t -``` - -`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. - -```res example -Js.String2.substr("abcdefghij", ~from=3) == "defghij" -Js.String2.substr("abcdefghij", ~from=-3) == "hij" -Js.String2.substr("abcdefghij", ~from=12) == "" -``` - -## substrAtMost - -```res sig -let substrAtMost: (t, ~from: int, ~length: int) => t -``` - -`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. - -```res example -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) == "" -``` - -## substring - -```res sig -let substring: (t, ~from: int, ~to_: int) => t -``` - -`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. - -```res example -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" -``` - -## substringToEnd - -```res sig -let substringToEnd: (t, ~from: int) => t -``` - -`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. - -```res example -Js.String2.substringToEnd("playground", ~from=4) == "ground" -Js.String2.substringToEnd("playground", ~from=-3) == "playground" -Js.String2.substringToEnd("playground", ~from=12) == "" -``` - -## toLowerCase - -```res sig -let toLowerCase: t => t -``` - -`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. - -```res example -Js.String2.toLowerCase("ABC") == "abc" -Js.String2.toLowerCase(`ΣΠ`) == `σπ` -Js.String2.toLowerCase(`ΠΣ`) == `πς` -``` - -## toLocaleLowerCase - -```res sig -let toLocaleLowerCase: t => t -``` - -`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. - -## toUpperCase - -```res sig -let toUpperCase: t => t -``` - -`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. - -```res example -Js.String2.toUpperCase("abc") == "ABC" -Js.String2.toUpperCase(`Straße`) == `STRASSE` -Js.String2.toUpperCase(`πς`) == `ΠΣ` -``` - -## toLocaleUpperCase - -```res sig -let toLocaleUpperCase: t => t -``` - -`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. - -## trim - -```res sig -let trim: t => t -``` - -`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. - -```res example -Js.String2.trim(" abc def ") == "abc def" -Js.String2.trim("\n\r\t abc def \n\n\t\r ") == "abc def" -``` - -## anchor - -```res sig -let anchor: (t, t) => t -``` - -`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. - -```res example -Js.String2.anchor("Page One", "page1") == "Page One" -``` - -## link - -```res sig -let link: (t, t) => t -``` - -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. - -```res example -Js.String2.link("Go to page two", "page2.html") == "Go to page two" -``` - -## castToArrayLike - -```res sig -let castToArrayLike: t => Js_array2.array_like -``` - -Casts its argument to an `array_like` entity that can be processed by functions such as `Js.Array2.fromMap()` - -```res example -let s = "abcde" -let arr = Js.Array2.fromMap(Js.String2.castToArrayLike(s), x => x) -arr == ["a", "b", "c", "d", "e"] -``` diff --git a/pages/docs/manual/v9.0.0/api/js/string.mdx b/pages/docs/manual/v9.0.0/api/js/string.mdx deleted file mode 100644 index 597ff07b8..000000000 --- a/pages/docs/manual/v9.0.0/api/js/string.mdx +++ /dev/null @@ -1,813 +0,0 @@ -# String - - - -Provide bindings to JS string. Optimized for pipe-last. - - - -## t - -```res prelude -type t = string -``` - -## make - -```res sig -let make: 'a => t -``` - -`make(value)` converts the given value to a `string`. - -```res example -Js.String2.make(3.5) == "3.5" -Js.String2.make([1, 2, 3]) == "1,2,3" -``` - -## fromCharCode - -```res sig -let fromCharCode: int => t -``` - -`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. - -```res example -Js.String2.fromCharCode(65) == "A" -Js.String2.fromCharCode(0x3c8) == `ψ` -Js.String2.fromCharCode(0xd55c) == `한` -Js.String2.fromCharCode(-64568) == `ψ` -``` - -## fromCharCodeMany - -```res sig -let fromCharCodeMany: array => t -``` - -`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. - -## fromCodePoint - -```res sig -let fromCodePoint: int => t -``` - -`fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. -If the number is not a valid code point, it raises `RangeError`. -Thus, `fromCodePoint(0x1F63A)` will produce a correct value, unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) on MDN. - -```res example -Js.String2.fromCodePoint(65) == "A" -Js.String2.fromCodePoint(0x3c8) == `ψ` -Js.String2.fromCodePoint(0xd55c) == `한` -Js.String2.fromCodePoint(0x1f63a) == `😺` -``` - -## fromCodePointMany - -```res sig -let fromCodePointMany: array => t -``` - -`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. - -```res example -Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` -``` - -## length - -```res sig -let length: t => int -``` - -`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. - -```res example -Js.String2.length("abcd") == 4 -``` - -## get - -```res sig -let get: (t, int) => t -``` - -`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(string)`. - -```res example -Js.String2.get("Reason", 0) == "R" -Js.String2.get("Reason", 4) == "o" -Js.String2.get(`Rẽasöń`, 5) == `ń` -``` - -## charAt - -```res sig -let charAt: (int, t) => 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. - -```res example -Js.String.charAt(0, "Reason") == "R" -Js.String.charAt(12, "Reason") == "" -Js.String.charAt(5, `Rẽasöń`) == `ń` -``` - -## charCodeAt - -```res sig -let charCodeAt: (int, t) => float -``` - -`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. - -```res example -Js.String.charCodeAt(0, `😺`) == 0xd83d->Belt.Int.toFloat -Js.String.codePointAt(0, `😺`) == Some(0x1f63a) -``` - -## codePointAt - -```res sig -let codePointAt: (int, t) => option -``` - -`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. - -```res example -Js.String.codePointAt(1, `¿😺?`) == Some(0x1f63a) -Js.String.codePointAt(5, "abc") == None -``` - -## concat - -```res sig -let concat: (t, t) => t -``` - -`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. - -```res example -Js.String.concat("bell", "cow") == "cowbell" -``` - -## concatMany - -```res sig -let concatMany: (array, t) => t -``` - -`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. - -```res example -Js.String.concatMany(["2nd", "3rd", "4th"], "1st") == "1st2nd3rd4th" -``` - -## endsWith - -```res sig -let endsWith: (t, t) => bool -``` - -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. - -```res example -Js.String.endsWith("Script", "BuckleScript") == true -Js.String.endsWith("Script", "BuckleShoes") == false -``` - -## endsWithFrom - -```res sig -let endsWithFrom: (t, int, t) => bool -``` - -`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. - -```res example -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 -``` - -## includes - -```res sig -let includes: (t, t) => bool -``` - -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. - -```res example -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 -``` - -## includesFrom - -```res sig -let includesFrom: (t, int, t) => bool -``` - -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. - -```res example -Js.String.includesFrom("gram", 1, "programmer") == true -Js.String.includesFrom("gram", 4, "programmer") == false -Js.String.includesFrom(`한`, 1, `대한민국`) == true -``` - -## indexOf - -```res sig -let indexOf: (t, t) => int -``` - -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. - -```res example -Js.String.indexOf("ok", "bookseller") == 2 -Js.String.indexOf("sell", "bookseller") == 4 -Js.String.indexOf("ee", "beekeeper") == 1 -Js.String.indexOf("xyz", "bookseller") == -1 -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (t, t, int) => int -``` - -`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. - -```res example -Js.String.indexOfFrom("ok", 1, "bookseller") == 2 -Js.String.indexOfFrom("sell", 2, "bookseller") == 4 -Js.String.indexOfFrom("sell", 5, "bookseller") == -1 -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (t, t) => int -``` - -`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. - -```res example -Js.String.lastIndexOf("ok", "bookseller") == 2 -Js.String.lastIndexOf("ee", "beekeeper") == 4 -Js.String.lastIndexOf("xyz", "abcdefg") == -1 -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (t, int, t) => int -``` - -`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. - -```res example -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 -``` - -## localeCompare - -```res sig -let localeCompare: (t, t) => float -``` - -`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. - -```res example -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 -``` - -## match - -```res sig -let match_: (Js_re.t, t) => option> -``` - -`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. - -```res example -Js.String.match_(%re("/b[aeiou]t/"), "The better bats") == Some(["bet"]) -Js.String.match_(%re("/b[aeiou]t/g"), "The better bats") == Some(["bet", "bat"]) -Js.String.match_(%re("/(\d+)-(\d+)-(\d+)/"), "Today is 2018-04-05.") == - Some(["2018-04-05", "2018", "04", "05"]) -Js.String.match_(%re("/b[aeiou]g/"), "The large container.") == None -``` - -## normalize - -```res sig -let normalize: t => t -``` - -`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. - -## normalizeByForm - -```res sig -let normalizeByForm: (t, t) => t -``` - -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. - -## repeat - -```res sig -let repeat: (t, int) => t -``` - -`repeat(n, str)` returns a `string` that consists of `n` repetitions of `str`. Raises `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. - -```res example -Js.String.repeat(3, "ha") == "hahaha" -Js.String.repeat(0, "empty") == "" -``` - -## replace - -```res sig -let replace: (t, t, t) => t -``` - -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. - -```res example -Js.String.replace("old", "new", "old string") == "new string" -Js.String.replace("the", "this", "the cat and the dog") == "this cat and the dog" -``` - -## replaceByRe - -```res sig -let replaceByRe: (Js_re.t, t, t) => t -``` - -`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. - -```res example -Js.String.replaceByRe(%re("/[aeiou]/g"), "x", "vowels be gone") == "vxwxls bx gxnx" -Js.String.replaceByRe(%re("/(\w+) (\w+)/"), "$2, $1", "Juan Fulano") == "Fulano, Juan" -``` - -## unsafeReplaceBy0 - -```res sig -let unsafeReplaceBy0: (Js_re.t, (t, int, t) => t, t) => t -``` - -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. - -```res example -let str = "beautiful vowels" -let re = %re("/[aeiou]/g") -let matchFn = (matchPart, _offset, _wholeString) => Js.String.toUpperCase(matchPart) - -Js.String.unsafeReplaceBy0(re, matchFn, str) == "bEAUtIfUl vOwEls" -``` - -## unsafeReplaceBy1 - -```res sig -let unsafeReplaceBy1: (Js_re.t, (t, t, int, t) => t, t) => t -``` - -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. - -```res example -let str = "Jony is 40" -let re = %re("/(Jony is )\d+/g") -let matchFn = (_match, part1, _offset, _wholeString) => { - part1 ++ "41" -} - -Js.String.unsafeReplaceBy1(re, matchFn, str) == "Jony is 41" -``` - -## unsafeReplaceBy2 - -```res sig -let unsafeReplaceBy2: (Js_re.t, (t, t, t, int, t) => t, t) => t -``` - -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. - -```res example -let str = "7 times 6" -let re = %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" -``` - -## unsafeReplaceBy3 - -```res sig -let unsafeReplaceBy3: (Js_re.t, (t, t, t, t, int, t) => t, t) => t -``` - -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. - -## search - -```res sig -let search: (Js_re.t, t) => int -``` - -`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. - -```res example -Js.String.search(%re("/\d+/"), "testing 1 2 3") == 8 -Js.String.search(%re("/\d+/"), "no numbers") == -1 -``` - -## slice - -```res sig -let slice: (~from: int, ~to_: int, t) => t -``` - -`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. - -```res example -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") == "" -``` - -## sliceToEnd - -```res sig -let sliceToEnd: (~from: int, t) => t -``` - -`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. - -```res example -Js.String.sliceToEnd(~from=4, "abcdefg") == "efg" -Js.String.sliceToEnd(~from=-2, "abcdefg") == "fg" -Js.String.sliceToEnd(~from=7, "abcdefg") == "" -``` - -## split - -```res sig -let split: (t, t) => array -``` - -`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. - -```res example -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"] -``` - -## splitAtMost - -```res sig -let splitAtMost: (t, ~limit: int, t) => array -``` - -`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. - -```res example -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"] -``` - -## splitLimited - -```res sig -let splitLimited: (t, int, t) => array -``` - -Deprecated - Please use splitAtMost. - -## splitByRe - -```res sig -let splitByRe: (Js_re.t, t) => array> -``` - -`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. - -```res example -Js.String.splitByRe(%re("/\s*[,;]\s*/"), "art; bed , cog ;dad") == [ - Some("art"), - Some("bed"), - Some("cog"), - Some("dad"), - ] -``` - -## splitByReAtMost - -```res sig -let splitByReAtMost: (Js_re.t, ~limit: int, t) => array> -``` - -`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. - -```res example -Js.String.splitByReAtMost(%re("/\s*:\s*/"), ~limit=3, "one: two: three: four") == [ - Some("one"), - Some("two"), - Some("three"), - ] - -Js.String.splitByReAtMost(%re("/\s*:\s*/"), ~limit=0, "one: two: three: four") == [] - -Js.String.splitByReAtMost(%re("/\s*:\s*/"), ~limit=8, "one: two: three: four") == [ - Some("one"), - Some("two"), - Some("three"), - Some("four"), - ] -``` - -## splitRegexpLimited - -```res sig -let splitRegexpLimited: (Js_re.t, int, t) => array -``` - -Deprecated - Please use splitByReAtMost. - -## startsWith - -```res sig -let startsWith: (t, t) => bool -``` - -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. - -```res example -Js.String.startsWith("Buckle", "BuckleScript") == true -Js.String.startsWith("", "BuckleScript") == true -Js.String.startsWith("Buckle", "JavaScript") == false -``` - -## startsWithFrom - -```res sig -let startsWithFrom: (t, int, t) => bool -``` - -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. - -```res example -Js.String.startsWithFrom("kle", 3, "BuckleScript") == true -Js.String.startsWithFrom("", 3, "BuckleScript") == true -Js.String.startsWithFrom("Buckle", 2, "JavaScript") == false -``` - -## substr - -```res sig -let substr: (~from: int, t) => t -``` - -`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. - -```res example -Js.String.substr(~from=3, "abcdefghij") == "defghij" -Js.String.substr(~from=-3, "abcdefghij") == "hij" -Js.String.substr(~from=12, "abcdefghij") == "" -``` - -## substrAtMost - -```res sig -let substrAtMost: (~from: int, ~length: int, t) => t -``` - -`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. - -```res example -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") == "" -``` - -## substring - -```res sig -let substring: (~from: int, ~to_: int, t) => t -``` - -`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. - -```res example -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" -``` - -## substringToEnd - -```res sig -let substringToEnd: (~from: int, t) => t -``` - -`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. - -```res example -Js.String.substringToEnd(~from=4, "playground") == "ground" -Js.String.substringToEnd(~from=-3, "playground") == "playground" -Js.String.substringToEnd(~from=12, "playground") == "" -``` - -## toLowerCase - -```res sig -let toLowerCase: t => t -``` - -`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. - -```res example -Js.String.toLowerCase("ABC") == "abc" -Js.String.toLowerCase(`ΣΠ`) == `σπ` -Js.String.toLowerCase(`ΠΣ`) == `πς` -``` - -## toLocaleLowerCase - -```res sig -let toLocaleLowerCase: t => t -``` - -`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. - -## toUpperCase - -```res sig -let toUpperCase: t => t -``` - -`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. - -```res example -Js.String.toUpperCase("abc") == "ABC" -Js.String.toUpperCase(`Straße`) == `STRASSE` -Js.String.toUpperCase(`πς`) == `ΠΣ` -``` - -## toLocaleUpperCase - -```res sig -let toLocaleUpperCase: t => t -``` - -`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. - -## trim - -```res sig -let trim: t => t -``` - -`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. - -```res example -Js.String.trim(" abc def ") == "abc def" -Js.String.trim("\n\r\t abc def \n\n\t\r ") == "abc def" -``` - -## anchor - -```res sig -let anchor: (t, t) => t -``` - -`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. - -```res example -Js.String.anchor("page1", "Page One") == "Page One" -``` - -## link - -```res sig -let link: (t, t) => t -``` - -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. - -```res example -Js.String.link("page2.html", "Go to page two") == "Go to page two" -``` - -## castToArrayLike - -```res sig -let castToArrayLike: t => Js_array2.array_like -``` - -Casts its argument to an `array_like` entity that can be processed by functions such as `Js.Array2.fromMap()` - -```res example -let s = "abcde" -let arr = Js.Array2.fromMap(Js.String.castToArrayLike(s), x => x) -arr == ["a", "b", "c", "d", "e"] -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2.mdx deleted file mode 100644 index ab447dbdc..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2.mdx +++ /dev/null @@ -1,41 +0,0 @@ -# TypedArray2 - - - -Provide bindings to JS typed array. - - - -## array_buffer - -```res sig -type array_buffer -``` - -## array_like - -```res sig -type array_like<'a> -``` - -## module ArrayBuffer - -## module Int8Array - -## module Uint8Array - -## module Uint8ClampedArray - -## module Int16Array - -## module Uint16Array - -## module Int32Array - -## module Uint32Array - -## module Float32Array - -## module Float64Array - -## module DataView diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_array-buffer.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_array-buffer.mdx deleted file mode 100644 index a0af5cafa..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_array-buffer.mdx +++ /dev/null @@ -1,39 +0,0 @@ -# TypedArray2.ArrayBuffer - - - -Provide bindings to JS typed array ArrayBuffer. - - - -## t - -```res prelude -type t = Js_typed_array2.array_buffer -``` - -## make - -```res sig -let make: int => t -``` - -Takes length. initializes elements to 0. - -## byteLength - -```res sig -let byteLength: t => int -``` - -## slice - -```res sig -let slice: (t, ~start: int, ~end_: int) => Js_typed_array2.array_buffer -``` - -## sliceFrom - -```res sig -let sliceFrom: (t, int) => Js_typed_array2.array_buffer -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_data-view.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_data-view.mdx deleted file mode 100644 index 0b65c8da7..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_data-view.mdx +++ /dev/null @@ -1,223 +0,0 @@ -# TypedArray2.DataView - - - -Provide bindings to JS typed array DataView. - - - -## t - -```res prelude -type t -``` - -## make - -```res sig -let make: Js_typed_array2.array_buffer => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## getInt8 - -```res sig -let getInt8: (t, int) => int -``` - -## getUint8 - -```res sig -let getUint8: (t, int) => int -``` - -## getInt16 - -```res sig -let getInt16: (t, int) => int -``` - -## getInt16LittleEndian - -```res sig -let getInt16LittleEndian: (t, int) => int -``` - -## getUint16 - -```res sig -let getUint16: (t, int) => int -``` - -## getUint16LittleEndian - -```res sig -let getUint16LittleEndian: (t, int) => int -``` - -## getInt32 - -```res sig -let getInt32: (t, int) => int -``` - -## getInt32LittleEndian - -```res sig -let getInt32LittleEndian: (t, int) => int -``` - -## getUint32 - -```res sig -let getUint32: (t, int) => int -``` - -## getUint32LittleEndian - -```res sig -let getUint32LittleEndian: (t, int) => int -``` - -## getFloat32 - -```res sig -let getFloat32: (t, int) => float -``` - -## getFloat32LittleEndian - -```res sig -let getFloat32LittleEndian: (t, int) => float -``` - -## getFloat64 - -```res sig -let getFloat64: (t, int) => float -``` - -## getFloat64LittleEndian - -```res sig -let getFloat64LittleEndian: (t, int) => float -``` - -## setInt8 - -```res sig -let setInt8: (t, int, int) => unit -``` - -## setUint8 - -```res sig -let setUint8: (t, int, int) => unit -``` - -## setInt16 - -```res sig -let setInt16: (t, int, int) => unit -``` - -## setInt16LittleEndian - -```res sig -let setInt16LittleEndian: (t, int, int) => unit -``` - -## setUint16 - -```res sig -let setUint16: (t, int, int) => unit -``` - -## setUint16LittleEndian - -```res sig -let setUint16LittleEndian: (t, int, int) => unit -``` - -## setInt32 - -```res sig -let setInt32: (t, int, int) => unit -``` - -## setInt32LittleEndian - -```res sig -let setInt32LittleEndian: (t, int, int) => unit -``` - -## setUint32 - -```res sig -let setUint32: (t, int, int) => unit -``` - -## setUint32LittleEndian - -```res sig -let setUint32LittleEndian: (t, int, int) => unit -``` - -## setFloat32 - -```res sig -let setFloat32: (t, int, float) => unit -``` - -## setFloat32LittleEndian - -```res sig -let setFloat32LittleEndian: (t, int, float) => unit -``` - -## setFloat64 - -```res sig -let setFloat64: (t, int, float) => unit -``` - -## setFloat64LittleEndian - -```res sig -let setFloat64LittleEndian: (t, int, float) => unit -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_float-32-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_float-32-array.mdx deleted file mode 100644 index e8ded9652..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_float-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Float32Array - - - -Provide bindings to JS typed array Float32Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_float-64-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_float-64-array.mdx deleted file mode 100644 index 9e56a8585..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_float-64-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Float64Array - - - -Provide bindings to JS typed array Float64Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-16-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-16-array.mdx deleted file mode 100644 index 754bbaa80..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Int16Array - - - -Provide bindings to JS typed array Int16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-32-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-32-array.mdx deleted file mode 100644 index efeb8dddd..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray2.Int32Array - - - -Provide bindings to JS typed array Int32Array. - - - -## t - -```res prelude -type elt = int32 -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array2.array_buffer => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-8-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-8-array.mdx deleted file mode 100644 index c75df550c..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_int-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Int8Array - - - -Provide bindings to JS typed array Int8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-16-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-16-array.mdx deleted file mode 100644 index 38a507f30..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint16Array - - - -Provide bindings to JS typed array Uint16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-32-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-32-array.mdx deleted file mode 100644 index d65d4174d..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.UInt32Array - - - -Provide bindings to JS typed array Uint32Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-array.mdx deleted file mode 100644 index 4bb64163b..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint8Array - - - -Provide bindings to JS typed array Uint8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx deleted file mode 100644 index effd38955..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-clamped-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray2.Uint8ClampedArray - - - -Provide bindings to JS typed array Uint8ClampedArray. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array2.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array2.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array2.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array2.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array2.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array.mdx deleted file mode 100644 index cbafefce5..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array.mdx +++ /dev/null @@ -1,51 +0,0 @@ -# TypedArray - - - -Provide bindings to JS typed array. - - - -## array_buffer - -```res sig -type array_buffer -``` - -## array_like - -```res sig -type array_like<'a> -``` - -## module type Type - -```res sig -module type Type = { - type t -} -``` - -## module ArrayBuffer - -## module type S - -## module Int8Array - -## module Uint8Array - -## module Uint8ClampedArray - -## module Int16Array - -## module Uint16Array - -## module Int32Array - -## module Uint32Array - -## module Float32Array - -## module Float64Array - -## module DataView diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_array-buffer.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_array-buffer.mdx deleted file mode 100644 index f5dbd3860..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_array-buffer.mdx +++ /dev/null @@ -1,39 +0,0 @@ -# TypedArray.ArrayBuffer - - - -Provide bindings to JS typed array ArrayBuffer. - - - -## t - -```res prelude -type t = Js_typed_array.array_buffer -``` - -## make - -```res sig -let make: int => t -``` - -Takes length. initializes elements to 0. - -## byteLength - -```res sig -let byteLength: t => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => Js_typed_array.array_buffer -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => Js_typed_array.array_buffer -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_data-view.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_data-view.mdx deleted file mode 100644 index 6a02034ff..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_data-view.mdx +++ /dev/null @@ -1,223 +0,0 @@ -# TypedArray.DataView - - - -Provide bindings to JS typed array DataView. - - - -## t - -```res prelude -type t = Js_typed_array2.DataView.t -``` - -## make - -```res sig -let make: Js_typed_array.array_buffer => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## getInt8 - -```res sig -let getInt8: (t, int) => int -``` - -## getUint8 - -```res sig -let getUint8: (t, int) => int -``` - -## getInt16 - -```res sig -let getInt16: (t, int) => int -``` - -## getInt16LittleEndian - -```res sig -let getInt16LittleEndian: (t, int) => int -``` - -## getUint16 - -```res sig -let getUint16: (t, int) => int -``` - -## getUint16LittleEndian - -```res sig -let getUint16LittleEndian: (t, int) => int -``` - -## getInt32 - -```res sig -let getInt32: (t, int) => int -``` - -## getInt32LittleEndian - -```res sig -let getInt32LittleEndian: (t, int) => int -``` - -## getUint32 - -```res sig -let getUint32: (t, int) => int -``` - -## getUint32LittleEndian - -```res sig -let getUint32LittleEndian: (t, int) => int -``` - -## getFloat32 - -```res sig -let getFloat32: (t, int) => float -``` - -## getFloat32LittleEndian - -```res sig -let getFloat32LittleEndian: (t, int) => float -``` - -## getFloat64 - -```res sig -let getFloat64: (t, int) => float -``` - -## getFloat64LittleEndian - -```res sig -let getFloat64LittleEndian: (t, int) => float -``` - -## setInt8 - -```res sig -let setInt8: (t, int, int) => unit -``` - -## setUint8 - -```res sig -let setUint8: (t, int, int) => unit -``` - -## setInt16 - -```res sig -let setInt16: (t, int, int) => unit -``` - -## setInt16LittleEndian - -```res sig -let setInt16LittleEndian: (t, int, int) => unit -``` - -## setUint16 - -```res sig -let setUint16: (t, int, int) => unit -``` - -## setUint16LittleEndian - -```res sig -let setUint16LittleEndian: (t, int, int) => unit -``` - -## setInt32 - -```res sig -let setInt32: (t, int, int) => unit -``` - -## setInt32LittleEndian - -```res sig -let setInt32LittleEndian: (t, int, int) => unit -``` - -## setUint32 - -```res sig -let setUint32: (t, int, int) => unit -``` - -## setUint32LittleEndian - -```res sig -let setUint32LittleEndian: (t, int, int) => unit -``` - -## setFloat32 - -```res sig -let setFloat32: (t, int, float) => unit -``` - -## setFloat32LittleEndian - -```res sig -let setFloat32LittleEndian: (t, int, float) => unit -``` - -## setFloat64 - -```res sig -let setFloat64: (t, int, float) => unit -``` - -## setFloat64LittleEndian - -```res sig -let setFloat64LittleEndian: (t, int, float) => unit -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_float-32-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_float-32-array.mdx deleted file mode 100644 index 06b3a5866..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_float-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Float32Array - - - -Provide bindings to JS typed array Float32Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> = Js_typed_array2.Float32Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array.array_buffer => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_float-64-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_float-64-array.mdx deleted file mode 100644 index 3df7aaa1a..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_float-64-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Float64Array - - - -Provide bindings to JS typed array Float64Array. - - - -## t - -```res prelude -type elt = float -type typed_array<'a> = Js_typed_array2.Float64Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array.array_buffer => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_int-16-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_int-16-array.mdx deleted file mode 100644 index ba9bb68b2..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_int-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Int16Array - - - -Provide bindings to JS typed array Int16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Int16Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_int-32-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_int-32-array.mdx deleted file mode 100644 index 181940b34..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_int-32-array.mdx +++ /dev/null @@ -1,375 +0,0 @@ -# TypedArray.Int32Array - - - -Provide bindings to JS typed array Int32Array. - - - -## t - -```res prelude -type elt = int32 -type typed_array<'a> = Js_typed_array2.Int32Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` - -## create - -```res sig -let create: array => t -``` - -## of_buffer - -```res sig -let of_buffer: Js_typed_array.array_buffer => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_int-8-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_int-8-array.mdx deleted file mode 100644 index fce0667de..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_int-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Int8Array - - - -Provide bindings to JS typed array Int8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Int8Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_type-s.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_type-s.mdx deleted file mode 100644 index d71e5dcd7..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_type-s.mdx +++ /dev/null @@ -1,309 +0,0 @@ -# TypedArray type S - - - -TODO - - - -## t - -```res prelude -type elt -type typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-16-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_uint-16-array.mdx deleted file mode 100644 index 4628398b5..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-16-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint16Array - - - -Provide bindings to JS typed array Uint16Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint16Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-32-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_uint-32-array.mdx deleted file mode 100644 index 667ed5134..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-32-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.UInt32Array - - - -Provide bindings to JS typed array Uint32Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint32Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-8-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_uint-8-array.mdx deleted file mode 100644 index 1cc7887ab..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-8-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint8Array - - - -Provide bindings to JS typed array Uint8Array. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint8Array.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-8-clamped-array.mdx b/pages/docs/manual/v9.0.0/api/js/typed-array_uint-8-clamped-array.mdx deleted file mode 100644 index e5372dfbe..000000000 --- a/pages/docs/manual/v9.0.0/api/js/typed-array_uint-8-clamped-array.mdx +++ /dev/null @@ -1,363 +0,0 @@ -# TypedArray.Uint8ClampedArray - - - -Provide bindings to JS typed array Uint8ClampedArray. - - - -## t - -```res prelude -type elt = int -type typed_array<'a> = Js_typed_array2.Uint8ClampedArray.typed_array<'a> -type t = typed_array -``` - -## unsafe_get - -```res sig -let unsafe_get: (t, int) => elt -``` - -## unsafe_set - -```res sig -let unsafe_set: (t, int, elt) => unit -``` - -## buffer - -```res sig -let buffer: t => Js_typed_array.array_buffer -``` - -## byteLength - -```res sig -let byteLength: t => int -``` - -## byteOffset - -```res sig -let byteOffset: t => int -``` - -## setArray - -```res sig -let setArray: (array, t) => unit -``` - -## setArrayOffset - -```res sig -let setArrayOffset: (array, int, t) => unit -``` - -## length - -```res sig -let length: t => int -``` - -## copyWithin - -```res sig -let copyWithin: (~to_: int, t) => t -``` - -## copyWithinFrom - -```res sig -let copyWithinFrom: (~to_: int, ~from: int, t) => t -``` - -## copyWithinFromRange - -```res sig -let copyWithinFromRange: (~to_: int, ~start: int, ~end_: int, t) => t -``` - -## fillInPlace - -```res sig -let fillInPlace: (elt, t) => t -``` - -## fillFromInPlace - -```res sig -let fillFromInPlace: (elt, ~from: int, t) => t -``` - -## fillRangeInPlace - -```res sig -let fillRangeInPlace: (elt, ~start: int, ~end_: int, t) => t -``` - -## reverseInPlace - -```res sig -let reverseInPlace: t => t -``` - -## sortInPlace - -```res sig -let sortInPlace: t => t -``` - -## sortInPlaceWith - -```res sig -let sortInPlaceWith: ((. elt, elt) => int, t) => t -``` - -## includes - -```res sig -let includes: (elt, t) => bool -``` - -ES2016 - -## indexOf - -```res sig -let indexOf: (elt, t) => int -``` - -## indexOfFrom - -```res sig -let indexOfFrom: (elt, ~from: int, t) => int -``` - -## join - -```res sig -let join: t => string -``` - -## joinWith - -```res sig -let joinWith: (string, t) => string -``` - -## lastIndexOf - -```res sig -let lastIndexOf: (elt, t) => int -``` - -## lastIndexOfFrom - -```res sig -let lastIndexOfFrom: (elt, ~from: int, t) => int -``` - -## slice - -```res sig -let slice: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## copy - -```res sig -let copy: t => t -``` - -## sliceFrom - -```res sig -let sliceFrom: (int, t) => t -``` - -## subarray - -```res sig -let subarray: (~start: int, ~end_: int, t) => t -``` - -`start` is inclusive, `end_` exclusive. - -## subarrayFrom - -```res sig -let subarrayFrom: (int, t) => t -``` - -## toString - -```res sig -let toString: t => string -``` - -## toLocaleString - -```res sig -let toLocaleString: t => string -``` - -## every - -```res sig -let every: ((. elt) => bool, t) => bool -``` - -## everyi - -```res sig -let everyi: ((. elt, int) => bool, t) => bool -``` - -## filter - -```res sig -let filter: ((. elt) => bool, t) => t -``` - -## filteri - -```res sig -let filteri: ((. elt, int) => bool, t) => t -``` - -## find - -```res sig -let find: ((. elt) => bool, t) => Js.undefined -``` - -## findi - -```res sig -let findi: ((. elt, int) => bool, t) => Js.undefined -``` - -## findIndex - -```res sig -let findIndex: ((. elt) => bool, t) => int -``` - -## findIndexi - -```res sig -let findIndexi: ((. elt, int) => bool, t) => int -``` - -## forEach - -```res sig -let forEach: ((. elt) => unit, t) => unit -``` - -## forEachi - -```res sig -let forEachi: ((. elt, int) => unit, t) => unit -``` - -## map - -```res sig -let map: ((. elt) => 'b, t) => typed_array<'b> -``` - -## mapi - -```res sig -let mapi: ((. elt, int) => 'b, t) => typed_array<'b> -``` - -## reduce - -```res sig -let reduce: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reducei - -```res sig -let reducei: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## reduceRight - -```res sig -let reduceRight: ((. 'b, elt) => 'b, 'b, t) => 'b -``` - -## reduceRighti - -```res sig -let reduceRighti: ((. 'b, elt, int) => 'b, 'b, t) => 'b -``` - -## some - -```res sig -let some: ((. elt) => bool, t) => bool -``` - -## somei - -```res sig -let somei: ((. elt, int) => bool, t) => bool -``` - -## \_BYTES_PER_ELEMENT - -```res sig -let _BYTES_PER_ELEMENT: int -``` - -## make - -```res sig -let make: array => t -``` - -## fromBuffer - -```res sig -let fromBuffer: Js_typed_array.array_buffer => t -``` - -## fromBufferOffset - -```res sig -let fromBufferOffset: (Js_typed_array.array_buffer, int) => t -``` - -Can throw an exception. - -## fromBufferRange - -```res sig -let fromBufferRange: (Js_typed_array.array_buffer, ~offset: int, ~length: int) => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## fromLength - -```res sig -let fromLength: int => t -``` - -Raises `Js.Exn.Error` raise Js exception. - -## from - -```res sig -let from: Js_typed_array.array_like => t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/types.mdx b/pages/docs/manual/v9.0.0/api/js/types.mdx deleted file mode 100644 index bf19e7d0b..000000000 --- a/pages/docs/manual/v9.0.0/api/js/types.mdx +++ /dev/null @@ -1,78 +0,0 @@ -# Types - - - -Provide utilities for manipulating JS types. - - - -## symbol - -```res prelude -type symbol -``` - -## obj_val - -```res prelude -type obj_val -``` - -## undefined_val - -```res prelude -type undefined_val -``` - -## null_val - -```res prelude -type null_val -``` - -## function_val - -```res prelude -type function_val -``` - -## t - -```res prelude -type rec t<'a> = - | Undefined: t - | Null: t - | Boolean: t - | Number: t - | String: t - | Function: t - | Object: t - | Symbol: t -``` - -## test - -```res sig -let test: ('a, t<'b>) => bool -``` - -## tagged_t - -```res prelude -type tagged_t = - | JSFalse - | JSTrue - | JSNull - | JSUndefined - | JSNumber(float) - | JSString(string) - | JSFunction(function_val) - | JSObject(obj_val) - | JSSymbol(symbol) -``` - -## classify - -```res sig -let classify: 'a => tagged_t -``` diff --git a/pages/docs/manual/v9.0.0/api/js/undefined.mdx b/pages/docs/manual/v9.0.0/api/js/undefined.mdx deleted file mode 100644 index b15b0cd26..000000000 --- a/pages/docs/manual/v9.0.0/api/js/undefined.mdx +++ /dev/null @@ -1,119 +0,0 @@ -# Undefined - - - -Provide utilities around `Js.undefined`. - - - -## t - -```res prelude -type t<'a> = Js.undefined<'a> -``` - -Local alias for 'a Js.undefined. - -## return - -```res sig -let return: 'a => t<'a> -``` - -Constructs a value of `Js.undefined('a)` containing a value of `'a`. - -## test - -```res sig -let test: t<'a> => bool -``` - -Returns `true` if the given value is empty (undefined), `false` otherwise. - -## testAny - -```res sig -let testAny: 'a => bool -``` - -Since 1.6.1 Returns `true` if the given value is empty (undefined). - -## empty - -```res sig -let empty: t<'a> -``` - -The empty value, `undefined`. - -## getUnsafe - -```res sig -let getUnsafe: t<'a> => 'a -``` - -## getExn - -```res sig -let getExn: t<'a> => 'a -``` - -## bind - -```res sig -let bind: (t<'a>, (. 'a) => 'b) => t<'b> -``` - -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)`. - -```res example -let maybeGreetWorld = (maybeGreeting: Js.undefined) => - Js.Undefined.bind(maybeGreeting, (. greeting) => greeting ++ " world!") -``` - -## iter - -```res sig -let iter: (t<'a>, (. 'a) => unit) => unit -``` - -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. - -```res example -let maybeSay = (maybeMessage: Js.undefined) => - Js.Undefined.iter(maybeMessage, (. message) => Js.log(message)) -``` - -## fromOption - -```res sig -let fromOption: option<'a> => t<'a> -``` - -Maps `option('a)` to `Js.undefined('a)`. -`Some(a)` => `a` -`None` => `empty` - -## from_opt - -```res sig -let from_opt: option<'a> => t<'a> -``` - -## toOption - -```res sig -let toOption: t<'a> => option<'a> -``` - -Maps `Js.undefined('a)` to `option('a)` -`a` => `Some(a)` -`empty` => `None` - -## to_opt - -```res sig -let to_opt: t<'a> => option<'a> -``` diff --git a/pages/docs/manual/v9.0.0/api/js/vector.mdx b/pages/docs/manual/v9.0.0/api/js/vector.mdx deleted file mode 100644 index cefea9a87..000000000 --- a/pages/docs/manual/v9.0.0/api/js/vector.mdx +++ /dev/null @@ -1,157 +0,0 @@ -# Vector - - - -Provide vector utilities. - - - -## t - -```res prelude -type t<'a> = array<'a> -``` - -## filterInPlace - -```res sig -let filterInPlace: ((. 'a) => bool, t<'a>) => unit -``` - -p : predicate -a : array - -## empty - -```res sig -let empty: t<'a> => unit -``` - -## pushBack - -```res sig -let pushBack: ('a, t<'a>) => unit -``` - -## copy - -```res sig -let copy: t<'a> => t<'a> -``` - -Create a shallow copy of a vector. - -## memByRef - -```res sig -let memByRef: ('a, t<'a>) => bool -``` - -Find by JS (===) equality. - -## iter - -```res sig -let iter: ((. 'a) => unit, t<'a>) => unit -``` - -## iteri - -```res sig -let iteri: ((. int, 'a) => unit, t<'a>) => unit -``` - -## toList - -```res sig -let toList: t<'a> => list<'a> -``` - -## map - -```res sig -let map: ((. 'a) => 'b, t<'a>) => t<'b> -``` - -## mapi - -```res sig -let mapi: ((. int, 'a) => 'b, t<'a>) => t<'b> -``` - -## foldLeft - -```res sig -let foldLeft: ((. 'a, 'b) => 'a, 'a, t<'b>) => 'a -``` - -## foldRight - -```res sig -let foldRight: ((. 'b, 'a) => 'a, t<'b>, 'a) => 'a -``` - -## length - -```res sig -let length: t<'a> => int -``` - -Return the length (number of elements) of the given array. - -## get - -```res sig -let get: (t<'a>, int) => 'a -``` - -`Vector.get(a, n)` returns the element number `n` of vector `a`. The first element has number 0. The last element has number `Vector.length(a) - 1`. You can also write `a[n]` instead of `Vector.get(a, n)`. -Raise `Invalid_argument "index out of bounds"` if `n` is outside the range 0 to (`Array.length(a) - 1`). - -## set - -```res sig -let set: (t<'a>, int, 'a) => unit -``` - -`Vector.set(a, n, x)` modifies vector `a` in place, replacing element number `n` with `x`. -Raise `Invalid_argument "index out of bounds"` if `n` is outside the range 0 to `Array.length(a) - 1`. - -## make - -```res sig -let make: (int, 'a) => t<'a> -``` - -`Vector.make(n, x)` returns a fresh vector of length `n`, initialized with `x`. All the elements of this new vector are initially physically equal to `x` (in the sense of the `==` predicate). -Consequently, if `x` is mutable, it is shared among all elements of the array, and modifying `x` through one of the array entries will modify all other entries at the same time. -Raise `Invalid_argument` if `n < 0` or `n > Sys.max_array_length`. If the value of `x` is a floating-point number, then the maximum size is only `Sys.max_array_length / 2`. - -## init - -```res sig -let init: (int, (. int) => 'a) => t<'a> -``` - -Raises `RangeError` when n is negative. -n : size - -## append - -```res sig -let append: ('a, t<'a>) => t<'a> -``` - -`append(x, a)` returns a fresh vector with `x` appended to `a`. - -## unsafe_get - -```res sig -let unsafe_get: (t<'a>, int) => 'a -``` - -## unsafe_set - -```res sig -let unsafe_set: (t<'a>, int, 'a) => unit -``` diff --git a/pages/docs/manual/v9.0.0/array-and-list.mdx b/pages/docs/manual/v9.0.0/array-and-list.mdx deleted file mode 100644 index e76e501f1..000000000 --- a/pages/docs/manual/v9.0.0/array-and-list.mdx +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: "Array & List" -description: "Arrays and List data structures" -canonical: "/docs/manual/latest/array-and-list" ---- - -# Array and List - -## Array - -Arrays are our main ordered data structure. They work the same way as JavaScript arrays: they can be randomly accessed, dynamically resized, updated, etc. - - - -```res example -let myArray = ["hello", "world", "how are you"] -``` - -```js -var myArray = ["hello", "world", "how are you"]; -``` - - - -ReScript arrays' items must have the same type, i.e. homogeneous. - -### Usage - -See the [Js.Array](api/js/array) API. - -Access & update an array item like so: - - - -```res example -let myArray = ["hello", "world", "how are you"] - -let firstItem = myArray[0] // "hello" - -myArray[0] = "hey" // now ["hey", "world", "how are you"] - -let pushedValue = Js.Array2.push(myArray, "bye") -``` - -```js -var myArray = ["hello", "world", "how are you"]; - -var firstItem = myArray[0]; - -myArray[0] = "hey"; - -var pushedValue = myArray.push("bye"); -``` - - - -## List - -ReScript provides a singly linked list too. Lists are: - -- immutable -- fast at prepending items -- fast at getting the tail -- slow at everything else - - - -```res example -let myList = list{1, 2, 3} -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; -``` - - - -Like arrays, lists' items need to be of the same type. - -### Usage - -You'd use list for its resizability, its fast prepend (adding at the head), and its fast split, all of which are immutable and relatively efficient. - -Do **not** use list if you need to randomly access an item or insert at non-head position. Your code would end up obtuse and/or slow. - -The standard lib provides a [List module](api/belt/list). - -#### Immutable Prepend - -Use the spread syntax: - - - -```res prelude -let myList = list{1, 2, 3} -let anotherList = list{0, ...myList} -``` - -```js -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: 0, - }, - }, -}; - -var anotherList = { - hd: 0, - tl: myList, -}; -``` - - - -`myList` didn't mutate. `anotherList` is now `list{0, 1, 2, 3}`. This is efficient (constant time, not linear). `anotherList`'s last 3 elements are shared with `myList`! - -**Note that `list{a, ...b, ...c}` is a syntax error**. We don't support multiple spread for a list. That'd be an accidental linear operation (`O(b)`), since each item of b would be one-by-one added to the head of `c`. You can use `List.concat` for this, but we highly discourage it. - -Updating an arbitrary item in the middle of a list is also discouraged, since its performance and allocation overhead would be linear (`O(n)`). - -#### Access - -`switch` (described in the [pattern matching section](pattern-matching-destructuring.md)) is usually used to access list items: - - - -```res example -let message = - switch myList { - | list{} => "This list is empty" - | list{a, ...rest} => "The head of the list is the string " ++ Js.Int.toString(a) - } -``` - -```js -var message = myList - ? "The head of the list is the string " + (1).toString() - : "This list is empty"; -``` - - diff --git a/pages/docs/manual/v9.0.0/attribute.mdx b/pages/docs/manual/v9.0.0/attribute.mdx deleted file mode 100644 index b125a3f8f..000000000 --- a/pages/docs/manual/v9.0.0/attribute.mdx +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: "Attribute (Decorator)" -description: "Annotations in ReScript" -canonical: "/docs/manual/latest/attribute" ---- - -# Attribute (Decorator) - -Like many other languages, ReScript allows annotating a piece of code to express extra functionality. Here's an example: - - - -```res -@inline -let mode = "dev" - -let mode2 = mode -``` - -```js -var mode2 = "dev"; -``` - - - -The `@inline` annotation tells `mode`'s value to be inlined into its usage sites (see output). We call such annotation "attribute" (or "decorator" in JavaScript). - -An attribute starts with `@` and goes before the item it annotates. In the above example, it's hooked onto the let binding. - -## Usage - -> **Note:** In previous versions (< 8.3) all our interop related attributes started with a `bs.` prefix (`bs.module`, `bs.val`). Our formatter will automatically drop them in newer ReScript versions. - -You can put an attribute almost anywhere. You can even add extra data to them by using them visually like a function call. Here are a few famous attributes (explained in other sections): - - - -```res -@@warning("-27") - - -@unboxed -type a = Name(string) - -@val external message: string = "message" - -type student = { - age: int, - @as("aria-label") ariaLabel: string, -} - -@deprecated -let customDouble = foo => foo * 2 - -@deprecated("Use SomeOther.customTriple instead") -let customTriple = foo => foo * 3 -``` - -```js - -``` - - - -1. `@@warning("-27")` is a standalone attribute that annotates the entire file. Those attributes start with `@@`. Here, it carries the data `"-27"`. -2. `@unboxed` annotates the type definition. -3. `@val` annotates the `external` statement. -4. `@as("aria-label")` annotates the `ariaLabel` record field. -5. `@deprecated` annotates the `customDouble` expression. This shows a warning while compiling telling consumers to not rely on this method long-term. -6. `@deprecated("Use SomeOther.customTriple instead")` annotates the `customTriple` expression with a string to describe the reason for deprecation. - -## Extension Point - -There's a second category of attributes, called "extension points" (a remnant term of our early systems): - - - -```res -%raw("var a = 1") -``` - -```js -var a = 1; -``` - - - -Extension points are attributes that don't _annotate_ an item; they _are_ the item. Usually they serve as placeholders for the compiler to implicitly substitute them with another item. - -Extension points start with `%`. A standalone extension point (akin to a standalone regular attribute) starts with `%%`. diff --git a/pages/docs/manual/v9.0.0/bind-to-global-js-values.mdx b/pages/docs/manual/v9.0.0/bind-to-global-js-values.mdx deleted file mode 100644 index 373e8cf12..000000000 --- a/pages/docs/manual/v9.0.0/bind-to-global-js-values.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: "Bind to Global JS Values" -description: "JS interop with global JS values in ReScript" -canonical: "/docs/manual/latest/bind-to-global-js-values" ---- - -# Bind to Global JS Values - -**First**, make sure the value you'd like to model doesn't already exist in our [provided API](api/js). - -Some JS values, like `setTimeout`, live in the global scope. You can bind to them like so: - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -@val external clearTimeout: float => unit = "clearTimeout" -``` - -```js -// Empty output -``` - - - -(We already provide `setTimeout`, `clearTimeout` and others in the [Js.Global](api/js/global) module). - -This binds to the JavaScript [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrworkerGlobalScope/setTimeout) methods and the corresponding `clearTimeout`. The `external`'s type annotation specifies that `setTimeout`: - -- Takes a function that accepts `unit` and returns `unit` (which on the JS side turns into a function that accepts nothing and returns nothing aka `undefined`), -- and an integer that specifies the duration before calling said function, -- returns a number that is the timeout's ID. This number might be big, so we're modeling it as a float rather than the 32-bit int. - -### Tips & Tricks - -**The above isn't ideal**. See how `setTimeout` returns a `float` and `clearTimeout` accepts one. There's no guarantee that you're passing the float created by `setTimeout` into `clearTimeout`! For all we know, someone might pass it `Math.random()` into the latter. - -We're in a language with a great type system now! Let's leverage a popular feature to solve this problem: abstract types. - - - -```res example -type timerId -@val external setTimeout: (unit => unit, int) => timerId = "setTimeout" -@val external clearTimeout: timerId => unit = "clearTimeout" - -let id = setTimeout(() => Js.log("hello"), 100) -clearTimeout(id) -``` - -```js -var id = setTimeout(function (param) { - console.log("hello"); -}, 100); - -clearTimeout(id); -``` - - - -Clearly, `timerId` is a type that can only be created by `setTimeout`! Now we've guaranteed that `clearTimeout` _will_ be passed a valid ID. Whether it's a number under the hood is now a mere implementation detail. - -Since `external`s are inlined, we end up with JS output as readable as hand-written JS. - -## Global Modules - -If you want to bind to a value inside a global module, e.g. `Math.random`, attach a `scope` to your `val` external: - - - -```res example -@scope("Math") @val external random: unit => float = "random" -let someNumber = random() -``` - -```js -var someNumber = Math.random(); -``` - - - -you can bind to an arbitrarily deep object by passing a tuple to `scope`: - - - -```res example -@val @scope(("window", "location", "ancestorOrigins")) -external length: int = "length" -``` - -```js -// Empty output -``` - - - -This binds to `window.location.ancestorOrigins.length`. - -## Special Global Values - -Global values like `__filename` and `__DEV__` don't always exist; you can't even model them as an `option`, since the mere act of referring to them in ReScript (then compiled into JS) would trigger the usual `Uncaught ReferenceError: __filename is not defined` error in e.g. the browser environment. - -For these troublesome global values, ReScript provides a special approach: `%external(a_single_identifier)`. - - - -```res example -switch %external(__DEV__) { -| Some(_) => Js.log("dev mode") -| None => Js.log("production mode") -} -``` - -```js -var match = typeof __DEV__ === "undefined" ? undefined : __DEV__; - -if (match !== undefined) { - console.log("dev mode"); -} else { - console.log("production mode"); -} -``` - - - -That first line's `typeof` check won't trigger a JS ReferenceError. - -Another example: - - - -```res example -switch %external(__filename) { -| Some(f) => Js.log(f) -| None => Js.log("non-node environment") -}; -``` - -```js -var match = typeof __filename === "undefined" ? undefined : __filename; - -if (match !== undefined) { - console.log(match); -} else { - console.log("non-node environment"); -} -``` - - - - diff --git a/pages/docs/manual/v9.0.0/bind-to-js-function.mdx b/pages/docs/manual/v9.0.0/bind-to-js-function.mdx deleted file mode 100644 index c8e5cfd9b..000000000 --- a/pages/docs/manual/v9.0.0/bind-to-js-function.mdx +++ /dev/null @@ -1,477 +0,0 @@ ---- -title: "Bind to JS Function" -description: "JS interop with functions in ReScript" -canonical: "/docs/manual/latest/bind-to-js-function" ---- - -# Function - -Binding a JS function is like binding any other value: - - - -```res example -// Import nodejs' path.dirname -@module("path") external dirname: string => string = "dirname" -let root = dirname("/User/github") // returns "User" -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - - - -We also expose a few special features, described below. - -## Labeled Arguments - -ReScript has [labeled arguments](function.md#labeled-arguments) (that can also be optional). These work on an `external` too! You'd use them to _fix_ a JS function's unclear usage. Assuming we're modeling this: - -```js -// MyGame.js - -function draw(x, y, border) { - // suppose `border` is optional and defaults to false -} -draw(10, 20); -draw(20, 20, true); -``` - -It'd be nice if on ReScript's side, we can bind & call `draw` while labeling things a bit: - - - -```res example -@module("MyGame") -external draw: (~x: int, ~y: int, ~border: bool=?, unit) => unit = "draw" - -draw(~x=10, ~y=20, ~border=true, ()) -draw(~x=10, ~y=20, ()) -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, true); -MyGame.draw(10, 20, undefined); -``` - - - -We've compiled to the same function, but now the usage is much clearer on the ReScript side thanks to labels! - -**Note**: in this particular case, you need a unit, `()` after `border`, since `border` is an [optional argument at the last position](function.md#optional-labeled-arguments). Not having a unit to indicate you've finished applying the function would generate a warning. - -Note that you can freely reorder the labels on the ReScript side; they'll always correctly appear in their declaration order in the JavaScript output: - - - -```res example -@module("MyGame") -external draw: (~x: int, ~y: int, ~border: bool=?, unit) => unit = "draw" - -draw(~x=10, ~y=20, ()) -draw(~y=20, ~x=10, ()) -``` - -```js -var MyGame = require("MyGame"); - -MyGame.draw(10, 20, undefined); -MyGame.draw(10, 20, undefined); -``` - - - -## Object Method - -Functions attached to JS objects (other than JS modules) require a special way of binding to them, using `send`: - - - -```res example -type document // abstract type for a document object -@send external getElementById: (document, string) => Dom.element = "getElementById" -@val external doc: document = "document" - -let el = getElementById(doc, "myId") -``` - -```js -var el = document.getElementById("myId"); -``` - - - -In a `send`, the object is always the first argument. Actual arguments of the method follow (this is a bit what modern OOP objects are really). - -### Chaining - -Ever used `foo().bar().baz()` chaining ("fluent api") in JS OOP? We can model that in ReScript too, through the [pipe operator](pipe.md). - -## Variadic Function Arguments - -You might have JS functions that take an arbitrary amount of arguments. ReScript supports modeling those, under the condition that the arbitrary arguments part is homogenous (aka of the same type). If so, add `variadic` to your `external`. - - - -```res example -@module("path") @variadic -external join: array => string = "join" - -let v = join(["a", "b"]) -``` - -```js -var Path = require("path"); -var v = Path.join("a", "b"); -``` - - - -`module` will be explained in [Import from/Export to JS](import-from-export-to-js.md). - -## Modeling Polymorphic Function - -Apart from the above special-case, JS function in general are often arbitrary overloaded in terms of argument types and number. How would you bind to those? - -### Trick 1: Multiple `external`s - -If you can exhaustively enumerate the many forms an overloaded JS function can take, simply bind to each differently: - - - -```res example -@module("MyGame") external drawCat: unit => unit = "draw" -@module("MyGame") external drawDog: (~giveName: string) => unit = "draw" -@module("MyGame") external draw: (string, ~useRandomAnimal: bool) => unit = "draw" -``` - -```js -// Empty output -``` - - - -Note how all three externals bind to the same JS function, `draw`. - -### Trick 2: Polymorphic Variant + `unwrap` - -If you have the irresistible urge of saying "if only this JS function argument was a variant instead of informally being either `string` or `int`", then good news: we do provide such `external` features through annotating a parameter as a polymorphic variant! Assuming you have the following JS function you'd like to bind to: - -```js -function padLeft(value, padding) { - if (typeof padding === "number") { - return Array(padding + 1).join(" ") + value; - } - if (typeof padding === "string") { - return padding + value; - } - throw new Error(`Expected string or number, got '${padding}'.`); -} -``` - -Here, `padding` is really conceptually a variant. Let's model it as such. - - - -```res example -@val -external padLeft: ( - string, - @unwrap [ - | #Str(string) - | #Int(int) - ]) - => string = "padLeft" -padLeft("Hello World", #Int(4)) -padLeft("Hello World", #Str("Message from ReScript: ")) -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -Obviously, the JS side couldn't have an argument that's a polymorphic variant! But here, we're just piggy backing on poly variants' type checking and syntax. The secret is the `@unwrap` annotation on the type. It strips the variant constructors and compile to just the payload's value. See the output. - -## Constrain Arguments Better - -Consider the Node `fs.readFileSync`'s second argument. It can take a string, but really only a defined set: `"ascii"`, `"utf8"`, etc. You can still bind it as a string, but we can use poly variants + `string` to ensure that our usage's more correct: - - - -```res example -@module("fs") -external readFileSync: ( - ~name: string, - @string [ - | #utf8 - | @as("ascii") #useAscii - ], -) => string = "readFileSync" - -readFileSync(~name="xx.txt", #useAscii) -``` - -```js -var Fs = require("fs"); -Fs.readFileSync("xx.txt", "ascii"); -``` - - - -- Attaching `@string` to the whole poly variant type makes its constructor compile to a string of the same name. -- Attaching a `@as("bla")` to a constructor lets you customize the final string. - -And now, passing something like `"myOwnUnicode"` or other variant constructor names to `readFileSync` would correctly error. - -Aside from string, you can also compile an argument to an int, using `int` instead of `string` in a similar way: - - - -```res example -@val -external testIntType: ( - @int [ - | #onClosed - | @as(20) #onOpen - | #inBinary - ]) - => int = "testIntType" -testIntType(#inBinary) -``` - -```js -testIntType(21); -``` - - - -`onClosed` compiles to `0`, `onOpen` to `20` and `inBinary` to **`21`**. - -## Special-case: Event Listeners - -One last trick with polymorphic variants: - - - -```res example -type readline - -@send -external on: ( - readline, - @string [ - | #close(unit => unit) - | #line(string => unit) - ] - ) - => readline = "on" - -let register = rl => - rl - ->on(#close(event => ())) - ->on(#line(line => Js.log(line))); -``` - -```js -function register(rl) { - return rl - .on("close", function ($$event) {}) - .on("line", function (line) { - console.log(line); - }); -} -``` - - - - - -## Fixed Arguments - -Sometimes it's convenient to bind to a function using an `external`, while passing predetermined argument values to the JS function: - - - -```res example -@val -external processOnExit: ( - @as("exit") _, - int => unit -) => unit = "process.on" - -processOnExit(exitCode => - Js.log("error code: " ++ Js.Int.toString(exitCode)) -); -``` - -```js -process.on("exit", function (exitCode) { - console.log("error code: " + exitCode.toString()); -}); -``` - - - -The `@as("exit")` and the placeholder `_` argument together indicates that you want the first argument to compile to the string `"exit"`. You can also use any JSON literal with `as`: ``@as(json`true`)``, ``@as(json`{"name": "John"}`)``, etc. - -## Curry & Uncurry - -Curry is a delicious Indian dish. More importantly, in the context of ReScript (and functional programming in general), currying means that function taking multiple arguments can be applied a few arguments at time, until all the arguments are applied. - -See the `addFive` intermediate function? `add` takes in 3 arguments but received only 1. It's interpreted as "currying" the argument `5` and waiting for the next 2 arguments to be applied later on. Type signatures: - -```res sig -let add: (int, int, int) => int -let addFive: (int, int) => int -let twelve: int -``` - -(In a dynamic language such as JS, currying would be dangerous, since accidentally forgetting to pass an argument doesn't error at compile time). - -### Drawback - -Unfortunately, due to JS not having currying because of the aforementioned reason, it's hard for ReScript multi-argument functions to map cleanly to JS functions 100% of the time: - -1. When all the arguments of a function are supplied (aka no currying), ReScript does its best to to compile e.g. a 3-arguments call into a plain JS call with 3 arguments. - -2. If it's too hard to detect whether a function application is complete\*, ReScript will use a runtime mechanism (the `Curry` module) to curry as many args as we can and check whether the result is fully applied. - -3. Some JS APIs like `throttle`, `debounce` and `promise` might mess with context, aka use the function `bind` mechanism, carry around `this`, etc. Such implementation clashes with the previous currying logic. - -\* If the call site is typed as having 3 arguments, we sometimes don't know whether it's a function that's being curried, or if the original one indeed has only 3 arguments. - -ReScript tries to do #1 as much as it can. Even when it bails and uses #2's currying mechanism, it's usually harmless. - -**However**, if you encounter #3, heuristics are not good enough: you need a guaranteed way of fully applying a function, without intermediate currying steps. We provide such guarantee through the use of the ["uncurrying" syntax](./function#uncurried-function) on a function declaration & call site. - -### Solution: Use Guaranteed Uncurrying - -[Uncurried function](function.md#uncurried-function) annotation also works on `external`: - - - -```res example -type timerId -@val external setTimeout: ((. unit) => unit, int) => timerId = "setTimeout" - -let id = setTimeout((.) => Js.log("hello"), 1000) -``` - -```js -var id = setTimeout(function () { - console.log("hello"); -}, 1000); -``` - - - -#### Extra Solution - -The above solution is safe, guaranteed, and performant, but sometimes visually a little burdensome. We provide an alternative solution if: - -- you're using `external` -- the `external` function takes in an argument that's another function -- you want the user **not** to need to annotate the call sites with the dot - - - -Then try `@uncurry`: - - - -```res example -@send external map: (array<'a>, @uncurry ('a => 'b)) => array<'b> = "map" -map([1, 2, 3], x => x + 1) -``` - -```js -// Empty output -``` - - - -In general, `uncurry` is recommended; the compiler will do lots of optimizations to resolve the currying to uncurrying at compile time. However, there are some cases the compiler can't optimize it. In these cases, it will be converted to a runtime check. - -## Modeling `this`-based Callbacks - -Many JS libraries have callbacks which rely on this (the source), for example: - -```js -x.onload = function (v) { - console.log(this.response + v); -}; -``` - -Here, `this` would point to `x` (actually, it depends on how `onload` is called, but we digress). It's not correct to declare `x.onload` of type `(. unit) -> unit`. Instead, we introduced a special attribute, `this`, which allows us to type `x` as so: - - - -```res example -type x -@val external x: x = "x" -@set external setOnload: (x, @this ((x, int) => unit)) => unit = "onload" -@get external resp: x => int = "response" -setOnload(x, @this ((o, v) => Js.log(resp(o) + v))) -``` - -```js -x.onload = function (v) { - var o = this; - console.log((o.response + v) | 0); -}; -``` - - - -`this` has its first parameter is reserved for `this` and for arity of 0, there is no need for a redundant `unit` type. - -## Function Nullable Return Value Wrapping - -For JS functions that return a value that can also be `undefined` or `null`, we provide `@return(...)`. To automatically convert that value to an `option` type (recall that ReScript `option` type's `None` value only compiles to `undefined` and not `null`). - - - -```res example -type element -type dom - -@send @return(nullable) -external getElementById: (dom, string) => option = "getElementById" - -let test = dom => { - let elem = dom->(getElementById("haha")) - switch (elem) { - | None => 1 - | Some(_ui) => 2 - } -} -``` - -```js -function test(dom) { - var elem = dom.getElementById("haha"); - if (elem == null) { - return 1; - } else { - console.log(elem); - return 2; - } -} -``` - - - -`return(nullable)` attribute will automatically convert `null` and `undefined` to `option` type. - -Currently 4 directives are supported: `null_to_opt`, `undefined_to_opt`, `nullable` and `identity`. - - - -`identity` will make sure that compiler will do nothing about the returned value. It is rarely used, but introduced here for debugging purpose. diff --git a/pages/docs/manual/v9.0.0/bind-to-js-object.mdx b/pages/docs/manual/v9.0.0/bind-to-js-object.mdx deleted file mode 100644 index 4acba9bba..000000000 --- a/pages/docs/manual/v9.0.0/bind-to-js-object.mdx +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: "Bind to JS Object" -description: "Interop with JS objects in ReScript" -canonical: "/docs/manual/latest/bind-to-js-object" ---- - -# Bind to JS Object - -JavaScript objects are a combination of several use-cases: - -- As a "record" or "struct" in other languages (like ReScript and C). -- As a hash map. -- As a class. -- As a module to import/export. - -ReScript cleanly separates the binding methods for JS object based on these 4 use-cases. This page documents the first three. Binding to JS module objects is described in the [Import from/Export to JS](import-from-export-to-js.md) section. - - - -## Bind to Record-like JS Objects - -### Bind Using ReScript Record - -If your JavaScript object has fixed fields, then it's conceptually like a ReScript record. Since a ReScript record compiles to a clean JavaScript object, you can definitely type a JS object as a ReScript record! - - - -```res example -type person = { - name: string, - friends: array, - age: int, -} - -@module("MySchool") external john: person = "john" - -let johnName = john.name -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -External is documented [here](external.md). `@module` is documented [here](import-from-export-to-js.md). - -### Bind Using ReScript Object - -Alternatively, you can use [ReScript object](object.md) to model a JS object too: - - - -```res example -type person = { - "name": string, - "friends": array, - "age": int, -} - -@module("MySchool") external john: person = "john" - -let johnName = john["name"] -``` - -```js -var MySchool = require("MySchool"); - -var johnName = MySchool.john.name; -``` - - - -### Bind Using Special Getter and Setter Attributes - -Alternatively, you can use `get` and `set` to bind to individual fields of a JS object: - - - -```res example -type textarea -@set external setName: (textarea, string) => unit = "name" -@get external getName: textarea => string = "name" -``` - -```js - -``` - - - -You can also use `get_index` and `set_index` to access a dynamic property or an index: - - - -```res example -type t -@new external create: int => t = "Int32Array" -@get_index external get: (t, int) => int = "" -@set_index external set: (t, int, int) => unit = "" - -let i32arr = create(3) -i32arr->set(0, 42) -Js.log(i32arr->get(0)) -``` - -```js -var i32arr = new Int32Array(3); -i32arr[0] = 42; -console.log(i32arr[0]); -``` - - - -## Bind to Hash Map-like JS Object - -If your JavaScript object: - -- might or might not add/remove keys -- contains only values that are of the same type - -Then it's not really an object, it's a hash map. Use [Js.Dict](api/js/dict), which contains operations like `get`, `set`, etc. and cleanly compiles to a JavaScript object still. - -## Bind to a JS Object That's a Class - -Use `new` to emulate e.g. `new Date()`: - - - -```res example -type t -@new external createDate: unit => t = "Date" - -let date = createDate() -``` - -```js -var date = new Date(); -``` - - - -You can chain `new` and `module` if the JS module you're importing is itself a class: - - - -```res example -type t -@new @module external book: unit => t = "Book" -let myBook = book() -``` - -```js -var Book = require("Book"); -var myBook = new Book(); -``` - - diff --git a/pages/docs/manual/v9.0.0/browser-support-polyfills.mdx b/pages/docs/manual/v9.0.0/browser-support-polyfills.mdx deleted file mode 100644 index c1de7a491..000000000 --- a/pages/docs/manual/v9.0.0/browser-support-polyfills.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: "Browser Support & Polyfills" -description: "Note on browser support in ReScript" -canonical: "/docs/manual/latest/browser-support-polyfills" ---- - -# Browser Support & Polyfills - -ReScript compiles to JavaScript **ES5**, with the exception of optionally allowing to compile to ES6's module import & export. - -For [old browsers](https://caniuse.com/#search=typed%20array), you also need to polyfill TypedArray. The following standard library functions require it: - -- `Int64.float_of_bits` -- `Int64.bits_of_float` -- `Int32.float_of_bits` -- `Int32.bits_of_float` - -If you don't use these functions, you're fine. Otherwise, it'll be a runtime failure. diff --git a/pages/docs/manual/v9.0.0/build-configuration-schema.mdx b/pages/docs/manual/v9.0.0/build-configuration-schema.mdx deleted file mode 100644 index 918ee6b9f..000000000 --- a/pages/docs/manual/v9.0.0/build-configuration-schema.mdx +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: "Configuration Schema" -metaTitle: "Build System Configuration Schema" -description: "Schema exploration widget for the ReScript configuration file" -canonical: "/docs/manual/latest/build-configuration-schema" ---- - -import dynamic from "next/dynamic"; - -export const Docson = dynamic( - () => - import("src/components/Docson").then((comp) => { - return comp.make; - }), - { - ssr: false, - loading: () =>
Loading...
, - }, -); - -export default function BuildConfigurationSchemaPage() { - return ; -} diff --git a/pages/docs/manual/v9.0.0/build-configuration.mdx b/pages/docs/manual/v9.0.0/build-configuration.mdx deleted file mode 100644 index 8cf9d0f23..000000000 --- a/pages/docs/manual/v9.0.0/build-configuration.mdx +++ /dev/null @@ -1,196 +0,0 @@ ---- -title: "Configuration" -metaTitle: "Build System Configuration" -description: "Details about the configuration of the ReScript build system (bsconfig.json)" -canonical: "/docs/manual/latest/build-configuration" ---- - -# Configuration - -`bsconfig.json` is the single, mandatory build meta file needed for bsb. - -**The complete configuration schema is [here](./build-configuration-schema)**. We'll _non-exhaustively_ highlight the important parts in prose below. - -## Tips & Tricks - -If you're using an editor like VSCode, put the following code as your first field in `bsconfig.json` to get schema autocompletion! - -```json -"$schema": "https://raw.githubusercontent.com/rescript-lang/rescript/master/docs/docson/build-schema.json" -``` - -## name, namespace - -`name` is the name of the library, used as its "namespace". You can activate namespacing through `"namespace": true` in your `bsconfig.json`. Namespacing is almost **mandatory**; we haven't turned it on by default yet to preserve backward-compatibility. - -**Explanation**: by default, your files, once used as a third-party dependency, are available globally to the consumer. E.g. if you have an `Util.re` and the consumer also has a file of the same name, they will clash. Turning on `namespace` avoids this by wrapping all your own project's files into an extra module layer; instead of a global `Util` module, the consumer will see you as `MyProject.Util`. **The namespacing affects your consumers, not yourself**. - -Aka, in Bsb, "namespace" is just a fancy term for an auto-generated module that wraps all your project's files (efficiently and correctly, of course!) for third-party consumption. - -We don't do folder-level namespacing for your own project; all your own file names must be unique. This is a constraint that enables several features such as fast search and easier project reorganization. - -**Note**: the `bsconfig.json` `name` should be the same as the `package.json` `name`, to avoid confusing corner-cases. However, this means that you can't use a camelCased names such as `MyProject`, since `package.json` and npm forbid you to do so (some file systems are case-insensitive). To have the namespace/module as `MyProject`, write `"name": "my-project"`. Bsb will turn that into the camelCased name correctly. - -**Note on custom namespacing**: if for some reason, you need a namespace that is different from what your `name` will produce, you can directly send a string to the `namespace` option. For example, if your package is a binding named `bs-some-thing`, you can use `"namespace": "some-thing"` to get `SomeThing` namespace instead of `BsSomeThing`. - -## sources - -Your source files need to be specified explicitly (we don't want to accidentally drill down into some unrelated directories). Examples: - -```json -{ - "sources": ["src", "examples"] -} -``` - -```json -{ - "sources": { - "dir": "src", - "subdirs": ["page"] - } -} -``` - -```json -{ - "sources": [ - "examples", - { - "dir": "src", - "subdirs": true // recursively builds every subdirectory - } - ] -} -``` - -You can mark your directories as dev-only (for e.g. tests). These won't be built and exposed to third-parties, or even to other "dev" directories in the same project: - -```json -{ - "sources": { - "dir": "test", - "type": "dev" - } -} -``` - -## bs-dependencies, bs-dev-dependencies - -List of ReScript dependencies. Just like `package.json`'s dependencies, they'll be searched in `node_modules`. - -Note that only sources marked with `"type":"dev"` will be able to resolve modules from `bs-dev-dependencies`. - -## pinned-dependencies - -**Since 8.4**: List of pinned dependencies. A pinned dependency will always be rebuilt whenever you build a toplevel package (e.g. your main app) with `bsb -make-world`. - -This is useful for working on multiple independent ReScript packages simultaneously. More usage details can be found in our dedicated [pinned dependencies](./build-pinned-dependencies) page. - -## external-stdlib - -**Since 9.0**: This setting allows depending on an externally built stdlib package (instead of a locally built stdlib runtime). Useful for shipping packages that are only consumed in JS or TS without any dependencies to the ReScript development toolchain. - -More details can be found on our [external stdlib](./build-external-stdlib) page. - -## reason, refmt (old) - -`reason` config is enabled by default. To turn on JSX for [ReasonReact](https://reasonml.github.io/reason-react/), specify: - -```json -{ - "reason": { "react-jsx": 3 }, - "refmt": 3 -} -``` - -The `refmt` config **should be explicitly specified** as `3`. - -## js-post-build - -Hook that's invoked every time a file is recompiled. Good for JS build system interop, but please use it **sparingly**. Calling your custom command for every recompiled file slows down your build and worsens the building experience for even third-party users of your lib. - -Example: - -```json -{ - "js-post-build": { - "cmd": "/path/to/node ../../postProcessTheFile.js" - } -} -``` - -Note that the path resolution for the command (`node` in this case) is done so: - -- `/myCommand` is resolved into `/myCommand` -- `package/myCommand` is resolved into `node_modules/package/myCommand` -- `./myCommand` is resolved into `myProjectRoot/myCommand` -- `myCommand` is just called as `myCommand`, aka a globally available executable. But note that Bsb doesn't read into your shell's environment, so if you put e.g. `node`, it won't find it unless you specify an absolute path. Alternatively, add `#!/usr/local/bin/node` to the top of your script to directly call it without prepending `node`. - -The command itself is called from inside `lib/bs`. - -## package-specs - -Output to either CommonJS (the default) or ES6 modules. Example: - -```json -{ - "package-specs": { - "module": "commonjs", - "in-source": true - } -} -``` - -- `"module": "es6-global"` resolves `node_modules` using relative paths. Good for development-time usage of ES6 in conjunction with browsers like Safari and Firefox that support ES6 modules today. **No more dev-time bundling**! -- `"in-source": true` generates output alongside source files. If you omit it, it'll generate the artifacts into `lib/js`. The output directory is not configurable otherwise. - -This configuration only applies to you, when you develop the project. When the project is used as a third-party library, the consumer's own `bsconfig.json` `package-specs` overrides the configuration here, logically. - -## suffix - -Either `".js"`, `".mjs"`, `".cjs"` or `".bs.js"`. Currently prefer `bs.js` for now. - -### Design Decisions - -Generating JS files with the `.bs.js` suffix means that, on the JS side, you can do `const myReScriptFile = require('./theFile.bs')`. The benefits: - -- It's immediately clear that we're dealing with a generated JS file here. -- It avoids clashes with a potential `theFile.js` file in the same folder. -- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**. -- [genType](/docs/manual/latest/typescript-integration) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. - -## warnings - -Selectively turn on/off certain warnings and/or turn them into hard errors. Example: - -```json -{ - "warnings": { - "number": "-44-102", - "error": "+5" - } -} -``` - -Turn off warning `44` and `102` (polymorphic comparison). Turn warning `5` (partial application whose result has function type and is ignored) into a hard error. - -The warning number are shown in the build output when they're triggered. The complete list is [here](https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec281), a little bit below. `100` and up are ReScript-specific. - -## bsc-flags - -Extra flags to pass to the underlying `bsc` call. Notably: `["-bs-super-errors"]` for turning on cleaner error output. No need to pass this flag for a new ReScript project; it's enabled by default. - -## Environment Variables - -We heavily disrecommend the usage of environment variables, but for certain cases, they're justified. - -### Error Output Coloring: `NINJA_ANSI_FORCED` - -This is mostly for other programmatic usage of `bsb` where outputting colors is not desired. - -When `NINJA_ANSI_FORCED` is set to `1`: `bsb` produces color. -When `NINJA_ANSI_FORCED` is set to `0`: `bsb` doesn't produce color. -When `NINJA_ANSI_FORCED` is not set: `bsb` might or might not produce color, depending on a smart detection of where it's outputted. - -> Note that bsc, the barebone compiler, will always be passed `-color always`. See more details in [this issue](https://github.com/rescript-lang/rescript/issues/2984#issuecomment-410669163). diff --git a/pages/docs/manual/v9.0.0/build-external-stdlib.mdx b/pages/docs/manual/v9.0.0/build-external-stdlib.mdx deleted file mode 100644 index 62bdc8a29..000000000 --- a/pages/docs/manual/v9.0.0/build-external-stdlib.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: "External Stdlib" -metaTitle: "External Stdlib" -description: "Configuring an external ReScript stdlib package" -canonical: "/docs/manual/latest/build-external-stdlib" ---- - -# External Stdlib - -**Since 9.0** - -Your ReScript project depends on the `bs-platform` (soon `rescript`) package as a [`devDependency`](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file), which includes our compiler, build system and runtime like `Belt`. However, you had to move it to `dependency` in `package.json` if you publish your code: - -- To Docker or other low-storage deployment devices. -- For pure JS/TS consumers who probably won't install `bs-platform` in their own project. - -In these cases, the size or mere presence of `bs-platform` can be troublesome, since it includes not just our necessary runtime like `Belt`, but also our compiler and build system. - -To solve that, we now publish our runtime as a standalone package at [`@rescript/std`](https://www.npmjs.com/package/@rescript/std), whose versions mirror `bs-platform`'s. Now you can keep `bs-platform` as a `devDependency` and have only `@rescript/std` as your runtime `dependency`. - -**This is an advanced feature**. Please only use it in the aforementioned scenarios. If you already use a JS bundler with dead code elimination, you might not need this feature. - -## Configuration - -Say you want to publish a JS-only ReScript 9.0 library. Install the packages like this: - -```sh -npm install bs-platform@9.0.0 --save-dev -npm install @rescript/std@9.0.0 --save -``` - -Then add this to `bsconfig.json`: - -```json -{ - // ... - "external-stdlib": "@rescript/std" -} -``` - -Now the compiled JS code will import using the path defined by `external-stdlib`. Check the JS output tab: - - - -```res -Belt.Array.forEach([1, 2, 3], num => Js.log(num)) -``` - -```js -// Note the require path starting with "@rescript/std". -var Belt_Array = require("@rescript/std/lib/js/belt_Array.js"); - -Belt_Array.forEach([1, 2, 3], function (num) { - console.log(num); -}); -``` - - - -**Make sure the version number of `bs-platform` and `@rescript/std` match in your `package.json`** to avoid running into runtime issues due to mismatching stdlib assumptions. diff --git a/pages/docs/manual/v9.0.0/build-overview.mdx b/pages/docs/manual/v9.0.0/build-overview.mdx deleted file mode 100644 index 5f0d681aa..000000000 --- a/pages/docs/manual/v9.0.0/build-overview.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Overview" -metaTitle: "Build System Overview" -description: "Documentation about the ReScript build system and its toolchain" -canonical: "/docs/manual/latest/build-overview" ---- - -# Build System Overview - -ReScript comes with a build system, bsb, that's meant to be fast, lean and used as the authoritative build system of the community. - -The build description file is called `bsconfig.json`. Every ReScript project needs one. - -## Build Project - -Each build will create build artifacts from your project's source files. - -**To build a project (including its dependencies / pinned-dependencies)**, run: - -```sh -bsb -make-world -``` - -Add `-w` to keep the built-in watcher running. Any new file change will be picked up and the build will re-run. - -**Note**: third-party libraries (in `node_modules`, or via `pinned-dependencies`) aren't watched, as doing so may exceed the node.js watcher count limit. - -**Note 2**: In case you want to set up a project in a JS-monorepo-esque approach (`yarn workspaces` / `lerna`) where changes in your sub packages should be noticed by the compiler (`bsb -make-world`), you will need to define pinned dependencies in your main project's `bsconfig.json`. More details [here](./build-pinned-dependencies). - -**To build only your project's files (without dependencies)**, run: - -```sh -bsb -``` - -## Clean Project - -If you ever get into a stale build for edge-case reasons, use: - -```sh -bsb -clean-world -``` - -This will clean all your project's build artifacts, including those in your dependencies. Alternatively you can run `bsb -clean` to clean your project's build artifacts only. - -For more infos, run `bsb -help` to see all the available options. diff --git a/pages/docs/manual/v9.0.0/build-performance.mdx b/pages/docs/manual/v9.0.0/build-performance.mdx deleted file mode 100644 index d144140a9..000000000 --- a/pages/docs/manual/v9.0.0/build-performance.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: "Performance" -metaTitle: "Build Performance" -description: "ReScript build performance and measuring tools" -canonical: "/docs/manual/latest/build-performance" ---- - -# Build Performance - -ReScript considers performance at install time, build time and run time as a serious feature. Here are some more info, and tips on keeping the build fast. **Feel free to skip this section** if you're just starting out. - -## Profile Your Build - -Sometime your build can be slow due to some confused infra setups. We provide an interactive visualization of your build's performance via `bstracing`: - -```sh -./node_modules/.bin/bstracing -``` - -Run the above command at your ReScript project's root; it'll spit out a JSON file you can drag and drop into `chrome://tracing`. - -import Image from "src/components/Image"; - - - -## Under the Hood - -Bsb itself uses a build system under the hood, called [Ninja](https://ninja-build.org). Ninja is like Make, but cross-platform, minimal, focuses in perf and destined to be more of a low-level building block than a full-blown build system. In this regard, Ninja's a great implementation detail for bsb. - -Bsb reads into `bsconfig.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level `bsc`-related commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build. - -## The JS Wrapper - -`bsb` itself is a Node.js wrapper which takes care of some miscellaneous tasks, plus the watcher. The lower-level, watcher-less, true `bsb` is called `bsb.exe`. It can be located in the same directory as where `bsb` is found: - -```sh -> bsb -where -/usr/local/lib/node_modules/bs-platform/lib -``` - -The path varies across systems. - -If you don't need the watcher, you can run said `bsb.exe`: `/usr/local/lib/node_modules/bs-platform/lib/bsb.exe`. This side-steps the node.js startup time, which can be big (in the order of `100ms`). - -## Numbers - -Raw `bsb.exe` build on a small project should be around `70ms`. This doubles when you use the more common `bsb` wrapper which comes with a watcher, which is practically faster since you don't manually run the build at every change (though you should opt for the raw `bsb.exe` for programmatic usage, e.g. inserting bsb into your existing JS build pipeline). - -No-op build (when no file's changed) should be around `15ms`. Incremental rebuild (described soon) of a single file in a project is around `70ms` too. - -Cleaning the artifacts should be instantaneous. - -### Extreme Test - -We've stress-tested bsb on a big project of 10,000 files (2 directories, 5000 files each, first 5000 no dependencies, last 5000 10 dependencies on files from the former directory) using https://github.com/ocaml-omake/omake/blob/perf-test/performance/generate.ml, on Retina Macbook Pro Early 2015 (3.1 GHz Intel Core i7). - - - -- No-op build of 10k files: `800ms` (the minimum amount of time required to check the mtimes of 10k files). -- Clean build: \<3 minutes. -- Incremental build: depends on the number of the dependents of the file. No dependent means `1s`. - -Note that bsb is a file-based build system. We don't do in-memory build, even if that speeds up the build a lot. In-memory builds risk memory leaks, out-of-memory errors and others. The bsb watcher, on the other hand, can stay open for days. - -## Incrementality - -Bsb doesn't take whole seconds to run every time. The bulk of the build performance comes from incremental build, aka re-building a previously built project when a few files changed. - -In short, thanks to our bsc compiler and bsb build system's architecture, we're able to **only build what's needed**. E.g. if `MyFile.res` isn't changed, then it's not recompiled. You can roughly emulate such incrementality in languages like JavaScript, but the degree of correctness is unfortunately low. For example, if you rename or move a JS file, then the watcher might get confused and not pick up the "new" file or fail to clean things up correctly, resulting in you needing to clean your build and restart anew, which defeats the purpose. - -## Speed Up Incremental Build - -ReScript uses the concept of interface files (`.resi`) (or, equivalently, [module signatures](module.md#signatures)). Exposing only what you need naturally speeds up incremental builds. E.g. if you change a `.res` file whose corresponding `.resi` file doesn't expose the changed part, then you've reduced the amount of dependent files you have to rebuild. - - - -## Programmatic Usage - -Unfortunately, JS build systems are usually the bottleneck for building a JS project nowadays. Having parts of the build blazingly fast doesn't matter much if the rest of the build takes seconds or literally minutes. Here are a few suggestions: - -- Convert more files into ReScript =). Fewer files going through fewer parts of the JS pipeline helps a ton. -- Careful with bringing in more dependencies: libraries, syntax transforms, build step loaders, etc. The bulk of these dragging down the editing & building experience might out-weight the API benefits they provide. -- Wait for us to create our own super fast linker (aka bundler). - -## Hot Reloading - -Hot reloading refers to maintaining a dev server and listening to file changes in a way that allows the server to pipe some delta changes right into the currently running browser page. This provides a relatively fast iteration workflow while working in specific frameworks. - -However, hot reloading is fragile by nature, and counts on the occasional inconsistencies (bad state, bad eval, etc.) and the heavy devserver setup/config being less of a hassle than the benefits it provides. We err on the side of caution and stability in general, and decided not to provide a built-in hot reloading _yet_. **Note**: you can still use the hot reloading facility provided by your JS build pipeline. diff --git a/pages/docs/manual/v9.0.0/build-pinned-dependencies.mdx b/pages/docs/manual/v9.0.0/build-pinned-dependencies.mdx deleted file mode 100644 index 1c149c99a..000000000 --- a/pages/docs/manual/v9.0.0/build-pinned-dependencies.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: "Pinned Dependencies" -metaTitle: "Pinned Dependencies" -description: "Handling multiple packages within one ReScript project with pinned dependencies" -canonical: "/docs/manual/latest/build-pinned-dependencies" ---- - -# Pinned Dependencies - -**Since 8.4** - -Usually we'd recommend to use ReScript in a single-codebase style by using one `bsconfig.json` file for your whole codebase. - -There are scenarios where you still want to connect and build multiple independent ReScript packages for one main project though (`yarn workspaces`-like "monorepos"). This is where `pinned-dependencies` come into play. - -## Package Types - -Before we go into detail, let's first explain all the different package types recognized by the build system: - -- Toplevel (this is usually the final app you are building, which has dependencies to other packages) -- Pinned dependencies (these are your local packages that should always rebuild when you build your toplevel, those should be listed in `bs-dependencies` and `pinned-dependencies`) -- Normal dependencies (these are packages that are consumed from npm and listed via `bs-dependencies`) - -Whenever a package is being built (`bsb -make-world`), the build system will build the toplevel package with its pinned-dependencies. So any changes made in a pinned dependency will automatically be reflected in the final app. - -## Build System Package Rules - -The build system respects the following rules for each package type: - -**Toplevel** - -- Warnings reported -- Warn-error respected -- Builds dev dependencies -- Builds pinned dependencies -- Runs custom rules -- Package-specs like ES6/CommonJS overrides all its dependencies - -**Pinned dependencies** - -- Warnings reported -- Warn-error respected -- Ignores pinned dependencies -- Builds dev dependencies -- Runs custom rules - -**Normal dependencies** - -- Warnings, warn-error ignored -- Ignores dev directories -- Ignores pinned dependencies -- Ignores custom generator rules - -So with that knowledge in mind, let's dive into some more concrete examples to see our pinned dependencies in action. - -## Examples - -### Yarn workspaces - -Let's assume we have a codebase like this: - -``` -myproject/ - app/ - - src/App.res - - bsconfig.json - common/ - - src/Header.res - - bsconfig.json - myplugin/ - - src/MyPlugin.res - - bsconfig.json - package.json -``` - -Our `package.json` file within our codebase root would look like this: - -```json -{ - "name": "myproject", - "private": true, - "workspaces": { - "packages": ["app", "common", "myplugin"] - } -} -``` - -Our `app` folder would be our toplevel package, consuming our `common` and `myplugin` packages as `pinned-dependencies`. The configuration for `app/bsconfig.json` looks like this: - -```json -{ - "name": "app", - "version": "1.0.0", - "sources": { - "dir": "src", - "subdirs": true - }, - /* ... */ - "bs-dependencies": ["common", "myplugin"], - "pinned-dependencies": ["common", "myplugin"] - /* ... */ -} -``` - -Now, whenever we are running `npx bsb -make-world` within our `app` package, the compiler would always rebuild any changes within its pinned dependencies as well. - -**Important:** ReScript will not rebuild any `pinned-dependencies` in watch mode! This is due to the complexity of file watching, so you'd need to set up your own file-watcher process that runs `bsb -make-world` on specific file changes. E.g. you could use [`watchman-make`](https://facebook.github.io/watchman/docs/watchman-make.html) to automatically run the build task when a file in `common` or `myplugin` has been changed. diff --git a/pages/docs/manual/v9.0.0/control-flow.mdx b/pages/docs/manual/v9.0.0/control-flow.mdx deleted file mode 100644 index 0abb918c7..000000000 --- a/pages/docs/manual/v9.0.0/control-flow.mdx +++ /dev/null @@ -1,221 +0,0 @@ ---- -title: "If-Else & Loops" -description: "If, else, ternary, for, and while" -canonical: "/docs/manual/latest/control-flow" ---- - -# If-Else & Loops - -ReScript supports `if`, `else`, ternary expression (`a ? b : c`), `for` and `while`. - -ReScript also supports our famous pattern matching, which will be covered in [its own section](pattern-matching-destructuring.md) - -## If-Else & Ternary - -Unlike its JavaScript counterpart, ReScript's `if` is an expression; they evaluate to their body's content: - - - -```res -let message = if isMorning { - "Good morning!" -} else { - "Hello!" -} -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**Note:** an `if-else` expression without the final `else` branch implicitly gives `()` (aka the `unit` type). So this: - - - -```res -if showMenu { - displayMenu() -} -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -is basically the same as: - - - -```res -if showMenu { - displayMenu() -} else { - () -} -``` - -```js -if (showMenu) { - displayMenu(); -} -``` - - - -Here's another way to look at it. This is clearly wrong: - -```res -let result = if showMenu { - 1 + 2 -} -``` - -It'll give a type error, saying basically that the implicit `else` branch has the type `unit` while the `if` branch has type `int`. Intuitively, this makes sense: what would `result`'s value be, if `showMenu` was `false`? - -We also have ternary sugar, but **we encourage you to prefer if-else when possible**. - - - -```res -let message = isMorning ? "Good morning!" : "Hello!" -``` - -```js -var message = isMorning ? "Good morning!" : "Hello!"; -``` - - - -**`if-else` and ternary are much less used** in ReScript than in other languages; [Pattern-matching](pattern-matching-destructuring.md) kills a whole category of code that previously required conditionals. - -## For Loops - -For loops iterate from a starting value up to (and including) the ending value. - - - -```res -for i in startValueInclusive to endValueInclusive { - Js.log(i) -} -``` - -```js -for (var i = startValueInclusive; i <= endValueInclusive; ++i) { - console.log(i); -} -``` - - - - - -```res example -// prints: 1 2 3, one per line -for x in 1 to 3 { - Js.log(x) -} -``` - -```js -for (var x = 1; x <= 3; ++x) { - console.log(x); -} -``` - - - -You can make the `for` loop count in the opposite direction by using `downto`. - - - -```res -for i in startValueInclusive downto endValueInclusive { - Js.log(i) -} -``` - -```js -for (var i = startValueInclusive; i >= endValueInclusive; --i) { - console.log(i); -} -``` - - - - - -```res example -// prints: 3 2 1, one per line -for x in 3 downto 1 { - Js.log(x) -} -``` - -```js -for (var x = 3; x >= 1; --x) { - console.log(x); -} -``` - - - -## While Loops - -While loops execute its body code block while its condition is true. - - - -```res -while testCondition { - // body here -} -``` - -```js -while (testCondition) { - // body here -} -``` - - - -### Tips & Tricks - -There's no loop-breaking `break` keyword (nor early `return` from functions, for that matter) in ReScript. However, we can break out of a while loop easily through using a [mutable binding](mutation.md). - - - -```res example -let break = ref(false) - -while !break.contents { - if Js.Math.random() > 0.3 { - break := true - } else { - Js.log("Still running") - } -} -``` - -```js -var $$break = { - contents: false, -}; - -while (!$$break.contents) { - if (Math.random() > 0.3) { - $$break.contents = true; - } else { - console.log("Still running"); - } -} -``` - - diff --git a/pages/docs/manual/v9.0.0/converting-from-js.mdx b/pages/docs/manual/v9.0.0/converting-from-js.mdx deleted file mode 100644 index e4c01b6ef..000000000 --- a/pages/docs/manual/v9.0.0/converting-from-js.mdx +++ /dev/null @@ -1,315 +0,0 @@ ---- -title: "Converting from JS" -description: "How to convert to ReScript with an existing JS codebase" -canonical: "/docs/manual/latest/converting-from-js" ---- - -# Converting from JS - -ReScript offers a unique project conversion methodology which: - -- Ensures minimal disruption to your teammates (very important!). -- Remove the typical friction of verifying conversion's correctness and performance guarantees. -- Doesn't force you to search for pre-made binding libraries made by others. **ReScript doesn't need the equivalent of TypeScript's `DefinitelyTyped`**. - -Enjoy! - -## Step 1: Install ReScript - -Run `npm install --save-dev bs-platform` on your project, then imitate our [New Project](installation#new-project) workflow by adding a `bsconfig.json` at the root. Then start `bsb -w`. - -## Step 2: Copy Paste the Entire JS File - -Let's work on converting a file called `src/main.js`. - -```js -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -``` - -First, copy the entire file content over to a new file called `src/Main.res` by using our [`%%raw` JS embedding trick](embed-raw-javascript): - - - -```res example -%%raw(` -const school = require('school'); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -`) -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -const school = require("school"); - -const defaultId = 10; - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} - -/* Not a pure module */ -``` - - - -Add this file to `bsconfig.json`: - -```json - "sources": { - "dir" : "src", - "subdirs" : true - }, -``` - -Open an editor tab for `src/Main.bs.js`. Do a command-line `diff -u src/main.js src/Main.bs.js`. Aside from whitespaces, you should see only minimal, trivial differences. You're already a third of the way done! - -**Always make sure** that at each step, you keep the ReScript output `.bs.js` file open to compare against the existing JavaScript file. Our compilation output is very close to your hand-written JavaScript; you can simply eye the difference to catch conversion bugs! - -## Step 3: Extract Parts into Idiomatic ReScript - -Let's turn the `defaultId` variable into a ReScript let-binding: - - - -```res example -let defaultId = 10 - -%%raw(` -const school = require('school'); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return school.getStudentById(defaultId); - } -} -`) -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -const school = require('school'); - -function queryResult(usePayload, payload) { - if usePayload { - return payload.student - } else { - return school.getStudentById(defaultId) - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -/* Not a pure module */ -``` - - - -Check the output. Diff it. Code still works. Moving on! Extract the function: - - - -```res -%%raw(` -const school = require('school'); -`) - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload.student - } else { - school.getStudentById(defaultId) - } -} -``` - -```js - -``` - - - -Format the code: `./node_modules/.bin/bsc -format src/Main.res`. - -We have a type error: "The record field student can't be found". That's fine! **Always ensure your code is syntactically valid first**. Fixing type errors comes later. - -## Step 4: Add `external`s, Fix Types - -The previous type error is caused by `payload`'s record declaration (which supposedly contains the field `student`) not being found. Since we're trying to convert as quickly as possible, let's use our [object](object) feature to avoid needing type declaration ceremonies: - - - -```res -%%raw(` -const school = require('school'); -`) - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload["student"] - } else { - school["getStudentById"](defaultId) - } -} -``` - -```js - -``` - - - -Now this triggers the next type error, that `school` isn't found. Let's use [`external`](external) to bind to that module: - - - -```res example -@bs.module external school: 'whatever = "school" - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload["student"] - } else { - school["getStudentById"](defaultId) - } -} -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We hurrily typed `school` as a polymorphic `'whatever` and let its type be inferred by its usage below. The inference is technically correct, but within the context of bringing it a value from JavaScript, slightly dangerous. This is just the interop trick we've shown in the [`external`](external) page. - -Anyway, the file passes the type checker again. Check the `.bs.js` output, diff with the original `.js`; we've now converted a file over to ReScript! - -Now, you can delete the original, hand-written `main.js` file, and grep the files importing `main.js` and change them to importing `Main.bs.js`. - -## (Optional) Step 5: Cleanup - -If you prefer more advanced, rigidly typed `payload` and `school`, feel free to do so: - - - -```res example -type school -type student -type payload = { - student: student -} - -@bs.module external school: school = "school" -@bs.send external getStudentById: (school, int) => student = "getStudentById" - -let defaultId = 10 - -let queryResult = (usePayload, payload) => { - if usePayload { - payload.student - } else { - school->getStudentById(defaultId) - } -} -``` - -```js -// Generated by ReScript, PLEASE EDIT WITH CARE -"use strict"; - -var School = require("school"); - -function queryResult(usePayload, payload) { - if (usePayload) { - return payload.student; - } else { - return School.getStudentById(10); - } -} - -var defaultId = 10; - -exports.defaultId = defaultId; -exports.queryResult = queryResult; -/* school Not a pure module */ -``` - - - -We've: - -- introduced an opaque types for `school` and `student` to prevent misusages their values -- typed the payload as a record with only the `student` field -- typed `getStudentById` as the sole method of `student` - -Check that the `.bs.js` output didn't change. How rigidly to type your JavaScript code is up to you; we recommend not typing them too elaborately; it's sometime an endless chase, and produces diminishing returns, especially considering that the elaborate-ness might turn off your potential teammates. - -## Tips & Tricks - -In the same vein of idea, **resist the urge to write your own wrapper functions for the JS code you're converting**. Use [`external`s](external), which are guaranteed to be erased in the output. And avoid trying to take the occasion to convert JS data structures into ReScript-specific data structures like variant or list. **This isn't the time for that**. - -The moment you produce extra conversion code in the output, your skeptical teammate's mental model might switch from "I recognize this output" to "this conversion might be introducing more problems than it solves. Why are we testing ReScript again?". Then you've lost. - -## Conclusion - -- Paste the JS code into a new ReScript file as embedded raw JS code. -- Compile and keep the output file open. Check and diff against original JS file. Free regression tests. -- Always make sure your file is syntactically valid. Don't worry about fixing types before that. -- (Ab)use [object](object.md) accesses to quickly convert things over. -- Optionally clean up the types for robustness. -- Don't go overboard and turn off your boss and fellow teammates. -- Proudly display that you've conserved the semantics and performance characteristics during the conversion by showing your teammates the eerily familiar output. -- Get promoted for introducing a new technology the safer, mature way. diff --git a/pages/docs/manual/v9.0.0/editor-plugins.mdx b/pages/docs/manual/v9.0.0/editor-plugins.mdx deleted file mode 100644 index e564b81e7..000000000 --- a/pages/docs/manual/v9.0.0/editor-plugins.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: "Editor Plugins" -description: "List of ReScript editor plugins" -canonical: "/docs/manual/latest/editor-plugins" ---- - -# Editor Plugins - -- [VSCode](https://marketplace.visualstudio.com/items?itemName=chenglou92.rescript-vscode) -- [Sublime Text](https://github.com/reasonml-editor/sublime-reason) -- [Vim/Neovim](https://github.com/rescript-lang/vim-rescript) -- - -## Community Supported - -We don't officially support these; use them at your own risk! - -- [Atom](https://atom.io/packages/ide-rescript) -- [IDEA](https://github.com/reasonml-editor/reasonml-idea-plugin) -- [Emacs](https://github.com/reasonml-editor/reason-mode) (only legacy `v8.0.0` Reason/OCaml syntax support) diff --git a/pages/docs/manual/v9.0.0/embed-raw-javascript.mdx b/pages/docs/manual/v9.0.0/embed-raw-javascript.mdx deleted file mode 100644 index f89d61f2f..000000000 --- a/pages/docs/manual/v9.0.0/embed-raw-javascript.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: "Embed Raw JavaScript" -description: "Utility syntax to for raw JS usage in ReScript" -canonical: "/docs/manual/latest/embed-raw-javascript" ---- - -# Embed Raw JavaScript - -## Paste Raw JS Code - -First thing first. If you're ever stuck learning ReScript, remember that you can always just paste raw JavaScript code into our source file: - - - -```res example -%%raw(` -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m) -} -`) -``` - -```js -// look ma, regular JavaScript! -var message = "hello"; -function greet(m) { - console.log(m); -} -``` - - - -The `%%raw` special ReScript call takes your code string and pastes it as-is into the output. **You've now technically written your first ReScript file!** - -(The back tick syntax is a multiline string, similar to JavaScript's. Except for us, no escaping is needed inside the string. More on string in a later section.) - -While `%%raw` lets you embed top-level raw JS code, `%raw` lets you embed expression-level JS code: - - - -```res example -let add = %raw(` - function(a, b) { - console.log("hello from raw JavaScript!"); - return a + b - } -`) - -Js.log(add(1, 2)) -``` - -```js -var add = function (a, b) { - console.log("hello from raw JavaScript!"); - return a + b; -}; - -console.log(add(1, 2)); -``` - - - -The above code: - -- declared a ReScript variable `add`, -- with the raw JavaScript value of a function declaration, -- then called that function in ReScript. - -If your boss is ever worried that your teammates can't adopt ReScript, just let them keep writing JavaScript inside ReScript files =). - -## Debugger - -You can also drop a `%debugger` expression in a body: - - - -```res example -let f = (x, y) => { - %debugger - x + y -} -``` - -```js -function f(x, y) { - debugger; - return (x + y) | 0; -} -``` - - - -Output: - -```js -function f(x, y) { - debugger; // JavaScript developer tools will set an breakpoint and stop here - x + y; -} -``` - -## Tips & Tricks - -Embedding raw JS snippets isn't the best way to experience ReScript, though it's also highly useful if you're just starting out. As a matter of fact, the first few ReScript projects were converted through: - -- pasting raw JS snippets inside a file -- examining the JS output (identical to the old hand-written JS) -- gradually extract a few values and functions and making sure the output still looks OK - -At the end, we get a fully safe, converted ReScript file whose JS output is clean enough that we can confidently assert that no new bug has been introduced during the conversion process. - -We have a small guide on this iteration [here](converting-from-js.md). Feel free to peruse it later. diff --git a/pages/docs/manual/v9.0.0/exception.mdx b/pages/docs/manual/v9.0.0/exception.mdx deleted file mode 100644 index b25d3740d..000000000 --- a/pages/docs/manual/v9.0.0/exception.mdx +++ /dev/null @@ -1,280 +0,0 @@ ---- -title: "Exception" -description: "Exceptions and exception handling in ReScript" -canonical: "/docs/manual/latest/exception" ---- - -# Exception - -Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!). - -## Usage - - - -```res -let getItem = (items) => - if callSomeFunctionThatThrows() { - // return the found item here - 1 - } else { - raise(Not_found) - } - -let result = - try { - getItem([1, 2, 3]) - } catch { - | Not_found => 0 // Default value if getItem throws - } -``` - -```js -function getItem(items) { - if (callSomeFunctionThatThrows()) { - return 1; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error(), - }; -} - -var result; - -try { - result = getItem([1, 2, 3]); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - result = 0; - } else { - throw exn; - } -} -``` - - - -Note that the above is just for demonstration purposes; in reality, you'd return an `option` directly from `getItem` and avoid the `try` altogether. - -You can directly match on exceptions _while_ getting another return value from a function: - - - -```res -switch List.find(i => i === theItem, myItems) { -| item => Js.log(item) -| exception Not_found => Js.log("No such item found!") -} -``` - -```js -var exit = 0; - -var item; - -try { - item = List.find(function (i) { - return i === theItem; - }, myItems); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -You can also make your own exceptions like you'd make a variant (exceptions need to be capitalized too). - - - -```res example -exception InputClosed(string) -// later on -raise(InputClosed("The stream has closed!")) -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var InputClosed = Caml_exceptions.create("MyFile.InputClosed"); - -throw { - RE_EXN_ID: InputClosed, - _1: "The stream has closed!", - Error: new Error(), -}; -``` - - - -## Catching JS Exceptions - -To distinguish between JavaScript exceptions and ReScript exceptions, ReScript namespaces JS exceptions under the `Js.Exn.Error(payload)` variant. To catch an exception thrown from the JS side: - - - -```res -try { - someJSFunctionThatThrows() -} catch { -| Js.Exn.Error(obj) => - switch Js.Exn.message(obj) { - | Some(m) => Js.log("Caught a JS exception! Message: " ++ m) - | None => () - } -} -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); -var Caml_js_exceptions = require("./stdlib/caml_js_exceptions.js"); - -try { - someJSFunctionThatThrows(); -} catch (raw_obj) { - var obj = Caml_js_exceptions.internalToOCamlException(raw_obj); - if (obj.RE_EXN_ID === Js_exn.$$Error) { - var m = obj._1.message; - if (m !== undefined) { - console.log("Caught a JS exception! Message: " + m); - } - } else { - throw obj; - } -} -``` - - - -The `obj` here is of type `Js.Exn.t`, intentionally opaque to disallow illegal operations. To operate on `obj`, do like the code above by using the standard library's [`Js.Exn`](api/js/exn) module's helpers. - -## Raise a JS Exception - -`raise(MyException)` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Js.Exn.raiseError`: - - - -```res example -let myTest = () => { - Js.Exn.raiseError("Hello!") -} -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); - -function myTest() { - return Js_exn.raiseError("Hello!"); -} -``` - - - -Then you can catch it from the JS side: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.message); // "Hello!" -} -``` - -## Catch ReScript Exceptions from JS - -The previous section is less useful than you think; to let your JS code work with your exception-throwing ReScript code, the latter doesn't actually need to throw a JS exception. ReScript exceptions can be used by JS code! - - - -```res example -exception BadArgument({myMessage: string}) - -let myTest = () => { - raise(BadArgument({myMessage: "Oops!"})) -} -``` - -```js -var Caml_exceptions = require("./stdlib/caml_exceptions.js"); - -var BadArgument = Caml_exceptions.create("Playground.BadArgument"); - -function myTest() { - throw { - RE_EXN_ID: BadArgument, - myMessage: "Oops!", - Error: new Error(), - }; -} -``` - - - -Then, in your JS: - -```js -// after importing `myTest`... -try { - myTest(); -} catch (e) { - console.log(e.myMessage); // "Oops!" - console.log(e.Error.stack); // the stack trace -} -``` - -> Note: `RE_EXN_ID` is an internal field for bookkeeping purposes. Don't use it on the JS side. Use the other fields. - -The above `BadArgument` exception takes an inline record type. We special-case compile the exception as `{RE_EXN_ID, myMessage, Error}` for good ergonomics. If the exception instead took ordinary positional arguments, l like the standard library's `Invalid_argument("Oops!")`, which takes a single argument, the argument is compiled to JS as the field `_1` instead. A second positional argument would compile to `_2`, etc. - -## Tips & Tricks - -When you have ordinary variants, you often don't **need** exceptions. For example, instead of throwing when `item` can't be found in a collection, try to return an `option` (`None` in this case) instead. - -### Catch Both ReScript and JS Exceptions in the Same `catch` Clause - - - -```res -try { - someOtherJSFunctionThatThrows() -} catch { -| Not_found => ... // catch a ReScript exception -| Invalid_argument(_) => ... // catch a second ReScript exception -| Js.Exn.Error(obj) => ... // catch the JS exception -} -``` - -```js -var Js_exn = require("./stdlib/js_exn.js"); -var Caml_js_exceptions = require("./stdlib/caml_js_exceptions.js"); - -try { - someOtherJSFunctionThatThrows(); -} catch (raw_obj) { - var obj = Caml_js_exceptions.internalToOCamlException(raw_obj); - if ( - obj.RE_EXN_ID !== "Not_found" && - obj.RE_EXN_ID !== "Invalid_argument" && - obj.RE_EXN_ID !== Js_exn.$$Error - ) { - throw obj; - } -} -``` - - - -This technically works, but hopefully you don't ever have to work with such code... diff --git a/pages/docs/manual/v9.0.0/external.mdx b/pages/docs/manual/v9.0.0/external.mdx deleted file mode 100644 index 2a63fac3c..000000000 --- a/pages/docs/manual/v9.0.0/external.mdx +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: "External (Bind to Any JS Library)" -description: "The external keyword" -canonical: "/docs/manual/latest/external" ---- - -# External (Bind to Any JS Library) - -`external` is the primary ReScript feature for bringing in and using JavaScript values. - -`external` is like a let binding, but: - -- The right side of `=` isn't a value; it's the name of the JS value you're referring to. -- The type for the binding is mandatory, since we need to know what the type of that JS value is. -- Can only exist at the top level of a file or module. - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -``` - -```js -// Empty output -``` - - - -There are several kinds of `external`s, differentiated and/or augmented through the `@bs` notation they carry. This page deals with the general, shared mechanism behind most `external`s. The different `@bs` annotations are documented in their respective pages later. A few notable ones: - -- `@val`, `@scope`: [bind to global JS values](bind-to-global-js-values). -- `@module`: [bind to JS imported/exported values](import-from-export-to-js). -- `@send`: [bind to JS methods](bind-to-js-function). - -## Usage - -Once declared, you can use an `external` as a normal value, just like a let binding. - -## Tips & Tricks - -`external` + ReScript objects are a wonderful combination for quick prototyping. Check the JS output tab: - - - -```res example -// The type of document is just some random type 'a -// that we won't bother to specify -@val external document: 'a = "document" - -// call a method -document["addEventListener"]("mouseup", _event => { - Js.log("clicked!") -}) - -// get a property -let loc = document["location"] - -// set a property -document["location"]["href"] = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); - -var loc = document.location; - -document.location.href = "rescript-lang.org"; -``` - - - -We've specified `document`'s type as `'a`, aka a placeholder type that's polymorphic. Any value can be passed there, so you're not getting much type safety (except the inferences at various call sites). However, this is excellent for quickly getting started using a JavaScript library in ReScript **without needing the equivalent of a repository of typed bindings** like TypeScript's `DefinitelyTyped` repo. - -However, if you want to more rigidly bind to the JavaScript library you want, keep reading the next few interop pages. - -## Performance & Output Readability - -`external`s declarations are inlined into their callers during compilation, **and completely disappear from the JS output**. This means any time you use one, you can be sure that you're not incurring extra JavaScript \<-> ReScript conversion cost. - -Additionally, no extra ReScript-specific runtime is better for output readability. - -> **Note:** do also use `external`s and the `@blabla` attributes in the interface files. Otherwise the inlining won't happen. - -## Design Decisions - -ReScript takes interoperating with existing code very seriously. Our type system has very strong guarantees. However, such strong feature also means that, without a great interop system, it'd be very hard to gradually convert a codebase over to ReScript. Fortunately, our interop are comprehensive and cooperate very well with most existing JavaScript code. - -The combination of a sound type system + great interop means that we get the benefits of a traditional gradual type system regarding incremental codebase coverage & conversion, without the downside of such gradual type system: complex features to support existing patterns, slow analysis, diminishing return in terms of type coverage, etc. diff --git a/pages/docs/manual/v9.0.0/faq.mdx b/pages/docs/manual/v9.0.0/faq.mdx deleted file mode 100644 index 7913c5de7..000000000 --- a/pages/docs/manual/v9.0.0/faq.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: "FAQ" -description: "Frequently asked questions about ReScript and its ecosystem" -canonical: "/docs/manual/latest/faq" ---- - -# Frequently Asked Questions - -**What's the goal of this project?** - -We aim to provide the best typed language experience for the JavaScript platform. - -**What’s the relationship with BuckleScript?** - -BuckleScript is ReScript's old branding, with a sharper focus on proper JS support and familiarity which we previously couldn't achieve to the degree we wanted, due to us needing to cater to various different crowds. - -**What’s ReScript's relationship with OCaml?** - -We reuse and adjust the excellent type system and lots of other high quality components from OCaml for JS experience. -Additionally, ReScript provides its own syntax, build system, IDE, backend, JS interop, extra language features, etc. - -The ReScript toolchain is developed using OCaml, however, the version of ReScript is decoupled against the version of OCaml, -ReScript compiler should build against any reasonable modern version of OCaml compiler. - -For the majority of ReScript users, they don't need to learn OCaml or use OCaml toolchain to be productive in ReScript. - -**What’s the relationship with Reason?** - -See [here](/blog/bucklescript-is-rebranding). Reason is a syntax layer for OCaml that BuckleScript also adopted. The current ReScript compiler also supports the old Reason syntax v3.6 for backward compatibility. We will support it for a long time to make sure existing users do not get breaking changes. - -**I come from Reason/OCaml. Will ReScript keep supporting X?** - -Please see our [blog post](/blog/a-note-on-bucklescripts-future-commitments) on this matter. - -**Where can I see the docs in old Reason/OCaml syntax?** - -Switch the doc version to `v8.0.0` in the sidebar on the left! - -**Will ReScript support native compilation eventually?** - -Our focus is a solid JS story right now. In the future, if there’s strong demand, we might consider it. - -**What’s the current state of ReScript?** - -Currently, we're actively working on the editor support. - -**When will we get the `async/await` keywords?** - -See our answer on the [Async & Promise](promise) page's intro. - -**Why create a new syntax?** - -The existing Reason syntax is owned by a different team with a different vision. Reason aims to be 100% compatible with OCaml syntax and to support all versions of OCaml. In the last few years, we've drawn the conclusion that it’s very hard to deliver such goal without sacrificing user experience. The other reason is that we feel it’s better to have the same vision as a team so that we can make more coherent decisions. - -**Who is behind the project?** - -The ReScript team (Hongbo, Cheng, Cristiano, Maxim, Patrick, Ricky). - -**We have a new forum; will we also have our own Discord?** - -Not now. We've found that too much important information get casually passed in Discord then lost within the noise. We prefer folks to communicate on the [forum](https://forum.rescript-lang.org). This is nicer to the less active members. - -The team doesn't use the old Discord anymore. We encourage you to move your questions to the forum instead. diff --git a/pages/docs/manual/v9.0.0/function.mdx b/pages/docs/manual/v9.0.0/function.mdx deleted file mode 100644 index 9618fd6a7..000000000 --- a/pages/docs/manual/v9.0.0/function.mdx +++ /dev/null @@ -1,569 +0,0 @@ ---- -title: "Function" -description: "Function syntax in ReScript" -canonical: "/docs/manual/latest/function" ---- - -# Function - -_Cheat sheet for the full function syntax at the end_. - -ReScript functions are declared with an arrow and return an expression, just like JS functions. They compile to clean JS functions too. - - - -```res prelude -let greet = (name) => "Hello " ++ name -``` - -```js -function greet(name) { - return "Hello " + name; -} -``` - - - -This declares a function and assigns to it the name `greet`, which you can call like so: - - - -```res example -greet("world!") // "Hello world!" -``` - -```js -greet("world!"); -``` - - - -Multi-arguments functions have arguments separated by comma: - - - -```res example -let add = (x, y, z) => x + y + z -add(1, 2, 3) // 6 -``` - -```js -function add(x, y, z) { - return (((x + y) | 0) + z) | 0; -} -``` - - - -For longer functions, you'd surround the body with a block: - - - -```res example -let greetMore = (name) => { - let part1 = "Hello" - part1 ++ " " ++ name -} -``` - -```js -function greetMore(name) { - return "Hello " + name; -} -``` - - - -If your function has no argument, just write `let greetMore = () => {...}`. - -## Labeled Arguments - -Multi-arguments functions, especially those whose arguments are of the same type, can be confusing to call. - - - -```res -let addCoordinates = (x, y) => { - // use x and y here -} -// ... -addCoordinates(5, 6) // which is x, which is y? -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can attach labels to an argument by prefixing the name with the `~` symbol: - - - -```res -let addCoordinates = (~x, ~y) => { - // use x and y here -} -// ... -addCoordinates(~x=5, ~y=6) -``` - -```js -function addCoordinates(x, y) { - // use x and y here -} - -addCoordinates(5, 6); -``` - - - -You can provide the arguments in **any order**: - - - -```res -addCoordinates(~y=6, ~x=5) -``` - -```js -addCoordinates(5, 6); -``` - - - -The `~x` part in the declaration means the function accepts an argument labeled `x` and can refer to it in the function body by the same name. You can also refer to the arguments inside the function body by a different name for conciseness: - - - -```res -let drawCircle = (~radius as r, ~color as c) => { - setColor(c) - startAt(r, r) - // ... -} - -drawCircle(~radius=10, ~color="red") -``` - -```js -function drawCircle(r, c) { - setColor(c); - return startAt(r, r); -} - -drawCircle(10, "red"); -``` - - - -As a matter of fact, `(~radius)` is just a shorthand for `(~radius as radius)`. - -Here's the syntax for typing the arguments: - - - -```res -let drawCircle = (~radius as r: int, ~color as c: string) => { - // code here -} -``` - -```js -function drawCircle(r, c) { - // code here -} -``` - - - -## Optional Labeled Arguments - -Labeled function arguments can be made optional during declaration. You can then omit them when calling the function. - - - -```res -// radius can be omitted -let drawCircle = (~color, ~radius=?, ()) => { - setColor(color) - switch radius { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - } -} -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -function drawCircle(color, radius, param) { - setColor(color); - if (radius === undefined) { - return startAt(1, 1); - } - var r_ = Caml_option.valFromOption(radius); - return startAt(r_, r_); -} -``` - - - -When given in this syntax, `radius` is **wrapped** in the standard library's `option` type, defaulting to `None`. If provided, it'll be wrapped with a `Some`. So `radius`'s type value is `None | Some(int)` here. - -More on `option` type [here](null-undefined-option.md). - -**Note** for the sake of the type system, whenever you have an optional argument, you need to ensure that there's also at least one positional argument (aka non-labeled, non-optional argument) after it. If there's none, provide a dummy `unit` (aka `()`) argument. - -### Signatures and Type Annotations - -Functions with optional labeled arguments can be confusing when it comes to signature and type annotations. Indeed, the type of an optional labeled argument looks different depending on whether you're calling the function, or working inside the function body. Outside the function, a raw value is either passed in (`int`, for example), or left off entirely. Inside the function, the parameter is always there, but its value is an option (`option`). This means that the type signature is different, depending on whether you're writing out the function type, or the parameter type annotation. The first being a raw value, and the second being an option. - -If we get back to our previous example and both add a signature and type annotations to its argument, we get this: - - - -```res -let drawCircle: (~color: color, ~radius: int=?, unit) => unit = - (~color: color, ~radius: option=?, ()) => { - setColor(color) - switch radius { - | None => startAt(1, 1) - | Some(r_) => startAt(r_, r_) - } - } -``` - -```js -function drawCircle(color, radius, param) { - setColor(color); - if (radius !== undefined) { - return startAt(radius, radius); - } else { - return startAt(1, 1); - } -} -``` - - - -The first line is the function's signature, we would define it like that in an interface file (see [Signatures](module.md#signatures)). The function's signature describes the types that the **outside world** interacts with, hence the type `int` for `radius` because it indeed expects an `int` when called. - -In the second line, we annotate the arguments to help us remember the types of the arguments when we use them **inside** the function's body, here indeed `radius` will be an `option` inside the function. - -So if you happen to struggle when writing the signature of a function with optional labeled arguments, try to remember this! - -### Explicitly Passed Optional - -Sometimes, you might want to forward a value to a function without knowing whether the value is `None` or `Some(a)`. Naively, you'd do: - - - -```res -let result = - switch payloadRadius { - | None => drawCircle(~color, ()) - | Some(r) => drawCircle(~color, ~radius=r, ()) - } -``` - -```js -var r = payloadRadius; - -var result = - r !== undefined - ? drawCircle(color, Caml_option.valFromOption(r), undefined) - : drawCircle(color, undefined); -``` - - - -This quickly gets tedious. We provide a shortcut: - - - -```res -let result = drawCircle(~color, ~radius=?payloadRadius, ()) -``` - -```js -var result = drawCircle(1, undefined, undefined); -``` - - - -This means "I understand `radius` is optional, and that when I pass it a value it needs to be an `int`, but I don't know whether the value I'm passing is `None` or `Some(val)`, so I'll pass you the whole `option` wrapper". - -### Optional with Default Value - -Optional labeled arguments can also be provided a default value. In this case, they aren't wrapped in an `option` type. - - - -```res -let drawCircle = (~radius=1, ~color, ()) => { - setColor(color) - startAt(radius, radius) -} -``` - -```js -function drawCircle(radiusOpt, color, param) { - var radius = radiusOpt !== undefined ? radiusOpt : 1; - setColor(color); - return startAt(radius, radius); -} -``` - - - -## Recursive Functions - -ReScript chooses the sane default of preventing a function to be called recursively within itself. To make a function recursive, add the `rec` keyword after the `let`: - - - -```res example -let rec neverTerminate = () => neverTerminate() -``` - -```js -function neverTerminate(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -A simple recursive function may look like this: - - - -```res example -// Recursively check every item on the list until one equals the `item` -// argument. If a match is found, return `true`, otherwise return `false` -let rec listHas = (list, item) => - switch list { - | list{} => false - | list{a, ...rest} => a === item || listHas(rest, item) - } -``` - -```js -function listHas(_list, item) { - while (true) { - var list = _list; - if (!list) { - return false; - } - if (list.hd === item) { - return true; - } - _list = list.tl; - continue; - } -} -``` - - - -Recursively calling a function is bad for performance and the call stack. However, ReScript intelligently compiles [tail recursion](https://stackoverflow.com/questions/33923/what-is-tail-recursion) into a fast JavaScript loop. Try checking the JS output of the above code! - -### Mutually Recursive Functions - -Mutually recursive functions start like a single recursive function using the -`rec` keyword, and then are chained together with `and`: - - - -```res example -let rec callSecond = () => callFirst() -and callFirst = () => callSecond() -``` - -```js -function callSecond(_param) { - while (true) { - _param = undefined; - continue; - } -} - -function callFirst(_param) { - while (true) { - _param = undefined; - continue; - } -} -``` - - - -## Uncurried Function - -ReScript's functions are curried by default, which is one of the few performance penalties we pay in the compiled JS output. The compiler does a best-effort job at removing those currying whenever possible. However, in certain edge cases, you might want guaranteed uncurrying. In those cases, put a dot in the function's parameter list: - - - -```res example -let add = (. x, y) => x + y - -add(. 1, 2) -``` - -```js -function add(x, y) { - return (x + y) | 0; -} - -add(1, 2); -``` - - - -If you need to call a curried function with a single unit `()` argument, you can use the `ignore()` function: - - - -```res example -let echo = (. a) => a - -echo(. ignore()) -``` - -```js -function echo(a) { - return a; -} - -echo(undefined); -``` - - - -If you write down the uncurried function's type, you'll add a dot there as well. - -**Note**: both the declaration site and the call site need to have the uncurry annotation. That's part of the guarantee/requirement. - -**This feature seems trivial**, but is actually one of our most important features, as a primarily functional language. We encourage you to use it if you'd like to remove any mention of `Curry` runtime in the JS output. - -## Tips & Tricks - -Cheat sheet for the function syntaxes: - -### Declaration - -```res -// anonymous function -(x, y) => 1 -// bind to a name -let add = (x, y) => 1 - -// labeled -let add = (~first as x, ~second as y) => x + y -// with punning sugar -let add = (~first, ~second) => first + second - -// labeled with default value -let add = (~first as x=1, ~second as y=2) => x + y -// with punning -let add = (~first=1, ~second=2) => first + second - -// optional -let add = (~first as x=?, ~second as y=?) => switch x {...} -// with punning -let add = (~first=?, ~second=?) => switch first {...} -``` - -#### With Type Annotation - -```res -// anonymous function -(x: int, y: int): int => 1 -// bind to a name -let add = (x: int, y: int): int => 1 - -// labeled -let add = (~first as x: int, ~second as y: int) : int => x + y -// with punning sugar -let add = (~first: int, ~second: int) : int => first + second - -// labeled with default value -let add = (~first as x: int=1, ~second as y: int=2) : int => x + y -// with punning sugar -let add = (~first: int=1, ~second: int=2) : int => first + second - -// optional -let add = (~first as x: option=?, ~second as y: option=?) : int => switch x {...} -// with punning sugar -// note that the caller would pass an `int`, not `option` -// Inside the function, `first` and `second` are `option`. -let add = (~first: option=?, ~second: option=?) : int => switch first {...} -``` - -### Application - -```res -add(x, y) - -// labeled -add(~first=1, ~second=2) -// with punning sugar -add(~first, ~second) - -// application with default value. Same as normal application -add(~first=1, ~second=2) - -// explicit optional application -add(~first=?Some(1), ~second=?Some(2)) -// with punning -add(~first?, ~second?) -``` - -#### With Type Annotation - -```res -// labeled -add(~first=1: int, ~second=2: int) -// with punning sugar -add(~first: int, ~second: int) - -// application with default value. Same as normal application -add(~first=1: int, ~second=2: int) - -// explicit optional application -add(~first=?Some(1): option, ~second=?Some(2): option) -// no punning sugar when you want to type annotate -``` - -### Standalone Type Signature - -```res -// first arg type, second arg type, return type -type add = (int, int) => int - -// labeled -type add = (~first: int, ~second: int) => int - -// labeled -type add = (~first: int=?, ~second: int=?, unit) => int -``` - -#### In Interface Files - -To annotate a function from the implementation file (`.res`) in your interface file (`.resi`): - -```res sig -let add: (int, int) => int -``` - -The type annotation part is the same as the previous section on With Type Annotation. - -**Don't** confuse `let add: myType` with `type add = myType`. When used in `.resi` interface files, the former exports the binding `add` while annotating it as type `myType`. The latter exports the type `add`, whose value is the type `myType`. diff --git a/pages/docs/manual/v9.0.0/generate-converters-accessors.mdx b/pages/docs/manual/v9.0.0/generate-converters-accessors.mdx deleted file mode 100644 index 4502232e9..000000000 --- a/pages/docs/manual/v9.0.0/generate-converters-accessors.mdx +++ /dev/null @@ -1,612 +0,0 @@ ---- -title: "Generate Converters & Helpers" -description: "All about the @deriving decorator, and how to generate code from types" -canonical: "/docs/manual/latest/generate-converters-accessors" ---- - -# Generate Converters & Helpers - - - -When using ReScript, you will sometimes come into situations where you want to - -- Automatically generate functions that convert between ReScript's internal and JS runtime values (e.g. variants). -- Convert a record type into an abstract type with generated creation, accessor and method functions. -- Generate some other helper functions, such as functions from record attribute names. - -You can use the `@deriving` decorator for different code generation scenarios. All different options and configurations will be discussed on this page. - -**Note:** Please be aware that extensive use of code generation might make it harder to understand your programs (since the code being generated is not visible in the source code, and you just need to know what kind of functions / values a decorator generates). - -## Generate Functions & Plain Values for Variants - -Use `@deriving(accessors)` on a variant type to create accessor functions for its constructors. - - - -```res -@deriving(accessors) -type action = - | Click - | Submit(string) - | Cancel; -``` - -```js -function submit(param_0) { - return /* Submit */ [param_0]; -} - -var click = /* Click */ 0; - -var cancel = /* Cancel */ 1; - -exports.click = click; -exports.submit = submit; -exports.cancel = cancel; -``` - - - -Variants constructors with payloads generate functions, payload-less constructors generate plain integers (the internal representation of variants). - -**Note**: - -- The generated accessors are lower-cased. -- You can now use these helpers on the JavaScript side! But don't rely on their actual values please. - -### Usage - -```res -let s = submit("hello"); /* gives Submit("hello") */ -``` - -This is useful: - -- When you're passing the accessor function as a higher-order function (which plain variant constructors aren't). -- When you'd like the JS side to use these values & functions opaquely and pass you back a variant constructor (since JS has no such thing). - -Please note that in case you just want to _pipe a payload into a constructor_, you don't need to generate functions for that. Use the `->` syntax instead, e.g. `"test"->Submit`. - -## Generate Field Accessors for Records - -Use `@deriving(accessors)` on a record type to create accessors for its record field names. - - - -```res -@deriving(accessors) -type pet = {name: string} - -let pets = [{name: "bob"}, {name: "bob2"}] - -pets - ->Belt.Array.map(name) - ->Js.Array2.joinWith("&") - ->Js.log -``` - -```js -function name(param) { - return param.name; -} - -var pets = [ - { - name: "bob", - }, - { - name: "bob2", - }, -]; - -console.log(Belt_Array.map(pets, name).join("&")); -``` - - - -## Generate Converters for JS Object and Record - -> **Note:** In ReScript >= v7 [records are already compiled to JS -> objects](bind-to-js-object#bind-to-record-like-js-objects). `@deriving(jsConverter)` is therefore -> obsolete and will generate a no-op function for compatibility instead. - -Use `@deriving(jsConverter)` on a record type to create convertion functions between records / JS object runtime values. - -```res -@deriving(jsConverter) -type coordinates = { - x: int, - y: int -}; -``` - -Generates 2 functions of the following types: - -```res -let coordinatesToJs: coordinates => {"x": int, "y": int}; - -let coordinatesFromJs: {.. "x": int, "y": int} => coordinates; -``` - -**Note**: - -- `coordinatesFromJs` uses an open object type that accepts more fields, just to be more permissive. -- The converters are shallow. They don't recursively drill into the fields and convert them. This preserves the speed and simplicity of output while satisfying 80% of use-cases. - -### Usage - -This exports a `jsCoordinates` JS object (not a record!) for JS files to use: - -```res -let jsCoordinates = coordinatesToJs({x: 1, y: 2}); -``` - -This binds to a `jsCoordinates` record (not a JS object!) that exists on the JS side, presumably created by JS calling the function `coordinatesFromJs`: - -```res -@module("myGame") -external jsCoordinates : coordinates = "jsCoordinates"; -``` - -### More Safety - -The above generated functions use JS object types. You can also hide this implementation detail by making the object type **abstract** by using the `newType` option with `@deriving(jsConverter)`: - -```res -@deriving({jsConverter: newType}) -type coordinates = { - x: int, - y: int, -} -``` - -Generates 2 functions of the following types: - -```resi -let coordinatesToJs: coordinates => abs_coordinates; - -let coordinatesFromJs: abs_coordinates => coordinates; -``` - -#### Usage - -Using `newType`, you've now prevented consumers from inadvertently doing the following: - -```res -let myCoordinates = { - x: 10, - y: 20 -}; -let jsCoords = coordinatesToJs(myCoordinates); - -let x = jsCoords["x"]; /* disallowed! Don't access the object's internal details */ -``` - -Same generated output. Isn't it great that types prevent invalid accesses you'd otherwise have to encode at runtime? - -## Generate Converters for JS Integer Enums and Variants - -Use `@deriving(jsConverter)` on a variant type to create converter functions that allow back and forth conversion between JS integer enum and ReScript variant values. - -```res -@deriving(jsConverter) -type fruit = - | Apple - | Orange - | Kiwi - | Watermelon; -``` - -This option causes `jsConverter` to, again, generate functions of the following types: - -```resi -let fruitToJs: fruit => int; - -let fruitFromJs: int => option(fruit); -``` - -For `fruitToJs`, each fruit variant constructor would map into an integer, starting at 0, in the order they're declared. - -For `fruitFromJs`, the return value is an `option`, because not every int maps to a constructor. - -You can also attach a `@as(1234)` to each constructor to customize their output. - -### Usage - -```res -@deriving(jsConverter) -type fruit = - | Apple - | @as(10) Orange - | @as(100) Kiwi - | Watermelon - -let zero = fruitToJs(Apple) /* 0 */ - -switch fruitFromJs(100) { -| Some(Kiwi) => Js.log("this is Kiwi") -| _ => Js.log("received something wrong from the JS side") -} -``` - -**Note**: by using `@as` here, all subsequent number encoding changes. `Apple` is still `0`, `Orange` is `10`, `Kiwi` is `100` and `Watermelon` is **`101`**! - -### More Safety - -Similar to the JS object \<-> record deriving, you can hide the fact that the JS enum are ints by using the same `newType` option with `@deriving(jsConverter)`: - -```res -@deriving({jsConverter: newType}) -type fruit = - | Apple - | @as(100) Kiwi - | Watermelon; -``` - -This option causes `@deriving(jsConverter)` to generate functions of the following types: - -```resi -let fruitToJs: fruit => abs_fruit; - -let fruitFromJs: abs_fruit => fruit; -``` - -For `fruitFromJs`, the return value, unlike the previous non-abstract type case, doesn't contain an `option`, because there's no way a bad value can be passed into it; the only creator of `abs_fruit` values is `fruitToJs`! - -#### Usage - -```res -@deriving({jsConverter: newType}) -type fruit = - | Apple - | @as(100) Kiwi - | Watermelon - -let opaqueValue = fruitToJs(Apple) - -@module("myJSFruits") external jsKiwi: abs_fruit = "iSwearThisIsAKiwi" -let kiwi = fruitFromJs(jsKiwi) - -let error = fruitFromJs(100) /* nope, can't take a random int */ -``` - -## Generate Converters for JS String Enums and Polymorphic Variants - -> **Note**: Since ReScript v8.2, polymorphic variants are already compiled to strings, so this feature is getting deprecated at some point. It's currently still useful for aliasing JS output with `@as`. - -Similarly as with [generating int converters](#generate-converters-between-js-integer-enums-and-variants), use `@deriving(jsConverter)` on a polymorphic variant type to create converter functions for JS string and ReScript poly variant values. - -### Usage - -```res -@deriving(jsConverter) -type fruit = [ - | #Apple - | @as("miniCoconut") #Kiwi - | #Watermelon -] - -let appleString = fruitToJs(#Apple); /* "Apple" */ -let kiwiString = fruitToJs(#Kiwi); /* "miniCoconut" */ -``` - -As in similar use-cases before, you can also use `@deriving({jsConverter: newType})` to generate abstract types instead. - -## Convert Record Type to Abstract Record - -> **Note**: For ReScript >= v7, we recommend using [plain records to compile to JS objects](bind-to-js-object#bind-to-record-like-js-objects). -> This feature might still be useful for certain scenarios, but the ergonomics might be worse - -Use `@deriving(abstract)` on a record type to expand the type into a creation, and a set of getter / setter functions for fields and methods. - -Usually you'd just use ReScript records to compile to JS objects of the same shape. There is still one particular use-case left where the `@deriving(abstract)` convertion is still useful: Whenever you need compile a record with an optional field where the JS object attribute shouldn't show up in the resulting JS when undefined (e.g. `{name: "Carl", age: undefined}` vs `{name: "Carl"}`). Check the [Optional Labels](#optional-labels) section for more infos on this particular scenario. - -### Usage Example - -```res -@deriving(abstract) -type person = { - name: string, - age: int, - job: string, -}; - -@val external john : person = "john"; -``` - -**Note**: the `person` type is **not** a record! It's a record-looking type that uses the record's syntax and type-checking. The `@deriving(abstract)` decorator turns it into an "abstract type" (aka you don't know what the actual value's shape). - -### Creation - -You don't have to bind to an existing `person` object from the JS side. You can also create such `person` JS object from ReScript's side. - -Since `@deriving(abstract)` turns the above `person` record into an abstract type, you can't directly create a person record as you would usually. This doesn't work: `{name: "Joe", age: 20, job: "teacher"}`. - -Instead, you'd use the **creation function** of the same name as the record type, implicitly generated by the `@deriving(abstract)` annotation: - - - -```res -let joe = person(~name="Joe", ~age=20, ~job="teacher") -``` - -```js -var joe = { - name: "Joe", - age: 20, - job: "teacher", -}; -``` - - - -Note how in the example above there is no JS runtime overhead. - -#### Rename Fields - -Sometimes you might be binding to a JS object with field names that are invalid in ReScript. Two examples would be `{type: "foo"}` (reserved keyword in ReScript) and `{"aria-checked": true}`. Choose a valid field name then use `@as` to circumvent this: - - - -```res -@deriving(abstract) -type data = { - @as("type") type_: string, - @as("aria-label") ariaLabel: string, -}; - -let d = data(~type_="message", ~ariaLabel="hello"); -``` - -```js -var d = { - type: "message", - "aria-label": "hello", -}; -``` - - - -#### Optional Labels - -You can omit fields during the creation of the object: - - - -```res -@deriving(abstract) -type person = { - @optional name: string, - age: int, - job: string, -}; - -let joe = person(~age=20, ~job="teacher", ()); -``` - -```js -var joe = { - age: 20, - job: "teacher", -}; -``` - - - -Optional values that are not defined, will not show up as an attribute in the resulting JS object. In the example above, you will see that `name` was omitted. - -**Note** that the `@optional` tag turned the `name` field optional. Merely typing `name` as `option` wouldn't work. - -**Note**: now that your creation function contains optional fields, we mandate an unlabeled `()` at the end to indicate that [you've finished applying the function](function#optional-labeled-arguments). - -### Accessors - -Again, since `@deriving(abstract)` hides the actual record shape, you can't access a field using e.g. `joe.age`. We remediate this by generating getter and setters. - -#### Read - -One getter function is generated per `@deriving(abstract)` record type field. In the above example, you'd get 3 functions: `nameGet`, `ageGet`, `jobGet`. They take in a `person` value and return `string`, `int`, `string` respectively: - -```res -let twenty = ageGet(joe) -``` - -Alternatively, you can use the [Pipe](pipe) operator (`->`) for a nicer-looking access syntax: - -```res -let twenty = joe->ageGet -``` - -If you prefer shorter names for the getter functions, we also support a `light` setting: - -```res -@deriving({abstract: light}) -type person = { - name: string, - age: int, -} - -let joe = person(~name="Joe", ~age=20) -let joeName = name(joe) -``` - -The getter functions will now have the same names as the object fields themselves. - -#### Write - -A `@deriving(abstract)` value is immutable by default. To mutate such value, you need to first mark one of the abstract record field as `mutable`, the same way you'd mark a normal record as mutable: - -```res -@deriving(abstract) -type person = { - name: string, - mutable age: int, - job: string, -} -``` - -Then, a setter of the name `ageSet` will be generated. Use it like so: - -```res -let joe = person(~name="Joe", ~age=20, ~job="teacher"); -ageSet(joe, 21); -``` - -Alternatively, with the Pipe First syntax: - -```res -joe->ageSet(21) -``` - -### Methods - -You can attach arbitrary methods onto a type (_any_ type, as a matter of fact. Not just `@deriving(abstract)` record types). See [Object Method](bind-to-js-function#object-method) in the "Bind to JS Function" section for more infos. - -### Tips & Tricks - -You can leverage `@deriving(abstract)` for finer-grained access control. - -#### Mutability - -You can mark a field as mutable in the implementation (`.res`) file, while _hiding_ such mutability in the interface file: - -```res -/* test.res */ -@deriving(abstract) -type cord = { - @optional mutable x: int, - y: int, -}; -``` - -```resi -/* test.resi */ -@deriving(abstract) -type cord = { - @optional x: int, - y: int, -}; -``` - -Tada! Now you can mutate inside your own file as much as you want, and prevent others from doing so! - -#### Hide the Creation Function - -Mark the record as `private` to disable the creation function: - -```res -@deriving(abstract) -type cord = private { - @optional x: int, - y: int, -} -``` - -The accessors are still there, but you can no longer create such data structure. Great for binding to a JS object while preventing others from creating more such object! - -#### Use submodules to prevent naming collisions and binding shadowing - -Oftentimes you will have multiple abstract types with similar attributes. Since -ReScript will expand all abstract getter, setter and creation functions in the -same scope where the type is defined, you will eventually run into value shadowing problems. - -**For example:** - -```res -@deriving(abstract) -type person = {name: string} - -@deriving(abstract) -type cat = { - name: string, - isLazy: bool, -}; - -let person = person(~name="Alice") - -/* Error: This expression has type person but an expression was expected - of type cat */ -person->nameGet() -``` - -To get around this issue, you can use modules to group a type with its related -functions and later use them via local open statements: - -```res -module Person = { - @deriving(abstract) - type t = {name: string} -} - -module Cat = { - @deriving(abstract) - type t = { - name: string, - isLazy: bool, - } -} - -let person = Person.t(~name="Alice") -let cat = Cat.t(~name="Snowball", ~isLazy=true) - -/* We can use each nameGet function separately now */ -let shoutPersonName = { - open Person - person->nameGet->Js.String.toUpperCase -} - -/* Note how we use a local `open Cat` expression to - get access to Cat's nameGet function */ -let whisperCatName = { - open Cat - cat->nameGet->Js.String.toLowerCase -} -``` - -## Convert External into JS Object Creation Function - -Use `@obj` on an `external` binding to create a function that, when called, will evaluate to a JS object with fields corresponding to the function's parameter labels. - -This is very handy because you can make some of those labelled parameters optional and if you don't pass them in, the output object won't include the corresponding fields. Thus you can use it to dynamically create objects with the subset of fields you need at runtime. - -For example, suppose you need a JavaScript object like this: - -```js -var homeRoute = { - type: "GET", - path: "/", - action: () => console.log("Home"), - // options: ... -}; -``` - -But only the first three fields are required; the options field is optional. You can declare the binding function like so: - -```res -@obj -external route: ( - ~\"type": string, - ~path: string, - ~action: list => unit, - ~options: {..}=?, - unit, -) => _ = "" -``` - -**Note**: the ` = ""` part at the end is just a dummy placeholder, due to syntactic limitations. It serves no purpose currently. - -This function has four labelled parameters (the fourth one optional), one unlabelled parameter at the end (which we mandate for functions with [optional parameters](function#optional-labeled-arguments), and one parameter (`\"type"`) that required quoting to [avoid clashing](use-illegal-identifier-names) with the reserved `type` keyword. - -Also of interest is the return type: `_`, which tells ReScript to automatically infer the full type of the JS object, sparing you the hassle of writing down the type manually! - -The function is called like so: - -```res -let homeRoute = route( - ~\"type"="GET", - ~path="/", - ~action=_ => Js.log("Home"), - (), -) -``` diff --git a/pages/docs/manual/v9.0.0/import-export.mdx b/pages/docs/manual/v9.0.0/import-export.mdx deleted file mode 100644 index 965a1b983..000000000 --- a/pages/docs/manual/v9.0.0/import-export.mdx +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: "Import & Export" -description: "Importing / exporting in ReScript modules" -canonical: "/docs/manual/latest/import-export" ---- - -# Import & Export - -## Import a Module/File - -Unlike JavaScript, ReScript doesn't have or need import statements: - - - -```res -// Inside School.res -let studentMessage = Student.message -``` - -```js -var Student = require("./Student.bs"); -var studentMessage = Student.message; -``` - - - -The above code refers to the `message` binding in the file `Student.res`. Every ReScript file is also a module, so accessing another file's content is the same as accessing another module's content! - -A ReScript project's file names need to be unique. - -## Export Stuff - -By default, every file's type declaration, binding and module is exported, aka publicly usable by another file. **This also means those values, once compiled into JS, are immediately usable by your JS code**. - -To only export a few selected things, use a `.resi` [interface file](module.md#signatures). - -## Work with JavaScript Import & Export - -To see how to import JS modules and export stuff for JS consumption, see the JavaScript Interop section's [Import from/Export to JS](import-from-export-to-js.md). diff --git a/pages/docs/manual/v9.0.0/import-from-export-to-js.mdx b/pages/docs/manual/v9.0.0/import-from-export-to-js.mdx deleted file mode 100644 index 8bbc3cfdc..000000000 --- a/pages/docs/manual/v9.0.0/import-from-export-to-js.mdx +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: "Import from / Export to JS" -description: "Importing / exporting JS module content in ReScript" -canonical: "/docs/manual/latest/import-from-export-to-js" ---- - -# Import from/Export to JS - -You've seen how ReScript's idiomatic [Import & Export](import-export.md) works. This section describes how we work with importing stuff from JavaScript and exporting stuff for JavaScript consumption. - -**Note**: due to JS ecosystem's module compatibility issues, our advice of keeping your ReScript file's compiled JS output open in a tab applies here **more than ever**, as you don't want to subtly output the wrong JS module import/export code, on top of having to deal with Babel/Webpack/Jest/Node's CommonJS\<->ES6 compatibility shims. - -In short: **make sure your bindings below output what you'd have manually written in JS**. - -## Output Format - -We support 2 JavaScript import/export formats: - -- CommonJS: `require('myFile')` and `module.export = ...`. -- ES6 modules: `import * from 'MyReScriptFile'` and `export let ...`. - -The format is [configurable in bsb](build-configuration.md#package-specs). - -## Import From JavaScript - -### Import a JavaScript Module's Named Export - -Use the `module` [external](external.md): - - - -```res example -// Import nodejs' path.dirname -@module("path") external dirname: string => string = "dirname" -let root = dirname("/User/github") // returns "User" -``` - -```js -var Path = require("path"); -var root = Path.dirname("/User/github"); -``` - -```js -import * as Path from "path"; -var root = Path.dirname("/User/github"); -``` - - - -Here's what the `external` does: - -- `@module("path")`: pass the name of the JS module; in this case, `"path"`. The string can be anything: `"./src/myJsFile"`, `"@myNpmNamespace/myLib"`, etc. -- `external`: the general keyword for declaring a value that exists on the JS side. -- `dirname`: the binding name you'll use on the ReScript side. -- `string => string`: the type signature of `dirname`. Mandatory for `external`s. -- `= "dirname"`: the name of the variable inside the `path` JS module. There's repetition in writing the first and second `dirname`, because sometime the binding name you want to use on the ReScript side is different than the variable name the JS module exported. - -### Import a JavaScript Module As a Single Value - -By omitting the string argument to `module`, you bind to the whole JS module: - - - -```res example -@module external leftPad: string => int => string = "./leftPad" -let paddedResult = leftPad("hi", 5) -``` - -```js -var LeftPad = require("./leftPad"); -var paddedResult = LeftPad("hi", 5); -``` - -```js -import * as LeftPad from "./leftPad"; -var paddedResult = LeftPad("hi", 5); -``` - - - -Depending on whether you're compiling ReScript to CommonJS or ES6 module, **this feature will generate subtly different code**. Please check both output tabs to see the difference. The ES6 output here would be wrong! - -### Import an ES6 Default Export (Since >= 8.3.0) - -Use the value `"default"` on the right hand side: - - - -```res example -@module("./student") external studentName: string = "default" -Js.log(studentName) -``` - -```js -import Student from "./student"; -var studentName = Student; -``` - - - -## Export To JavaScript - -### Export a Named Value - -As mentioned in ReScript's idiomatic [Import & Export](import-export.md), every let binding and module is exported by default to other ReScript modules (unless you use a `.resi` [interface file](module#signatures)). If you open up the compiled JS file, you'll see that these values can also directly be used by a _JavaScript_ file too. - -### Export an ES6 Default Value - -If your JS project uses ES6 modules, you're likely exporting & importing some default values: - -```js -// student.js -export default name = "Al"; -``` - -```js -// teacher.js -import studentName from "student.js"; -``` - -A JavaScript default export is really just syntax sugar for a named export implicitly called `default` (now you know!). So to export a default value from ReScript, you can just do: - - - -```res example -// ReScriptStudent.res -let default = "Bob" -``` - -```js -var $$default = "Bob"; - -exports.$$default = $$default; -exports.default = $$default; -// informal transpiler-compatible marker of a default export compiled from ES6 -exports.__esModule = true; -``` - -```js -var $$default = "Bob"; - -export { $$default, $$default as default }; -``` - - - -You can then import this default export as usual on the JS side: - -```js -// teacher2.js -import studentName from "ReScriptStudent.js"; -``` - -If your JavaScript's ES6 default import is transpiled by Babel/Webpack/Jest into CommonJS `require`s, we've taken care of that too! See the CommonJS output tab for `__esModule`. diff --git a/pages/docs/manual/v9.0.0/inlining-constants.mdx b/pages/docs/manual/v9.0.0/inlining-constants.mdx deleted file mode 100644 index 5673c1e93..000000000 --- a/pages/docs/manual/v9.0.0/inlining-constants.mdx +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: "Inlining Constants" -description: "Inlining constants" -canonical: "/docs/manual/latest/inlining-constants" ---- - -# Inlining Constants - -Sometime, in the JavaScript output, you might want a certain value to be forcefully inlined. For example: - -```js -if (process.env.mode === "development") { - console.log("Dev-only code here!"); -} -``` - -The reason is that your JavaScript bundler (e.g. Webpack) might turn that into: - -```js -if ("production" === "development") { - console.log("Dev-only code here!"); -} -``` - -Then your subsequent Uglifyjs optimization would remove that entire `if` block. This is how projects like ReactJS provide a development mode code with plenty of dev warnings, while ensuring that the uglified (minified) production code is free of those expensive blocks. - -So, in ReScript, producing that example `if (process.env.mode === 'development')` output is important. This first try doesn't work: - - - -```res example -@val external process: 'a = "process" - -let mode = "development" - -if (process["env"]["mode"] === mode) { - Js.log("Dev-only code here!") -} -``` - -```js -var mode = "development"; - -if (process.env.mode === mode) { - console.log("Dev-only code here!"); -} -``` - - - -The JS output shows `if (process.env.mode === mode)`, which isn't what we wanted. To inline `mode`'s value, use `@inline`: - - - -```res example -@val external process: 'a = "process" - -@inline -let mode = "development" - -if (process["env"]["mode"] === mode) { - Js.log("Dev-only code here!") -} -``` - -```js -if (process.env.mode === "development") { - console.log("Dev-only code here!"); -} -``` - - - -Now your resulting JS code can pass through Webpack and Uglifyjs like the rest of your JavaScript code, and that whole `console.log` can be removed. - -The inlining currently only works for **string, float and boolean**. - -## Tips & Tricks - -This is **not** an optimization. This is an edge-case feature for folks who absolutely need particular values inlined for a JavaScript post-processing step, like conditional compilation. Beside the difference in code that the conditional compilation might end up outputting, there's no performance difference between inlining and not inlining simple values in the eyes of a JavaScript engine. diff --git a/pages/docs/manual/v9.0.0/installation.mdx b/pages/docs/manual/v9.0.0/installation.mdx deleted file mode 100644 index 1c8d702ab..000000000 --- a/pages/docs/manual/v9.0.0/installation.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: "Installation" -description: "ReScript installation and setup instructions" -canonical: "/docs/manual/latest/installation" ---- - -# Installation - -Prerequisite: NPM, which comes with [NodeJS](https://nodejs.org/en/). [Yarn](https://yarnpkg.com/en/) also works. - -To install ReScript globally: - -```sh -npm install -g bs-platform -``` - -## New Project - -```sh -git clone https://github.com/rescript-lang/rescript-project-template -cd rescript-project-template -npm install -npm run build -node src/Demo.bs.js -``` - -That compiles your ReScript into JavaScript, then uses NodeJS to run said JavaScript. **We recommend you use our unique workflow of keeping a tab open for the generated `.bs.js` file**, so that you can learn how ReScript transforms into JavaScript. Not many languages output clean JavaScript code you can inspect and learn from! - -During development, instead of running `npm run build` each time to compile, use `npm run start` to start a watcher that recompiles automatically after file changes. - -## Integrate Into Existing JS Project - -If you already have a JavaScript project into which you'd like to add ReScript: - -- Install ReScript locally as a [devDependency](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file): - ```sh - npm install --save-dev bs-platform - ``` -- Create a ReScript build configuration at the root: - ```json - { - "name": "your-project-name", - "sources": [ - { - "dir": "src", // update this to wherever you're putting ReScript files - "subdirs": true - } - ], - "package-specs": [ - { - "module": "es6", - "in-source": true - } - ], - "suffix": ".bs.js", - "bs-dependencies": [] - } - ``` - See [Build Configuration](build-configuration) for more details on `bsconfig.json`. -- Add convenience `npm` scripts to `package.json`: - ```json - "scripts": { - "re:build": "bsb -make-world -clean-world", - "re:start": "bsb -make-world -clean-world -w" - } - ``` - -Since ReScript compiles to clean readable JS files, the rest of your existing toolchain (e.g. Babel and Webpack) should just work! - -Helpful guides: - -- [Converting from JS](converting-from-js). -- [Shared Data Types](shared-data-types). -- [Import from/Export to JS](import-from-export-to-js). - -### Integrate with a ReactJS Project - -To start a [rescript-react](/docs/react/latest/introduction) app, or to integrate ReScript into an existing ReactJS app, follow the instructions [here](/docs/react/latest/installation). diff --git a/pages/docs/manual/v9.0.0/interop-cheatsheet.mdx b/pages/docs/manual/v9.0.0/interop-cheatsheet.mdx deleted file mode 100644 index 55891053e..000000000 --- a/pages/docs/manual/v9.0.0/interop-cheatsheet.mdx +++ /dev/null @@ -1,259 +0,0 @@ ---- -title: "Interop Cheatsheet" -description: "Cheatsheet for various interop scenarios in ReScript" -canonical: "/docs/manual/latest/interop-cheatsheet" ---- - -# Interop Cheatsheet - -This is a glossary with examples. All the features are described by later pages. - -## List of Decorators - -> **Note:** In previous versions (< 8.3) all our attributes started with a `bs.` prefix. Our formatter will automatically drop them in newer ReScript versions. - - - -### Attributes - -- `@as`: [here](attribute#usage), [here](bind-to-js-function#fixed-arguments), [here](bind-to-js-function#constrain-arguments-better) and [here](generate-converters-accessors#usage-3) -- [`@deriving`](generate-converters-accessors#generate-functions--plain-values-for-variants) -- [`@get`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@get_index`](bind-to-js-object#bind-using-special-bs-getters--setters) - -- [`@inline`](inlining-constants) -- [`@int`](bind-to-js-function#constrain-arguments-better) - -- [`@module`](import-from-export-to-js#import-a-javascript-modules-content) -- [`@new`](bind-to-js-object#bind-to-a-js-object-thats-a-class) -- [`@obj`](generate-converters-accessors#convert-external-into-js-object-creation-function) -- [`@optional`](generate-converters-accessors#optional-labels) -- [`@return`](bind-to-js-function#function-nullable-return-value-wrapping) -- `@send`: [here](bind-to-js-function#object-method) and [here](pipe#js-method-chaining) -- [`@scope`](bind-to-global-js-values#global-modules) -- [`@set`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@set_index`](bind-to-js-object#bind-using-special-bs-getters--setters) -- [`@variadic`](bind-to-js-function#variadic-function-arguments) -- [`@string`](bind-to-js-function#constrain-arguments-better) -- [`@this`](bind-to-js-function#modeling-this-based-callbacks) -- [`@uncurry`](bind-to-js-function#extra-solution) -- [`@unwrap`](bind-to-js-function#trick-2-polymorphic-variant--bsunwrap) -- [`@val`](bind-to-global-js-values#global-modules) - -- [`@deprecated`](attribute#usage) -- [`genType`](https://github.com/reason-association/genType) -- [`@JSX`](jsx) -- `@react.component`: [here](/docs/react/latest/introduction) and [here](https://github.com/reasonml/reason-react) -- [`@warning`](attribute#usage) -- [`@unboxed`](unboxed) - -### Extension Points - -- [`%debugger`](embed-raw-javascript#debugger) -- [`%external`](bind-to-global-js-values#special-global-values) - - -- [`%raw`](embed-raw-javascript#paste-raw-js-code) -- [`%re`](primitive-types#regular-expression) - -## Raw JS - - - -```res example -let add = %raw("(a, b) => a + b") -%%raw("const a = 1") -``` - -```js -var add = (a, b) => a + b; -const a = 1; -``` - - - -## Global Value - - - -```res example -@val external setTimeout: (unit => unit, int) => float = "setTimeout" -``` - -```js -// Empty output -``` - - - -## Global Module's Value - - - -```res example -@val @scope("Math") -external random: unit => float = "random" - -let someNumber = random() - -@val @scope(("window", "location", "ancestorOrigins")) -external length: int = "length" -``` - -```js -var someNumber = Math.random(); -``` - - - -## Nullable - - - -```res example -let a = Some(5) // compiles to 5 -let b = None // compiles to undefined -``` - -```js -var a = 5; -var b; -``` - - - -Handling a value that can be `undefined` and `null`, by ditching the `option` type and using `Js.Nullable.t`: - - - -```res example -let jsNull = Js.Nullable.null -let jsUndefined = Js.Nullable.undefined -let result1: Js.Nullable.t = Js.Nullable.return("hello") -let result2: Js.Nullable.t = Js.Nullable.fromOption(Some(10)) -let result3: option = Js.Nullable.toOption(Js.Nullable.return(10)) -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); -var Js_null_undefined = require("./stdlib/js_null_undefined.js"); - -var jsNull = null; -var jsUndefined; -var result1 = "hello"; -var result2 = Js_null_undefined.fromOption(10); -var result3 = Caml_option.nullable_to_opt(10); -``` - - - -## JS Object - -- [Bind to a JS object as a ReScript record](bind-to-js-object#bind-to-record-like-js-objects). -- [Bind to a JS object that acts like a hash map](bind-to-js-object#bind-to-hash-map-like-js-object). -- [Bind to a JS object that's a class](bind-to-js-object#bind-to-a-js-object-thats-a-class). - -## Function - -### Object Method & Chaining - - - -```res example -@send external map: (array<'a>, 'a => 'b) => array<'b> = "map" -@send external filter: (array<'a>, 'a => 'b) => array<'b> = "filter" -[1, 2, 3] - ->map(a => a + 1) - ->filter(a => mod(a, 2) == 0) - ->Js.log -``` - -```js -console.log( - [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }), -); -``` - - - -### Variadic Arguments - - - -```res example -@module("path") @variadic -external join: array => string = "join" -``` - -```js -// Empty output -``` - - - -### Polymorphic Function - - - -```res example -@module("Drawing") external drawCat: unit => unit = "draw" -@module("Drawing") external drawDog: (~giveName: string) => unit = "draw" -``` - -```js -// Empty output -``` - - - - - -```res example -@val -external padLeft: ( - string, - @unwrap [ - | #Str(string) - | #Int(int) - ]) - => string = "padLeft" - -padLeft("Hello World", #Int(4)) -padLeft("Hello World", #Str("Message from ReScript: ")) -``` - -```js -padLeft("Hello World", 4); -padLeft("Hello World", "Message from ReScript: "); -``` - - - -## JS Module Interop - -[See here](import-from-export-to-js.md) - -## Dangerous Type Cast - -Final escape hatch converter. Do not abuse. - - - -```res example -external convertToFloat: int => float = "%identity" -let age = 10 -let gpa = 2.1 +. convertToFloat(age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - diff --git a/pages/docs/manual/v9.0.0/interop-with-js-build-systems.mdx b/pages/docs/manual/v9.0.0/interop-with-js-build-systems.mdx deleted file mode 100644 index 04a34a6c4..000000000 --- a/pages/docs/manual/v9.0.0/interop-with-js-build-systems.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Interop with JS Build Systems" -description: "Documentation on how to interact with existing JS build systems" -canonical: "/docs/manual/latest/interop-with-js-build-systems" ---- - -# Interop with JS Build Systems - -If you come from JS, chances are that you already have a build system in your existing project. Here's an overview of the role bsb would play in your build pipeline, if you want to introduce some ReScript code into the codebase. - -> As much as possible, please try not to wrap bsb into your own incremental build framework. ReScript's compilation is very hard to get right, and you'll inevitably run into stale or badly performing builds (therefore erasing much of our value proposition) if you create your own meta layer on top. - -## Popular JS Build Systems - -The JS ecosystem uses a few build systems: [browserify](http://browserify.org/), [rollup](https://github.com/rollup/rollup), [webpack](https://webpack.js.org/), etc. The latter's probably the most popular of the three (as of 2019 =P). These build systems do both the compilation and the linking (aka, bundling many files into one or few files). - -ReScript and bsb only take care of the compilation step; it maps one `.res`/`.resi` file into one JS output file. As such, in theory, no build system integration is needed from our side. From e.g. the webpack watcher's perspective, the JS files ReScript generates are almost equivalent to your hand-written JS files. We also recommend that you initially check in those ReScript-generated JS files, as this workflow means: - -- You can introduce ReScript silently into your codebase without disturbing existing infra. -- You have a **visual** diff of the performance & correctness of your JS file when you update the `.res` files and the JS artifacts change. -- You can let teammates hot-patch the JS files in emergency situations, without needing to first start learning ReScript. -- You can remove ReScript completely from your codebase and things will still work (in case your company decides to stop using us for whatever reason). - -For what it's worth, you can also turn bsb into an automated step in your build pipeline, e.g. into a webpack loader; but such approach is error-prone and therefore discouraged. - -### Tips & Tricks - -You can make ReScript JS files look even more idiomatic through the in-source + bs suffix config in `bsconfig.json`: - -```json -{ - "package-specs": { - "module": "commonjs", // or whatever module system your project uses - "in-source": true - }, - "suffix": ".bs.js" -} -``` - -This will: - -- Generate the JS files alongside your ReScript source files. -- Use the file extension `.bs.js`, so that you can require these files on the JS side through `require('./MyFile.bs')`, without needing a loader. - -## Use Loaders on ReScript Side - -"What if my build system uses a CSS/png/whatever loader and I'd like to use it in ReScript?" - -Loaders are indeed troublesome; in the meantime, please use e.g. `%raw("require('./myStyles.css')")` at the top of your file. This just uses [`raw`](embed-raw-javascript.md) to compile the snippet into an actual JS require. - -## Getting Project's Dependencies - -`bsb` generates one `MyFile.d` file per `MyFile` source file; you'll find them in `lib/bs`. These are human readable, machine-friendly list of the dependencies of said `MyFile`. You can read into them for your purpose (though mind the IO overhead). Use these files instead of creating your own dependency graph; we did the hard work of tracking the dependencies as best as possible (including inner modules, `open`s, module names overlap, etc). - -## Run Script Per File Built - -See [js-post-build](build-configuration#js-post-build). Though please use it sparingly; if you hook up a node.js script after each file built, you'll incur the node startup time per file! diff --git a/pages/docs/manual/v9.0.0/introduction.mdx b/pages/docs/manual/v9.0.0/introduction.mdx deleted file mode 100644 index ab8764d7b..000000000 --- a/pages/docs/manual/v9.0.0/introduction.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: "Introduction" -description: "The hows and whys of ReScript" -canonical: "/docs/manual/latest/introduction" ---- - -# ReScript - -Ever wanted a language like JavaScript, but without the warts, with a great type system, and with a lean build toolchain that doesn't waste your time? - -ReScript looks like JS, acts like JS, and compiles to the highest quality of clean, readable and performant JS, directly runnable in browsers and Node. - -**This means you can pick up ReScript and access the vast JavaScript ecosystem and tooling as if you've known ReScript for a long time!** - -**ReScript is the language for folks who don't necessarily love JavaScript, but who still acknowledge its importance**. - -## Difference vs TypeScript - -We respect TypeScript very much and think that it's a positive force in the JavaScript ecosystem. ReScript shares some of the same goals as TypeScript, but is different enough regarding some important nuances: - -- TypeScript's (admittedly noble) goal is to cover the entire JavaScript feature set and more. **ReScript covers only a curated subset of JavaScript**. For example, we emphasize plain data + functions over classes, clean [pattern matching](pattern-matching-destructuring.md) over fragile `if`s and virtual dispatches, [proper data modeling](variant.md) over string abuse, etc. JavaScript supersets will only grow larger over time; ReScript doesn't. \* - -- Consequently, TypeScript's type system is necessarily complex, pitfalls-ridden, potentially requires tweaking, sometimes slow, and requires quite a bit of noisy annotations that often feel like manual bookkeeping rather than clear documentation. In contrast, ReScript's type system: - - Is deliberately curated to be a simple subset most folks will have an easier time to use. - - Has **no** pitfalls, aka the type system is "sound" (the types will always be correct). E.g. If a type isn't marked as nullable, its value will never lie and let through some `undefined` value silently. **ReScript code has no null/undefined errors**. - - Is the same for everyone. No knobs, no bikeshedding opportunity. - - Runs extremely fast precisely thanks to its simplicity and curation. It's one of the fastest compiler & build system toolchains for JavaScript development. - - **Doesn't need type annotations**. Annotate as much or as little as you'd like. The types are inferred by the language (and, again, are guaranteed correct). - -- Migrating to TypeScript is done "breadth-first," whereas migrating to ReScript is done "depth-first." You can convert your codebase to TypeScript by "turning it on" for all files and annotate here and there; but how much type safety did you gain? How do you measure it? Type errors can still slip in and out of the converted pieces. For ReScript, our interop features draw clear boundaries: there's pure ReScript code, and there's JS interop code. Every piece of converted ReScript code is 100% clean. You'd convert file by file and each conversion increases your safety monotonically. - -\* When you absolutely need to write or interoperate with free-for-all JavaScript, we expose enough escape hatches for you. - -## Other Highlights - -Aside from the aforementioned simple, robust and fast type system, ReScript presents a few more advantages. - -### Faster than JavaScript - -JavaScript's been aggressively optimized by talented engineers over a long span. Unfortunately, even for seasoned JS devs, it can be hard to know how to properly leverage JS's performance. ReScript's type system and compiler naturally guides you toward writing code that's very often performant by default, with good leverage of various Just-In-Time optimizations (hidden classes, inline caching, avoiding deopts, etc). - -A widespread adage to write fast JavaScript code is to write as if there's a type system (in order to trigger JS engines' good optimization heuristics); ReScript gives you a real one and generates code that's friendly to optimizations by default. - -### High Quality Dead Code Elimination - -The JavaScript ecosystem is very reliant on dependencies. Shipping the final product inevitably drags in a huge amount of code, lots of which the project doesn't actually use. These regions of dead code impact loading, parsing and interpretation speed. ReScript provides powerful dead code elimination at all levels: - -- Function- and module-level code elimination is facilitated by the well-engineered type system and purity analysis. -- At the global level, ReScript generates code that is naturally friendly to dead code elimination done by bundling tools such as [Rollup](https://github.com/rollup/rollup) and [Closure Compiler](https://developers.google.com/closure/compiler/), after its own sophisticated elimination pass. -- The same applies for ReScript's own tiny runtime (which is written in ReScript itself). - -### Tiny JS Output - -A `Hello world` ReScript program generates **20 bytes** of JS code. Additionally, the standard library pieces you require in are only included when needed. - -### Fast Iteration Loop - -ReScript's build time is **one or two orders of magnitude** faster than alternatives. In its watcher mode, the build system usually finishes before you switch screen from the editor to the terminal tab (two digits of milliseconds). A fast iteration cycle reduces the need of keeping one's mental state around longer; this in turn allows one to stay in the flow longer and more often. - -### Readable Output & Great Interop - -Unreadable JavaScript code generated from other compiled-to-js languages makes it so that it could be, practically speaking: - -- Hard to debug (cryptic stack trace, mangled variable names) -- Hard to learn from (non-straightforward mapping of concepts from one language to another) -- Hard to profile for performance (unclear what runtime performance cost there is) -- Hard to integrate with existing hand-written JS code - -ReScript's JS output is very readable. This is especially important while learning, where users might want to understand how the code's compiled, and to audit for bugs. - -This characteristic, combined with a fully-featured JS interop system, allows ReScript code to be inserted into an existing JavaScript codebase almost unnoticed. - -### Preservation of Code Structure - -ReScript maps one source file to one JavaScript output file. This eases the integration of existing tools such as bundlers and test runners. You can even start writing a single file without much change to your build setup. Each file's code structure is approximately preserved, too. - -## Conclusion - -We hope the above gave you enough of an idea of ReScript and its differentiators. Feel free to [try it online](/try) to get a feel! diff --git a/pages/docs/manual/v9.0.0/json.mdx b/pages/docs/manual/v9.0.0/json.mdx deleted file mode 100644 index 55c0efee3..000000000 --- a/pages/docs/manual/v9.0.0/json.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: "JSON" -description: "Interacting with JSON in ReScript" -canonical: "/docs/manual/latest/json" ---- - -# JSON - -## Parse - -Bind to JavaScript's `JSON.parse` and type the return value as the type you're expecting: - - - -```res example -// declare the shape of the json you're binding to -type data = {names: array} - -// bind to JS' JSON.parse -@scope("JSON") @val -external parseIntoMyData: string => data = "parse" - -let result = parseIntoMyData(`{"names": ["Luke", "Christine"]}`) -let name1 = result.names[0] -``` - -```js -var result = JSON.parse('{"names": ["Luke", "Christine"]}'); -var name1 = result.names[0]; -``` - - - -Where `data` can be any type you assume the JSON is. As you can see, this compiles to a straightforward `JSON.parse` call. As with regular JS, this is convenient, but has no guarantee that e.g. the data is correctly shaped, or even syntactically valid. Slightly dangerous. - -## Stringify - -Use `Js.Json.stringify`: - - - -```res example -Js.log(Js.Json.stringifyAny(["Amy", "Joe"])) -``` - -```js -console.log(JSON.stringify(["Amy", "Joe"])); -``` - - - -## Advanced - -The [Js.Json](api/js/json) module provides slightly safer, low-level building blocks for power users who want to parse JSON on a per-field basis. See the examples in the API docs. diff --git a/pages/docs/manual/v9.0.0/jsx.mdx b/pages/docs/manual/v9.0.0/jsx.mdx deleted file mode 100644 index 8819bb705..000000000 --- a/pages/docs/manual/v9.0.0/jsx.mdx +++ /dev/null @@ -1,302 +0,0 @@ ---- -title: "JSX" -description: "JSX syntax in ReScript and React" -canonical: "/docs/manual/latest/jsx" ---- - -# JSX - -Would you like some HTML syntax in your ReScript? If not, quickly skip over this section and pretend you didn't see anything! - -ReScript supports the JSX syntax, with some slight differences compared to the one in [ReactJS](https://facebook.github.io/react/docs/introducing-jsx.html). ReScript JSX isn't tied to ReactJS; they translate to normal function calls: - -**Note** for [ReasonReact](https://reasonml.github.io/reason-react/en/) readers: this isn't what ReasonReact turns JSX into, in the end. See Usage section for more info. - -## Capitalized Tag - - - -```res - -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps("ReScript", undefined), -); -``` - - - -becomes - - - -```res -@JSX MyComponent.createElement(~name="ReScript", ~children=list{}, ()) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps("ReScript", undefined), -); -``` - - - -## Uncapitalized Tag - - - -```res -
child1 child2
-``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - -
- -becomes - - - -```res -@JSX div(~onClick=handler, ~children=list{child1, child2}, ()) -``` - -```js -React.createElement( - "div", - { - onClick: handler, - }, - child1, - child2, -); -``` - - - -## Fragment - - - -```res -<> child1 child2 -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -becomes - - - -```res -@JSX list{child1, child2} -``` - -```js -React.createElement(React.Fragment, undefined, child1, child2); -``` - - - -### Children - - - -```res - child1 child2 -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(null, undefined), - child1, - child2, -); -``` - - - -This is the syntax for passing a list of two items, `child1` and `child2`, to the children position. It desugars to a list containing `child1` and `child2`: - - - -```res -@JSX MyComponent.createElement(~children=list{child1, child2}, ()) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(null, undefined), - child1, - child2, -); -``` - - - -**Note** again that this isn't the transform for ReasonReact; ReasonReact turns the final list into an array. But the idea still applies. - -So naturally, ` myChild ` desugars to `@JSX MyComponent.createElement(~children=list{myChild}, ())`. I.e. whatever you do, the arguments passed to the children position will be wrapped in a list. What if you don't want that? **What if you want to directly pass `myChild` without an extra wrapping**? - -#### Children Spread - -To solve the above problem, we've introduced - - - -```res - ...myChild -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(myChild, undefined), -); -``` - - - -This passes the value `myChild` _without_ wrapping it in a list (or array, in the case of ReasonReact). Aka, this desugars to: - - - -```res -@JSX MyComponent.createElement(~children=myChild, ()) -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(myChild, undefined), -); -``` - - - -This is extra useful in the cases where you are handled `myChild` that is already a list of things, and want to forward that without wrapping it an extra time (which would be a type error) \*. It also allows you to pass arbitrary data structures at `children` position (remember, JSX `children` is really just a totally normal prop): - - - -```res - ...((theClassName) =>
) - - ...("Hello", "Submit") -``` - -```js -React.createElement( - make, - makeProps(function (theClassName) { - return React.createElement("div", { - className: theClassName, - }); - }, undefined), -); - -React.createElement( - MyForm.make, - MyForm.makeProps(["Hello", "Submit"], undefined), -); -``` - - - -## Usage - -See [ReasonReact JSX](https://reasonml.github.io/reason-react/docs/en/jsx) for an example application of JSX, which transforms the above calls into a ReasonReact-specific call. - -Here's a JSX tag that shows most of the features. - - - -```res - -
{React.string("hello")}
-
-``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps( - true, - "string", - 1, - "hello", - handleClick, - React.createElement("div", undefined, "hello"), - undefined, - ), -); -``` - -
- -## Departures From JS JSX - -- Attributes and children don't mandate `{}`, but we show them anyway for ease of learning. Once you format your file, some of them go away and some turn into parentheses. -- There is no support for JSX prop spread: ``. Though somewhat related, we do have children spread, described above: ` ...children `. -- Punning! - -### Punning - -"Punning" refers to the syntax shorthand for when a label and a value are the same. For example, in JavaScript, instead of doing `return {name: name}`, you can do `return {name}`. - -Reason JSX supports punning. `` is just a shorthand for ``. The formatter will help you format to the punned syntax whenever possible. This is convenient in the cases where there are lots of props to pass down: - - - -```res - -``` - -```js -React.createElement( - MyComponent.make, - MyComponent.makeProps(isLoading, text, onClick, undefined), -); -``` - - - -Consequently, a Reason JSX component can cram in a few more props before reaching for extra libraries solutions that avoids props passing. - -**Note** that this is a departure from ReactJS JSX, which does **not** have punning. ReactJS' `` desugars to ``, in order to conform to DOM's idioms and for backward compatibility. - -## Tip & Tricks - -For library authors wanting to take advantage of the JSX: the `@JSX` attribute above is a hook for potential ppx macros to spot a function wanting to format as JSX. Once you spot the function, you can turn it into any other expression. - -This way, everyone gets to benefit the JSX syntax without needing to opt into a specific library using it, e.g. ReasonReact. - -JSX calls supports the features of [labeled functions](function.md#labeled-arguments): optional, explicitly passed optional and optional with default. - -## Design Decisions - -\* You might wonder why you never needed such children spread in ReactJS; ReactJS uses some special runtime logic + special syntax transforms + variadic argument detection & marking to avoid most of these cases ([see here](https://github.com/facebook/react/blob/9b36df86c6ccecb73ca44899386e6a72a83ad445/packages/react/src/ReactElement.js#L207)). Such dynamic usage complexifies the type system detection _quite a bit_. Since we control the whole syntax and ReasonReact, we decided to introduce children spread to disambiguate between the case of wrapping vs not wrapping, without compile-time & runtime cost! diff --git a/pages/docs/manual/v9.0.0/lazy-values.mdx b/pages/docs/manual/v9.0.0/lazy-values.mdx deleted file mode 100644 index 5ef3ab575..000000000 --- a/pages/docs/manual/v9.0.0/lazy-values.mdx +++ /dev/null @@ -1,128 +0,0 @@ ---- -title: "Lazy Value" -description: "Data type for deferred computation in ReScript" -canonical: "/docs/manual/latest/lazy-values" ---- - -# Lazy Value - -If you have some expensive computations you'd like to **defer and cache** subsequently, you can wrap it with `lazy`: - - - -```res prelude -// Read the directory, only once -let expensiveFilesRead = lazy({ - Js.log("Reading dir") - Node.Fs.readdirSync("./pages") -}) -``` - -```js -var Fs = require("fs"); - -var expensiveFilesRead = { - LAZY_DONE: false, - VAL: function () { - console.log("Reading dir"); - return Fs.readdirSync("./pages"); - }, -}; -``` - - - -Check the JS Output tab: that `expensiveFilesRead`'s code isn't executed yet, even though you declared it! You can carry it around without fearing that it'll run the directory read. - -**Note**: a lazy value is **not** a [shared data type](shared-data-types.md). Don't rely on its runtime representation in your JavaScript code. - -## Execute The Lazy Computation - -To actually run the lazy value's computation, use `Lazy.force` from the globally available `Lazy` module: - - - -```res example -// First call. The computation happens -Js.log(Lazy.force(expensiveFilesRead)) // logs "Reading dir" and the directory content - -// Second call. Will just return the already calculated result -Js.log(Lazy.force(expensiveFilesRead)) // logs the directory content -``` - -```js -console.log(CamlinternalLazy.force(expensiveFilesRead)); - -console.log(CamlinternalLazy.force(expensiveFilesRead)); -``` - - - -The first time `Lazy.force` is called, the expensive computation happens and the result is **cached**. The second time, the cached value is directly used. - -**You can't re-trigger the computation after the first `force` call**. Make sure you only use a lazy value with computations whose results don't change (e.g. an expensive server request whose response is always the same). - -Instead of using `Lazy.force`, you can also use [pattern matching](pattern-matching-destructuring.md) to trigger the computation: - - - -```res example -switch expensiveFilesRead { -| lazy(result) => Js.log(result) -} -``` - -```js -var result = CamlinternalLazy.force(expensiveFilesRead); -``` - - - -Since pattern matching also works on a `let` binding, you can also do: - - - -```res example -let lazy(result) = expensiveFilesRead -Js.log(result) -``` - -```js -var result = CamlinternalLazy.force(expensiveFilesRead); -console.log(result); -``` - - - -## Exception Handling - -For completeness' sake, our files read example might raise an exception because of `readdirSync`. Here's how you'd handle it: - - - -```res example -let result = try { - Lazy.force(expensiveFilesRead) -} catch { -| Not_found => [] // empty array of files -} -``` - -```js -var result; - -try { - result = CamlinternalLazy.force(expensiveFilesRead); -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - result = []; - } else { - throw exn; - } -} -``` - - - -Though you should probably handle the exception inside the lazy computation itself. diff --git a/pages/docs/manual/v9.0.0/let-binding.mdx b/pages/docs/manual/v9.0.0/let-binding.mdx deleted file mode 100644 index 5db39032c..000000000 --- a/pages/docs/manual/v9.0.0/let-binding.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -title: "Let Binding" -description: "Let binding syntax for binding to values in ReScript" -canonical: "/docs/manual/latest/let-binding" ---- - -# Let Binding - -A "let binding", in other languages, might be called a "variable declaration". `let` _binds_ values to names. They can be seen and referenced by code that comes _after_ them. - - - -```res example -let greeting = "hello!" -let score = 10 -let newScore = 10 + score -``` - -```js -var greeting = "hello!"; -var score = 10; -var newScore = 20; -``` - - - -## Block Scope - -Bindings can be scoped through `{}`. - - - -```res example -let message = { - let part1 = "hello" - let part2 = "world" - part1 ++ " " ++ part2 -} -// `part1` and `part2` not accessible here! -``` - -```js -var message = "hello world"; -``` - - - -The value of the last line of a scope is implicitly returned. - -### Design Decisions - -ReScript's `if`, `while` and functions all use the same block scoping mechanism. The code below works **not** because of some special "if scope"; but simply because it's the same scope syntax and feature you just saw: - - - -```res -if displayGreeting { - let message = "Enjoying the docs so far?" - Js.log(message) -} -// `message` not accessible here! -``` - -```js -if (displayGreeting) { - console.log("Enjoying the docs so far?"); -} -``` - - - -## Bindings Are Immutable - -Let bindings are "immutable", aka "cannot change". This helps our type system deduce and optimize much more than other languages (and in turn, help you more). - -## Binding Shadowing - -The above restriction might sound unpractical at first. How would you change a value then? Usually, 2 ways: - -The first is to realize that many times, what you want isn't to mutate a variable's value. For example, this JavaScript pattern: - -```js -var result = 0; -result = calculate(result); -result = calculateSomeMore(result); -``` - -...is really just to comment on intermediate steps. You didn't need to mutate `result` at all! You could have just written this JS: - -```js -var result1 = 0; -var result2 = calculate(result1); -var result3 = calculateSomeMore(result2); -``` - -In ReScript, this obviously works too: - - - -```res -let result1 = 0 -let result2 = calculate(result1) -let result3 = calculateSomeMore(result2) -``` - -```js -var result1 = 0; -var result2 = calculate(0); -var result3 = calculateSomeMore(result2); -``` - - - -Additionally, reusing the same let binding name overshadows the previous bindings with the same name. So you can write this too: - - - -```res -let result = 0 -let result = calculate(result) -let result = calculateSomeMore(result) -``` - -```js -var result = calculate(0); -var result$1 = calculateSomeMore(result); -``` - - - -(Though for the sake of clarity, we don't recommend this). - -As a matter of fact, even this is valid code: - - - -```res example -let result = "hello" -Js.log(result) // prints "hello" -let result = 1 -Js.log(result) // prints 1 -``` - -```js -var result = 1; -console.log("hello"); -console.log(1); -``` - - - -The binding you refer to is whatever's the closest upward. No mutation here! -If you need _real_ mutation, e.g. passing a value around, have it modified by many pieces of code, we provide a slightly heavier [mutation feature](mutation.md). - -## Private let bindings - -Private let bindings are introduced in the release [7.2](https://rescript-lang.org/blog/bucklescript-release-7-2). - -In the module system, everything is public by default, -the only way to hide some values is by providing a separate signature to -list public fields and their types: - -```res -module A: { - let b: int -} = { - let a = 3 - let b = 4 -} -``` - -`%private` gives you an option to mark private fields directly - -```res -module A = { - %%private(let a = 3) - let b = 4 -} -``` - -`%private` also applies to file level modules, so in some cases, -users do not need to provide a separate interface file just to hide some particular values. - -Note interface files are still recommended as a general best practice since they give you better -separate compilation units and also they're better for documentation. - -Still, `%private` is useful in the following scenarios: - -- Code generators. Some code generators want to hide some values but it is sometimes very hard or time consuming for code generators to synthesize the types for public fields. - -- Quick prototyping. During prototyping, we still want to hide some values, but the interface file is not stable yet. `%private` provides you such convenience. diff --git a/pages/docs/manual/v9.0.0/libraries.mdx b/pages/docs/manual/v9.0.0/libraries.mdx deleted file mode 100644 index 57876b799..000000000 --- a/pages/docs/manual/v9.0.0/libraries.mdx +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: "Libraries & Publishing" -description: "Install & publish ReScript packages" -canonical: "/docs/manual/latest/libraries" ---- - -# Libraries & Publishing - -ReScript libraries are just like JavaScript libraries: published & hosted on [NPM](http://npmjs.com). You can reuse your `npm`, `yarn` and `package.json`-related tools to manage them! - -## Tips & Tricks - -### Publish - -We recommend you to check in your compiled JavaScript output, for its [various benefits](interop-with-js-build-systems.md#popular-js-build-systems). If not, then at least consider publishing the JavaScript output by un-ignoring them in your [npmignore](https://docs.npmjs.com/cli/v7/using-npm/developers#keeping-files-out-of-your-package). This way, your published ReScript package comes with plain JavaScript files that JS users can consume. If your project's good, JS users might not even realize that they've installed a library written in ReScript! - -In case your library is only consumed by JS users, you may want to check out our [external stdlib](./build-external-stdlib) configuration as well. - -### Find Libraries - -Search `rescript`-related packages on NPM, or use our [Package Index](/packages). - -If you can't find what you're looking for, remember that **you don't need a wrapper** to use a JS library: - -- Most JS data types, such as array and objects, [map over cleanly to ReScript and vice-versa](shared-data-types.md). -- You also have access to the familiar [JS API](api/js). -- You can use a JavaScript library without needing to install dedicated binding libraries. Check the [`external`](external) page. diff --git a/pages/docs/manual/v9.0.0/migrate-from-bucklescript-reason.mdx b/pages/docs/manual/v9.0.0/migrate-from-bucklescript-reason.mdx deleted file mode 100644 index 164837aa0..000000000 --- a/pages/docs/manual/v9.0.0/migrate-from-bucklescript-reason.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: "Migrate to ReScript Syntax" -description: "Instructions on upgrading from Reason to ReScript" -canonical: "/docs/manual/latest/migrate-to-new-syntax" ---- - -# Migrate from BuckleScript/Reason - -ReScript is a rebranding and cleanup of BuckleScript (since `v8.2.0`) & Reason (`v3.6`) that enables us to ship a tighter compile-to-JS stack with more coherent documentation & tools. If you're an existing user of BuckleScript & Reason, here's the gist: - -- ReScript is mostly just BuckleScript rebranded, with a new syntax that's like the Reason syntax, but catered more toward the JavaScript crowd. -- All your existing code will keep working even if you don't upgrade. - -## Upgrade Your Codebase - -There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial, backward-compatible and can be done on a per-file basis: - -- Upgrade your project to `bs-platform 8.2.0` or later. -- Choose a file to convert, for example `MyFile.re` -- Compile your project and keep the generated JavaScript file around (probably `MyFile.bs.js` but might depend on your `bsconfig.json` config). -- Run `node_modules/.bin/bsc -format MyFile.re > MyFile.res`. -- If your new `MyFile.res` looks good, you can delete (or move/rename) `MyFile.re` before compiling again your project (otherwise you will have an error `Invalid bsconfig.json implementation and interface have different path names or different cases MyFile vs MyFile` because 2 files with the same module name (file basename) cannot coexist in your project). -- Last thing you can do to ensure conversion is correct: build your project with the new `MyFile.res` file to compare the newly generated JavaScript file with the old one. You should get almost identical generated JavaScript code. - -**That's it**! `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file. - -Enjoy the improved experience! - -### Upgrade an Entire Folder - -Please use this with caution. Migrating an entire codebase at once is an unnecessary risk. -It is recommended to migrate small portion of code to ensure correctness. -That being said, for small codebases or some tiny folders that are safely versioned, you can try the following: - -```console -for f in your-folder/**/*.re; do; node_modules/.bin/bsc -format $f > ${f%.re}.res && rm $f; done; -``` - -This command loops on the `.re` files from the `your-folder` folder, converts them with a proper `.res` extension, and asks you if you want to remove the previous file (check the newly created `.res` file first and refer to instructions above to follow the check to do on your generated JavaScript). -If you are confident enough, you can add `-f` option to the `rm` command to avoid all checks. This will convert your entire folder without any confirmations. - -## Difference With Old Reason - -- Complete removal of semicolon (you can still write them). -- No need for parentheses around `if`, `switch` and `try`. -- Type arguments: from `option(int)` to `option`. -- Old interpolated string: from `{j|hello ${name}|j}` to `` j`hello ${name}` ``. Now with proper unicode support! -- New interpolated string: `` `hello world` ``. Also supports multiline and unicode. `"hello world"` string is now singleline. -- Polymorphic variants: from `` `red`` to `#red`. -- Arrays: from `[|1,2,3|]` to `[1,2,3]`. In JS, arrays are the right default. -- Lists: from `[1,2,3]` to `list[1,2,3]` (_8.1.1 update_: now it is `list{1, 2, 3}`). This ties with upcoming plans to access containers in a uniform way: `set[...]` and `map[...]`. Maybe temporary. -- Exception: from `try (compute()) { | Not_found => Js.log("oops")}` to `try compute() catch { | Not_found => Js.log("oops")}`. -- First class module: from `(module S: Student)` to `module(S: Student)`. -- No custom infix operator for now (including `mod`). -- Object access: from `settings##visible #= true` to `settings["visible"] = true`. Rejoice! -- Object: from `Js.t({"age": int})` to just `{"age": int}`. The `Js.t` part is now implicit. -- Attribute: from `[@myAttribute "hello"]` to `@myAttribute("hello")`. From `[%re bla]` to `%re(bla)`. -- Removed dereference syntax `result^`. Just use `result.contents`. -- `fun` pattern matching syntax removed. -- Type declaration is non-recursive by default, consistent with let bindings. To have recursive types, use `type rec myList<'a> = Nil | Cons('a, myList<'a>)`. -- Use any words, including reserved keywords, as your identifier name: `let \"try" = true`. diff --git a/pages/docs/manual/v9.0.0/module.mdx b/pages/docs/manual/v9.0.0/module.mdx deleted file mode 100644 index c723c2250..000000000 --- a/pages/docs/manual/v9.0.0/module.mdx +++ /dev/null @@ -1,548 +0,0 @@ ---- -title: "Module" -description: "ReScript modules, module signatures and interface files" -canonical: "/docs/manual/latest/module" ---- - -# Module - -## Basics - -**Modules are like mini files**! They can contain type definitions, `let` -bindings, nested modules, etc. - -### Creation - -To create a module, use the `module` keyword. The module name must start with a -**capital letter**. Whatever you could place in a `.res` file, you may place -inside a module definition's `{}` block. - - - -```res example -module School = { - type profession = Teacher | Director - - let person1 = Teacher - let getProfession = (person) => - switch person { - | Teacher => "A teacher" - | Director => "A director" - } -} -``` - -```js -function getProfession(person) { - if (person) { - return "A director"; - } else { - return "A teacher"; - } -} - -var School = { - person1: /* Teacher */ 0, - getProfession: getProfession, -}; -``` - - - -A module's contents (including types!) can be accessed much like a record's, -using the `.` notation. This demonstrates modules' utility for namespacing. - - - -```res -let anotherPerson: School.profession = School.Teacher -Js.log(School.getProfession(anotherPerson)) /* "A teacher" */ -``` - -```js -var anotherPerson = /* Teacher */ 0; -console.log("A teacher"); -``` - - - -Nested modules work too. - - - -```res example -module MyModule = { - module NestedModule = { - let message = "hello" - } -} - -let message = MyModule.NestedModule.message -``` - -```js -var NestedModule = { - message: message, -}; - -var MyModule = { - NestedModule: NestedModule, -}; - -var message = MyModule.NestedModule.message; -``` - - - -### `open`ing a module - -Constantly referring to a value/type in a module can be tedious. Instead, we can "open" a module and refer to its contents without always prepending them with the -module's name. Instead of writing: - - - -```res -let p = School.getProfession(School.person1) -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -We can write: - - - -```res -open School -let p = getProfession(person1) -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -The content of `School` module are made visible (**not** copied into the file, but simply made visible!) in scope. `profession`, `getProfession` and `person1` will thus correctly be found. - -**Use `open` this sparingly, it's convenient, but makes it hard to know where some values come from**. You should usually use `open` in a local scope: - - - -```res -let p = { - open School - getProfession(person1) -} -/* School's content isn't visible here anymore */ -``` - -```js -var p = School.getProfession(School.person1); -``` - - - -### Use `open!` to ignore shadow warnings - -There are situations where `open` will cause a warning due to existing identifiers (bindings, types) being redefined. Use `open!` to explicitly tell the compiler that this is desired behavior. - -```res -let map = (arr, value) => { - value -} - -// opening Js.Array2 would shadow our previously defined `map` -// `open!` will explicitly turn off the automatic warning -open! Js.Array2 -let arr = map([1,2,3], (a) => { a + 1}) -``` - -**Note:** Same as with `open`, don't overuse `open!` statements if not necessary. Use (sub)modules to prevent shadowing issues. - -### Extending modules - -Using `include` in a module statically "spreads" a module's content into a new one, thus often fulfill the role of "inheritance" or "mixin". - -**Note**: this is equivalent to a compiler-level copy paste. **We heavily discourage `include`**. Use it as last resort! - - - -```res example -module BaseComponent = { - let defaultGreeting = "Hello" - let getAudience = (~excited) => excited ? "world!" : "world" -} - -module ActualComponent = { - /* the content is copied over */ - include BaseComponent - /* overrides BaseComponent.defaultGreeting */ - let defaultGreeting = "Hey" - let render = () => defaultGreeting ++ " " ++ getAudience(~excited=true) -} -``` - -```js -function getAudience(excited) { - if (excited) { - return "world!"; - } else { - return "world"; - } -} - -var BaseComponent = { - defaultGreeting: "Hello", - getAudience: getAudience, -}; - -var defaultGreeting = "Hey"; - -function render(param) { - return "Hey world!"; -} - -var ActualComponent = { - getAudience: getAudience, - defaultGreeting: defaultGreeting, - render: render, -}; -``` - - - -**Note**: `open` and `include` are very different! The former brings a module's content into your current scope, so that you don't have to refer to a value by prefixing it with the module's name every time. The latter **copies over** the definition of a module statically, then also do an `open`. - -### Every `.res` file is a module - -Every ReScript file is itself compiled to a module of the same name as the file name, capitalized. The file `React.res` implicitly forms a module `React`, which can be seen by other source files. - -**Note**: ReScript file names should, by convention, be capitalized so that their casing matches their module name. Uncapitalized file names are not invalid, but will be implicitly transformed into a capitalized module name. I.e. `file.res` will be compiled into the module `File`. To simplify and minimize the disconnect here, the convention is therefore to capitalize file names. - -## Signatures - -A module's type is called a "signature", and can be written explicitly. If a -module is like a `.res` (implementation) file, then a module's signature is like -a `.resi` (interface) file. - -### Creation - -To create a signature, use the `module type` keyword. The signature name must start with a -**capital letter**. Whatever you could place in a `.resi` file, you may place -inside a signature definition's `{}` block. - - - -```res example -/* Picking up previous section's example */ -module type EstablishmentType = { - type profession - let getProfession: profession => string -} -``` - -```js -// Empty output -``` - - - -A signature defines the list of requirements that a module must satisfy in order -for that module to match the signature. Those requirements are of the form: - -- `let x: int` requires a `let` binding named `x`, of type `int`. -- `type t = someType` requires a type field `t` to be equal to `someType`. -- `type t` requires a type field `t`, but without imposing any requirements on the actual, concrete type of `t`. We'd use `t` in other entries in the signature to describe relationships, e.g. `let makePair: t => (t, t)` but we cannot, for example, assume that `t` is an `int`. This gives us great, enforced abstraction abilities. - -To illustrate the various kinds of type entries, consider the above signature -`EstablishmentType` which requires that a module: - -- Declare a type named `profession`. -- Must include a function that takes in a value of the type `profession` and returns a string. - -**Note**: - -Modules of the type `EstablishmentType` can contain more fields than the -signature declares, just like the module `School` in the previous section (if we -choose to assign it the type `EstablishmentType`. Otherwise, `School` exposes -every field). This effectively makes the `person1` field an enforced -implementation detail! Outsiders can't access it, since it's not present in the -signature; the signature **constrained** what others can access. - -The type `EstablishmentType.profession` is **abstract**: it doesn't have a -concrete type; it's saying "I don't care what the actual type is, but it's used -as input to `getProfession`". This is useful to fit many modules under the same -interface: - - - -```res -module Company: EstablishmentType = { - type profession = CEO | Designer | Engineer | ... - - let getProfession = (person) => ... - let person1 = ... - let person2 = ... -} -``` - -```js -function getProfession(person) { - ... -} - -var person1 = ... - -var person2 = ... - -var Company = { - getProfession: getProfession, - person1: person1, - person2: person2 -}; -``` - - - -It's also useful to hide the underlying type as an implementation detail others -can't rely on. If you ask what the type of `Company.profession` is, instead of -exposing the variant, it'll only tell you "it's `Company.profession`". - -### Extending module signatures - -Like modules themselves, module signatures can also be extended by other module signatures using `include`. Again, **heavily discouraged**: - - - -```res example -module type BaseComponent = { - let defaultGreeting: string - let getAudience: (~excited: bool) => string -} - -module type ActualComponent = { - /* the BaseComponent signature is copied over */ - include BaseComponent - let render: unit => string -} -``` - -```js -// Empty output -``` - - - -**Note**: `BaseComponent` is a module **type**, not an actual module itself! - -If you do not have a defined module type, you can extract it from an actual module -using `include (module type of ActualModuleName)`. For example, we can extend the -`List` module from the standard library, which does not define a module -type. - - - -```res example -module type MyList = { - include (module type of List) - let myListFun: list<'a> => list<'a> -} -``` - -```js -// Empty output -``` - - - -### Every `.resi` file is a signature - -Similar to how a `React.res` file implicitly defines a module `React`, a file -`React.resi` implicitly defines a signature for `React`. If `React.resi` isn't -provided, the signature of `React.res` defaults to exposing all the fields of the -module. Because they don't contain implementation files, `.resi` files are used -in the ecosystem to also document the public API of their corresponding modules. - - - -```res example -/* file React.res (implementation. Compiles to module React) */ -type state = int -let render = (str) => str -``` - -```js -function render(str) { - return str; -} -``` - - - -```res sig -/* file React.resi (interface. Compiles to the signature of React.res) */ -type state = int -let render: string => string -``` - -## Module Functions (functors) - -Modules can be passed to functions! It would be the equivalent of passing a file -as a first-class item. However, modules are at a different "layer" of the -language than other common concepts, so we can't pass them to _regular_ -functions. Instead, we pass them to special functions called "functors". - -The syntax for defining and using functors is very much like the syntax -for defining and using regular functions. The primary differences are: - -- Functors use the `module` keyword instead of `let`. -- Functors take modules as arguments and return a module. -- Functors _require_ annotating arguments. -- Functors must start with a capital letter (just like modules/signatures). - -Here's an example `MakeSet` functor, that takes in a module of the type -`Comparable` and returns a new set that can contain such comparable items. - - - -```res prelude -module type Comparable = { - type t - let equal: (t, t) => bool -} - -module MakeSet = (Item: Comparable) => { - // let's use a list as our naive backing data structure - type backingType = list - let empty = list{} - let add = (currentSet: backingType, newItem: Item.t): backingType => - // if item exists - if List.exists(x => Item.equal(x, newItem), currentSet) { - currentSet // return the same (immutable) set (a list really) - } else { - list{ - newItem, - ...currentSet // prepend to the set and return it - } - } -} -``` - -```js -var List = require("./stdlib/list.js"); - -function MakeSet(Item) { - var add = function (currentSet, newItem) { - if ( - List.exists(function (x) { - return Item.equal(x, newItem); - }, currentSet) - ) { - return currentSet; - } else { - return { - hd: newItem, - tl: currentSet, - }; - } - }; - return { - empty: /* [] */ 0, - add: add, - }; -} -``` - - - -Functors can be applied using function application syntax. In this case, we're -creating a set, whose items are pairs of integers. - - - -```res example -module IntPair = { - type t = (int, int) - let equal = ((x1: int, y1: int), (x2, y2)) => x1 == x2 && y1 == y2 - let create = (x, y) => (x, y) -} - -/* IntPair abides by the Comparable signature required by MakeSet */ -module SetOfIntPairs = MakeSet(IntPair) -``` - -```js -function equal(param, param$1) { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } -} - -function create(x, y) { - return [x, y]; -} - -var IntPair = { - equal: equal, - create: create, -}; - -var SetOfIntPairs = { - empty: /* [] */ 0, - add: add, -}; -``` - - - -### Module functions types - -Like with module types, functor types also act to constrain and hide what we may -assume about functors. The syntax for functor types are consistent with those -for function types, but with types capitalized to represent the signatures of -modules the functor accepts as arguments and return values. In the -previous example, we're exposing the backing type of a set; by giving `MakeSet` -a functor signature, we can hide the underlying data structure! - - - -```res -module type Comparable = ... - -module type MakeSetType = (Item: Comparable) => { - type backingType - let empty: backingType - let add: (backingType, Item.t) => backingType -} - -module MakeSet: MakeSetType = (Item: Comparable) => { - ... -} -``` - -```js -// Empty output -``` - - - -## Exotic Module Filenames - -**Since 8.3** - -It is possible to use non-conventional characters in your filenames (which is sometimes needed for specific JS frameworks). Here are some examples: - -- `src/Button.ios.res` -- `pages/[id].res` - -Please note that modules with an exotic filename will not be accessible from other ReScript modules. - -## Tips & Tricks - -Modules and functors are at a different "layer" of language than the rest (functions, let bindings, data structures, etc.). For example, you can't easily pass them into a tuple or record. Use them judiciously, if ever! Lots of times, just a record or a function is enough. diff --git a/pages/docs/manual/v9.0.0/mutation.mdx b/pages/docs/manual/v9.0.0/mutation.mdx deleted file mode 100644 index d7bbf3d03..000000000 --- a/pages/docs/manual/v9.0.0/mutation.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: "Mutation" -description: "Imperative and mutative programming capabilities in ReScript" -canonical: "/docs/manual/latest/mutation" ---- - -# Mutation - -ReScript has great traditional imperative & mutative programming capabilities. You should use these features sparingly, but sometimes they allow your code to be more performant and written in a more familiar pattern. - -## Mutate Let-binding - -Let-bindings are immutable, but you can wrap it with a `ref`, exposed as a record with a single mutable field in the standard library: - - - -```res prelude -let myValue = ref(5) -``` - -```js -var myValue = { - contents: 5, -}; -``` - - - -## Usage - -You can get the actual value of a `ref` box through accessing its `contents` field: - - - -```res example -let five = myValue.contents // 5 -``` - -```js -var five = myValue.contents; -``` - - - -Assign a new value to `myValue` like so: - - - -```res example -myValue.contents = 6 -``` - -```js -myValue.contents = 6; -``` - - - -We provide a syntax sugar for this: - - - -```res example -myValue := 6 -``` - -```js -myValue.contents = 6; -``` - - - -Note that the previous binding `five` stays `5`, since it got the underlying item on the `ref` box, not the `ref` itself. - -**Note**: you might see in the JS output tabs above that `ref` allocates an object. Worry not; local, non-exported `ref`s allocations are optimized away. - -## Tip & Tricks - -Before reaching for `ref`, know that you can achieve lightweight, local "mutations" through [overriding let bindings](let-binding.md#binding-shadowing). diff --git a/pages/docs/manual/v9.0.0/newcomer-examples.mdx b/pages/docs/manual/v9.0.0/newcomer-examples.mdx deleted file mode 100644 index 360c86fab..000000000 --- a/pages/docs/manual/v9.0.0/newcomer-examples.mdx +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: "Newcomer Examples" -description: "Quick examples for users new to ReScript" -canonical: "/docs/manual/latest/newcomer-examples" ---- - -# Newcomer Examples - - - -An example is worth a thousand words. - -This section is dedicated to newcomers trying to figure out general idioms & conventions. If you're a beginner who's got a good idea for an example, please suggest an edit! - -## Use the [`option` type](null-undefined-option.md) - - - -```res example -let possiblyNullValue1 = None -let possiblyNullValue2 = Some("Hello") - -switch possiblyNullValue2 { -| None => Js.log("Nothing to see here.") -| Some(message) => Js.log(message) -} -``` - -```js -var possiblyNullValue1; -var possiblyNullValue2 = "Hello"; - -if (possiblyNullValue2 !== undefined) { - console.log(possiblyNullValue2); -} else { - console.log("Nothing to see here."); -} -``` - - - -## Create a Parametrized Type - - - -```res example -type universityStudent = {gpa: float} - -type response<'studentType> = { - status: int, - student: 'studentType, -} -``` - -```js -// Empty output -``` - - - -## Creating a JS Object - - - -```res example -let student1 = { - "name": "John", - "age": 30, -} -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -Or using [record](record.md): - - - -```res example -type payload = { - name: string, - age: int, -} - -let student1 = { - name: "John", - age: 30, -} -``` - -```js -var student1 = { - name: "John", - age: 30, -}; -``` - - - -## Modeling a JS Module with Default Export - -See [here](import-from-export-to-js.md#import-a-javascript-module-itself-es6-module-format). - -## Checking for JS nullable types using the `option` type - -For a function whose argument is passed a JavaScript value that's potentially `null` or `undefined`, it's idiomatic to convert it to an `option`. The conversion is done through the helper functions in ReScript's [`Js.Nullable`](api/js/nullable#t) module. In this case, `toOption`: - - - -```res example -let greetByName = (possiblyNullName) => { - let optionName = Js.Nullable.toOption(possiblyNullName) - switch optionName { - | None => "Hi" - | Some(name) => "Hello " ++ name - } -} -``` - -```js -function greetByName(possiblyNullName) { - if (possiblyNullName == null) { - return "Hi"; - } else { - return "Hello " + possiblyNullName; - } -} -``` - - - -This check compiles to `possiblyNullName == null` in JS, so checks for the presence of `null` or `undefined`. diff --git a/pages/docs/manual/v9.0.0/null-undefined-option.mdx b/pages/docs/manual/v9.0.0/null-undefined-option.mdx deleted file mode 100644 index 125cc874d..000000000 --- a/pages/docs/manual/v9.0.0/null-undefined-option.mdx +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: "Null, Undefined and Option" -description: "JS interop with nullable and optional values in ReScript" -canonical: "/docs/manual/latest/null-undefined-option" ---- - -# Null, Undefined and Option - -ReScript itself doesn't have the notion of `null` or `undefined`. This is a _great_ thing, as it wipes out an entire category of bugs. No more `undefined is not a function`, and `cannot access someAttribute of undefined`! - -However, the **concept** of a potentially nonexistent value is still useful, and safely exists in our language. - -We represent the existence and nonexistence of a value by wrapping it with the `option` type. Here's its definition from the standard library: - - - -```res example -type option<'a> = None | Some('a) -``` - -```js -// Empty output -``` - - - -It means "a value of type option is either None (representing nothing) or that actual value wrapped in a Some". - -**Note** how the `option` type is just a regular [variant](variant.md). - -## Example - -Here's a normal value: - - - -```res example -let licenseNumber = 5 -``` - -```js -var licenseNumber = 5; -``` - - - -To represent the concept of "maybe null", you'd turn this into an `option` type by wrapping it. For the sake of a more illustrative example, we'll put a condition around it: - - - -```res -let licenseNumber = - if personHasACar { - Some(5) - } else { - None - } -``` - -```js -var licenseNumber = personHasACar ? 5 : undefined; -``` - - - -Later on, when another piece of code receives such value, it'd be forced to handle both cases through [pattern matching](pattern-matching-destructuring.md): - - - -```res -switch licenseNumber { -| None => - Js.log("The person doesn't have a car") -| Some(number) => - Js.log("The person's license number is " ++ Js.Int.toString(number)) -} -``` - -```js -var number = licenseNumber; - -if (number !== undefined) { - console.log("The person's license number is " + number.toString()); -} else { - console.log("The person doesn't have a car"); -} -``` - - - -By turning your ordinary number into an `option` type, and by forcing you to handle the `None` case, the language effectively removed the possibility for you to mishandle, or forget to handle, a conceptual `null` value! **A pure ReScript program doesn't have null errors**. - -## Interoperate with JavaScript `undefined` and `null` - -The `option` type is common enough that we special-case it when compiling to JavaScript: - - - -```res example -let x = Some(5) -``` - -```js -var x = 5; -``` - - - -simply compiles down to `5`, and - - - -```res example -let x = None -``` - -```js -var x; -``` - - - -compiles to `undefined`! If you've got e.g. a string in JavaScript that you know might be `undefined`, type it as `option` and you're done! Likewise, you can send a `Some(5)` or `None` to the JS side and expect it to be interpreted correctly =) - -### Caveat 1 - -The option-to-undefined translation isn't perfect, because on our side, `option` values can be composed: - - - -```res example -let x = Some(Some(Some(5))) -``` - -```js -var x = 5; -``` - - - -This still compiles to `5`, but this gets troublesome: - - - -```res example -let x = Some(None) -``` - -```js -var Caml_option = require("./stdlib/caml_option.js"); - -var x = Caml_option.some(undefined); -``` - -(See output tab). - - - -What's this `Caml_option.some` thing? Why can't this compile to `undefined`? Long story short, when dealing with a polymorphic `option` type (aka `option<'a>`, for any `'a`), many operations become tricky if we don't mark the value with some special annotation. If this doesn't make sense, don't worry; just remember the following rule: - -- **Never, EVER, pass a nested `option` value (e.g. `Some(Some(Some(5)))`) into the JS side.** -- **Never, EVER, annotate a value coming from JS as `option<'a>`. Always give the concrete, non-polymorphic type.** - -### Caveat 2 - -Unfortunately, lots of times, your JavaScript value might be _both_ `null` or `undefined`. In that case, you unfortunately can't type such value as e.g. `option`, since our `option` type only checks for `undefined` and not `null` when dealing with a `None`. - -#### Solution: More Sophisticated `undefined` & `null` Interop - -To solve this, we provide access to more elaborate `null` and `undefined` helpers through the [`Js.Nullable`](api/js/nullable) module. This somewhat works like an `option` type, but is different from it. - -#### Examples - -To create a JS `null`, use the value `Js.Nullable.null`. To create a JS `undefined`, use `Js.Nullable.undefined` (you can naturally use `None` too, but that's not the point here; the `Js.Nullable.*` helpers wouldn't work with it). - -If you're receiving, for example, a JS string that can be `null` and `undefined`, type it as: - - - -```res example -@module("MyConstant") external myId: Js.Nullable.t = "myId" -``` - -```js -// Empty output -``` - - - -To create such a nullable string from our side (presumably to pass it to the JS side, for interop purpose), do: - - - -```res example -@module("MyIdValidator") external validate: Js.Nullable.t => bool = "validate" -let personId: Js.Nullable.t = Js.Nullable.return("abc123") - -let result = validate(personId) -``` - -```js -var MyIdValidator = require("MyIdValidator"); -var personId = "abc123"; -var result = MyIdValidator.validate(personId); -``` - - - -The `return` part "wraps" a string into a nullable string, to make the type system understand and track the fact that, as you pass this value around, it's not just a string, but a string that can be `null` or `undefined`. - -#### Convert to/from `option` - -`Js.Nullable.fromOption` converts from a `option` to `Js.Nullable.t`. `Js.Nullable.toOption` does the opposite. diff --git a/pages/docs/manual/v9.0.0/object.mdx b/pages/docs/manual/v9.0.0/object.mdx deleted file mode 100644 index 419580c25..000000000 --- a/pages/docs/manual/v9.0.0/object.mdx +++ /dev/null @@ -1,167 +0,0 @@ ---- -title: "Object" -description: "Interoping with JS objects in ReScript" -canonical: "/docs/manual/latest/object" ---- - -# Object - -ReScript objects are like [records](record.md), but: - -- No type declaration needed. -- Structural and more polymorphic, [unlike records](record.md#record-types-are-found-by-field-name). -- Doesn't support updates unless the object comes from the JS side. -- Doesn't support [pattern matching](pattern-matching-destructuring.md). - - - -Although ReScript records compile to clean JavaScript objects, ReScript objects are a better candidate for emulating/binding to JS objects, as you'll see. - -## Type Declaration - -**Optional**, unlike for records. The type of an object is inferred from the value, so you never really need to write down its type definition. Nevertheless, here's its type declaration syntax: - - - -```res prelude -type person = { - "age": int, - "name": string -}; -``` - -```js -// Empty output -``` - - - -Visually similar to record type's syntax, with the field names quoted. - - - -## Creation - -To create a new object: - - - -```res example -let me = { - "age": 5, - "name": "Big ReScript" -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -**Note**: as said above, unlike for record, this `me` value does **not** try to find a conforming type declaration with the field `"age"` and `"name"`; rather, the type of `me` is inferred as `{"age": int, "name": string}`. This is convenient, but also means this code passes type checking without errors: - - - -```res -type person = { - "age": int -}; - -let me = { - "age": "hello!" // age is a string. No error. -} -``` - -```js -var me = { - age: "hello!", -}; -``` - - - -Since the type checker doesn't try to match `me` with the type `person`. If you ever want to force an object value to be of a predeclared object type, just annotate the value: - -```res -let me: person = { - "age": "hello!" -} -``` - -Now the type system will error properly. - -## Access - - - -```res -let age = me["age"] -``` - -```js -var age = me["age"]; -``` - - - -## Update - -Disallowed unless the object is a binding that comes from the JavaScript side. In that case, use `=`: - - - -```res example -type student = { - @set "age": int, - @set "name": string, -} -@module("MyJSFile") external student1: student = "student1" - -student1["name"] = "Mary" -``` - -```js -var MyJSFile = require("MyJSFile"); -MyJSFile.student1.name = "Mary"; -``` - - - -## Tips & Tricks - -Since objects don't require type declarations, and since ReScript infers all the types for you, you get to very quickly and easily (and dangerously) bind to any JavaScript API. Check the JS output tab: - - - -```res example -// The type of document is just some random type 'a -// that we won't bother to specify -@val external document: 'a = "document" - -// call a method -document["addEventListener"]("mouseup", _event => { - Js.log("clicked!") -}) - -// get a property -let loc = document["location"] - -// set a property -document["location"]["href"] = "rescript-lang.org" -``` - -```js -document.addEventListener("mouseup", function (_event) { - console.log("clicked!"); -}); -var loc = document.location; -document.location.href = "rescript-lang.org"; -``` - - - -The `external` feature and the usage of this trick are also documented in the [external](external#tips--tricks) section later. It's an excellent way to start writing some ReScript code without worrying about whether bindings to a particular library exists. diff --git a/pages/docs/manual/v9.0.0/overview.mdx b/pages/docs/manual/v9.0.0/overview.mdx deleted file mode 100644 index fbe887ecb..000000000 --- a/pages/docs/manual/v9.0.0/overview.mdx +++ /dev/null @@ -1,243 +0,0 @@ ---- -title: "Overview" -metaTitle: "Language Features Overview" -description: "A quick overview on ReScript's syntax" -canonical: "/docs/manual/latest/overview" ---- - -# Overview - -## Comparison to JS - -### Semicolon - -| JavaScript | ReScript | -| ---------------------------------- | -------------------- | -| Rules enforced by linter/formatter | No semicolon needed! | - -### Comments - -| JavaScript | ReScript | -| ----------------- | -------- | -| `/* Comment */` | Same | -| `// Line comment` | Same | - -### Variable - -| JavaScript | ReScript | -| ----------------------- | ------------------------------------- | -| `const x = 5;` | `let x = 5` | -| `var x = y;` | No equivalent (thankfully) | -| `let x = 5; x = x + 1;` | `let x = ref(5); x := x.contents + 1` | - -### String & Character - -| JavaScript | ReScript | -| ------------------------ | --------------------- | -| `"Hello world!"` | Same | -| `'Hello world!'` | Strings must use `"` | -| `"hello " + "world"` | `"hello " ++ "world"` | -| `` `hello ${message}` `` | Same | - -### Boolean - -| JavaScript | ReScript | -| ------------------------------------ | ---------------------------------------------- | -| `true`, `false` | Same | -| `!true` | Same | -| `\|\|`, `&&`, `<=`, `>=`, `<`, `>` | Same | -| `a === b`, `a !== b` | Same | -| No deep equality (recursive compare) | `a == b`, `a != b` | -| `a == b` | No equality with implicit casting (thankfully) | - -### Number - -| JavaScript | ReScript | -| ----------- | ------------ | -| `3` | Same \* | -| `3.1415` | Same | -| `3 + 4` | Same | -| `3.0 + 4.5` | `3.0 +. 4.5` | -| `5 % 3` | `mod(5, 3)` | - -\* JS has no distinction between integer and float. - -### Object/Record - -| JavaScript | ReScript | -| ------------------- | --------------------------------------- | -| no types | `type point = {x: int, mutable y: int}` | -| `{x: 30, y: 20}` | Same | -| `point.x` | Same | -| `point.y = 30;` | Same | -| `{...point, x: 30}` | Same | - -### Array - -| JavaScript | ReScript | -| ------------------ | --------------------- | -| `[1, 2, 3]` | Same | -| `myArray[1] = 10` | Same | -| `[1, "Bob", true]` | `(1, "Bob", true)` \* | - -\* Heterogenous arrays in JS are disallowed for us. Use tuple instead. - -### Null - -| JavaScript | ReScript | -| ------------------- | --------- | -| `null`, `undefined` | `None` \* | - -\* Again, only a spiritual equivalent; we don't have nulls, nor null bugs! But we do have an `option` type for when you actually need nullability. - -### Function - -| JavaScript | ReScript | -| ------------------------------- | ---------------------------- | -| `arg => retVal` | Same | -| `function named(arg) {...}` | `let named = (arg) => {...}` | -| `const f = function(arg) {...}` | `let f = (arg) => {...}` | -| `add(4, add(5, 6))` | Same | - -### Blocks - - - - - - - - - - - - - - -
JavaScriptReScript
- ``` - const myFun = (x, y) => { - const doubleX = x + x; - const doubleY = y + y; - return doubleX + doubleY; - }; - ``` - - ``` - let myFun = (x, y) => { - let doubleX = x + x - let doubleY = y + y - doubleX + doubleY - } - ``` -
- -### If-else - -| JavaScript | ReScript | -| --------------------- | --------------------------------------------------------------------------------- | -| `if (a) {b} else {c}` | `if a {b} else {c}` \* | -| `a ? b : c` | Same | -| `switch` | `switch` but [super-powered pattern matching!](pattern-matching-destructuring.md) | - -\* Our conditionals are always expressions! You can write `let result = if a {"hello"} else {"bye"}` - -### Destructuring - -| JavaScript | ReScript | -| ----------------------------- | --------------------------------- | -| `const {a, b} = data` | `let {a, b} = data` | -| `const [a, b] = data` | let [a, b] = data \* | -| `const {a: aa, b: bb} = data` | `let {a: aa, b: bb} = data` | - -\* Gives good compiler warning that `data` might not be of length 2. - -### Loop - -| JavaScript | ReScript | -| ------------------------------------- | ---------------------------- | -| `for (let i = 0; i <= 10; i++) {...}` | `for i in 0 to 10 {...}` | -| `for (let i = 10; i >= 0; i--) {...}` | `for i in 10 downto 0 {...}` | -| `while (true) {...}` | `while true {...}` | - -### JSX - -| JavaScript | ReScript | -| ----------------------------------------- | -------------------------- | -| `` | Same | -| `` | `` \* | -| `` | `` | -| No children spread | `...children` | - -\* Argument punning! - -### Exception - -| JavaScript | ReScript | -| ----------------------------------------- | --------------------------------- | -| `throw new SomeError(...)` | `raise(SomeError(...))` | -| `try {a} catch (Err) {...} finally {...}` | `try a catch { \| Err => ...}` \* | - -\* No finally. - -### Blocks - -The last expression of a block delimited by `{}` implicitly returns (including function body). In JavaScript, this can only be simulated via an immediately-invoked function expression (since function bodies have their own local scope). - - - - - - - - - - - - - - -
JavaScriptReScript
- ``` - let result = (function() { - const x = 23; - const y = 34; - return x + y; - })(); - ``` - - ``` - let result = { - let x = 23 - let y = 34 - x + y - } - ``` -
- -## Common Features' JS Output - -| Feature | Example | JavaScript Output | -| ------------------------------- | ------------------------------------ | ------------------------------------------ | -| String | `"Hello"` | `"Hello"` | -| String Interpolation | `` `Hello ${message}` `` | `"Hello " + message` | -| Character (disrecommended) | `'x'` | `120` (char code) | -| Integer | `23`, `-23` | `23`, `-23` | -| Float | `23.0`, `-23.0` | `23.0`, `-23.0` | -| Integer Addition | `23 + 1` | `23 + 1` | -| Float Addition | `23.0 +. 1.0` | `23.0 + 1.0` | -| Integer Division/Multiplication | `2 / 23 * 1` | `2 / 23 * 1` | -| Float Division/Multiplication | `2.0 /. 23.0 *. 1.0` | `2.0 / 23.0 * 1.0` | -| Float Exponentiation | `2.0 ** 3.0` | `Math.pow(2.0, 3.0)` | -| String Concatenation | `"Hello " ++ "World"` | `"Hello " + "World"` | -| Comparison | `>`, `<`, `>=`, `<=` | `>`, `<`, `>=`, `<=` | -| Boolean operation | `!`, `&&`, `\|\|` | `!`, `&&`, `\|\|` | -| Shallow and deep Equality | `===`, `==` | `===`, `==` | -| List (disrecommended) | `list{1, 2, 3}` | `{hd: 1, tl: {hd: 2, tl: {hd: 3, tl: 0}}}` | -| List Prepend | `list{a1, a2, ...oldList}` | `{hd: a1, tl: {hd: a2, tl: theRest}}` | -| Array | `[1, 2, 3]` | `[1, 2, 3]` | -| Record | `type t = {b: int}; let a = {b: 10}` | `var a = {b: 10}` | -| Multiline Comment | `/* Comment here */` | Not in output | -| Single line Comment | `// Comment here` | Not in output | - -_Note that this is a cleaned-up comparison table; a few examples' JavaScript output are slightly different in reality._ diff --git a/pages/docs/manual/v9.0.0/pattern-matching-destructuring.mdx b/pages/docs/manual/v9.0.0/pattern-matching-destructuring.mdx deleted file mode 100644 index e20f4d36e..000000000 --- a/pages/docs/manual/v9.0.0/pattern-matching-destructuring.mdx +++ /dev/null @@ -1,901 +0,0 @@ ---- -title: "Pattern Matching / Destructuring" -description: "Pattern matching and destructuring complex data structures in ReScript" -canonical: "/docs/manual/latest/pattern-matching-destructuring" ---- - -# Pattern Matching / Destructuring - -One of ReScript's **best** feature is our pattern matching. Pattern matching combines 3 brilliant features into one: - -- Destructuring. -- `switch` based on shape of data. -- Exhaustiveness check. - -We'll dive into each aspect below. - -## Destructuring - -Even JavaScript has destructuring, which is "opening up" a data structure to extract the parts we want and assign variable names to them: - - - -```res example -let coordinates = (10, 20, 30) -let (x, _, _) = coordinates -Js.log(x) // 10 -``` - -```js -var coordinates = [10, 20, 30]; -var x = 10; -console.log(10); -``` - - - -Destructuring works with most built-in data structures: - - - -```res -// Record -type student = {name: string, age: int} -let student1 = {name: "John", age: 10} -let {name} = student1 // "John" assigned to `name` - -// Variant -type result = - | Success(string) -let myResult = Success("You did it!") -let Success(message) = myResult // "You did it!" assigned to `message` -``` - -```js -var student1 = { - name: "John", - age: 10, -}; -var name = "John"; - -var myResult = /* Success */ { - _0: "You did it!", -}; -var message = "You did it!"; - -var myArray = [1, 2, 3]; -if (myArray.length !== 2) { - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 14, 4], - Error: new Error(), - }; -} -var item1 = myArray[0]; -var item2 = myArray[1]; - -var myList = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */ 0, - }, - }, -}; -// ... -``` - - - -You can also use destructuring anywhere you'd usually put a binding: - - - -```res example -type result = - | Success(string) -let displayMessage = (Success(m)) => { - // we've directly extracted the success message - // string by destructuring the parameter - Js.log(m) -} -displayMessage(Success("You did it!")) -``` - -```js -function displayMessage(m) { - console.log(m._0); -} - -displayMessage( - /* Success */ { - _0: "You did it!", - }, -); -``` - - - -For a record, you can rename the field while destructuring: - - - -```res -let {name: n} = student1 // "John" assigned to `n` -``` - -```js -var n = "John"; -``` - - - -You _can_ in theory destructure array and list at the top level too: - -```res -let myArray = [1, 2, 3] -let [item1, item2, _] = myArray -// 1 assigned to `item1`, 2 assigned to `item2`, 3rd item ignored - -let myList = list{1, 2, 3} -let list{head, ...tail} = myList -// 1 assigned to `head`, `list{2, 3}` assigned to tail -``` - -But the array example is **highly disrecommended** (use tuple instead) and the list example will error on you. They're only there for completeness' sake. As you'll see below, the proper way of using destructuring array and list is using `switch`. - -## `switch` Based on Shape of Data - -While the destructuring aspect of pattern matching is nice, it doesn't really change the way you think about structuring your code. One paradigm-changing way of thinking about your code is to execute some code based on the shape of the data. - -Consider a variant: - - - -```res prelude -type payload = - | BadResult(int) - | GoodResult(string) - | NoResult -``` - -```js -// Empty output -``` - - - -We'd like to handle each of the 3 cases differently. For example, print a success message if the value is `GoodResult(...)`, do something else when the value is `NoResult`, etc. - -In other languages, you'd end up with a series of if-elses that are hard to read and error-prone. In ReScript, you can instead use the supercharged `switch` pattern matching facility to destructure the value while calling the right code based on what you destructured: - - - -```res example -let data = GoodResult("Product shipped!") -switch data { -| GoodResult(theMessage) => - Js.log("Success! " ++ theMessage) -| BadResult(errorCode) => - Js.log("Something's wrong. The error code is: " ++ Js.Int.toString(errorCode)) -| NoResult => - Js.log("Bah.") -} -``` - -```js -var data = { - TAG: /* GoodResult */ 1, - _0: "Product shipped!", -}; - -if (typeof data === "number") { - console.log("Bah."); -} else if (data.TAG === /* BadResult */ 0) { - console.log( - "Something's wrong. The error code is: " + "Product shipped!".toString(), - ); -} else { - console.log("Success! Product shipped!"); -} -``` - - - -In this case, `message` will have the value `"Success! Product shipped!"`. - -Suddenly, your if-elses that messily checks some structure of the value got turned into a clean, compiler-verified, linear list of code to execute based on exactly the shape of the value. - -### Complex Examples - -Here's a real-world scenario that'd be a headache to code in other languages. Given this data structure: - - - -```res prelude -type status = Vacations(int) | Sabbatical(int) | Sick | Present -type reportCard = {passing: bool, gpa: float} -type person = - | Teacher({ - name: string, - age: int, - }) - | Student({ - name: string, - status: status, - reportCard: reportCard, - }) -``` - -```js -// Empty output -``` - - - -Imagine this requirement: - -- Informally greet a person who's a teacher and if his name is Mary or Joe. -- Greet other teachers formally. -- If the person's a student, congratulate him/her score if they passed the semester. -- If the student has a gpa of 0 and is on vacations or sabbatical, display a different message. -- A catch-all message for a student. - -ReScript can do this easily! - - - -```res prelude -let person1 = Teacher({name: "Jane", age: 35}) - -let message = switch person1 { -| Teacher({name: "Mary" | "Joe"}) => - `Hey, still going to the party on Saturday?` -| Teacher({name}) => - // 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!` -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - `Come back in ${Js.Int.toString(daysLeft)} days!` -| Student({status: Sick}) => - `How are you feeling?` -| Student({name}) => - `Good luck next semester ${name}!` -} -``` - -```js -var person1 = { - TAG: /* Teacher */ 0, - name: "Jane", - age: 35, -}; - -var message; - -if (person1.TAG) { - var match$1 = person1.status; - var name = person1.name; - var match$2 = person1.reportCard; - message = match$2.passing - ? "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!" - : typeof match$1 === "number" - ? match$1 !== 0 - ? "Good luck next semester " + name + "!" - : "How are you feeling?" - : person1.reportCard.gpa !== 0.0 - ? "Good luck next semester " + name + "!" - : "Come back in " + match$1._0.toString() + " days!"; -} else { - var name$1 = person1.name; - switch (name$1) { - case "Joe": - case "Mary": - message = "Hey, still going to the party on Saturday?"; - break; - default: - message = "Hello " + name$1 + "."; - } -} -``` - - - -**Note** how we've: - -- drilled deep down into the value concisely -- using a **nested pattern check** `"Mary" | "Joe"` and `Vacations | Sabbatical` -- while extracting the `daysLeft` number from the latter case -- and assigned the greeting to the binding `message`. - -Here's another example of pattern matching, this time on an inline tuple. - - - -```res -type animal = Dog | Cat | Bird -let categoryId = switch (isBig, myAnimal) { -| (true, Dog) => 1 -| (true, Cat) => 2 -| (true, Bird) => 3 -| (false, Dog | Cat) => 4 -| (false, Bird) => 5 -} -``` - -```js -var categoryId = isBig ? (myAnimal + 1) | 0 : myAnimal >= 2 ? 5 : 4; -``` - - - -**Note** how pattern matching on a tuple is equivalent to a 2D table: - -| isBig \ myAnimal | Dog | Cat | Bird | -| ---------------- | --- | --- | ---- | -| true | 1 | 2 | 3 | -| false | 4 | 4 | 5 | - -### Fall-Through Patterns - -The nested pattern check, demonstrated in the earlier `person` example, also works at the top level of a `switch`: - - - -```res prelude -let myStatus = Vacations(10) - -switch myStatus { -| Vacations(days) -| Sabbatical(days) => Js.log(`Come back in ${Js.Int.toString(days)} days!`) -| Sick -| Present => Js.log("Hey! How are you?") -} -``` - -```js -var myStatus = { - TAG: /* Vacations */ 0, - _0: 10, -}; - -if (typeof myStatus === "number") { - console.log("Hey! How are you?"); -} else { - console.log("Come back in " + (10).toString() + " days!"); -} -``` - - - -Having multiple cases fall into the same handling can clean up certain types of logic. - -### Ignore Part of a Value - -If you have a value like `Teacher(payload)` where you just want to pattern match on the `Teacher` part and ignore the `payload` completely, you can use the `_` wildcard like this: - - - -```res example -switch person1 { -| Teacher(_) => Js.log("Hi teacher") -| Student(_) => Js.log("Hey student") -} -``` - -```js -if (person1.TAG) { - console.log("Hey student"); -} else { - console.log("Hi teacher"); -} -``` - - - -`_` also works at the top level of the `switch`, serving as a catch-all condition: - - - -```res example -switch myStatus { -| Vacations(_) => Js.log("Have fun!") -| _ => Js.log("Ok.") -} -``` - -```js -if (typeof myStatus === "number" || myStatus.TAG) { - console.log("Ok."); -} else { - console.log("Have fun!"); -} -``` - - - -**Do not** abuse a top-level catch-all condition. Instead, prefer writing out all the cases: - - - -```res example -switch myStatus { -| Vacations(_) => Js.log("Have fun!") -| Sabbatical(_) | Sick | Present => Js.log("Ok.") -} -``` - -```js -if (typeof myStatus === "number" || myStatus.TAG) { - console.log("Ok."); -} else { - console.log("Have fun!"); -} -``` - - - -Slightly more verbose, but a one-time writing effort. This helps when you add a new variant case e.g. `Quarantined` to the `status` type and need to update the places that pattern match on it. A top-level wildcard here would have accidentally and silently continued working, potentially causing bugs. - -### If Clause - -Sometime, you want to check more than the shape of a value. You want to also run some arbitrary check on it. You might be tempted to write this: - - - -```res example -switch person1 { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) => - if gpa < 0.5 { - Js.log("What's happening") - } else { - Js.log("Heyo") - } -} -``` - -```js -if (person1.TAG) { - if (person1.reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -`switch` patterns support a shortcut for the arbitrary `if` check, to keep your pattern linear-looking: - - - -```res example -switch person1 { -| Teacher(_) => () // do nothing -| Student({reportCard: {gpa}}) if gpa < 0.5 => - Js.log("What's happening") -| Student(_) => - // fall-through, catch-all case - Js.log("Heyo") -} -``` - -```js -if (person1.TAG) { - if (person1.reportCard.gpa < 0.5) { - console.log("What's happening"); - } else { - console.log("Heyo"); - } -} -``` - - - -**Note:** In ReScript version < 9.0, the `if` clause is denoted as a `when`, but will be reformatted to `if` in newer versions. - -### Match on Exceptions - -If the function throws an exception (covered later), you can also match on _that_, in addition to the function's normally returned values. - - - -```res -switch List.find(i => i === theItem, myItems) { -| item => Js.log(item) -| exception Not_found => Js.log("No such item found!") -} -``` - -```js -var exit = 0; - -var item; - -try { - item = List.find(function (i) { - return i === theItem; - }, myItems); - exit = 1; -} catch (raw_exn) { - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - console.log("No such item found!"); - } else { - throw exn; - } -} - -if (exit === 1) { - console.log(item); -} -``` - - - -### Match on Array - - - -```res example -let students = ["Jane", "Harvey", "Patrick"] -switch students { -| [] => Js.log("There are no students") -| [student1] => - Js.log("There's a single student here: " ++ student1) -| manyStudents => - // display the array of names - Js.log2("The students are: ", manyStudents) -} -``` - -```js -var students = ["Jane", "Harvey", "Patrick"]; - -var len = students.length; - -if (len !== 1) { - if (len !== 0) { - console.log("The students are: ", students); - } else { - console.log("There are no students"); - } -} else { - var student1 = students[0]; - console.log("There's a single student here: " + student1); -} -``` - - - -### Match on List - -Pattern matching on list is similar to array, but with the extra feature of extracting the tail of a list (all elements except the first one): - - - -```res example -let rec printStudents = (students) => { - switch students { - | list{} => () // done - | list{student} => Js.log("Last student: " ++ student) - | list{student1, ...otherStudents} => - Js.log(student1) - printStudents(otherStudents) - } -} -printStudents(list{"Jane", "Harvey", "Patrick"}) -``` - -```js -function printStudents(_students) { - while (true) { - var students = _students; - if (!students) { - return; - } - var otherStudents = students.tl; - var student = students.hd; - if (otherStudents) { - console.log(student); - _students = otherStudents; - continue; - } - console.log("Last student: " + student); - return; - } -} - -printStudents({ - hd: "Jane", - tl: { - hd: "Harvey", - tl: { - hd: "Patrick", - tl: /* [] */ 0, - }, - }, -}); -``` - - - -### Small Pitfall - -**Note**: you can only pass literals (i.e. concrete values) as a pattern, not let-binding names or other things. The following doesn't work as expected: - - - -```res example -let coordinates = (10, 20, 30) -let centerY = 20 -switch coordinates { -| (x, centerY, _) => Js.log(x) -} -``` - -```js -var coordinates = [10, 20, 30]; -var centerY = 20; - -console.log(10); -``` - - - -A first time ReScript user might accidentally write that code, assuming that it's matching on `coordinates` when the second value is of the same value as `centerY`. In reality, this is interpreted as matching on coordinates and assigning the second value of the tuple to the name `centerY`, which isn't what's intended. - -## Exhaustiveness Check - -As if the above features aren't enough, ReScript also provides arguably the most important pattern matching feature: **compile-time check of missing patterns**. - -Let's revisit one of the above examples: - - - -```res -let message = switch person1 { -| Teacher({name: "Mary" | "Joe"}) => - `Hey, still going to the party on Saturday?` -| Student({name, reportCard: {passing: true, gpa}}) => - `Congrats ${name}, nice GPA of ${Js.Float.toString(gpa)} you got there!` -| Student({ - reportCard: {gpa: 0.0}, - status: Vacations(daysLeft) | Sabbatical(daysLeft) - }) => - `Come back in ${Js.Int.toString(daysLeft)} days!` -| Student({status: Sick}) => - `How are you feeling?` -| Student({name}) => - `Good luck next semester ${name}!` -} -``` - -```js -if (person1.TAG) { - var match$1 = person1.status; - var name = person1.name; - var match$2 = person1.reportCard; - if (match$2.passing) { - "Congrats " + - name + - ", nice GPA of " + - match$2.gpa.toString() + - " you got there!"; - } else if (typeof match$1 === "number") { - if (match$1 !== 0) { - "Good luck next semester " + name + "!"; - } else { - ("How are you feeling?"); - } - } else if (person1.reportCard.gpa !== 0.0) { - "Good luck next semester " + name + "!"; - } else { - "Come back in " + match$1._0.toString() + " days!"; - } -} else { - switch (person1.name) { - case "Joe": - case "Mary": - break; - default: - throw { - RE_EXN_ID: "Match_failure", - _1: ["playground.res", 13, 0], - Error: new Error(), - }; - } -} -``` - - - -Did you see what we removed? This time, we've omitted the handling of the case where `person1` is `Teacher({name})` when `name` isn't Mary or Joe. - -Failing to handle every scenario of a value likely constitutes the majority of program bugs out there. This happens very often when you refactor a piece of code someone else wrote. Fortunately for ReScript, the compiler will tell you so: - -``` -Warning 8: this pattern-matching is not exhaustive. -Here is an example of a value that is not matched: -Some({name: ""}) -``` - -**BAM**! You've just erased an entire category of important bugs before you even ran the code. In fact, this is how most of nullable values is handled: - - - -```res example -let myNullableValue = Some(5) - -switch myNullableValue { -| Some(v) => Js.log("value is present") -| None => Js.log("value is absent") -} -``` - -```js -var myNullableValue = 5; - -if (myNullableValue !== undefined) { - console.log("value is present"); -} else { - console.log("value is absent"); -} -``` - - - -If you don't handle the `None` case, the compiler warns. No more `undefined` bugs in your code! - -## Conclusion & Tips & Tricks - -Hopefully you can see how pattern matching is a game changer for writing correct code, through the concise destructuring syntax, the proper conditions handling of `switch`, and the static exhaustiveness check. - -Here are some advices. - -Do not abuse the wildcard `_` too much. This prevents the compiler from giving you better exhaustiveness check, which would be especially important after a refactoring where you add a new case to a variant. Try only using `_` against infinite possibilities, e.g. string, int, etc. - -Use `when` clause sparingly. - -**Flatten your pattern-match whenever you can**. This is a real bug remover. Here's a series of examples, from worst to best: - - - -```res example -let optionBoolToBool = opt => { - if opt == None { - false - } else if opt === Some(true) { - true - } else { - false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt === undefined) { - return false; - } else { - return opt === true; - } -} -``` - - - -Now that's just silly =). Let's turn it into pattern-matching: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | None => false - | Some(a) => a ? true : false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Slightly better, but still nested. Pattern-matching allows you to do this: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | None => false - | Some(true) => true - | Some(false) => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Much more linear-looking! Now, you might be tempted to do this: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | Some(true) => true - | _ => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined && opt) { - return true; - } else { - return false; - } -} -``` - - - -Which is much more concise, but kills the exhaustiveness check mentioned above; refrain from using that. This is the best: - - - -```res example -let optionBoolToBool = opt => { - switch opt { - | Some(trueOrFalse) => trueOrFalse - | None => false - } -} -``` - -```js -function optionBoolToBool(opt) { - if (opt !== undefined) { - return opt; - } else { - return false; - } -} -``` - - - -Pretty darn hard to make a mistake in this code at this point! Whenever you'd like to use an if-else with many branches, prefer pattern matching instead. It's more concise and [performant](variant#design-decisions) too. diff --git a/pages/docs/manual/v9.0.0/pipe.mdx b/pages/docs/manual/v9.0.0/pipe.mdx deleted file mode 100644 index 9b98d1d25..000000000 --- a/pages/docs/manual/v9.0.0/pipe.mdx +++ /dev/null @@ -1,261 +0,0 @@ ---- -title: "Pipe" -description: "The Pipe operator (->)" -canonical: "/docs/manual/latest/pipe" ---- - -# Pipe - -ReScript provides a tiny but surprisingly useful operator `->`, called the "pipe", that allows you to "flip" your code inside-out. `a(b)` becomes `b->a`. It's a simple piece of syntax that doesn't have any runtime cost. - -Why would you use it? Imagine you have the following: - - - -```res -validateAge(getAge(parseData(person))) -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -This is slightly hard to read, since you need to read the code from the innermost part, to the outer parts. Use pipe to streamline it: - - - -```res -person - ->parseData - ->getAge - ->validateAge -``` - -```js -validateAge(getAge(parseData(person))); -``` - - - -Basically, `parseData(person)` is transformed into `person->parseData`, and `getAge(person->parseData)` is transformed into `person->parseData->getAge`, etc. - -**This works when the function takes more than one argument too**. - - - -```res -a(one, two, three) -``` - -```js -a(one, two, three); -``` - - - -is the same as - - - -```res -one->a(two, three) -``` - -```js -a(one, two, three); -``` - - - -This also works with labeled arguments. - -Pipes are used to emulate object-oriented programming, e.g. what's `myStudent.getName` in other languages like Java would be `myStudent->getName` in ReScript (aka `getName(myStudent)`). This allows us to have the readability of the good parts of OOP without its downside of dragging in a huge class system just to call a function on a piece of data. - -## Tips & Tricks - -Do **not** to abuse pipes; they're a means to an end. Inexperienced engineers sometimes shape a library's API to take advantage of the pipe. This is backward. - -## JS Method Chaining - -_This section requires understanding of [our binding API](bind-to-js-function.md#object-method)_. - -JavaScript's APIs are often attached to objects, and often chainable, like so: - -```js -const result = [1, 2, 3].map((a) => a + 1).filter((a) => a % 2 === 0); - -asyncRequest().setWaitDuration(4000).send(); -``` - -Assuming we don't need the chaining behavior above, we'd bind to each case this using `bs.send` from the aforementioned binding API page: - - - -```res prelude -@bs.send external map: (array<'a>, 'a => 'b) => array<'b> = "map" -@bs.send external filter: (array<'a>, 'a => bool) => array<'a> = "filter" - -type request -@bs.val external asyncRequest: unit => request = "asyncRequest" -@bs.send external setWaitDuration: (request, int) => request = "setWaitDuration" -@bs.send external send: request => unit = "send" -``` - -```js -// Empty output -``` - - - -You'd use them like this: - - - -```res example -let result = Js.Array2.filter( - Js.Array2.map([1, 2, 3], a => a + 1), - a => mod(a, 2) == 0 -) - -send(setWaitDuration(asyncRequest(), 4000)) -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -This looks much worse than the JS counterpart! Clean it up visually with pipe: - - - -```res example -let result = [1, 2, 3] - ->map(a => a + 1) - ->filter(a => mod(a, 2) == 0) - -asyncRequest()->setWaitDuration(4000)->send -``` - -```js -var result = [1, 2, 3] - .map(function (a) { - return (a + 1) | 0; - }) - .filter(function (a) { - return a % 2 === 0; - }); - -asyncRequest().setWaitDuration(4000).send(); -``` - - - -## Pipe Into Variants - -You can pipe into a variant's constructor as if it was a function: - - - -```res -let result = name->preprocess->Some -``` - -```js -var result = preprocess(name); -``` - - - -We turn this into: - - - -```res -let result = Some(preprocess(name)) -``` - -```js -var result = preprocess(name); -``` - - - -**Note** that using a variant constructor as a function wouldn't work anywhere else beside here. - -## Pipe Placeholders - -A placeholder is written as an underscore and it tells ReScript that you want to fill in an argument of a function later. These two have equivalent meaning: - -```res -let addTo7 = (x) => add3(3, x, 4) -let addTo7 = add3(3, _, 4) -``` - -Sometimes you don't want to pipe the value you have into the first position. In these cases you can mark a placeholder value to show which argument you would like to pipe into. - -Let's say you have a function `namePerson`, which takes a `person` then a `name` argument. If you are transforming a person then pipe will work as-is: - - - -```res -makePerson(~age=47, ()) - ->namePerson("Jane") -``` - -```js -namePerson(makePerson(47), "Jane"); -``` - - - -If you have a name that you want to apply to a person object, you can use a placeholder: - - - -```res -getName(input) - ->namePerson(personDetails, _) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -This allows you to pipe into any positional argument. It also works for named arguments: - - - -```res -getName(input) - ->namePerson(~person=personDetails, ~name=_) -``` - -```js -var __x = getName(input); -namePerson(personDetails, __x); -``` - - - -## Triangle Pipe (Deprecated) - -You might see usages of another pipe, `|>`, in some codebases. These are deprecated. - -Unlike `->` pipe, the `|>` pipe puts the subject as the last (not first) argument of the function. `a |> f(b)` turns into `f(b, a)`. - -For a more thorough discussion on the rationale and differences between the two operators, please refer to the [Data-first and Data-last comparison by Javier Chávarri](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/) diff --git a/pages/docs/manual/v9.0.0/polymorphic-variant.mdx b/pages/docs/manual/v9.0.0/polymorphic-variant.mdx deleted file mode 100644 index 9b2962d4a..000000000 --- a/pages/docs/manual/v9.0.0/polymorphic-variant.mdx +++ /dev/null @@ -1,449 +0,0 @@ ---- -title: "Polymorphic Variant" -description: "The Polymorphic Variant data structure in ReScript" -canonical: "/docs/manual/latest/polymorphic-variant" ---- - -# Polymorphic Variant - -Now that we know what [variant types](./variant) are, let's dive into a more specific version, so called polymorphic variants (or poly variants). - -First off, here are some key features: - -- Poly variants are structurally typed, which means they don't require any explicit type definition to be used as a value, and are not coupled to any specific module. The compiler will infer the type on demand, and compare poly variants by their value, instead of their type name (which would be called nominal typing). -- They allow easier JavaScript interop (compile to strings / objects with predictable `NAME` and `VAL` attribute) and don't need explicit runtime conversions, unlike common variants. -- Due to their structural nature, poly variant types may cause tricky type checking errors when types don't match up. - -## Basics - -Here is how you'd construct a poly variant value: - - - -```res -// Note how a poly variant starts with a hashtag (#) -// We also don't need any explicit type definition -let myColor = #Red -``` - -```js -var myColor = "Red"; -``` - - - -This is how you'd define a closed poly variant type with an exact set of constructors: - -```res -// Note the surrounding square brackets, and # for constructors -type color = [ #Red | #Green | #Blue ] -``` - -We can also use poly variant types in annotations without an explicit type definition: - - - -```res -let render = (color: [#Red | #Green | #Blue]) => { - switch(color) { - | _ => Js.log("...") - } -} - -let color: [#Red] = #Red -``` - -```js -function render(color) { - console.log("..."); -} - -var color = "Red"; -``` - - - -### Constructor Names - -Poly variant constructor names are less restrictive than in common variants (e.g. they don't need to be capitalized): - - - -```res -type users = [ #admin | #moderator | #user ] - -let admin = #admin -``` - -```js -var admin = "admin"; -``` - - - -In rare cases (mostly for JS interop reasons), it's also possible to define "invalid identifiers", such as hypens or numbers: - - - -```res -type numbers = [#"1" | #"2"] -let one = #"1" -let oneA = #"1a" -``` - -```js -var one = "1"; -var oneA = "1a"; -``` - - - -**Note:** For ReScript versions < 9.0 you'll need to use the `\` character as an escape sequence to represent invalid identifiers (e.g. `#\"1"`). - -### Constructor Arguments - -This is equivalent to what we've [already learned](variant#constructor-arguments) with common variants: - - - -```res -type account = [ - | #Anonymous - | #Instagram(string) - | #Facebook(string, int) -] - -let acc: account = #Instagram("test") -``` - -```js -var acc = { - NAME: "Instagram", - VAL: "test", -}; -``` - - - -### Compose and Pattern Match Poly Variants - -You can use poly variant types within other poly variant types to create a sum of all constructors: - - - -```res -type red = [#Ruby | #Redwood | #Rust] -type blue = [#Sapphire | #Neon | #Navy] - -// Contains all constructors of red and blue. -// Also adds #Papayawhip -type color = [red | blue | #Papayawhip] - -let c: color = #Ruby -``` - -```js -var c = "Ruby"; -``` - - - -There's also some special [pattern matching](./pattern-matching-destructuring) syntax to match on constructors defined in a specific poly variant type: - - - -```res -// Continuing the previous example above... - -switch #Papayawhip { -| #...blue => Js.log("This is a blue color") -| #...red => Js.log("This is a red color") -| other => Js.log2("Other color than red and blue: ", other) -} -``` - -```js -// This code got heavily optimized due to the usage of -// constant values in a switch expression -console.log("Other color than red and blue: ", "Papayawhip"); - -var c = "Ruby"; -``` - - - -The `switch` expression above is a shorter and more convenient version of: - -```res -switch #Papayawhip { - | #Sapphire | #Neon | #Navy => Js.log("This is a blue color") - | #Ruby | #Redwood | #Rust => Js.log("This is a red color") - | other => Js.log2("Other color than red and blue: ", other) -} -``` - -### Recursive Type Definitions - -Poly variant types are non-recursive by default. Use the `rec` keyword to allow recursion: - - - -```res -type rec markdown = [ - | #Text(string) - | #Paragraph(markdown) - | #Ul(array) -] - -let content: markdown = #Paragraph(#Text("hello world")) -``` - -```js -var content = { - NAME: "Paragraph", - VAL: { - NAME: "Text", - VAL: "hello world", - }, -}; -``` - - - -### Annotations with Closed / Upper / Lower Bound Constraints - -There's also a way to define an "upper" and "lower" bound constraint for a poly variant type. Here is what it looks like in a type annotation: - -```res -// Only #Red allowed, no upper / lower bound (closed poly variant) -let basic: [#Red] = #Red - -// May contain #Red, or any other value (open poly variant) -// here, foreground will actually be inferred as [> #Red | #Green] -let foreground: [> #Red] = #Green - -// The value must be "one of" #Red | #Blue -// Only #Red and #Blue are valid values -let background: [< #Red | #Blue] = #Red -``` - -Don't worry about the upper / lower bound feature just yet, since this is a very advanced topic that's often not really needed. For the sake of completeness, we mention a few details about it [later on](#lower--upper-bound-constraints). - -## Polymorphic Variants are Structurally Typed - -As we've already seen in the section above, poly variants don't need any explicit type definition to be used as a value. - -The compiler treats every value as an independent type and doesn't couple it to any particular module (like with common variants). It therefore compares different poly variant types by their structure, not by a defined type name. - -Here is what the type checker sees whenever you are using a poly variant: - -```res -// inferred as [> #Red] -let color = #Red -``` - -The compiler will automatically infer the `color` binding as a value of type `[> #Red]`, which means `color` will type check with any other poly variant type that defines `#Red` in its constructors. - -You can interchangably use variant values from different modules and types as long as a value is part of a constructor set. For example: - -```res -type rgb = [#Red | #Green | #Blue] - -let colors: array = [#Red] - -// `other` is inferred as a type of array<[> #Green]> -let other = [#Green] - -// Because `other` is of type `array<[> Green]>`, -// this will type check even though we didn't define -// `other`to be of type rgb -let all = Belt.Array.concat(colors, other) -``` - -As you can see in the example above, the type checker doesn't really care about the fact that `other` is not annotated as an `array` type. - -As soon as it hits the first constraint (`Belt.Array.concat`), it will try to check if the structural types of `colors` and `other` unify into one poly variant type. If there's a mismatch, you will get an error on the `Belt.Array.concat` call. - -**Be aware that this behavior may cause confusing type errors in the wrong source code locations!** - -For instance, if we'd make a typo like this: - -```res -// Note the typo in the #Green constructor -let other = [#GreeN] - -let all = Belt.Array.concat(colors, other) -``` - -We'd get an error on the `concat` call, even thought the error was actually caused by the typo in the value assignment of `other`. - -## JavaScript Output - -Poly variants are a [shared data structure](./shared-data-types), so they are very useful to bind to JavaScript. It is safe to rely on its compiled JS structure. - -A value compiles to the following JavaScript output: - -- If the variant value is a constructor without any payload, it compiles to a string of the same name -- Values with a payload get compiled to an object with a `NAME` attribute stating the name of the constructor, and a `VAL` attribute containing the JS representation of the payload. - -Check the output in these examples: - - - -```res example -let capitalized = #Hello -let lowercased = #goodbye - -let err = #error("oops!") - -let num = #\"1" -``` - -```js -var capitalized = "Hello"; - -var lowercased = "goodbye"; - -var err = { - NAME: "error", - VAL: "oops!", -}; - -var num = "1"; -``` - - - -### Bind to JS Functions - -Poly variants play an important role for binding to functions in JavaScript. - -For example, let's assume we want to bind to `Intl.NumberFormat` and want to make sure that our users only pass valid locales, we could define an external binding like this: - -```res -// IntlNumberFormat.res -type t - -@bs.val -external make: ([#\"de-DE" | #\"en-GB" | #\"en-US" ]) => t = "Intl.NumberFormat" -``` - -We could later use our newly created bindings like this: - - - -```res -// MyApp.res - -let intl = IntlNumberFormat.make(#\"de-DE") -``` - -```js -var intl = Intl.NumberFormat("de-DE"); -``` - - - -The JS Output is practically identical to handwritten JS, but we also get to enjoy all the benefits of a variant. - -More usage examples for poly variant interop can be found in [Bind to JS Function](bind-to-js-function#constrain-arguments-better) and [Generate Converters and Helper](generate-converters-accessors#generate-converters-for-js-string-enums-and-polymorphic-variants). - -### Bind to String Enums - -Let's assume we have a TypeScript module that expresses following (stringly typed) enum export: - -```js -// direction.js -enum Direction { - Up = "UP", - Down = "DOWN", - Left = "LEFT", - Right = "RIGHT", -} - -export const myDirection = Direction.Up -``` - -For this particular example, we can also inline poly variant type definitions to design the type for the imported `myDirection` value: - - - -```res -type direction = [ #UP | #DOWN | #LEFT | #RIGHT ] -@bs.module("./direction.js") external myDirection: direction = "myDirection" -``` - -```js -var DirectionJs = require("./direction.js"); - -var myDirection = DirectionJs.myDirection; -``` - - - -Again: since we were using poly variants, the JS Output is practically zero-cost and doesn't add any extra code! - -## Lower / Upper Bound Constraints - -There are a few different ways to define constraints on a poly variant type, such as `[>`, `[<` and `[`. Some of them were briefly mentioned before, so in this section we will quickly explain what this syntax is about. - -**Note:** We added this info for educational purposes. In most cases you will not want to use any of this stuff, since it makes your APIs pretty unreadable / hard to use. - -### Closed (`[`) - -This is the simplest poly variant definition, and also the most practical one. Like a common variant type, this one defines an exact set of constructors. - -```res -type rgb = [ #Red | #Green | #Blue ] - -let color: rgb = #Green -``` - -In the example above, `color` will only allow one of the three constructors that are defined in the `rgb` type. This is usually the way how poly variants should be defined. - -In case you want to define a type that is extensible in polymorphic ways (or in other words, subtyping allowed sets of constructors), you'll need to use the lower / upper bound syntax. - -### Lower Bound (`[>`) - -A lower bound defines the minimum set of constructors a poly variant type is aware of. It is also considered an "open poly variant type", because it doesn't restrict any additional values. - -Here is an example on how to make a minimum set of `basicBlueTones` extensible for a new `color` type: - -```res -type basicBlueTone<'a> = [> #Blue | #DeepBlue | #LightBlue ] as 'a -type color = basicBlueTone<[#Blue | #DeepBlue | #LightBlue | #Purple]> - -let color: color = #Purple - -// This will fail due to missing minimum constructors: -type notWorking = basicBlueTone<[#Purple]> -``` - -Here, the compiler will enforce the user to define `#Blue | #DeepBlue | #LightBlue` as the minimum set of constructors when trying to extend `basicBlueTone<'a>`. - -**Note:** Since we want to define an extensible poly variant, we need to provide a type placeholder `<'a>`, and also add `as 'a` after the poly variant declaration, which essentially means: "Given type `'a` is constraint to the minimum set of constructors (`#Blue | #DeepBlue | #LightBlue`) defined in `basicBlueTone`". - -### Upper Bound (`[<`) - -The upper bound works in the opposite way than a lower bound: the extending type may only use constructors that are stated in the upper bound constraint. - -Here another example, but with red colors: - -```res -type validRed<'a> = [< #Fire | #Crimson | #Ash] as 'a -type myReds = validRed<[#Ash]> - -// This will fail due to unlisted constructor not defined by the lower bound -type notWorking = validRed<[#Purple]> -``` - -## Variant vs Polymorphic Variant - -One might think that polymorphic variants are fastly superior to common [variants](./variant). As always, it depends on the use case: - -- Variants allow better encapsulation for your APIs, because they always come with a type definition that is coupled to a specific module. -- Variants are conceptionally easier to understand, makes your code easy to refactor and provides better exhaustive pattern matching support -- Variants usually deliver better type error messages, especially in recursive type definitions -- Poly variants are useful for expressing strings in JS, and allow different type composition strategies. They can also be defined adhocly in your type definitions. - -In most scenarios, we'd recommend to use common variants over polymorphic variants, especially when you are writing plain ReScript code. In case you want to write zero-cost interop bindings or generate clean JS output, poly variants are oftentimes a better option. diff --git a/pages/docs/manual/v9.0.0/primitive-types.mdx b/pages/docs/manual/v9.0.0/primitive-types.mdx deleted file mode 100644 index 5ff3bec1b..000000000 --- a/pages/docs/manual/v9.0.0/primitive-types.mdx +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: "Primitive Types" -description: "Primitive Data Types in ReScript" -canonical: "/docs/manual/latest/primitive-types" ---- - -# Primitive Types - -ReScript comes with the familiar primitive types like `string`, `int`, `float`, etc. - - - -## String - -ReScript `string`s are delimited using **double** quotes (single quotes are reserved for the character type below). - - - -```res example -let greeting = "Hello world!" -let multilineGreeting = "Hello - world!" -``` - -```js -var greeting = "Hello world!"; -var multilineGreeting = "Hello\n world!"; -``` - - - -To concatenate strings, use `++`: - - - -```res example -let greetings = "Hello " ++ "world!" -``` - -```js -var greetings = "Hello world!"; -``` - - - -### String Interpolation - -There's a special syntax for string that allows - -- multiline string just like before -- no special character escaping -- Interpolation -- Proper unicode handling - - - -```res example -let name = "Joe" - -let greeting = `Hello -World -👋 -${name} -` -``` - -```js -var name = "Joe"; - -var greeting = "Hello\nWorld\n👋\n" + name + "\n"; -``` - - - -This is just like JavaScript's backtick string interpolation, except without needing to escape special characters. - -For interpolation, you'll have to convert the binding (`name` in the example) into a string if it isn't one. If you want the interpolation to implicitly convert a binding into a string, prepend a `j`: - - - -```res example -let age = 10 -let message = j`Today I am $age years old.` -``` - -```js -var message = "Today I am " + 10 + " years old."; -``` - - - -### Usage - -See the familiar `Js.String` API in the [API docs](api/js/string). Since a ReScript string maps to a JavaScript string, you can mix & match the string operations in both standard libraries. - -### Tips & Tricks - -**You have a good type system now**! In an untyped language, you'd often overload the meaning of string by using it as: - -- a unique id: `var BLUE_COLOR = "blue"` -- an identifier into a data structure: `var BLUE = "blue" var RED = "red" var colors = [BLUE, RED]` -- the name of an object field: `person["age"] = 24` -- an enum: `if (audio.canPlayType() === 'probably') {...}` [(ಠ_ಠ)](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType#Return_value) -- other crazy patterns you'll soon find horrible, after getting used to ReScript's alternatives. - -The more you overload the poor string type, the less the type system (or a teammate) can help you! ReScript provides concise, fast and maintainable types & data structures alternatives to the use-cases above (e.g. variants, in a later section). - -## Char - -ReScript has a type for a string with a single letter: - - - -```res example -let firstLetterOfAlphabet = 'a' -``` - -```js -var firstLetterOfAlphabet = /* "a" */ 97; -``` - - - -**Note**: Char doesn't support Unicode or UTF-8 and is therefore not recommended. - -To convert a String to a Char, use `String.get("a", 0)`. To convert a Char to a String, use `String.make(1, 'a')`. - -## Regular Expression - -ReScript regular expressions compile cleanly to their JavaScript counterpart: - - - -```res example -let r = %re("/b/g") -``` - -```js -var r = /b/g; -``` - - - -A regular expression like the above has the type `Js.Re.t`. The [Js.Re](api/js/re) module contains the regular expression helpers you have seen in JS. - -## Boolean - -A ReScript boolean has the type `bool` and can be either `true` or `false`. Common operations: - -- `&&`: logical and. -- `||`: logical or. -- `!`: logical not. -- `<=`, `>=`, `<`, `>` -- `==`: structural equal, compares data structures deeply: `(1, 2) == (1, 2)` is `true`. Convenient, but use with caution. -- `===`: referential equal, compares shallowly. `(1, 2) === (1, 2)` is `false`. `let myTuple = (1, 2); myTuple === myTuple` is `true`. -- `!=`: structural unequal. -- `!==`: referential unequal. - -ReScript's `true/false` compiles into a JavaScript `true/false`. - -## Integers - -32-bits, truncated when necessary. We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [Js.Int](api/js/int) for helper functions. - -**Careful when you bind to JavaScript numbers**! Long ones might be truncated. Bind JS number (especially Dates) as **float** instead. - -To improve readability, you may place underscores in the middle of numeric literals such as `1_000_000`. Note that underscores can be placed anywhere within a number, not just every three digits. - -## Floats - -Float requires other operators: `+.`, `-.`, `*.`, `/.`, etc. Like `0.5 +. 0.6`. See [Js.Float](api/js/float) for helper functions. - -As with integers, you may use underscores within literals to improve readability. - -## Unit - -The `unit` type has a single value, `()`. It compiles to JavaScript's `undefined`. It's a dummy type used as a placeholder in various places. You won't need it until you see it. diff --git a/pages/docs/manual/v9.0.0/project-structure.mdx b/pages/docs/manual/v9.0.0/project-structure.mdx deleted file mode 100644 index 93e77f0f0..000000000 --- a/pages/docs/manual/v9.0.0/project-structure.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Project Structure" -description: "Notes on project structure and other rough ReScript guidelines" -canonical: "/docs/manual/latest/project-structure" ---- - -# Project Structure - -These are the existing, non-codified community practices that are currently propagated through informal agreement. We might remove some of them at one point, and enforce some others. Right now, they're just recommendations for ease of newcomers. - -## File Casing - -Capitalized file names (aka first letter upper-cased). - -**Justification**: Module names can only be capitalized. Newcomers often ask how a file maps to a module, and why `draw.res` maps to the module `Draw`, and sometimes try to refer to a module through uncapitalized identifiers. Using `Draw.res` makes this mapping more straightforward. It also helps certain file names that'd be awkward in uncapitalized form: `uRI.res`. - -## Ignore `.merlin` File - -This is generated by the build system and you should not have to manually edit it. Don't check it into the repo. - -**Justification**: `.merlin` is for editor tooling. The file contains absolute paths, which are also not cross-platform (e.g. Windows paths are different). - -## Folders - -Try not to have too many nested folders. Keep your project flat, and have fewer files (reminder: you can use nested modules). - -**Justification**: The file system is a _tree_, but your code's dependencies are a _graph_. Because of that, any file & folder organization is usually imperfect. While it's still valuable to group related files together in a folder, the time wasted debating & getting decision paralysis over these far outweight their benefits. We'll always recommend you to Get Work Done instead of debating about these issues. - -## Third-party Dependencies - -Keep them to a minimum. - -**Justification**: A compiled, statically typed language cannot model its dependencies easily by muddling along like in a dynamic language, especially when we're still piggy-backing on NPM/Yarn (to reduce learning overhead in the medium-term). Keeping dependencies simple & lean helps reduce possibility of conflicts (e.g. two diamond dependencies, or clashing interfaces). - -## Documentation - -Have them. Spend more effort making them great (examples, pitfalls) and professional rather than _just_ fancy-looking. Do use examples, and avoid using names such as `foo` and `bar`. There's always more concrete names (it's an example, no need to be abstract/generalized just yet. The API docs will do this plentily). For blog posts, don't repeat the docs themselves, describe the _transition_ from old to new, and why (e.g. "it was a component, now it's a function, because ..."). - -**Justification**: It's hard for newcomers to distinguish between a simple/decent library and one that's fancy-looking. For the sake of the community, don't try too hard to one-up each other's libraries. Do spread the words, but use your judgement too. - -## PPX & Other Meta-tools - -Keep them to a minimum. PPX, unless used in renown cases (printer, accessors and serializer/deserializer generation), can cause big learning churn for newcomers; on top of the syntax, semantics, types, build tool & FFI that they already have to learn, learning per-library custom transformations of the code is an extra step. More invasive macros makes the code itself less semantically meaningful too, since the essence would be hiding somewhere else. - -## Paradigm - -Don't abuse overly fancy features. Do leave some breathing room for future APIs but don't over-architect things. - -**Justification**: Simple code helps newcomers understand and potentially contribute to your code. Contributing is the best way for them to learn. The extra help you receive might also surpass the gain of using a slightly more clever language trick. But do try new language tricks in some of more casual projects! You might discover new ways of architecting code. - -## Publishing - -If it's a wrapper for a JS library, don't publish the JS artifacts. If it's a legit library, publish the artifacts in lib/js if you think JS consumers might use it. This is especially the case when you gradually convert a JS lib to ReScript while not breaking existing JS consumers. - -Do put the keywords `"rescript"` in your package.json `keywords` field. This allows us to find the library much more easily for future purposes. - -**Justification**: Be nice to JS consumers of your library. They're your future ReScripters. diff --git a/pages/docs/manual/v9.0.0/promise.mdx b/pages/docs/manual/v9.0.0/promise.mdx deleted file mode 100644 index bb3bd0f45..000000000 --- a/pages/docs/manual/v9.0.0/promise.mdx +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: "Async & Promise" -description: "JS Promise handling in ReScript" -canonical: "/docs/manual/latest/promise" ---- - -# Async & Promise - -ReScript's primary mechanism for async programming is the same as JavaScript's (callbacks and promises), since we compile cleanly to JavaScript and would like to avoid dragging in a heavy custom runtime. - -However, it is planned for us to introduce a coroutine-like feature in the future; for that reason, we're postponing introducing the keywords `async` and `await` into the language; though our (upcoming) Promise API bindings revamp + [pipe](pipe) will make your async code already look better than otherwise. - -## Promise - -ReScript has built-in support for [JavaScript promises](api/js/promise). The 3 functions you generally need are: - -- `Js.Promise.resolve: 'a => Js.Promise.t('a)` -- `Js.Promise.then_: ('a => Js.Promise.t('b), Js.Promise.t('a)) => Js.Promise.t('b)` -- `Js.Promise.catch: (Js.Promise.error => Js.Promise.t('a), Js.Promise.t('a)) => Js.Promise.t('a)` - -Additionally, here's the type signature for creating a promise on the ReScript side: - -```res -Js.Promise.make: ( - ( - ~resolve: (. 'a) => unit, - ~reject: (. exn) => unit - ) => unit -) => Js.Promise.t<'a> -``` - -This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](function.md#uncurried-function) (with a dot). `make` returns the created promise. - -## Usage - -Using the [pipe operator](pipe.md): - - - -```res example -let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2)) - -myPromise->Js.Promise.then_(value => { - Js.log(value) - Js.Promise.resolve(value + 2) -}, _)->Js.Promise.then_(value => { - Js.log(value) - Js.Promise.resolve(value + 3) -}, _)->Js.Promise.catch(err => { - Js.log2("Failure!!", err) - Js.Promise.resolve(-2) -}, _) -``` - -```js -var myPromise = new Promise(function (resolve, reject) { - return resolve(2); -}); - -myPromise - .then(function (value) { - console.log(value); - return Promise.resolve((value + 2) | 0); - }) - .then(function (value) { - console.log(value); - return Promise.resolve((value + 3) | 0); - }) - .catch(function (err) { - console.log("Failure!!", err); - return Promise.resolve(-2); - }); -``` - - diff --git a/pages/docs/manual/v9.0.0/record.mdx b/pages/docs/manual/v9.0.0/record.mdx deleted file mode 100644 index 73c5ee1ca..000000000 --- a/pages/docs/manual/v9.0.0/record.mdx +++ /dev/null @@ -1,205 +0,0 @@ ---- -title: "Record" -description: "Record types in ReScript" -canonical: "/docs/manual/latest/record" ---- - -# Record - -Records are like JavaScript objects but: - -- are immutable by default -- have fixed fields (not extensible) - -## Type Declaration - -A record needs a mandatory type declaration: - - - -```res prelude -type person = { - age: int, - name: string -} -``` - -```js -// Empty output -``` - - - -## Creation - -To create a `person` record (declared above): - - - -```res prelude -let me = { - age: 5, - name: "Big ReScript" -} -``` - -```js -var me = { - age: 5, - name: "Big ReScript", -}; -``` - - - -When you create a new record value, ReScript tries to find a record type declaration that conforms to the shape of the value. So the `me` value here is inferred as of type `person`. - -The type is found by looking above the `me` value. **Note**: if the type instead resides in another file or module, you need to explicitly indicate which file or module it is: - - - -```res example -// School.res -type person = {age: int, name: string} -``` - -```js -// Empty output -``` - - - - - -```res -// Example.res - -let me: School.person = {age: 20, name: "Big ReScript"} -/* or */ -let me2 = {School.age: 20, name: "Big ReScript"} -``` - -```js -var me = { - age: 20, - name: "Big ReScript", -}; -var me2 = { - age: 20, - name: "Big ReScript", -}; -``` - - - -Either of the above 3 says "this record's definition is found in the School file". The first one, the regular type annotation, is preferred. - -## Access - -Use the familiar dot notation: - - - -```res example -let name = me.name -``` - -```js -var name = "Big ReScript"; -``` - - - -## Immutable Update - -New records can be created from old records with the `...` spread operator. The original record isn't mutated. - - - -```res example -let meNextYear = {...me, age: me.age + 1} -``` - -```js -var meNextYear = { - age: 21, - name: "Big ReScript", -}; -``` - - - -**Note**: spread cannot add new fields to the record value, as a record's shape is fixed by its type. - -## Mutable Update - -Record fields can optionally be mutable. This allows you to efficiently update those fields in-place with the `=` operator. - - - -```res example -type person = { - name: string, - mutable age: int -} - -let baby = {name: "Baby ReScript", age: 5} -baby.age = baby.age + 1 // `baby.age` is now 6. Happy birthday! -``` - -```js -var baby = { - name: "Baby ReScript", - age: 5, -}; - -baby.age = (baby.age + 1) | 0; -``` - - - -Fields not marked with `mutable` in the type declaration cannot be mutated. - -## JavaScript Output - -ReScript records compile to straightforward JavaScript objects; see the various JS output tabs above. - -## Tips & Tricks - -**Record Types Are Found By Field Name**. With records, you **cannot** say "I'd like this function to take any record type, as long as they have the field `age`". The following **won't work as intended**: - - - -```res -type person = {age: int, name: string} -type monster = {age: int, hasTentacles: bool} - -let getAge = (entity) => entity.age -``` - -```js -function getAge(entity) { - return entity.age; -} -``` - - - -Instead, `getAge` will infer that the parameter `entity` must be of type `monster`, the closest record type with the field `age`. The following code's last line fails: - -```res -let kraken = {age: 9999, hasTentacles: true} -let me = {age: 5, name: "Baby ReScript"} - -getAge(kraken) -getAge(me) // type error! -``` - -The type system will complain that `me` is a `person`, and that `getAge` only works on `monster`. If you need such capability, use ReScript objects, described [here](object.md). - -## Design Decisions - -After reading the constraints in the previous sections, and if you're coming from a dynamic language background, you might be wondering why one would bother with record in the first place instead of straight using object, since the former needs explicit typing and doesn't allow different records with the same field name to be passed to the same function, etc. - -1. The truth is that most of the times in your app, your data's shape is actually fixed, and if it's not, it can potentially be better represented as a combination of variant (introduced next) + record instead. -2. Since a record type is resolved through finding that single explicit type declaration (we call this "nominal typing"), the type error messages end up better than the counterpart ("structural typing", like for tuples). This makes refactoring easier; changing a record type's fields naturally allows the compiler to know that it's still the same record, just misused in some places. Otherwise, under structural typing, it might get hard to tell whether the definition site or the usage site is wrong. diff --git a/pages/docs/manual/v9.0.0/reserved-keywords.mdx b/pages/docs/manual/v9.0.0/reserved-keywords.mdx deleted file mode 100644 index f649ebebb..000000000 --- a/pages/docs/manual/v9.0.0/reserved-keywords.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "Reserved Keyword" -description: "All reserved keywords in ReScript" -canonical: "/docs/manual/latest/reserved-keywords" ---- - -# Reserved Keywords - -> **Note**: Some of these words are reserved purely for backward compatibility. -> -> If you _need_ to use one of these names as binding and/or field name, see [Use Illegal Identifier Names](use-illegal-identifier-names.md). - -- `and` -- `as` -- `assert` - - - - - -- `constraint` - - - - -- `downto` - -- `else` - - -- `exception` -- `external` - -- `false` -- `for` - - - - -- `if` -- `in` -- `include` - - - -- `lazy` -- `let` - -- `module` -- `mutable` - - - - - - -- `of` -- `open` - - - - - -- `rec` - - - - -- `switch` - - - -- `to` -- `true` -- `try` -- `type` - - - - -- `when` -- `while` -- `with` diff --git a/pages/docs/manual/v9.0.0/shared-data-types.mdx b/pages/docs/manual/v9.0.0/shared-data-types.mdx deleted file mode 100644 index 523e0df55..000000000 --- a/pages/docs/manual/v9.0.0/shared-data-types.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: "Shared Data Types" -description: "Data types that share runtime presentation between JS and ReScript" -canonical: "/docs/manual/latest/shared-data-types" ---- - -# Shared Data Types - -ReScript's built-in values of type `string`, `float`, `array` and a few others have a rather interesting property: they compile to the exact same value in JavaScript! - -This means that if you're passing e.g. a ReScript string to the JavaScript side, the JS side can directly use it as a native JS string. It also means that you can import a JS string and pretend it's a native ReScript string. - -Unlike most compiled-to-js languages, in ReScript, **you don't need to write data converters back and forth for most of our values**! - -**Shared, bidirectionally usable types**: - -- String. ReScript strings are JavaScript strings, vice-versa. (Caveat: only our backtick string `` `hello 👋 ${personName}` `` supports unicode and interpolation). -- Float. ReScript floats are JS numbers, vice-versa. -- Array. In addition to the [JS Array API](api/js/array), we provide our own [Belt.Array](api/belt/array#set) API too. -- Tuple. Compiles to a JS array. You can treat a fixed-sized, heterogenous JS array as ReScript tuple too. -- Boolean. -- Record. Record compiles to JS object. Therefore you can also treat JS objects as records. If they're too dynamic, consider modeling them on the ReScript side as a hashmap/dictionary [`Js.Dict`](api/js/dict) or a ReScript object. -- Object. ReScript objects are JavaScript objects, vice-versa. -- Function. They compile to clean JS functions. -- Module. ReScript files are considered top-level modules, and are compiled to JS files 1 to 1. Nested modules are compiled to JavaScript objects. -- Unit. The `unit` type, which has a single value `()`, compiles to `undefined` too. Likewise, you can treat an incoming JS `undefined` as `()`. - - - -**Types that are slightly different than JS, but that you can still use from JS**: - -- Int. **Ints are 32-bits**! Be careful, you can potentially treat them as JS numbers and vice-versa, but if the number's large, then you better treat JS numbers as floats. For example, we bind to Js.Date using `float`s. -- Option. The `option` type's `None` value compiles into JS `undefined`. The `Some` value, e.g. `Some(5)`, compiles to `5`. Likewise, you can treat an incoming JS `undefined` as `None`. **JS `null` isn't handled here**. If your JS value can be `null`, use [Js.Nullable](api/js/nullable) helpers. -- Exception. -- Variant. Check the compiled JavaScript output of variant to see its shape. We don't recommend exporting a ReScript variant for pure JS usage, but you can do that if you have some interop needs. -- List, which is just a regular variant. - -**Non-shared types (aka internal types)**: - -- Character. -- Int64. -- Lazy values. -- Everything else. - -Many of these are stable, which means that you can still serialize/deserialize them as-is without manual conversions. But we discourage actively peeking into their structure otherwise. - -These types require manual conversions if you want to export them for JS consumption. For a seamless JS/TypeScript/Flow integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand. diff --git a/pages/docs/manual/v9.0.0/try.mdx b/pages/docs/manual/v9.0.0/try.mdx deleted file mode 100644 index 6dabb9474..000000000 --- a/pages/docs/manual/v9.0.0/try.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: "Try" -description: "Try ReScript via Command Line" -canonical: "/docs/manual/latest/try" ---- - -## Try Online - -Our [Playground](/try) lets you try ReScript online, and comes with [ReScript-React](/docs/react/latest/introduction) preinstalled. - -## Quickly Evaluate Code In Terminal - -Use `bsc -e`: - -```sh -❯ bsc -e 'let add = (x, y) => x + y' -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function add(x, y) { - return x + y | 0; -} - -exports.add = add; -/* No side effect */ -``` - -You can pipe the output to Node to run it: - -```sh -❯ bsc -e 'let add = (x, y) => x + y; Js.log(add(1, 2))' | node -3 -``` - -## Quickly Compile A Single File - -You can compile a file directly via `bsc MyFile.res`: - -```res example -// MyFile.res -let rec fib = n => { - switch n { - | 0 | 1 => n - | n => fib(n - 1) + fib(n - 2) - } -} -Js.log(fib(0)) -``` - -```sh -❯ bsc MyFile.res -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function fib(n) { - if (n === 0 || n === 1) { - return n; - } else { - return fib(n - 1 | 0) + fib(n - 2 | 0) | 0; - } -} - -console.log(fib(0)); - -exports.fib = fib; -/* Not a pure module */ -``` - -You can also get the inferred type signatures directly via `bsc -i MyFile.res` - -```sh -❯ bsc -i MyFile.res -let fib: int => int -``` - -**Note** that this is for quick tests. For real projects, use our [build system](build-overview.md). - -## Format Code - -```sh -❯ bsc -format MyFile.res -let rec fib = n => { - switch n { - | 0 | 1 => n - | n => fib(n - 1) + fib(n - 2) - } -} -Js.log(fib(0)) -``` - -Our [editor plugins](editor-plugins.md) come with formatting by default. diff --git a/pages/docs/manual/v9.0.0/tuple.mdx b/pages/docs/manual/v9.0.0/tuple.mdx deleted file mode 100644 index 669408775..000000000 --- a/pages/docs/manual/v9.0.0/tuple.mdx +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: "Tuple" -description: "Tuple types and values in ReScript" -canonical: "/docs/manual/latest/tuple" ---- - -# Tuple - -Tuples are a ReScript-specific data structure that don't exist in JavaScript. They are: - -- immutable -- ordered -- fix-sized at creation time -- heterogeneous (can contain different types of values) - - - -```res example -let ageAndName = (24, "Lil' ReScript") -let my3dCoordinates = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -Tuples' types can be used in type annotations as well. Tuple types visually resemble tuples values. - - - -```res prelude -let ageAndName: (int, string) = (24, "Lil' ReScript") -// a tuple type alias -type coord3d = (float, float, float) -let my3dCoordinates: coord3d = (20.0, 30.5, 100.0) -``` - -```js -var ageAndName = [24, "Lil' ReScript"]; -var my3dCoordinates = [20.0, 30.5, 100.0]; -``` - - - -**Note**: there's no tuple of size 1. You'd just use the value itself. - -## Usage - -To get a specific member of a tuple, destructure it: - - - -```res example -let (_, y, _) = my3dCoordinates // now you've retrieved y -``` - -```js -var y = 30.5; -``` - - - -The `_` means you're ignoring the indicated members of the tuple. - -Tuples aren't meant to be updated mutatively. You'd create new ones by destructuring the old ones: - - - -```res example -let coordinates1 = (10, 20, 30) -let (c1x, _, _) = coordinates1 -let coordinates2 = (c1x + 50, 20, 30) -``` - -```js -var coordinates1 = [10, 20, 30]; -var c1x = 10; -var coordinates2 = [60, 20, 30]; -``` - - - -## Tips & Tricks - -You'd use tuples in handy situations that pass around multiple values without too much ceremony. For example, to return many values: - - - -```res -let getCenterCoordinates = () => { - let x = doSomeOperationsHere() - let y = doSomeMoreOperationsHere() - (x, y) -} -``` - -```js -function getCenterCoordinates(param) { - var x = doSomeOperationsHere(undefined); - var y = doSomeMoreOperationsHere(undefined); - return [x, y]; -} -``` - - - -Try to keep the usage of tuple **local**. For data structures that are long-living and passed around often, prefer a **record**, which has named fields. diff --git a/pages/docs/manual/v9.0.0/type.mdx b/pages/docs/manual/v9.0.0/type.mdx deleted file mode 100644 index a3ba6b4ed..000000000 --- a/pages/docs/manual/v9.0.0/type.mdx +++ /dev/null @@ -1,292 +0,0 @@ ---- -title: "Type" -description: "Types and type definitions in ReScript" -canonical: "/docs/manual/latest/type" ---- - -# Type - -Types are the highlight of ReScript! They are: - -- **Strong**. A type can't change into another type. In JavaScript, your variable's type might change when the code runs (aka at runtime). E.g. a `number` variable might change into a `string` sometimes. This is an anti-feature; it makes the code much harder to understand when reading or debugging. -- **Static**. ReScript types are erased after compilation and don't exist at runtime. Never worry about your types dragging down performance. You don't need type info during runtime; we report all the information (especially all the type errors) during compile time. Catch the bugs earlier! -- **Sound**. This is our biggest differentiator versus many other typed languages that compile to JavaScript. Our type system is guaranteed to **never** be wrong. Most type systems make a guess at the type of a value and show you a type in your editor that's sometime incorrect. We don't do that. We believe that a type system that is sometime incorrect can end up being dangerous due to expectation mismatches. -- **Fast**. Many developers underestimate how much of their project's build time goes into type checking. Our type checker is one of the fastest around. -- **Inferred**. You don't have to write down the types! ReScript can deduce them from their values. Yes, it might seem magical that we can deduce all of your program's types, without incorrectness, without your manual annotation, and do so quickly. Welcome to ReScript =). - -The following sections explore more of our type system. - -## Inference - -This let-binding doesn't contain any written type: - - - -```res example -let score = 10 -let add = (a, b) => a + b -``` - -```js -var score = 10; -function add(a, b) { - return (a + b) | 0; -} -``` - - - -ReScript knows that `score` is an `int`, judging by the value `10`. This is called **inference**. Likewise, it also knows that the `add` function takes 2 `int`s and returns an `int`, judging from the `+` operator, which works on ints. - -## Type Annotation - -But you can also optionally write down the type, aka annotate your value: - - - -```res example -let score: int = 10 -``` - -```js -var score = 10; -``` - - - -If the type annotation for `score` doesn't correspond to our inferred type for it, we'll show you an error during compilation time. We **won't** silently assume your type annotation is correct, unlike many other languages. - -You can also wrap any expression in parentheses and annotate it: - - - -```res -let myInt = 5 -let myInt: int = 5 -let myInt = (5: int) + (4: int) -let add = (x: int, y: int) : int => x + y -let drawCircle = (~radius as r: int): circleType => /* code here */ -``` - -```js -var myInt = 9; -function add(x, y) { - return (x + y) | 0; -} -function drawCircle(r) { - /* code here */ -} -``` - - - -Note: in the last line, `(~radius as r: int)` is a labeled argument. More on this in the [function](function.md) page. - -## Type Alias - -You can refer to a type by a different name. They'll be equivalent: - - - -```res example -type scoreType = int -let x: scoreType = 10 -``` - -```js -var x = 10; -``` - - - -## Type Parameter (Aka Generic) - -Types can accept parameters, akin to generics in other languages. The parameters' names **need** to start with `'`. - -The use-case of a parameterized type is to kill duplications. Before: - - - -```res example -// this is a tuple of 3 items, explained next -type intCoordinates = (int, int, int) -type floatCoordinates = (float, float, float) - -let a: intCoordinates = (10, 20, 20) -let b: floatCoordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -After: - - - -```res example -type coordinates<'a> = ('a, 'a, 'a) - -let a: coordinates = (10, 20, 20) -let b: coordinates = (10.5, 20.5, 20.5) -``` - -```js -var a = [10, 20, 20]; -var b = [10.5, 20.5, 20.5]; -``` - - - -Note that the above codes are just contrived examples for illustration purposes. Since the types are inferred, you could have just written: - - - -```res example -let buddy = (10, 20, 20) -``` - -```js -var buddy = [10, 20, 20]; -``` - - - -The type system infers that it's a `(int, int, int)`. Nothing else needed to be written down. - -Type arguments appear in many places. Our `array<'a>` type is such a type that requires a type parameter - - - -```res example -// inferred as `array` -let greetings = ["hello", "world", "how are you"] -``` - -```js -// inferred as `array` -var greetings = ["hello", "world", "how are you"]; -``` - - - -If types didn't accept parameters, the standard library would need to define the types `arrayOfString`, `arrayOfInt`, `arrayOfTuplesOfInt`, etc. That'd be tedious. - -Types can receive many arguments, and be composable. - - - - - -```res example -type result<'a, 'b> = - | Ok('a) - | Error('b) - -type myPayload = {data: string} - -type myPayloadResults<'errorType> = array> - -let payloadResults: myPayloadResults = [ - Ok({data: "hi"}), - Ok({data: "bye"}), - Error("Something wrong happened!") -] -``` - -```js -var payloadResults = [ - { - TAG: /* Ok */ 0, - _0: { data: "hi" }, - }, - { - TAG: /* Ok */ 0, - _0: { data: "bye" }, - }, - { - TAG: /* Error */ 1, - _0: "Something wrong happened!", - }, -]; -``` - - - -## Recursive Types - -Just like a functions, a type can reference itself within itself using `rec`: - - - -```res example -type rec person = { - name: string, - friends: array -} -``` - -```js -// Empty output -``` - - - -## Mutually Recursive Types - -Types can also be _mutually_ recursive through `and`: - - - -```res example -type rec student = {taughtBy: teacher} -and teacher = {students: array} -``` - -```js -// Empty output -``` - - - -## Type Escape Hatch - -ReScript's type system is robust and does not allow dangerous, unsafe stuff like implicit type casting, randomly guessing a value's type, etc. However, out of pragmatism, we expose a single escape hatch for you to "lie" to the type system: - - - -```res -external myShadyConversion: myType1 => myType2 = "%identity" -``` - -```js -// Empty output -``` - - - -This declaration converts a `myType1` of your choice to `myType2` of your choice. You can use it like so: - - - -```res example -external convertToFloat : int => float = "%identity" -let age = 10 -let gpa = 2.1 +. convertToFloat(age) -``` - -```js -var age = 10; -var gpa = 2.1 + 10; -``` - - - -Obviously, do **not** abuse this feature. Use it tastefully when you're working with existing, overly dynamic JS code, for example. - -More on externals [here](external.md). - -**Note**: this particular `external` is the only one that isn't preceded by a `@bs` annotation. diff --git a/pages/docs/manual/v9.0.0/unboxed.mdx b/pages/docs/manual/v9.0.0/unboxed.mdx deleted file mode 100644 index 85a053a22..000000000 --- a/pages/docs/manual/v9.0.0/unboxed.mdx +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: "Unboxed" -description: "Unbox a wrapper" -canonical: "/docs/manual/latest/unboxed" ---- - -# Unboxed - -Consider a ReScript variant with a single payload, and a record with a single field: - - - -```res -type name = Name(string) -let studentName = Name("Joe") - -type greeting = {message: string} -let hi = {message: "hello!"} -``` - -```js -var studentName = /* Name */ { - _0: "Joe", -}; - -var hi = { - message: "hello!", -}; -``` - - - -If you check the JavaScript output, you'll see the `studentName` and `hi` JS object, as expected (see the [variant JS output](variant#javascript-output) and [record JS output](record#javascript-output) sections for details). - -For performance and certain JavaScript interop situations, ReScript offers a way to unwrap (aka unbox) the JS object wrappers from the output for records with a single field and variants with a single constructor and single payload. Annotate their type declaration with the attribute `@unboxed`: - - - -```res -@unboxed -type name = Name(string) -let studentName = Name("Joe") - -@unboxed -type greeting = {message: string} -let hi = {message: "hello!"} -``` - -```js -var studentName = "Joe"; - -var hi = "hello!"; -``` - - - -Check the new output! Clean. - -## Usage - -Why would you ever want a variant or a record with a single payload? Why not just... pass the payload? Here's one use-case for variant. - -Suppose you have a game with a local/global coordinate system: - - - -```res example -type coordinates = {x: float, y: float} - -let renderDot = (coordinates) => { - Js.log3("Pretend to draw at:", coordinates.x, coordinates.y) -} - -let toWorldCoordinates = (localCoordinates) => { - { - x: localCoordinates.x +. 10., - y: localCoordinates.x +. 20., - } -} - -let playerLocalCoordinates = {x: 20.5, y: 30.5} - -renderDot(playerLocalCoordinates) -``` - -```js -function renderDot(coordinates) { - console.log("Pretend to draw at:", coordinates.x, coordinates.y); -} - -function toWorldCoordinates(localCoordinates) { - return { - x: localCoordinates.x + 10, - y: localCoordinates.x + 20, - }; -} - -var playerLocalCoordinates = { - x: 20.5, - y: 30.5, -}; - -renderDot(playerLocalCoordinates); -``` - - - -Oops, that's wrong! `renderDot` should have taken global coordinates, not local ones... Let's prevent passing the wrong kind of coordinates: - - - -```res example -type coordinates = {x: float, y: float} -@unboxed type localCoordinates = Local(coordinates) -@unboxed type worldCoordinates = World(coordinates) - -let renderDot = (World(coordinates)) => { - Js.log3("Pretend to draw at:", coordinates.x, coordinates.y) -} - -let toWorldCoordinates = (Local(coordinates)) => { - World({ - x: coordinates.x +. 10., - y: coordinates.x +. 20., - }) -} - -let playerLocalCoordinates = Local({x: 20.5, y: 30.5}) - -// This now errors! -// renderDot(playerLocalCoordinates) -// We're forced to do this instead: -renderDot(playerLocalCoordinates->toWorldCoordinates) -``` - -```js -function renderDot(coordinates) { - console.log("Pretend to draw at:", coordinates.x, coordinates.y); -} - -function toWorldCoordinates(coordinates) { - return { - x: coordinates.x + 10, - y: coordinates.x + 20, - }; -} - -var playerLocalCoordinates = { - x: 20.5, - y: 30.5, -}; - -renderDot(toWorldCoordinates(playerLocalCoordinates)); -``` - - - -Now `renderDot` only takes `worldCoordinates`. Through a nice combination of using distinct variant types + argument destructuring, we've achieved better safety **without compromising on performance**: the `unboxed` attribute compiled to clean, variant-wrapper-less JS code! Check the output. - -As for a record with a single field, the use-cases are a bit more edgy. We won't mention them here. diff --git a/pages/docs/manual/v9.0.0/use-illegal-identifier-names.mdx b/pages/docs/manual/v9.0.0/use-illegal-identifier-names.mdx deleted file mode 100644 index b1fc91e98..000000000 --- a/pages/docs/manual/v9.0.0/use-illegal-identifier-names.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: "Use Illegal Identifier Names" -description: "Handling (JS) naming collisions in ReScript" -canonical: "/docs/manual/latest/use-illegal-identifier-names" ---- - -# Use Illegal Identifier Names - -Sometime, for e.g. a let binding or a record field, you might want to use: - -- A capitalized name. -- A name that contains illegal characters (e.g. emojis, hyphen, space). -- A name that's one of ReScript's reserved keywords. - -We provide an escape hatch syntax for these cases: - - - -```res example -let \"my-🍎" = 10 - -type element = { - \"aria-label": string -} - -let myElement = { - \"aria-label": "close" -} - -let label = myElement.\"aria-label" - -let calculate = (~\"Props") => { - \"Props" + 1 -} -``` - -```js -var my$$unknown$unknown$unknown$unknown = 10; - -var myElement = { - "aria-label": "close", -}; - -var label = myElement["aria-label"]; - -function calculate(Props) { - return (Props + 1) | 0; -} -``` - - - -See the output. **Use them only when necessary**, for interop with JavaScript. This is a last-resort feature. If you abuse this, many of the compiler guarantees will go away. diff --git a/pages/docs/manual/v9.0.0/variant.mdx b/pages/docs/manual/v9.0.0/variant.mdx deleted file mode 100644 index 4b26abfd2..000000000 --- a/pages/docs/manual/v9.0.0/variant.mdx +++ /dev/null @@ -1,370 +0,0 @@ ---- -title: "Variant" -description: "Variant data structures in ReScript" -canonical: "/docs/manual/latest/variant" ---- - -# Variant - -So far, most of ReScript's data structures might look familiar to you. This section introduces an extremely important, and perhaps unfamiliar, data structure: variant. - -Most data structures in most languages are about "this **and** that". A variant allows us to express "this **or** that". - - - -```res example -type myResponse = - | Yes - | No - | PrettyMuch - -let areYouCrushingIt = Yes -``` - -```js -var areYouCrushingIt = /* Yes */ 0; -``` - - - -`myResponse` is a variant type with the cases `Yes`, `No` and `PrettyMuch`, which are called "variant constructors" (or "variant tag"). The `|` bar separates each constructor. - -**Note**: a variant's constructors need to be capitalized. - -## Variant Needs an Explicit Definition - -If the variant you're using is in a different file, bring it into scope like you'd do [for a record](record.md#record-needs-an-explicit-definition): - - - -```res example -// Zoo.res -type animal = Dog | Cat | Bird -``` - -```js -// Empty output -``` - - - - - -```res -// Example.res -let pet: Zoo.animal = Dog // preferred -// or -let pet2 = Zoo.Dog -``` - -```js -var pet = /* Dog */ 0; -var pet2 = /* Dog */ 0; -``` - - - -## Constructor Arguments - -A variant's constructors can hold extra data separated by comma. - - - -```res prelude -type account = - | None - | Instagram(string) - | Facebook(string, int) -``` - -```js -// Empty output -``` - - - -Here, `Instagram` holds a `string`, and `Facebook` holds a `string` and an `int`. Usage: - - - -```res example -let myAccount = Facebook("Josh", 26) -let friendAccount = Instagram("Jenny") -``` - -```js -var myAccount = { - TAG: /* Facebook */ 1, - _0: "Josh", - _1: 26, -}; -var friendAccount = { - TAG: /* Instagram */ 0, - _0: "Jenny", -}; -``` - - - -### Labeled Variant Payloads (Inline Record) - -If a variant payload has multiple fields, you can use a record-like syntax to label them for better readability: - - - -```res example -type user = - | Number(int) - | Id({name: string, password: string}) - -let me = Id({name: "Joe", password: "123"}) -``` - -```js -var me = { - TAG: /* Id */ 1, - name: "Joe", - password: "123", -}; -``` - - - -This is technically called an "inline record", and only allowed within a variant constructor. You cannot inline a record type declaration anywhere else in ReScript. - -Of course, you can just put a regular record type in a variant too: - - - -```res example -type u = {name: string, password: string} -type user = - | Number(int) - | Id(u) - -let me = Id({name: "Joe", password: "123"}) -``` - -```js -var me = { - TAG: /* Id */ 1, - _0: { - name: "Joe", - password: "123", - }, -}; -``` - - - -The output is slightly uglier and less performant than the former. - -### Pattern Matching On Variant - -See the [Pattern Matching/Destructuring](pattern-matching-destructuring.md) section later. - -## JavaScript Output - -A variant value compiles to 3 possible JavaScript outputs depending on its type declaration: - -- If the variant value is a constructor with no payload, it compiles to a number. -- If it's a constructor with a payload, it compiles to an object with the field `TAG` and the field `_0` for the first payload, `_1` for the second payload, etc. -- An exception to the above is a variant whose type declaration contains only a single constructor with payload. In that case, the constructor compiles to an object without the `TAG` field. -- Labeled variant payloads (the inline record trick earlier) compile to an object with the label names instead of `_0`, `_1`, etc. The object might or might not have the `TAG` field as per previous rule. - -Check the output in these examples: - - - -```res example -type greeting = Hello | Goodbye -let g1 = Hello -let g2 = Goodbye - -type outcome = Good | Error(string) -let o1 = Good -let o2 = Error("oops!") - -type family = Child | Mom(int, string) | Dad (int) -let f1 = Child -let f2 = Mom(30, "Jane") -let f3 = Dad(32) - -type person = Teacher | Student({gpa: float}) -let p1 = Teacher -let p2 = Student({gpa: 99.5}) - -type s = {score: float} -type adventurer = Warrior(s) | Wizard(string) -let a1 = Warrior({score: 10.5}) -let a2 = Wizard("Joe") -``` - -```js -var g1 = /* Hello */ 0; -var g2 = /* Goodbye */ 1; - -var o1 = /* Good */ 0; -var o2 = /* Error */ { - _0: "oops!", -}; - -var f1 = /* Child */ 0; -var f2 = { - TAG: /* Mom */ 0, - _0: 30, - _1: "Jane", -}; -var f3 = { - TAG: /* Dad */ 1, - _0: 32, -}; - -var p1 = /* Teacher */ 0; -var p2 = /* Student */ { - gpa: 99.5, -}; - -var a1 = { - TAG: /* Warrior */ 0, - _0: { - score: 10.5, - }, -}; -var a2 = { - TAG: /* Wizard */ 1, - _0: "Joe", -}; -``` - - - -## Tips & Tricks - -**Be careful** not to confuse a constructor carrying 2 arguments with a constructor carrying a single tuple argument: - - - -```res example -type account = - | Facebook(string, int) // 2 arguments -type account2 = - | Instagram((string, int)) // 1 argument - happens to be a 2-tuple -``` - -```js -// Empty output -``` - - - -### Variants Must Have Constructors - -If you come from an untyped language, you might be tempted to try `type myType = int | string`. This isn't possible in ReScript; you'd have to give each branch a constructor: `type myType = Int(int) | String(string)`. The former looks nice, but causes lots of trouble down the line. - -### Interop with JavaScript - -_This section assumes knowledge about our JavaScript interop. Skip this if you haven't felt the itch to use variants for wrapping JS functions yet_. - -Quite a few JS libraries use functions that can accept many types of arguments. In these cases, it's very tempting to model them as variants. For example, suppose there's a `myLibrary.draw` JS function that takes in either a `number` or a `string`. You might be tempted to bind it like so: - - - -```res example -// reserved for internal usage -@bs.module("myLibrary") external draw : 'a => unit = "draw" - -type animal = - | MyFloat(float) - | MyString(string) - -let betterDraw = (animal) => - switch animal { - | MyFloat(f) => draw(f) - | MyString(s) => draw(s) - } - -betterDraw(MyFloat(1.5)) -``` - -```js -var MyLibrary = require("myLibrary"); - -function betterDraw(animal) { - MyLibrary.draw(animal._0); -} - -betterDraw({ - TAG: /* MyFloat */ 0, - _0: 1.5, -}); -``` - - - -**Try not to do that**, as this generates extra noisy output. Alternatively, define two `external`s that both compile to the same JS call: - - - -```res example -@bs.module("myLibrary") external drawFloat: float => unit = "draw" -@bs.module("myLibrary") external drawString: string => unit = "draw" -``` - -```js -// Empty output -``` - - - -ReScript also provides [a few other ways](bind-to-js-function.md#modeling-polymorphic-function) to do this. - -### Variant Types Are Found By Field Name - -Please refer to this [record section](record#record-types-are-found-by-field-name). Variants are the same: a function can't accept an arbitrary constructor shared by two different variants. Again, such feature exists; it's called a polymorphic variant. We'll talk about this in the future =). - -## Design Decisions - -Variants, in their many forms (polymorphic variant, open variant, GADT, etc.), are likely _the_ feature of a type system such as ReScript's. The aforementioned `option` variant, for example, obliterates the need for nullable types, a major source of bugs in other languages. Philosophically speaking, a problem is composed of many possible branches/conditions. Mishandling these conditions is the majority of what we call bugs. **A type system doesn't magically eliminate bugs; it points out the unhandled conditions and asks you to cover them**\*. The ability to model "this or that" correctly is crucial. - -For example, some folks wonder how the type system can safely eliminate badly formatted JSON data from propagating into their program. They don't, not by themselves! But if the parser returns the `option` type `None | Some(actualData)`, then you'd have to handle the `None` case explicitly in later call sites. That's all there is. - -Performance-wise, a variant can potentially tremendously speed up your program's logic. Here's a piece of JavaScript: - -```js -let data = 'dog' -if (data === 'dog') { - ... -} else if (data === 'cat') { - ... -} else if (data === 'bird') { - ... -} -``` - -There's a linear amount of branch checking here (`O(n)`). Compare this to using a ReScript variant: - - - -```res example -type animal = Dog | Cat | Bird -let data = Dog -switch data { -| Dog => Js.log("Wof") -| Cat => Js.log("Meow") -| Bird => Js.log("Kashiiin") -} -``` - -```js -console.log("Wof"); - -var data = /* Dog */ 0; -``` - - - -The compiler sees the variant, then - -1. conceptually turns them into `type animal = 0 | 1 | 2` -2. compiles `switch` to a constant-time jump table (`O(1)`). diff --git a/pages/docs/react/latest/migrate-react.mdx b/pages/docs/react/latest/migrate-react.mdx deleted file mode 100644 index feb5c240e..000000000 --- a/pages/docs/react/latest/migrate-react.mdx +++ /dev/null @@ -1,254 +0,0 @@ ---- -title: Migrate from JSX v3 -description: "Migrate from JSX v3" -canonical: "/docs/react/latest/migrate-react" -section: "Overview" -order: 3 ---- - -# Migrate from JSX v3 - -JSX v4 introduces a new idiomatic record-based representation of components which is incompatible with v3. Because of this, either the entire project or dependencies need to be compiled in v4 mode, or some compatibility features need to be used to mix v3 and v4 in the same project. This page describes how to migrate from v3 to v4. - -## Configuration - -Remove the existing JSX configuration from `rescript.json`: - -```json -{ - "reason": { "react-jsx": 3 } -} -``` - -Then add the new JSX configuration: - -```json -{ - "jsx": { "version": 4 } -} -``` - -or, to keep using the legacy `React.createElement` API like with JSX v3: - -```json -{ - "jsx": { "version": 4, "mode": "classic" } -} -``` - -### File-level config - -The top-level attribute `@@jsxConfig` is used to update the `jsx` config for the rest of the file (or until the next config update). Only the values mentioned are updated, the others are left unchanged. - -```res -@@jsxConfig({ version: 4, mode: "automatic" }) - -module Wrapper = { - module R1 = { - @react.component // V4 and new _jsx transform - let make = () => body - } - - @@jsxConfig({ version: 4, mode: "classic" }) - - module R2 = { - @react.component // V4 with `React.createElement` - let make = () => body - } -} - -@@jsxConfig({ version: 3 }) - -@react.component // V3 -let make = () => body -``` - -### v3 compatible mode - -JSX v3 is still available with the latest version of compiler and rescript-react. - -```json -{ - "jsx": { "version": 3, "v3-dependencies": ["rescript-relay"] }, - "bsc-flags": ["-open ReactV3"] -} -``` - -To build certain dependencies in v3 compatibility mode, whatever the version used in the root project, use `"v3-dependencies"`. The listed dependencies will be built-in v3 mode, and in addition `-open ReactV3` is added to the compiler options. - -## Migration of v3 components - -Some components in existing projects are written in a way that is dependent on the v3 internal representation. Here are a few examples of how to convert them to v4. - -### `makeProps` does not exist in v4 - -Rewrite this: - -```res -// V3 -module M = { - @obj external makeProps: (~msg: 'msg, ~key: string=?, unit) => {"msg": 'msg} = "" - - let make = (~msg) =>
{React.string(msg)}
-} -``` - -To this: - -```res example -// V4 -module M = { - type props<'msg> = {msg: 'msg} - let make = props =>
{React.string(props.msg)}
-} -``` - -### React.Context - -Rewrite this: - -```res -module Context = { - let context = React.createContext(() => ()) - - module Provider = { - let provider = React.Context.provider(context) - - @react.component - let make = (~value, ~children) => { - React.createElement(provider, {"value": value, "children": children}) // Error - } - } -} -``` - -To this: - -```res example -module Context = { - let context = React.createContext(() => ()) - - module Provider = { - let make = React.Context.provider(context) - } -} -``` - -### React.forwardRef (Discouraged) - -Rewrite this: - -```res -module FancyInput = { - @react.component - let make = React.forwardRef(( - ~className=?, - ~children, - ref_, // argument - ) => -
- Nullable.toOption->Option.map(ReactDOM.Ref.domRef)} - /> - children -
- ) -} - -@react.component -let make = (~onClick) => { - let input = React.useRef(Nullable.null) - -
- // prop - - -
-} -``` - -To this: In v3, there is an inconsistency between `ref` as prop and `ref_` as argument. With JSX v4, `ref` is only allowed as an argument. - -```res example -module FancyInput = { - @react.component - let make = React.forwardRef(( - ~className=?, - ~children, - ref, // only `ref` is allowed - ) => -
- Nullable.toOption->Option.map(ReactDOM.Ref.domRef)} - /> - children -
- ) -} - -@react.component -let make = (~onClick) => { - let input = React.useRef(Nullable.null) - -
- - - -
-} -``` - -### Mangling the prop name - -The prop name was mangled automatically in v3, such as `_open` becomes `open` in the generated js code. This is no longer the case in v4 because the internal representation is changed to the record instead object. If you need to mangle the prop name, you can use the `@as` annotation. - -Rewrite this: - -```res -module Comp = { - @react.component - let make = (~_open, ~_type) => - - - -} -``` - -To this: - -```res -module Comp = { - @react.component - let make = - (@as("open") ~_open, @as("type") ~_type) => - - - -} -``` - -### Bindings to JS components with optional props - -Previously, you could wrap optional props with an explicit `option` when writing bindings to JS components. This approach functioned only due to an implementation detail of the ppx in JSX 3; it's not how to correctly write bindings to a function with optional arguments. - -Rewrite this: - -```res -module Button = { - @module("./Button") @react.component - external make: (~text: option=?) => React.element = "default" -} -``` - -To this: - -```res example -module Button = { - @module("./Button") @react.component - external make: (~text: string=?) => React.element = "default" -} -``` diff --git a/pages/docs/react/v0.10.0/hooks-overview.mdx b/pages/docs/react/v0.10.0/hooks-overview.mdx index 59c720d94..0ef3f5633 100644 --- a/pages/docs/react/v0.10.0/hooks-overview.mdx +++ b/pages/docs/react/v0.10.0/hooks-overview.mdx @@ -93,11 +93,11 @@ This was just a quick example on our first hook usage. We will go into more deta ### Additional Hooks: - [useReducer](./hooks-reducer): An alternative to `useState`. Uses the state / action / reduce pattern. - - + {/* - [useCallback](./hooks-callback): Returns a memoized callback */} + {/* - [useMemo](./hooks-memo): Returns a memoized value */} - [useRef](./hooks-ref): Returns a mutable React-Ref value - - + {/* - [useImperativeHandle](./hooks-imperative-handle): Customizes the instance value that is exposed to parent components when using `ref` */} + {/* - [useLayoutEffect](./hooks-layout-effect): Identical to useEffect, but it fires synchronously after all DOM mutations. */} ## Rules of Hooks diff --git a/pages/docs/react/v0.11.0/hooks-overview.mdx b/pages/docs/react/v0.11.0/hooks-overview.mdx index 59c720d94..0ef3f5633 100644 --- a/pages/docs/react/v0.11.0/hooks-overview.mdx +++ b/pages/docs/react/v0.11.0/hooks-overview.mdx @@ -93,11 +93,11 @@ This was just a quick example on our first hook usage. We will go into more deta ### Additional Hooks: - [useReducer](./hooks-reducer): An alternative to `useState`. Uses the state / action / reduce pattern. - - + {/* - [useCallback](./hooks-callback): Returns a memoized callback */} + {/* - [useMemo](./hooks-memo): Returns a memoized value */} - [useRef](./hooks-ref): Returns a mutable React-Ref value - - + {/* - [useImperativeHandle](./hooks-imperative-handle): Customizes the instance value that is exposed to parent components when using `ref` */} + {/* - [useLayoutEffect](./hooks-layout-effect): Identical to useEffect, but it fires synchronously after all DOM mutations. */} ## Rules of Hooks diff --git a/postcss.config.mjs b/postcss.config.mjs deleted file mode 100644 index c2ddf7482..000000000 --- a/postcss.config.mjs +++ /dev/null @@ -1,5 +0,0 @@ -export default { - plugins: { - "@tailwindcss/postcss": {}, - }, -}; diff --git a/public/static/Art-3-rescript-launch.jpg b/public/Art-3-rescript-launch.jpg similarity index 100% rename from public/static/Art-3-rescript-launch.jpg rename to public/Art-3-rescript-launch.jpg diff --git a/public/static/blog/archive/label-error.png b/public/blog/archive/label-error.png similarity index 100% rename from public/static/blog/archive/label-error.png rename to public/blog/archive/label-error.png diff --git a/public/static/blog/archive/playground-mockup.jpg b/public/blog/archive/playground-mockup.jpg similarity index 100% rename from public/static/blog/archive/playground-mockup.jpg rename to public/blog/archive/playground-mockup.jpg diff --git a/public/static/blog/archive/poly-error.png b/public/blog/archive/poly-error.png similarity index 100% rename from public/static/blog/archive/poly-error.png rename to public/blog/archive/poly-error.png diff --git a/public/static/blog/archive/reasonml-org-color-palette-retina.jpg b/public/blog/archive/reasonml-org-color-palette-retina.jpg similarity index 100% rename from public/static/blog/archive/reasonml-org-color-palette-retina.jpg rename to public/blog/archive/reasonml-org-color-palette-retina.jpg diff --git a/public/static/blog/archive/reasonml-org-structure-retina.jpg b/public/blog/archive/reasonml-org-structure-retina.jpg similarity index 100% rename from public/static/blog/archive/reasonml-org-structure-retina.jpg rename to public/blog/archive/reasonml-org-structure-retina.jpg diff --git a/public/static/blog/archive/recursive-error.png b/public/blog/archive/recursive-error.png similarity index 100% rename from public/static/blog/archive/recursive-error.png rename to public/blog/archive/recursive-error.png diff --git a/public/static/blog/archive/recursive.png b/public/blog/archive/recursive.png similarity index 100% rename from public/static/blog/archive/recursive.png rename to public/blog/archive/recursive.png diff --git a/public/static/blog/archive/search-mockup.jpg b/public/blog/archive/search-mockup.jpg similarity index 100% rename from public/static/blog/archive/search-mockup.jpg rename to public/blog/archive/search-mockup.jpg diff --git a/public/static/blog/archive/state-of-reasonml-2020-q2-pt2-articleimg.jpg b/public/blog/archive/state-of-reasonml-2020-q2-pt2-articleimg.jpg similarity index 100% rename from public/static/blog/archive/state-of-reasonml-2020-q2-pt2-articleimg.jpg rename to public/blog/archive/state-of-reasonml-2020-q2-pt2-articleimg.jpg diff --git a/public/static/blog/archive/state-of-reasonml-org-q2-2020.jpg b/public/blog/archive/state-of-reasonml-org-q2-2020.jpg similarity index 100% rename from public/static/blog/archive/state-of-reasonml-org-q2-2020.jpg rename to public/blog/archive/state-of-reasonml-org-q2-2020.jpg diff --git a/public/static/blog/archive/state-of-reasonml-pt1-hero.jpg b/public/blog/archive/state-of-reasonml-pt1-hero.jpg similarity index 100% rename from public/static/blog/archive/state-of-reasonml-pt1-hero.jpg rename to public/blog/archive/state-of-reasonml-pt1-hero.jpg diff --git a/public/static/blog/archive/state-of-reasonml-q1-2020-card.jpg b/public/blog/archive/state-of-reasonml-q1-2020-card.jpg similarity index 100% rename from public/static/blog/archive/state-of-reasonml-q1-2020-card.jpg rename to public/blog/archive/state-of-reasonml-q1-2020-card.jpg diff --git a/public/static/blog/archive/uncurry-label.png b/public/blog/archive/uncurry-label.png similarity index 100% rename from public/static/blog/archive/uncurry-label.png rename to public/blog/archive/uncurry-label.png diff --git a/public/static/blog/archive/youtube-search-reasonml.jpg b/public/blog/archive/youtube-search-reasonml.jpg similarity index 100% rename from public/static/blog/archive/youtube-search-reasonml.jpg rename to public/blog/archive/youtube-search-reasonml.jpg diff --git a/public/static/blog/compiler_release_11_0.jpg b/public/blog/compiler_release_11_0.jpg similarity index 100% rename from public/static/blog/compiler_release_11_0.jpg rename to public/blog/compiler_release_11_0.jpg diff --git a/public/static/blog/compiler_release_11_1.jpg b/public/blog/compiler_release_11_1.jpg similarity index 100% rename from public/static/blog/compiler_release_11_1.jpg rename to public/blog/compiler_release_11_1.jpg diff --git a/public/static/blog/compiler_release_9_0.jpg b/public/blog/compiler_release_9_0.jpg similarity index 100% rename from public/static/blog/compiler_release_9_0.jpg rename to public/blog/compiler_release_9_0.jpg diff --git a/public/static/blog/compiler_release_9_1.jpg b/public/blog/compiler_release_9_1.jpg similarity index 100% rename from public/static/blog/compiler_release_9_1.jpg rename to public/blog/compiler_release_9_1.jpg diff --git a/public/static/blog/editor_support_article.jpg b/public/blog/editor_support_article.jpg similarity index 100% rename from public/static/blog/editor_support_article.jpg rename to public/blog/editor_support_article.jpg diff --git a/public/static/blog/editor_support_preview.jpg b/public/blog/editor_support_preview.jpg similarity index 100% rename from public/static/blog/editor_support_preview.jpg rename to public/blog/editor_support_preview.jpg diff --git a/public/static/blog/grid_0.jpeg b/public/blog/grid_0.jpeg similarity index 100% rename from public/static/blog/grid_0.jpeg rename to public/blog/grid_0.jpeg diff --git a/public/static/blog/landing_page_figma.png b/public/blog/landing_page_figma.png similarity index 100% rename from public/static/blog/landing_page_figma.png rename to public/blog/landing_page_figma.png diff --git a/public/static/blog/rescript-launch/ReScript-1.jpg b/public/blog/rescript-launch/ReScript-1.jpg similarity index 100% rename from public/static/blog/rescript-launch/ReScript-1.jpg rename to public/blog/rescript-launch/ReScript-1.jpg diff --git a/public/static/blog/rescript-launch/ReScript-2.jpg b/public/blog/rescript-launch/ReScript-2.jpg similarity index 100% rename from public/static/blog/rescript-launch/ReScript-2.jpg rename to public/blog/rescript-launch/ReScript-2.jpg diff --git a/public/static/blog/rescript-launch/ReScript-3.jpg b/public/blog/rescript-launch/ReScript-3.jpg similarity index 100% rename from public/static/blog/rescript-launch/ReScript-3.jpg rename to public/blog/rescript-launch/ReScript-3.jpg diff --git a/public/static/blog/rescript-launch/ReScript-4.jpg b/public/blog/rescript-launch/ReScript-4.jpg similarity index 100% rename from public/static/blog/rescript-launch/ReScript-4.jpg rename to public/blog/rescript-launch/ReScript-4.jpg diff --git a/public/static/blog/rescript_assoc_rename_preview.jpg b/public/blog/rescript_assoc_rename_preview.jpg similarity index 100% rename from public/static/blog/rescript_assoc_rename_preview.jpg rename to public/blog/rescript_assoc_rename_preview.jpg diff --git a/public/static/blog/rescript_retreat_2024.jpg b/public/blog/rescript_retreat_2024.jpg similarity index 100% rename from public/static/blog/rescript_retreat_2024.jpg rename to public/blog/rescript_retreat_2024.jpg diff --git a/public/static/blog/rescript_retreat_2024_group_work.jpg b/public/blog/rescript_retreat_2024_group_work.jpg similarity index 100% rename from public/static/blog/rescript_retreat_2024_group_work.jpg rename to public/blog/rescript_retreat_2024_group_work.jpg diff --git a/public/static/blog/rescript_retreat_2024_talk_parser.jpg b/public/blog/rescript_retreat_2024_talk_parser.jpg similarity index 100% rename from public/static/blog/rescript_retreat_2024_talk_parser.jpg rename to public/blog/rescript_retreat_2024_talk_parser.jpg diff --git a/public/static/blog/rescript_retreat_2024_winery.jpg b/public/blog/rescript_retreat_2024_winery.jpg similarity index 100% rename from public/static/blog/rescript_retreat_2024_winery.jpg rename to public/blog/rescript_retreat_2024_winery.jpg diff --git a/public/static/blog/wizard_typing_on_a_keyboard_in_a_sea_of_lava_flowing_54e33c58-aa14-4f1d-8249-dae636dfc0e9.png b/public/blog/wizard_typing_on_a_keyboard_in_a_sea_of_lava_flowing_54e33c58-aa14-4f1d-8249-dae636dfc0e9.png similarity index 100% rename from public/static/blog/wizard_typing_on_a_keyboard_in_a_sea_of_lava_flowing_54e33c58-aa14-4f1d-8249-dae636dfc0e9.png rename to public/blog/wizard_typing_on_a_keyboard_in_a_sea_of_lava_flowing_54e33c58-aa14-4f1d-8249-dae636dfc0e9.png diff --git a/public/static/brand/rescript-brandmark.png b/public/brand/rescript-brandmark.png similarity index 100% rename from public/static/brand/rescript-brandmark.png rename to public/brand/rescript-brandmark.png diff --git a/public/static/brand/rescript-brandmark.svg b/public/brand/rescript-brandmark.svg similarity index 100% rename from public/static/brand/rescript-brandmark.svg rename to public/brand/rescript-brandmark.svg diff --git a/public/static/brand/rescript-logo-white.png b/public/brand/rescript-logo-white.png similarity index 100% rename from public/static/brand/rescript-logo-white.png rename to public/brand/rescript-logo-white.png diff --git a/public/static/brand/rescript-logo-white.svg b/public/brand/rescript-logo-white.svg similarity index 100% rename from public/static/brand/rescript-logo-white.svg rename to public/brand/rescript-logo-white.svg diff --git a/public/static/brand/rescript-logo.png b/public/brand/rescript-logo.png similarity index 100% rename from public/static/brand/rescript-logo.png rename to public/brand/rescript-logo.png diff --git a/public/static/brand/rescript-logo.svg b/public/brand/rescript-logo.svg similarity index 100% rename from public/static/brand/rescript-logo.svg rename to public/brand/rescript-logo.svg diff --git a/public/static/docson/box.html b/public/docson/box.html similarity index 100% rename from public/static/docson/box.html rename to public/docson/box.html diff --git a/public/static/docson/signature.html b/public/docson/signature.html similarity index 100% rename from public/static/docson/signature.html rename to public/docson/signature.html diff --git a/public/static/favicon/favicon.ico b/public/favicon.ico similarity index 100% rename from public/static/favicon/favicon.ico rename to public/favicon.ico diff --git a/public/static/favicon/android-chrome-192x192.png b/public/favicon/android-chrome-192x192.png similarity index 100% rename from public/static/favicon/android-chrome-192x192.png rename to public/favicon/android-chrome-192x192.png diff --git a/public/static/favicon/android-chrome-512x512.png b/public/favicon/android-chrome-512x512.png similarity index 100% rename from public/static/favicon/android-chrome-512x512.png rename to public/favicon/android-chrome-512x512.png diff --git a/public/static/favicon/apple-touch-icon.png b/public/favicon/apple-touch-icon.png similarity index 100% rename from public/static/favicon/apple-touch-icon.png rename to public/favicon/apple-touch-icon.png diff --git a/public/static/favicon/favicon-16x16.png b/public/favicon/favicon-16x16.png similarity index 100% rename from public/static/favicon/favicon-16x16.png rename to public/favicon/favicon-16x16.png diff --git a/public/static/favicon/favicon-32x32.png b/public/favicon/favicon-32x32.png similarity index 100% rename from public/static/favicon/favicon-32x32.png rename to public/favicon/favicon-32x32.png diff --git a/public/static/favicon/site.webmanifest b/public/favicon/site.webmanifest similarity index 100% rename from public/static/favicon/site.webmanifest rename to public/favicon/site.webmanifest diff --git a/public/static/fonts/roboto-mono-400.woff2 b/public/fonts/roboto-mono-400.woff2 similarity index 100% rename from public/static/fonts/roboto-mono-400.woff2 rename to public/fonts/roboto-mono-400.woff2 diff --git a/public/static/fonts/roboto-mono-700.woff2 b/public/fonts/roboto-mono-700.woff2 similarity index 100% rename from public/static/fonts/roboto-mono-700.woff2 rename to public/fonts/roboto-mono-700.woff2 diff --git a/public/static/fonts/subset-Inter-Bold.woff2 b/public/fonts/subset-Inter-Bold.woff2 similarity index 100% rename from public/static/fonts/subset-Inter-Bold.woff2 rename to public/fonts/subset-Inter-Bold.woff2 diff --git a/public/static/fonts/subset-Inter-Italic.woff2 b/public/fonts/subset-Inter-Italic.woff2 similarity index 100% rename from public/static/fonts/subset-Inter-Italic.woff2 rename to public/fonts/subset-Inter-Italic.woff2 diff --git a/public/static/fonts/subset-Inter-Medium.woff2 b/public/fonts/subset-Inter-Medium.woff2 similarity index 100% rename from public/static/fonts/subset-Inter-Medium.woff2 rename to public/fonts/subset-Inter-Medium.woff2 diff --git a/public/static/fonts/subset-Inter-Regular.woff2 b/public/fonts/subset-Inter-Regular.woff2 similarity index 100% rename from public/static/fonts/subset-Inter-Regular.woff2 rename to public/fonts/subset-Inter-Regular.woff2 diff --git a/public/static/fonts/subset-Inter-SemiBold.woff2 b/public/fonts/subset-Inter-SemiBold.woff2 similarity index 100% rename from public/static/fonts/subset-Inter-SemiBold.woff2 rename to public/fonts/subset-Inter-SemiBold.woff2 diff --git a/public/static/hero.jpg b/public/hero.jpg similarity index 100% rename from public/static/hero.jpg rename to public/hero.jpg diff --git a/public/static/hyperlink.svg b/public/hyperlink.svg similarity index 100% rename from public/static/hyperlink.svg rename to public/hyperlink.svg diff --git a/public/static/ic_gentype@2x.png b/public/ic_gentype@2x.png similarity index 100% rename from public/static/ic_gentype@2x.png rename to public/ic_gentype@2x.png diff --git a/public/static/ic_manual@2x.png b/public/ic_manual@2x.png similarity index 100% rename from public/static/ic_manual@2x.png rename to public/ic_manual@2x.png diff --git a/public/static/ic_package.svg b/public/ic_package.svg similarity index 100% rename from public/static/ic_package.svg rename to public/ic_package.svg diff --git a/public/static/ic_reanalyze@2x.png b/public/ic_reanalyze@2x.png similarity index 100% rename from public/static/ic_reanalyze@2x.png rename to public/ic_reanalyze@2x.png diff --git a/public/static/ic_rescript_react@2x.png b/public/ic_rescript_react@2x.png similarity index 100% rename from public/static/ic_rescript_react@2x.png rename to public/ic_rescript_react@2x.png diff --git a/public/static/ic_search.svg b/public/ic_search.svg similarity index 100% rename from public/static/ic_search.svg rename to public/ic_search.svg diff --git a/public/static/ic_sidebar_drawer.svg b/public/ic_sidebar_drawer.svg similarity index 100% rename from public/static/ic_sidebar_drawer.svg rename to public/ic_sidebar_drawer.svg diff --git a/public/static/illu_index_rescript@2x.png b/public/illu_index_rescript@2x.png similarity index 100% rename from public/static/illu_index_rescript@2x.png rename to public/illu_index_rescript@2x.png diff --git a/public/static/img/bstracing.png b/public/img/bstracing.png similarity index 100% rename from public/static/img/bstracing.png rename to public/img/bstracing.png diff --git a/public/static/img/debugger-after.png b/public/img/debugger-after.png similarity index 100% rename from public/static/img/debugger-after.png rename to public/img/debugger-after.png diff --git a/public/static/img/debugger-before.png b/public/img/debugger-before.png similarity index 100% rename from public/static/img/debugger-before.png rename to public/img/debugger-before.png diff --git a/public/static/img/debugger-inspector.png b/public/img/debugger-inspector.png similarity index 100% rename from public/static/img/debugger-inspector.png rename to public/img/debugger-inspector.png diff --git a/public/static/img/landing_page_figma.png b/public/img/landing_page_figma.png similarity index 100% rename from public/static/img/landing_page_figma.png rename to public/img/landing_page_figma.png diff --git a/public/static/lp/aivero.svg b/public/lp/aivero.svg similarity index 100% rename from public/static/lp/aivero.svg rename to public/lp/aivero.svg diff --git a/public/static/lp/arizon.svg b/public/lp/arizon.svg similarity index 100% rename from public/static/lp/arizon.svg rename to public/lp/arizon.svg diff --git a/public/static/lp/bandprotocol.svg b/public/lp/bandprotocol.svg similarity index 100% rename from public/static/lp/bandprotocol.svg rename to public/lp/bandprotocol.svg diff --git a/public/static/lp/bettercart.svg b/public/lp/bettercart.svg similarity index 100% rename from public/static/lp/bettercart.svg rename to public/lp/bettercart.svg diff --git a/public/static/lp/bettervim.svg b/public/lp/bettervim.svg similarity index 100% rename from public/static/lp/bettervim.svg rename to public/lp/bettervim.svg diff --git a/public/static/lp/camelo.svg b/public/lp/camelo.svg similarity index 100% rename from public/static/lp/camelo.svg rename to public/lp/camelo.svg diff --git a/public/static/lp/cardoc.svg b/public/lp/cardoc.svg similarity index 100% rename from public/static/lp/cardoc.svg rename to public/lp/cardoc.svg diff --git a/public/static/lp/carla.svg b/public/lp/carla.svg similarity index 100% rename from public/static/lp/carla.svg rename to public/lp/carla.svg diff --git a/public/static/lp/cca-io-color.svg b/public/lp/cca-io-color.svg similarity index 100% rename from public/static/lp/cca-io-color.svg rename to public/lp/cca-io-color.svg diff --git a/public/static/lp/cca-io.svg b/public/lp/cca-io.svg similarity index 100% rename from public/static/lp/cca-io.svg rename to public/lp/cca-io.svg diff --git a/public/static/lp/collectiveaudience.svg b/public/lp/collectiveaudience.svg similarity index 100% rename from public/static/lp/collectiveaudience.svg rename to public/lp/collectiveaudience.svg diff --git a/public/static/lp/community-1.jpg b/public/lp/community-1.jpg similarity index 100% rename from public/static/lp/community-1.jpg rename to public/lp/community-1.jpg diff --git a/public/static/lp/community-2.jpg b/public/lp/community-2.jpg similarity index 100% rename from public/static/lp/community-2.jpg rename to public/lp/community-2.jpg diff --git a/public/static/lp/community-3.jpg b/public/lp/community-3.jpg similarity index 100% rename from public/static/lp/community-3.jpg rename to public/lp/community-3.jpg diff --git a/public/static/lp/darklang.svg b/public/lp/darklang.svg similarity index 100% rename from public/static/lp/darklang.svg rename to public/lp/darklang.svg diff --git a/public/static/lp/dev-it-jobs.svg b/public/lp/dev-it-jobs.svg similarity index 100% rename from public/static/lp/dev-it-jobs.svg rename to public/lp/dev-it-jobs.svg diff --git a/public/static/lp/draftbit.svg b/public/lp/draftbit.svg similarity index 100% rename from public/static/lp/draftbit.svg rename to public/lp/draftbit.svg diff --git a/public/static/lp/easy-to-unadopt.jpg b/public/lp/easy-to-unadopt.jpg similarity index 100% rename from public/static/lp/easy-to-unadopt.jpg rename to public/lp/easy-to-unadopt.jpg diff --git a/public/static/lp/editor-tooling-1.jpg b/public/lp/editor-tooling-1.jpg similarity index 100% rename from public/static/lp/editor-tooling-1.jpg rename to public/lp/editor-tooling-1.jpg diff --git a/public/static/lp/envio.svg b/public/lp/envio.svg similarity index 100% rename from public/static/lp/envio.svg rename to public/lp/envio.svg diff --git a/public/static/lp/fast-build-preview.jpg b/public/lp/fast-build-preview.jpg similarity index 100% rename from public/static/lp/fast-build-preview.jpg rename to public/lp/fast-build-preview.jpg diff --git a/public/static/lp/greenlabs.svg b/public/lp/greenlabs.svg similarity index 100% rename from public/static/lp/greenlabs.svg rename to public/lp/greenlabs.svg diff --git a/public/static/lp/grid.svg b/public/lp/grid.svg similarity index 100% rename from public/static/lp/grid.svg rename to public/lp/grid.svg diff --git a/public/static/lp/grid2.svg b/public/lp/grid2.svg similarity index 100% rename from public/static/lp/grid2.svg rename to public/lp/grid2.svg diff --git a/public/static/lp/humaans.svg b/public/lp/humaans.svg similarity index 100% rename from public/static/lp/humaans.svg rename to public/lp/humaans.svg diff --git a/public/static/lp/illu_left.png b/public/lp/illu_left.png similarity index 100% rename from public/static/lp/illu_left.png rename to public/lp/illu_left.png diff --git a/public/static/lp/illu_right.png b/public/lp/illu_right.png similarity index 100% rename from public/static/lp/illu_right.png rename to public/lp/illu_right.png diff --git a/public/static/lp/instapainting.png b/public/lp/instapainting.png similarity index 100% rename from public/static/lp/instapainting.png rename to public/lp/instapainting.png diff --git a/public/static/lp/interop-example-preview.jpg b/public/lp/interop-example-preview.jpg similarity index 100% rename from public/static/lp/interop-example-preview.jpg rename to public/lp/interop-example-preview.jpg diff --git a/public/static/lp/juspay.svg b/public/lp/juspay.svg similarity index 100% rename from public/static/lp/juspay.svg rename to public/lp/juspay.svg diff --git a/public/static/lp/komplio.svg b/public/lp/komplio.svg similarity index 100% rename from public/static/lp/komplio.svg rename to public/lp/komplio.svg diff --git a/public/static/lp/maker.svg b/public/lp/maker.svg similarity index 100% rename from public/static/lp/maker.svg rename to public/lp/maker.svg diff --git a/public/static/lp/nomadic_labs.svg b/public/lp/nomadic_labs.svg similarity index 100% rename from public/static/lp/nomadic_labs.svg rename to public/lp/nomadic_labs.svg diff --git a/public/static/lp/ohne-makler.svg b/public/lp/ohne-makler.svg similarity index 100% rename from public/static/lp/ohne-makler.svg rename to public/lp/ohne-makler.svg diff --git a/public/static/lp/porter.svg b/public/lp/porter.svg similarity index 100% rename from public/static/lp/porter.svg rename to public/lp/porter.svg diff --git a/public/static/lp/pupilfirst.svg b/public/lp/pupilfirst.svg similarity index 100% rename from public/static/lp/pupilfirst.svg rename to public/lp/pupilfirst.svg diff --git a/public/static/lp/reka_market.svg b/public/lp/reka_market.svg similarity index 100% rename from public/static/lp/reka_market.svg rename to public/lp/reka_market.svg diff --git a/public/static/lp/resmume.svg b/public/lp/resmume.svg similarity index 100% rename from public/static/lp/resmume.svg rename to public/lp/resmume.svg diff --git a/public/static/lp/rohea.svg b/public/lp/rohea.svg similarity index 100% rename from public/static/lp/rohea.svg rename to public/lp/rohea.svg diff --git a/public/static/lp/sanjagh.svg b/public/lp/sanjagh.svg similarity index 100% rename from public/static/lp/sanjagh.svg rename to public/lp/sanjagh.svg diff --git a/public/static/lp/seamonster-studios.svg b/public/lp/seamonster-studios.svg similarity index 100% rename from public/static/lp/seamonster-studios.svg rename to public/lp/seamonster-studios.svg diff --git a/public/static/lp/sensonomic.svg b/public/lp/sensonomic.svg similarity index 100% rename from public/static/lp/sensonomic.svg rename to public/lp/sensonomic.svg diff --git a/public/static/lp/silq.svg b/public/lp/silq.svg similarity index 100% rename from public/static/lp/silq.svg rename to public/lp/silq.svg diff --git a/public/static/lp/stencil.svg b/public/lp/stencil.svg similarity index 100% rename from public/static/lp/stencil.svg rename to public/lp/stencil.svg diff --git a/public/static/lp/tiny.svg b/public/lp/tiny.svg similarity index 100% rename from public/static/lp/tiny.svg rename to public/lp/tiny.svg diff --git a/public/static/lp/travelworld.svg b/public/lp/travelworld.svg similarity index 100% rename from public/static/lp/travelworld.svg rename to public/lp/travelworld.svg diff --git a/public/static/lp/type-better-preview.jpg b/public/lp/type-better-preview.jpg similarity index 100% rename from public/static/lp/type-better-preview.jpg rename to public/lp/type-better-preview.jpg diff --git a/public/static/lp/walnut.svg b/public/lp/walnut.svg similarity index 100% rename from public/static/lp/walnut.svg rename to public/lp/walnut.svg diff --git a/public/static/lp/webcurate.svg b/public/lp/webcurate.svg similarity index 100% rename from public/static/lp/webcurate.svg rename to public/lp/webcurate.svg diff --git a/public/static/lp/wino.svg b/public/lp/wino.svg similarity index 100% rename from public/static/lp/wino.svg rename to public/lp/wino.svg diff --git a/public/static/lp/ybru.svg b/public/lp/ybru.svg similarity index 100% rename from public/static/lp/ybru.svg rename to public/lp/ybru.svg diff --git a/public/static/messenger-logo-64@2x.png b/public/messenger-logo-64@2x.png similarity index 100% rename from public/static/messenger-logo-64@2x.png rename to public/messenger-logo-64@2x.png diff --git a/public/static/nav-logo-full@2x.png b/public/nav-logo-full@2x.png similarity index 100% rename from public/static/nav-logo-full@2x.png rename to public/nav-logo-full@2x.png diff --git a/public/static/nav-logo@2x.png b/public/nav-logo@2x.png similarity index 100% rename from public/static/nav-logo@2x.png rename to public/nav-logo@2x.png diff --git a/public/static/nextjs_starter_logo.svg b/public/nextjs_starter_logo.svg similarity index 100% rename from public/static/nextjs_starter_logo.svg rename to public/nextjs_starter_logo.svg diff --git a/public/static/nodejs_starter_logo.svg b/public/nodejs_starter_logo.svg similarity index 100% rename from public/static/nodejs_starter_logo.svg rename to public/nodejs_starter_logo.svg diff --git a/public/static/og/try.png b/public/og/try.png similarity index 100% rename from public/static/og/try.png rename to public/og/try.png diff --git a/public/static/partners/ahrefs.svg b/public/partners/ahrefs.svg similarity index 100% rename from public/static/partners/ahrefs.svg rename to public/partners/ahrefs.svg diff --git a/public/static/partners/tezos_foundation.svg b/public/partners/tezos_foundation.svg similarity index 100% rename from public/static/partners/tezos_foundation.svg rename to public/partners/tezos_foundation.svg diff --git a/public/static/pupilfirst-logo.png b/public/pupilfirst-logo.png similarity index 100% rename from public/static/pupilfirst-logo.png rename to public/pupilfirst-logo.png diff --git a/public/static/rescript_logo_black.svg b/public/rescript_logo_black.svg similarity index 100% rename from public/static/rescript_logo_black.svg rename to public/rescript_logo_black.svg diff --git a/public/static/star.svg b/public/star.svg similarity index 100% rename from public/static/star.svg rename to public/star.svg diff --git a/public/static/vitejs_starter_logo.png b/public/vitejs_starter_logo.png similarity index 100% rename from public/static/vitejs_starter_logo.png rename to public/vitejs_starter_logo.png diff --git a/public/static/vitejs_starter_logo.svg b/public/vitejs_starter_logo.svg similarity index 100% rename from public/static/vitejs_starter_logo.svg rename to public/vitejs_starter_logo.svg diff --git a/public/static/vitejs_starter_logo@2x.png b/public/vitejs_starter_logo@2x.png similarity index 100% rename from public/static/vitejs_starter_logo@2x.png rename to public/vitejs_starter_logo@2x.png diff --git a/react-router.config.mjs b/react-router.config.mjs new file mode 100644 index 000000000..bd955fc60 --- /dev/null +++ b/react-router.config.mjs @@ -0,0 +1,18 @@ +import * as fs from "node:fs"; +import { init } from "react-router-mdx/server"; + + +const mdx = init({ paths: ["_blogposts", "docs"], aliases: ["blog", "docs"] }); + +const { stdlibPaths } = await import("./app/routes.mjs"); + +export default { + ssr: false, + + async prerender({ getStaticPaths }) { + return [...(await getStaticPaths()), ...(await mdx.paths()), ...stdlibPaths]; + }, + buildEnd: async () => { + fs.cpSync("./build/client", "./out", { recursive: true }); + }, +}; diff --git a/rescript.json b/rescript.json index b4350b6de..efbb0d7b3 100644 --- a/rescript.json +++ b/rescript.json @@ -4,9 +4,18 @@ "jsx": { "version": 4 }, - "dependencies": ["@rescript/react", "@rescript/webapi"], - "compiler-flags": ["-open WebAPI.Global"], + "dependencies": [ + "@rescript/react", + "@rescript/webapi" + ], + "compiler-flags": [ + "-open WebAPI.Global" + ], "sources": [ + { + "dir": "app", + "subdirs": true + }, { "dir": "src", "subdirs": true @@ -21,7 +30,8 @@ "in-source": true }, "warnings": { - "error": "+8" + "error": "+8", + "number": "-27-26" }, "suffix": ".mjs", "gentypeconfig": { @@ -29,4 +39,4 @@ "shims": [], "module": "es6" } -} +} \ No newline at end of file diff --git a/scripts/generate_feed.res b/scripts/generate_feed.res index 213aae577..682d4c509 100644 --- a/scripts/generate_feed.res +++ b/scripts/generate_feed.res @@ -3,4 +3,4 @@ let content = { getLatest()->toXmlString } -Console.log(content) +Console.debug(content) diff --git a/scripts/test-hrefs.mjs b/scripts/test-hrefs.mjs index 075b8dd6e..9350484fa 100644 --- a/scripts/test-hrefs.mjs +++ b/scripts/test-hrefs.mjs @@ -7,12 +7,11 @@ */ import { config } from "dotenv"; +import fs from "fs"; import glob from "glob"; import path from "path"; -import fs from "fs"; -import urlModule from "url"; -import { URL } from "url"; -import { getAllPosts, blogPathToSlug } from "../src/common/BlogApi.mjs"; +import urlModule, { URL } from "url"; +import { blogPathToSlug, getAllPosts } from "../src/common/BlogApi.mjs"; import { defaultProcessor } from "./markdown.js"; @@ -39,8 +38,8 @@ const mapBlogFilePath = (path) => { return path; }; -// Static files are located in /public/static/img/somefile.png -// within markdown files they are referenced as /static/img/somefile.png +// Static files are located in /public/img/somefile.png +// within markdown files they are referenced as /img/somefile.png const mapStaticFilePath = (path) => { return path.replace("./public", ""); }; @@ -272,9 +271,7 @@ const main = () => { // We need to capture all files independently from the test file glob const pageMapFiles = glob.sync("./{pages,_blogposts}/**/*.{js,mdx}", { cwd }); - const staticFiles = glob.sync("./public/static/**/*.{svg,png,woff2}", { - cwd, - }); + const staticFiles = glob.sync("./public/**/*.{svg,png,woff2}", { cwd }); const allFiles = pageMapFiles.concat(staticFiles); diff --git a/src/ApiDocs.res b/src/ApiDocs.res index 807193122..19db9c226 100644 --- a/src/ApiDocs.res +++ b/src/ApiDocs.res @@ -13,6 +13,7 @@ type field = { optional: bool, deprecated: Null.t, } + type constructor = { name: string, docstrings: array, @@ -55,7 +56,8 @@ module RightSidebar = { let deprecatedIcon = switch deprecated->Null.toOption { | Some(_) =>
+ className={`bg-orange-100 min-w-[20px] min-h-[20px] w-5 h-5 mr-3 flex justify-center items-center rounded-xl ml-auto`} + > {"D"->React.string}
->Some | None => None @@ -66,9 +68,11 @@ module RightSidebar = { + href + >
+ className={`${bgColor} min-w-[20px] min-h-[20px] w-5 h-5 mr-3 flex justify-center items-center rounded-xl`} + > {icon->React.string} @@ -90,13 +94,21 @@ module RightSidebar = { module SidebarTree = { @react.component let make = (~isOpen: bool, ~toggle: unit => unit, ~node: node, ~items: array) => { - let router = Next.Router.useRouter() - let url = router.route->Url.parse - let version = url->Url.getVersionString + // let router = Next.Router.useRouter() // Remove Next.js router usage if not needed + open ReactRouter + + let location = useLocation() + + Console.log(location) + + // Use ReactRouter's useLocation if needed, or refactor to not use router + // let location = ReactRouter.useLocation() + // let url = "" + // let url = location.pathname->Url.parse let moduleRoute = - WebAPI.URL.make(~url="file://" ++ router.asPath).pathname - ->String.replace(`/docs/manual/${version}/api/`, "") + (location.pathname :> string) + ->String.replace(`/docs/manual/api/`, "") ->String.split("/") let summaryClassName = "truncate py-1 md:h-auto tracking-tight text-gray-60 font-medium text-14 rounded-sm hover:bg-gray-20 hover:-ml-2 hover:py-1 hover:pl-2 " @@ -132,9 +144,9 @@ module SidebarTree = {
- + {node.name->React.string} - + tocModule {if hasChildren { @@ -148,19 +160,20 @@ module SidebarTree = { }}
| false => -
  • +
  • - {node.name->React.string} + {node.name->React.string} tocModule
  • } } - let url = - router.asPath - ->Url.parse - ->Some + // TODO + let url = None + // location.pathname + // ->Url.parse + // ->Some let preludeSection =
    @@ -171,7 +184,8 @@ module SidebarTree = { ReactEvent.Form.preventDefault(evt) let version = (evt->ReactEvent.Form.target)["value"] WebAPI.Storage.setItem(localStorage, ~key=(Manual :> string), ~value=version) - let url = Url.parse(router.asPath) + let url = Url.parse("" /* TODO: location.pathname */) + switch url.pagepath[1] { | Some("core") | Some("stdlib") => if version < "v12.0.0" { @@ -186,7 +200,7 @@ module SidebarTree = { "/" ++ (Array.join(url.base, "/") ++ ("/" ++ (version ++ ("/" ++ Array.join(url.pagepath, "/"))))) - router->Next.Router.push(targetUrl) + ReactRouter.navigate(targetUrl) } let version = url->Url.getVersionString @@ -204,10 +218,12 @@ module SidebarTree = {
    + ) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white"} + >
    {"submodules"->React.string}
    @@ -300,10 +318,10 @@ module DocstringsStylize = { } } -let default = (props: props) => { +let make = (props: props) => { let (isSidebarOpen, setSidebarOpen) = React.useState(_ => false) let toggleSidebar = () => setSidebarOpen(prev => !prev) - let router = Next.Router.useRouter() + // let router = Next.Router.useRouter() let title = switch props { | Ok({module_: {id}}) => id @@ -350,7 +368,8 @@ let default = (props: props) => { | Ok({module_: {items}}) if Array.length(items) > 0 =>
    @@ -85,6 +86,7 @@ module BlogCard = { ) =>
    + {switch badge { | None => React.null | Some(badge) => @@ -92,7 +94,7 @@ module BlogCard = {
    }} - + { let className = "absolute top-0 h-full w-full object-cover" switch previewImg { @@ -100,12 +102,12 @@ module BlogCard = { | None => } } - +
    - -

    {React.string(title)}

    - + // + //

    {React.string(title)}

    + //
    {switch category { | Some(category) => @@ -141,9 +143,10 @@ module FeatureCard = {
    }
    + className="flex sm:px-4 md:px-8 lg:px-0 flex-col justify-end lg:flex-row sm:items-center h-full" + >
    } @@ -237,7 +242,8 @@ let default = (props: props): React.element => { | [] => React.null | rest =>
    + className="px-4 md:px-8 xl:px-0 grid grid-cols-1 xs:grid-cols-2 md:grid-cols-3 gap-20 gap-y-12 md:gap-y-24 w-full" + > {Array.map(rest, post => { let badge = post.frontmatter.badge->Null.toOption diff --git a/src/BlogArticle.res b/src/BlogArticle.res index e051701a4..bcfbfc009 100644 --- a/src/BlogArticle.res +++ b/src/BlogArticle.res @@ -171,10 +171,11 @@ let default = (props: props) => {
    {React.string("Want to read more?")}
    - - {React.string("Back to Overview")} - - + // ReactRouter.Link.to)} className="text-fire hover:text-fire-70"> + // {React.string("Back to Overview")} + // + //
    diff --git a/src/CommunityContent.res b/src/CommunityContent.res index 92598e92c..f15e2ce99 100644 --- a/src/CommunityContent.res +++ b/src/CommunityContent.res @@ -44,7 +44,7 @@ module LinkCards = { {resources ->Array.map(link => switch link.image { - | "" => {...link, image: "/static/Art-3-rescript-launch.jpg"} + | "" => {...link, image: "/Art-3-rescript-launch.jpg"} | _ => link } ) diff --git a/src/DocsOverview.res b/src/DocsOverview.res index a43159bc4..d4f39b976 100644 --- a/src/DocsOverview.res +++ b/src/DocsOverview.res @@ -6,7 +6,7 @@ module Card = {
      {Array.map(hrefs, ((text, href)) =>
    • - {React.string(text)} + {React.string(text)}
    • )->React.array}
    diff --git a/src/Packages.res b/src/Packages.res index b61e142ec..54f6d0dd2 100644 --- a/src/Packages.res +++ b/src/Packages.res @@ -177,7 +177,8 @@ module Card = { })->React.array} @@ -248,7 +249,8 @@ module InfoSidebar = { setFilter(prev => { {...prev, Filter.includeOfficial: !filter.includeOfficial} }) - }}> + }} + > {React.string("Official")} { {...prev, Filter.includeCommunity: !filter.includeCommunity} }) - }}> + }} + > {React.string("Community")} // { {...prev, Filter.includeOutdated: !filter.includeOutdated} }) - }}> + }} + > {React.string("Outdated")}
    @@ -283,9 +287,9 @@ module InfoSidebar = {

    {React.string("Guidelines")}