├── .gitattributes ├── .github └── workflows │ ├── check-build.yml │ ├── nodejs.yml │ ├── style.yml │ └── test-doc-examples.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── migration └── migration.toml ├── package-lock.json ├── package.json ├── rescript.json ├── scripts ├── DocTests.mjs └── DocTests.res ├── src ├── Core__Array.mjs ├── Core__Array.res ├── Core__Array.resi ├── Core__ArrayBuffer.mjs ├── Core__ArrayBuffer.res ├── Core__AsyncIterator.mjs ├── Core__AsyncIterator.res ├── Core__AsyncIterator.resi ├── Core__BigInt.mjs ├── Core__BigInt.res ├── Core__Console.mjs ├── Core__Console.res ├── Core__Console.resi ├── Core__DataView.mjs ├── Core__DataView.res ├── Core__Date.mjs ├── Core__Date.res ├── Core__Date.resi ├── Core__Dict.mjs ├── Core__Dict.res ├── Core__Dict.resi ├── Core__Error.mjs ├── Core__Error.res ├── Core__Error.resi ├── Core__Float.mjs ├── Core__Float.res ├── Core__Float.resi ├── Core__Global.mjs ├── Core__Global.res ├── Core__Global.resi ├── Core__Int.mjs ├── Core__Int.res ├── Core__Int.resi ├── Core__Intl.mjs ├── Core__Intl.res ├── Core__Iterator.mjs ├── Core__Iterator.res ├── Core__Iterator.resi ├── Core__JSON.mjs ├── Core__JSON.res ├── Core__JSON.resi ├── Core__List.mjs ├── Core__List.res ├── Core__List.resi ├── Core__Map.mjs ├── Core__Map.res ├── Core__Map.resi ├── Core__Math.mjs ├── Core__Math.res ├── Core__Math.resi ├── Core__Null.mjs ├── Core__Null.res ├── Core__Null.resi ├── Core__Nullable.mjs ├── Core__Nullable.res ├── Core__Nullable.resi ├── Core__Object.mjs ├── Core__Object.res ├── Core__Option.mjs ├── Core__Option.res ├── Core__Option.resi ├── Core__Ordering.mjs ├── Core__Ordering.res ├── Core__Promise.mjs ├── Core__Promise.res ├── Core__Promise.resi ├── Core__RegExp.mjs ├── Core__RegExp.res ├── Core__RegExp.resi ├── Core__Result.mjs ├── Core__Result.res ├── Core__Result.resi ├── Core__Set.mjs ├── Core__Set.res ├── Core__Set.resi ├── Core__String.mjs ├── Core__String.res ├── Core__String.resi ├── Core__Symbol.mjs ├── Core__Symbol.res ├── Core__Type.mjs ├── Core__Type.res ├── Core__Type.resi ├── Core__WeakMap.mjs ├── Core__WeakMap.res ├── Core__WeakSet.mjs ├── Core__WeakSet.res ├── OCamlCompat.mjs ├── OCamlCompat.res ├── RescriptCore.mjs ├── RescriptCore.res ├── intl │ ├── Core__Intl__Collator.mjs │ ├── Core__Intl__Collator.res │ ├── Core__Intl__Common.mjs │ ├── Core__Intl__Common.res │ ├── Core__Intl__DateTimeFormat.mjs │ ├── Core__Intl__DateTimeFormat.res │ ├── Core__Intl__ListFormat.mjs │ ├── Core__Intl__ListFormat.res │ ├── Core__Intl__Locale.mjs │ ├── Core__Intl__Locale.res │ ├── Core__Intl__NumberFormat.mjs │ ├── Core__Intl__NumberFormat.res │ ├── Core__Intl__NumberFormat__Grouping.mjs │ ├── Core__Intl__NumberFormat__Grouping.res │ ├── Core__Intl__PluralRules.mjs │ ├── Core__Intl__PluralRules.res │ ├── Core__Intl__RelativeTimeFormat.mjs │ ├── Core__Intl__RelativeTimeFormat.res │ ├── Core__Intl__Segmenter.mjs │ ├── Core__Intl__Segmenter.res │ ├── Core__Intl__Segments.mjs │ └── Core__Intl__Segments.res └── typed-arrays │ ├── Core__BigInt64Array.mjs │ ├── Core__BigInt64Array.res │ ├── Core__BigUint64Array.mjs │ ├── Core__BigUint64Array.res │ ├── Core__Float32Array.mjs │ ├── Core__Float32Array.res │ ├── Core__Float64Array.mjs │ ├── Core__Float64Array.res │ ├── Core__Int16Array.mjs │ ├── Core__Int16Array.res │ ├── Core__Int32Array.mjs │ ├── Core__Int32Array.res │ ├── Core__Int8Array.mjs │ ├── Core__Int8Array.res │ ├── Core__TypedArray.mjs │ ├── Core__TypedArray.res │ ├── Core__Uint16Array.mjs │ ├── Core__Uint16Array.res │ ├── Core__Uint32Array.mjs │ ├── Core__Uint32Array.res │ ├── Core__Uint8Array.mjs │ ├── Core__Uint8Array.res │ ├── Core__Uint8ClampedArray.mjs │ └── Core__Uint8ClampedArray.res └── test ├── ArrayTests.mjs ├── ArrayTests.res ├── DictTests.mjs ├── DictTests.res ├── ErrorTests.mjs ├── ErrorTests.res ├── FloatTests.mjs ├── FloatTests.res ├── ImportTests.mjs ├── ImportTests.res ├── IntTests.mjs ├── IntTests.res ├── IteratorTests.mjs ├── IteratorTests.res ├── JsonTests.mjs ├── JsonTests.res ├── NullableTests.mjs ├── NullableTests.res ├── ObjectTests.mjs ├── ObjectTests.res ├── PromiseTest.mjs ├── PromiseTest.res ├── ResultTests.mjs ├── ResultTests.res ├── StringTests.mjs ├── StringTests.res ├── TempTests.mjs ├── TempTests.res ├── Test.mjs ├── Test.res ├── TestSuite.mjs ├── TestSuite.res ├── TestTests.mjs ├── TestTests.res ├── TypedArrayTests.mjs ├── TypedArrayTests.res └── intl ├── IntlTests.mjs ├── IntlTests.res ├── Intl__CollatorTest.mjs ├── Intl__CollatorTest.res ├── Intl__DateTimeFormatTest.mjs ├── Intl__DateTimeFormatTest.res ├── Intl__ListFormatTest.mjs ├── Intl__ListFormatTest.res ├── Intl__LocaleTest.mjs ├── Intl__LocaleTest.res ├── Intl__NumberFormatTest.mjs ├── Intl__NumberFormatTest.res ├── Intl__PluralRulesTest.mjs ├── Intl__PluralRulesTest.res ├── Intl__RelativeTimeFormatTest.mjs ├── Intl__RelativeTimeFormatTest.res ├── Intl__SegmenterTest.mjs └── Intl__SegmenterTest.res /.gitattributes: -------------------------------------------------------------------------------- 1 | # Tell github that .res and .resi files are ReScript 2 | *.res linguist-language=ReScript 3 | *.resi linguist-language=ReScript 4 | -------------------------------------------------------------------------------- /.github/workflows/check-build.yml: -------------------------------------------------------------------------------- 1 | name: Check JS Files 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | check: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Use Node.js 20 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: 20 19 | - run: npm install 20 | - run: npm run build 21 | - name: JS Files Changed 22 | run: git diff --exit-code 23 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [main] 9 | pull_request: 10 | branches: [main] 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | node-version: [18.x, 20.x, 21.x] 19 | fail-fast: false 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v3 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | - run: npm install 28 | - run: npm run build 29 | - run: npm run test 30 | -------------------------------------------------------------------------------- /.github/workflows/style.yml: -------------------------------------------------------------------------------- 1 | name: Style Check 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | check: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Use Node.js 20 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: 20 19 | - run: npm install 20 | - run: npx rescript format -all -check 21 | - name: Helpful error message 22 | if: failure() 23 | run: echo "::error::Incorrect formatting. Please run 'npx rescript format -all' and commit the changes." 24 | -------------------------------------------------------------------------------- /.github/workflows/test-doc-examples.yml: -------------------------------------------------------------------------------- 1 | name: Test Doc Examples 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | check: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Use Node.js 20 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: 20 19 | - run: npm install 20 | - run: npm run build 21 | - run: npm run test-doc-examples 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.obj 3 | *.out 4 | *.compile 5 | *.native 6 | *.byte 7 | *.cmo 8 | *.annot 9 | *.cmi 10 | *.cmx 11 | *.cmt 12 | *.cmti 13 | *.cma 14 | *.a 15 | *.cmxa 16 | *.obj 17 | *~ 18 | *.annot 19 | *.cmj 20 | *.bak 21 | lib/bs 22 | *.mlast 23 | *.mliast 24 | .vscode 25 | .merlin 26 | .bsb.lock 27 | /node_modules/ 28 | .DS_Store 29 | 30 | 31 | .examples-tests/ 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ReScript 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rescript/core", 3 | "version": "1.6.1", 4 | "scripts": { 5 | "clean": "rescript clean", 6 | "build": "rescript", 7 | "watch": "rescript build -w", 8 | "test": "node test/TestSuite.mjs && node test/TempTests.mjs", 9 | "test-doc-examples": "node scripts/DocTests.mjs" 10 | }, 11 | "keywords": [ 12 | "rescript" 13 | ], 14 | "homepage": "https://github.com/rescript-association/rescript-core", 15 | "author": "ReScript Team", 16 | "license": "MIT", 17 | "files": [ 18 | "README.md", 19 | "CHANGELOG.md", 20 | "LICENSE", 21 | "rescript.json", 22 | "src/**/*.res", 23 | "src/**/*.resi", 24 | "src/**/*.mjs" 25 | ], 26 | "peerDependencies": { 27 | "rescript": ">=11.1.0" 28 | }, 29 | "devDependencies": { 30 | "@babel/code-frame": "7.18.6", 31 | "@rescript/tools": "0.6.4", 32 | "rescript": "11.1.4" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rescript.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rescript/core", 3 | "version": "0.5.0", 4 | "sources": [ 5 | { 6 | "dir": "src", 7 | "subdirs": ["intl", "typed-arrays"] 8 | }, 9 | { 10 | "dir": "test", 11 | "subdirs": ["intl"], 12 | "type": "dev" 13 | }, 14 | { 15 | "dir": "scripts", 16 | "type": "dev" 17 | } 18 | ], 19 | "suffix": ".mjs", 20 | "package-specs": { 21 | "module": "esmodule", 22 | "in-source": true 23 | }, 24 | "bs-dev-dependencies": ["@rescript/tools"], 25 | "warnings": { 26 | "error": "+101" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Core__Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_option from "rescript/lib/es6/caml_option.js"; 4 | 5 | function make(length, x) { 6 | if (length <= 0) { 7 | return []; 8 | } 9 | var arr = new Array(length); 10 | arr.fill(x); 11 | return arr; 12 | } 13 | 14 | function fromInitializer(length, f) { 15 | if (length <= 0) { 16 | return []; 17 | } 18 | var arr = new Array(length); 19 | for(var i = 0; i < length; ++i){ 20 | arr[i] = f(i); 21 | } 22 | return arr; 23 | } 24 | 25 | function equal(a, b, eq) { 26 | var len = a.length; 27 | if (len === b.length) { 28 | var _i = 0; 29 | while(true) { 30 | var i = _i; 31 | if (i === len) { 32 | return true; 33 | } 34 | if (!eq(a[i], b[i])) { 35 | return false; 36 | } 37 | _i = i + 1 | 0; 38 | continue ; 39 | }; 40 | } else { 41 | return false; 42 | } 43 | } 44 | 45 | function compare(a, b, cmp) { 46 | var lenA = a.length; 47 | var lenB = b.length; 48 | if (lenA < lenB) { 49 | return -1; 50 | } else if (lenA > lenB) { 51 | return 1; 52 | } else { 53 | var _i = 0; 54 | while(true) { 55 | var i = _i; 56 | if (i === lenA) { 57 | return 0; 58 | } 59 | var c = cmp(a[i], b[i]); 60 | if (c !== 0) { 61 | return c; 62 | } 63 | _i = i + 1 | 0; 64 | continue ; 65 | }; 66 | } 67 | } 68 | 69 | function indexOfOpt(arr, item) { 70 | var index = arr.indexOf(item); 71 | if (index !== -1) { 72 | return index; 73 | } 74 | 75 | } 76 | 77 | function lastIndexOfOpt(arr, item) { 78 | var index = arr.lastIndexOf(item); 79 | if (index !== -1) { 80 | return index; 81 | } 82 | 83 | } 84 | 85 | function reduce(arr, init, f) { 86 | return arr.reduce(f, init); 87 | } 88 | 89 | function reduceWithIndex(arr, init, f) { 90 | return arr.reduce(f, init); 91 | } 92 | 93 | function reduceRight(arr, init, f) { 94 | return arr.reduceRight(f, init); 95 | } 96 | 97 | function reduceRightWithIndex(arr, init, f) { 98 | return arr.reduceRight(f, init); 99 | } 100 | 101 | function findIndexOpt(array, finder) { 102 | var index = array.findIndex(finder); 103 | if (index !== -1) { 104 | return index; 105 | } 106 | 107 | } 108 | 109 | function swapUnsafe(xs, i, j) { 110 | var tmp = xs[i]; 111 | xs[i] = xs[j]; 112 | xs[j] = tmp; 113 | } 114 | 115 | function random_int(min, max) { 116 | return (Math.floor(Math.random() * (max - min | 0)) | 0) + min | 0; 117 | } 118 | 119 | function shuffle(xs) { 120 | var len = xs.length; 121 | for(var i = 0; i < len; ++i){ 122 | swapUnsafe(xs, i, random_int(i, len)); 123 | } 124 | } 125 | 126 | function toShuffled(xs) { 127 | var result = xs.slice(); 128 | shuffle(result); 129 | return result; 130 | } 131 | 132 | function filterMap(a, f) { 133 | var l = a.length; 134 | var r = new Array(l); 135 | var j = 0; 136 | for(var i = 0; i < l; ++i){ 137 | var v = a[i]; 138 | var v$1 = f(v); 139 | if (v$1 !== undefined) { 140 | r[j] = Caml_option.valFromOption(v$1); 141 | j = j + 1 | 0; 142 | } 143 | 144 | } 145 | r.length = j; 146 | return r; 147 | } 148 | 149 | function keepSome(__x) { 150 | return filterMap(__x, (function (x) { 151 | return x; 152 | })); 153 | } 154 | 155 | function findMap(arr, f) { 156 | var _i = 0; 157 | while(true) { 158 | var i = _i; 159 | if (i === arr.length) { 160 | return ; 161 | } 162 | var r = f(arr[i]); 163 | if (r !== undefined) { 164 | return r; 165 | } 166 | _i = i + 1 | 0; 167 | continue ; 168 | }; 169 | } 170 | 171 | function last(a) { 172 | return a[a.length - 1 | 0]; 173 | } 174 | 175 | export { 176 | make , 177 | fromInitializer , 178 | equal , 179 | compare , 180 | indexOfOpt , 181 | lastIndexOfOpt , 182 | reduce , 183 | reduceWithIndex , 184 | reduceRight , 185 | reduceRightWithIndex , 186 | findIndexOpt , 187 | filterMap , 188 | keepSome , 189 | toShuffled , 190 | shuffle , 191 | findMap , 192 | last , 193 | } 194 | /* No side effect */ 195 | -------------------------------------------------------------------------------- /src/Core__ArrayBuffer.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__ArrayBuffer.res: -------------------------------------------------------------------------------- 1 | type t = Js.TypedArray2.ArrayBuffer.t 2 | 3 | @new external make: int => t = "ArrayBuffer" 4 | @get external byteLength: t => int = "byteLength" 5 | 6 | @send external slice: (t, ~start: int, ~end: int) => t = "slice" 7 | @send external sliceToEnd: (t, ~start: int) => t = "slice" 8 | -------------------------------------------------------------------------------- /src/Core__AsyncIterator.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_option from "rescript/lib/es6/caml_option.js"; 4 | 5 | function value(v) { 6 | return { 7 | done: false, 8 | value: Caml_option.some(v) 9 | }; 10 | } 11 | 12 | function done(finalValue) { 13 | return { 14 | done: true, 15 | value: finalValue 16 | }; 17 | } 18 | 19 | async function forEach(iterator, f) { 20 | var iteratorDone = false; 21 | while(!iteratorDone) { 22 | var match = await iterator.next(); 23 | f(match.value); 24 | iteratorDone = match.done; 25 | }; 26 | } 27 | 28 | var make = (function makeAsyncIterator(next) { 29 | return { 30 | next, 31 | [Symbol.asyncIterator]() { 32 | return this; 33 | } 34 | } 35 | }); 36 | 37 | export { 38 | make , 39 | value , 40 | done , 41 | forEach , 42 | } 43 | /* No side effect */ 44 | -------------------------------------------------------------------------------- /src/Core__AsyncIterator.res: -------------------------------------------------------------------------------- 1 | type t<'a> 2 | 3 | type value<'a> = { 4 | done: bool, 5 | value: option<'a>, 6 | } 7 | 8 | let value = v => { 9 | done: false, 10 | value: Some(v), 11 | } 12 | 13 | let done = (~finalValue=?) => { 14 | done: true, 15 | value: finalValue, 16 | } 17 | 18 | @send external next: t<'a> => promise> = "next" 19 | 20 | let forEach = async (iterator, f) => { 21 | let iteratorDone = ref(false) 22 | 23 | while !iteratorDone.contents { 24 | let {done, value} = await iterator->next 25 | f(value) 26 | iteratorDone := done 27 | } 28 | } 29 | 30 | let make: (unit => promise>) => t<'value> = %raw(`function makeAsyncIterator(next) { 31 | return { 32 | next, 33 | [Symbol.asyncIterator]() { 34 | return this; 35 | } 36 | } 37 | }`) 38 | -------------------------------------------------------------------------------- /src/Core__BigInt.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function toInt(t) { 5 | return Number(t) | 0; 6 | } 7 | 8 | function lnot(x) { 9 | return x ^ -1n; 10 | } 11 | 12 | export { 13 | toInt , 14 | lnot , 15 | } 16 | /* No side effect */ 17 | -------------------------------------------------------------------------------- /src/Core__BigInt.res: -------------------------------------------------------------------------------- 1 | @val external asIntN: (~width: int, bigint) => bigint = "BigInt.asIntN" 2 | @val external asUintN: (~width: int, bigint) => bigint = "BigInt.asUintN" 3 | 4 | @val external fromString: string => bigint = "BigInt" 5 | 6 | @val 7 | /** 8 | Parses the given `string` into a `bigint` using JavaScript semantics. Return the 9 | number as a `bigint` if successfully parsed. Uncaught syntax exception otherwise. 10 | 11 | ## Examples 12 | 13 | ```rescript 14 | /* returns 123n */ 15 | BigInt.fromStringExn("123") 16 | 17 | /* returns 0n */ 18 | BigInt.fromStringExn("") 19 | 20 | /* returns 17n */ 21 | BigInt.fromStringExn("0x11") 22 | 23 | /* returns 3n */ 24 | BigInt.fromStringExn("0b11") 25 | 26 | /* returns 9n */ 27 | BigInt.fromStringExn("0o11") 28 | 29 | /* catch exception */ 30 | try { 31 | BigInt.fromStringExn("a") 32 | } catch { 33 | | Exn.Error(_error) => 0n 34 | } 35 | ``` 36 | */ 37 | external fromStringExn: string => bigint = "BigInt" 38 | @val external fromInt: int => bigint = "BigInt" 39 | @val external fromFloat: float => bigint = "BigInt" 40 | 41 | @send 42 | /** 43 | Formats a `bigint` as a string. Return a `string` representing the given value. 44 | See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. 45 | 46 | ## Examples 47 | 48 | ```rescript 49 | /* prints "123" */ 50 | Js.BigInt.toString(123n)->Js.log 51 | ``` 52 | */ 53 | external toString: (bigint, ~radix: int=?) => string = "toString" 54 | 55 | @deprecated("Use `toString` with `~radix` instead") @send 56 | external toStringWithRadix: (bigint, ~radix: int) => string = "toString" 57 | 58 | @send 59 | /** 60 | Returns a string with a language-sensitive representation of this BigInt value. 61 | 62 | ## Examples 63 | 64 | ```rescript 65 | /* prints "123" */ 66 | Js.BigInt.toString(123n)->Js.log 67 | ``` 68 | */ 69 | external toLocaleString: bigint => string = "toLocaleString" 70 | 71 | @val external toFloat: bigint => float = "Number" 72 | 73 | let toInt = t => t->toFloat->Core__Int.fromFloat 74 | 75 | external \"+": (bigint, bigint) => bigint = "%addbigint" 76 | external \"-": (bigint, bigint) => bigint = "%subbigint" 77 | external \"*": (bigint, bigint) => bigint = "%mulbigint" 78 | external \"/": (bigint, bigint) => bigint = "%divbigint" 79 | external \"~-": bigint => bigint = "%negbigint" 80 | external \"~+": bigint => bigint = "%identity" 81 | external \"**": (bigint, bigint) => bigint = "%powbigint" 82 | 83 | external add: (bigint, bigint) => bigint = "%addfloat" 84 | external sub: (bigint, bigint) => bigint = "%subfloat" 85 | external mul: (bigint, bigint) => bigint = "%mulfloat" 86 | external div: (bigint, bigint) => bigint = "%divfloat" 87 | 88 | external mod: (bigint, bigint) => bigint = "%modbigint" 89 | 90 | external land: (bigint, bigint) => bigint = "%andbigint" 91 | external lor: (bigint, bigint) => bigint = "%orbigint" 92 | external lxor: (bigint, bigint) => bigint = "%xorbigint" 93 | 94 | external lsl: (bigint, bigint) => bigint = "%lslbigint" 95 | external asr: (bigint, bigint) => bigint = "%asrbigint" 96 | 97 | let lnot = x => lxor(x, -1n) 98 | -------------------------------------------------------------------------------- /src/Core__Console.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__Console.res: -------------------------------------------------------------------------------- 1 | @val external assert_: (bool, 'a) => unit = "console.assert" 2 | @val external assert2: (bool, 'a, 'b) => unit = "console.assert" 3 | @val external assert3: (bool, 'a, 'b, 'c) => unit = "console.assert" 4 | @val external assert4: (bool, 'a, 'b, 'c, 'd) => unit = "console.assert" 5 | @val external assert5: (bool, 'a, 'b, 'c, 'd, 'e) => unit = "console.assert" 6 | @val external assert6: (bool, 'a, 'b, 'c, 'd, 'e, 'f) => unit = "console.assert" 7 | @val @variadic external assertMany: (bool, array<_>) => unit = "console.assert" 8 | 9 | @val external clear: unit => unit = "console.clear" 10 | 11 | @val external count: string => unit = "console.count" 12 | @val external countReset: string => unit = "console.countReset" 13 | 14 | @val external debug: 'a => unit = "console.debug" 15 | @val external debug2: ('a, 'b) => unit = "console.debug" 16 | @val external debug3: ('a, 'b, 'c) => unit = "console.debug" 17 | @val external debug4: ('a, 'b, 'c, 'd) => unit = "console.debug" 18 | @val external debug5: ('a, 'b, 'c, 'd, 'e) => unit = "console.debug" 19 | @val external debug6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.debug" 20 | @val @variadic external debugMany: array<_> => unit = "console.debug" 21 | 22 | @val external dir: 'a => unit = "console.dir" 23 | @val external dirxml: 'a => unit = "console.dirxml" 24 | 25 | @val external error: 'a => unit = "console.error" 26 | @val external error2: ('a, 'b) => unit = "console.error" 27 | @val external error3: ('a, 'b, 'c) => unit = "console.error" 28 | @val external error4: ('a, 'b, 'c, 'd) => unit = "console.error" 29 | @val external error5: ('a, 'b, 'c, 'd, 'e) => unit = "console.error" 30 | @val external error6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.error" 31 | @val @variadic external errorMany: array<_> => unit = "console.error" 32 | 33 | @val external group: string => unit = "console.group" 34 | @val external groupCollapsed: string => unit = "console.groupCollapsed" 35 | @val external groupEnd: unit => unit = "console.groupEnd" 36 | 37 | @val external info: 'a => unit = "console.info" 38 | @val external info2: ('a, 'b) => unit = "console.info" 39 | @val external info3: ('a, 'b, 'c) => unit = "console.info" 40 | @val external info4: ('a, 'b, 'c, 'd) => unit = "console.info" 41 | @val external info5: ('a, 'b, 'c, 'd, 'e) => unit = "console.info" 42 | @val external info6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.info" 43 | @val @variadic external infoMany: array<_> => unit = "console.info" 44 | 45 | @val external log: 'a => unit = "console.log" 46 | @val external log2: ('a, 'b) => unit = "console.log" 47 | @val external log3: ('a, 'b, 'c) => unit = "console.log" 48 | @val external log4: ('a, 'b, 'c, 'd) => unit = "console.log" 49 | @val external log5: ('a, 'b, 'c, 'd, 'e) => unit = "console.log" 50 | @val external log6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.log" 51 | @val @variadic external logMany: array<_> => unit = "console.log" 52 | 53 | @val external table: 'a => unit = "console.table" 54 | 55 | @val external time: string => unit = "console.time" 56 | @val external timeEnd: string => unit = "console.timeEnd" 57 | @val external timeLog: string => unit = "console.timeLog" 58 | 59 | @val external trace: unit => unit = "console.trace" 60 | 61 | @val external warn: 'a => unit = "console.warn" 62 | @val external warn2: ('a, 'b) => unit = "console.warn" 63 | @val external warn3: ('a, 'b, 'c) => unit = "console.warn" 64 | @val external warn4: ('a, 'b, 'c, 'd) => unit = "console.warn" 65 | @val external warn5: ('a, 'b, 'c, 'd, 'e) => unit = "console.warn" 66 | @val external warn6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.warn" 67 | @val @variadic external warnMany: array<_> => unit = "console.warn" 68 | -------------------------------------------------------------------------------- /src/Core__DataView.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__DataView.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | @new external fromBuffer: Core__ArrayBuffer.t => t = "DataView" 4 | @new external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "DataView" 5 | @new 6 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 7 | "DataView" 8 | 9 | @get external buffer: t => Core__ArrayBuffer.t = "buffer" 10 | @get external byteLength: t => int = "byteLength" 11 | @get external byteOffset: t => int = "byteOffset" 12 | 13 | @send external getInt8: (t, int) => int = "getInt8" 14 | @send external getUint8: (t, int) => int = "getUint8" 15 | @send external getInt16: (t, int) => int = "getInt16" 16 | @send external getUint16: (t, int) => int = "getUint16" 17 | @send external getInt32: (t, int) => int = "getInt32" 18 | @send external getUint32: (t, int) => int = "getUint32" 19 | 20 | @send external getFloat32: (t, int) => float = "getFloat32" 21 | @send external getFloat64: (t, int) => float = "getFloat64" 22 | 23 | @send external getBigInt64: (t, int) => bigint = "getBigInt64" 24 | @send external getBigUint64: (t, int) => bigint = "getBigUint64" 25 | 26 | @send external setInt8: (t, int, int) => unit = "setInt8" 27 | @send external setUint8: (t, int, int) => unit = "setUint8" 28 | @send external setInt16: (t, int, int) => unit = "setInt16" 29 | @send external setUint16: (t, int, int) => unit = "setUint16" 30 | @send external setInt32: (t, int, int) => unit = "setInt32" 31 | @send external setUint32: (t, int, int) => unit = "setUint32" 32 | 33 | @send external setFloat32: (t, int, float) => unit = "setFloat32" 34 | @send external setFloat64: (t, int, float) => unit = "setFloat64" 35 | 36 | @send external setBigInt64: (t, int, bigint) => unit = "setBigInt64" 37 | @send external setBigUint64: (t, int, bigint) => unit = "setBigUint64" 38 | -------------------------------------------------------------------------------- /src/Core__Date.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml from "rescript/lib/es6/caml.js"; 4 | 5 | var UTC = {}; 6 | 7 | function equal(a, b) { 8 | return a.getTime() === b.getTime(); 9 | } 10 | 11 | function compare(a, b) { 12 | return Caml.float_compare(a.getTime(), b.getTime()); 13 | } 14 | 15 | export { 16 | UTC , 17 | equal , 18 | compare , 19 | } 20 | /* No side effect */ 21 | -------------------------------------------------------------------------------- /src/Core__Dict.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function $$delete$1(dict, string) { 5 | delete(dict[string]); 6 | } 7 | 8 | function forEach(dict, f) { 9 | Object.values(dict).forEach(function (value) { 10 | f(value); 11 | }); 12 | } 13 | 14 | function forEachWithKey(dict, f) { 15 | Object.entries(dict).forEach(function (param) { 16 | f(param[1], param[0]); 17 | }); 18 | } 19 | 20 | function mapValues(dict, f) { 21 | var target = {}; 22 | forEachWithKey(dict, (function (value, key) { 23 | target[key] = f(value); 24 | })); 25 | return target; 26 | } 27 | 28 | export { 29 | $$delete$1 as $$delete, 30 | forEach , 31 | forEachWithKey , 32 | mapValues , 33 | } 34 | /* No side effect */ 35 | -------------------------------------------------------------------------------- /src/Core__Dict.res: -------------------------------------------------------------------------------- 1 | type t<'a> = Js.Dict.t<'a> 2 | 3 | @get_index external getUnsafe: (t<'a>, string) => 'a = "" 4 | @get_index external get: (t<'a>, string) => option<'a> = "" 5 | @set_index external set: (t<'a>, string, 'a) => unit = "" 6 | @val external delete: 'a => unit = "delete" 7 | 8 | let delete = (dict, string) => { 9 | delete(get(dict, string)) 10 | } 11 | 12 | @obj external make: unit => t<'a> = "" 13 | 14 | @val external fromArray: array<(string, 'a)> => t<'a> = "Object.fromEntries" 15 | @val external fromIterator: Core__Iterator.t<(string, 'a)> => t<'a> = "Object.fromEntries" 16 | 17 | @val external toArray: t<'a> => array<(string, 'a)> = "Object.entries" 18 | 19 | @val external keysToArray: t<'a> => array = "Object.keys" 20 | 21 | @val external valuesToArray: t<'a> => array<'a> = "Object.values" 22 | 23 | @val external assign: (t<'a>, t<'a>) => t<'a> = "Object.assign" 24 | 25 | @val external copy: (@as(json`{}`) _, t<'a>) => t<'a> = "Object.assign" 26 | 27 | let forEach = (dict, f) => { 28 | dict->valuesToArray->Core__Array.forEach(value => f(value)) 29 | } 30 | 31 | let forEachWithKey = (dict, f) => { 32 | dict->toArray->Core__Array.forEach(((key, value)) => f(value, key)) 33 | } 34 | 35 | let mapValues = (dict, f) => { 36 | let target = make() 37 | dict->forEachWithKey((value, key) => { 38 | target->set(key, f(value)) 39 | }) 40 | target 41 | } 42 | -------------------------------------------------------------------------------- /src/Core__Error.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var $$EvalError = {}; 5 | 6 | var $$RangeError = {}; 7 | 8 | var $$ReferenceError = {}; 9 | 10 | var $$SyntaxError = {}; 11 | 12 | var $$TypeError = {}; 13 | 14 | var $$URIError = {}; 15 | 16 | function panic(msg) { 17 | throw new Error("Panic! " + msg); 18 | } 19 | 20 | export { 21 | $$EvalError , 22 | $$RangeError , 23 | $$ReferenceError , 24 | $$SyntaxError , 25 | $$TypeError , 26 | $$URIError , 27 | panic , 28 | } 29 | /* No side effect */ 30 | -------------------------------------------------------------------------------- /src/Core__Error.res: -------------------------------------------------------------------------------- 1 | type t = Js.Exn.t 2 | 3 | external fromException: exn => option = "?as_js_exn" 4 | external toException: t => exn = "%identity" 5 | 6 | @get external stack: t => option = "stack" 7 | @get external message: t => option = "message" 8 | @get external name: t => option = "name" 9 | @get external fileName: t => option = "fileName" 10 | 11 | @new external make: string => t = "Error" 12 | 13 | module EvalError = { 14 | @new external make: string => t = "EvalError" 15 | } 16 | 17 | module RangeError = { 18 | @new external make: string => t = "RangeError" 19 | } 20 | 21 | module ReferenceError = { 22 | @new external make: string => t = "ReferenceError" 23 | } 24 | 25 | module SyntaxError = { 26 | @new external make: string => t = "SyntaxError" 27 | } 28 | 29 | module TypeError = { 30 | @new external make: string => t = "TypeError" 31 | } 32 | 33 | module URIError = { 34 | @new external make: string => t = "URIError" 35 | } 36 | 37 | external raise: t => 'a = "%raise" 38 | 39 | let panic = msg => make(`Panic! ${msg}`)->raise 40 | -------------------------------------------------------------------------------- /src/Core__Float.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | function fromString(i) { 7 | var i$1 = parseFloat(i); 8 | if (isNaN(i$1)) { 9 | return ; 10 | } else { 11 | return i$1; 12 | } 13 | } 14 | 15 | function clamp(min, max, value) { 16 | var value$1 = max !== undefined && max < value ? max : value; 17 | if (min !== undefined && min > value$1) { 18 | return min; 19 | } else { 20 | return value$1; 21 | } 22 | } 23 | 24 | export { 25 | Constants , 26 | fromString , 27 | clamp , 28 | } 29 | /* No side effect */ 30 | -------------------------------------------------------------------------------- /src/Core__Float.res: -------------------------------------------------------------------------------- 1 | module Constants = { 2 | @val external nan: float = "NaN" 3 | @val external epsilon: float = "Number.EPSILON" 4 | @val external positiveInfinity: float = "Number.POSITIVE_INFINITY" 5 | @val external negativeInfinity: float = "Number.NEGATIVE_INFINITY" 6 | @val external minValue: float = "Number.MIN_VALUE" 7 | @val external maxValue: float = "Number.MAX_VALUE" 8 | } 9 | 10 | external equal: (float, float) => bool = "%equal" 11 | 12 | external compare: (float, float) => Core__Ordering.t = "%compare" 13 | 14 | @val external isNaN: float => bool = "isNaN" 15 | @val external isFinite: float => bool = "isFinite" 16 | @val external parseFloat: 'a => float = "parseFloat" 17 | // parseInt's return type is a float because it can be NaN 18 | @val external parseInt: ('a, ~radix: int=?) => float = "parseInt" 19 | @deprecated("Use `parseInt` instead") @val 20 | external parseIntWithRadix: ('a, ~radix: int) => float = "parseInt" 21 | 22 | @send external toExponential: (float, ~digits: int=?) => string = "toExponential" 23 | @deprecated("Use `toExponential` instead") @send 24 | external toExponentialWithPrecision: (float, ~digits: int) => string = "toExponential" 25 | 26 | @send external toFixed: (float, ~digits: int=?) => string = "toFixed" 27 | @deprecated("Use `toFixed` instead") @send 28 | external toFixedWithPrecision: (float, ~digits: int) => string = "toFixed" 29 | 30 | @send external toPrecision: (float, ~digits: int=?) => string = "toPrecision" 31 | @deprecated("Use `toPrecision` instead") @send 32 | external toPrecisionWithPrecision: (float, ~digits: int) => string = "toPrecision" 33 | 34 | @send external toString: (float, ~radix: int=?) => string = "toString" 35 | @deprecated("Use `toString` instead") @send 36 | external toStringWithRadix: (float, ~radix: int) => string = "toString" 37 | @send external toLocaleString: float => string = "toLocaleString" 38 | 39 | let fromString = i => 40 | switch parseFloat(i) { 41 | | i if isNaN(i) => None 42 | | i => Some(i) 43 | } 44 | 45 | external toInt: float => int = "%intoffloat" 46 | external fromInt: int => float = "%identity" 47 | 48 | @unboxed @noalloc external mod: (float, float) => float = "?fmod_float" 49 | 50 | let clamp = (~min=?, ~max=?, value): float => { 51 | let value = switch max { 52 | | Some(max) if max < value => max 53 | | _ => value 54 | } 55 | switch min { 56 | | Some(min) if min > value => min 57 | | _ => value 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Core__Global.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__Global.res: -------------------------------------------------------------------------------- 1 | type timeoutId = Js.Global.timeoutId 2 | 3 | @val external setTimeout: (unit => unit, int) => timeoutId = "setTimeout" 4 | @val external setTimeoutFloat: (unit => unit, float) => timeoutId = "setTimeout" 5 | @val external clearTimeout: timeoutId => unit = "clearTimeout" 6 | 7 | type intervalId = Js.Global.intervalId 8 | 9 | @val external setInterval: (unit => unit, int) => intervalId = "setInterval" 10 | @val external setIntervalFloat: (unit => unit, float) => intervalId = "setInterval" 11 | @val external clearInterval: intervalId => unit = "clearInterval" 12 | 13 | @val external encodeURI: string => string = "encodeURI" 14 | @val external decodeURI: string => string = "decodeURI" 15 | 16 | @val external encodeURIComponent: string => string = "encodeURIComponent" 17 | @val external decodeURIComponent: string => string = "decodeURIComponent" 18 | -------------------------------------------------------------------------------- /src/Core__Int.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Core__Array from "./Core__Array.mjs"; 4 | 5 | function fromString(x, radix) { 6 | var maybeInt = radix !== undefined ? parseInt(x, radix) : parseInt(x); 7 | if (isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) { 8 | return ; 9 | } else { 10 | return maybeInt | 0; 11 | } 12 | } 13 | 14 | function abs(x) { 15 | if (x >= 0) { 16 | return x; 17 | } else { 18 | return -x | 0; 19 | } 20 | } 21 | 22 | function range(start, end, optionsOpt) { 23 | var options = optionsOpt !== undefined ? optionsOpt : ({}); 24 | var isInverted = start > end; 25 | var n = options.step; 26 | var step; 27 | if (n !== undefined) { 28 | if (n !== 0) { 29 | step = n; 30 | } else { 31 | if (start !== end) { 32 | throw new RangeError("Incorrect range arguments"); 33 | } 34 | step = n; 35 | } 36 | } else { 37 | step = isInverted ? -1 : 1; 38 | } 39 | var length; 40 | if (isInverted === step >= 0) { 41 | length = 0; 42 | } else if (step === 0) { 43 | length = options.inclusive === true ? 1 : 0; 44 | } else { 45 | var range$1 = isInverted ? start - end | 0 : end - start | 0; 46 | var range$2 = options.inclusive === true ? range$1 + 1 | 0 : range$1; 47 | length = Math.ceil(range$2 / abs(step)) | 0; 48 | } 49 | return Core__Array.fromInitializer(length, (function (i) { 50 | return start + Math.imul(i, step) | 0; 51 | })); 52 | } 53 | 54 | function rangeWithOptions(start, end, options) { 55 | return range(start, end, options); 56 | } 57 | 58 | function clamp(min, max, value) { 59 | var value$1 = max !== undefined && max < value ? max : value; 60 | if (min !== undefined && min > value$1) { 61 | return min; 62 | } else { 63 | return value$1; 64 | } 65 | } 66 | 67 | function lnot(x) { 68 | return x ^ -1; 69 | } 70 | 71 | var Bitwise = { 72 | lnot: lnot 73 | }; 74 | 75 | var Constants = { 76 | minValue: -2147483648, 77 | maxValue: 2147483647 78 | }; 79 | 80 | export { 81 | Constants , 82 | fromString , 83 | range , 84 | rangeWithOptions , 85 | clamp , 86 | Bitwise , 87 | } 88 | /* No side effect */ 89 | -------------------------------------------------------------------------------- /src/Core__Int.res: -------------------------------------------------------------------------------- 1 | module Constants = { 2 | @inline let minValue = -2147483648 3 | @inline let maxValue = 2147483647 4 | } 5 | 6 | external equal: (int, int) => bool = "%equal" 7 | 8 | external compare: (int, int) => Core__Ordering.t = "%compare" 9 | 10 | @send external toExponential: (int, ~digits: int=?) => string = "toExponential" 11 | @deprecated("Use `toExponential` instead") @send 12 | external toExponentialWithPrecision: (int, ~digits: int) => string = "toExponential" 13 | 14 | @send external toFixed: (int, ~digits: int=?) => string = "toFixed" 15 | @deprecated("Use `toFixed` instead") @send 16 | external toFixedWithPrecision: (int, ~digits: int) => string = "toFixed" 17 | 18 | @send external toPrecision: (int, ~digits: int=?) => string = "toPrecision" 19 | @deprecated("Use `toPrecision` instead") @send 20 | external toPrecisionWithPrecision: (int, ~digits: int) => string = "toPrecision" 21 | 22 | @send external toString: (int, ~radix: int=?) => string = "toString" 23 | @deprecated("Use `toString` instead") @send 24 | external toStringWithRadix: (int, ~radix: int) => string = "toString" 25 | @send external toLocaleString: int => string = "toLocaleString" 26 | 27 | external toFloat: int => float = "%identity" 28 | external fromFloat: float => int = "%intoffloat" 29 | 30 | let fromString = (x, ~radix=?) => { 31 | let maybeInt = switch radix { 32 | | Some(radix) => Core__Float.parseInt(x, ~radix) 33 | | None => Core__Float.parseInt(x) 34 | } 35 | 36 | if Core__Float.isNaN(maybeInt) { 37 | None 38 | } else if maybeInt > Constants.maxValue->toFloat || maybeInt < Constants.minValue->toFloat { 39 | None 40 | } else { 41 | let asInt = fromFloat(maybeInt) 42 | Some(asInt) 43 | } 44 | } 45 | 46 | external mod: (int, int) => int = "%modint" 47 | 48 | type rangeOptions = {step?: int, inclusive?: bool} 49 | 50 | let abs = x => 51 | if x >= 0 { 52 | x 53 | } else { 54 | -x 55 | } 56 | 57 | let range = (start, end, ~options: rangeOptions={}) => { 58 | let isInverted = start > end 59 | 60 | let step = switch options.step { 61 | | None => isInverted ? -1 : 1 62 | | Some(0) if start !== end => 63 | Core__Error.raise(Core__Error.RangeError.make("Incorrect range arguments")) 64 | | Some(n) => n 65 | } 66 | 67 | let length = if isInverted === (step >= 0) { 68 | 0 // infinite because step goes in opposite direction of end 69 | } else if step == 0 { 70 | options.inclusive === Some(true) ? 1 : 0 71 | } else { 72 | let range = isInverted ? start - end : end - start 73 | let range = options.inclusive === Some(true) ? range + 1 : range 74 | ceil(float(range) /. float(abs(step)))->Core__Float.toInt 75 | } 76 | 77 | Core__Array.fromInitializer(~length, i => start + i * step) 78 | } 79 | 80 | @deprecated("Use `range` instead") @send 81 | let rangeWithOptions = (start, end, options) => range(start, end, ~options) 82 | 83 | let clamp = (~min=?, ~max=?, value): int => { 84 | let value = switch max { 85 | | Some(max) if max < value => max 86 | | _ => value 87 | } 88 | switch min { 89 | | Some(min) if min > value => min 90 | | _ => value 91 | } 92 | } 93 | 94 | module Bitwise = { 95 | external land: (int, int) => int = "%andint" 96 | external lor: (int, int) => int = "%orint" 97 | external lxor: (int, int) => int = "%xorint" 98 | 99 | external lsl: (int, int) => int = "%lslint" 100 | external lsr: (int, int) => int = "%lsrint" 101 | external asr: (int, int) => int = "%asrint" 102 | 103 | let lnot = x => lxor(x, -1) 104 | } 105 | -------------------------------------------------------------------------------- /src/Core__Intl.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Common; 5 | 6 | var Collator; 7 | 8 | var DateTimeFormat; 9 | 10 | var ListFormat; 11 | 12 | var Locale; 13 | 14 | var NumberFormat; 15 | 16 | var PluralRules; 17 | 18 | var RelativeTimeFormat; 19 | 20 | var Segmenter; 21 | 22 | var Segments; 23 | 24 | export { 25 | Common , 26 | Collator , 27 | DateTimeFormat , 28 | ListFormat , 29 | Locale , 30 | NumberFormat , 31 | PluralRules , 32 | RelativeTimeFormat , 33 | Segmenter , 34 | Segments , 35 | } 36 | /* No side effect */ 37 | -------------------------------------------------------------------------------- /src/Core__Intl.res: -------------------------------------------------------------------------------- 1 | module Common = Core__Intl__Common 2 | module Collator = Core__Intl__Collator 3 | module DateTimeFormat = Core__Intl__DateTimeFormat 4 | module ListFormat = Core__Intl__ListFormat 5 | module Locale = Core__Intl__Locale 6 | module NumberFormat = Core__Intl__NumberFormat 7 | module PluralRules = Core__Intl__PluralRules 8 | module RelativeTimeFormat = Core__Intl__RelativeTimeFormat 9 | module Segmenter = Core__Intl__Segmenter 10 | module Segments = Core__Intl__Segments 11 | 12 | /** 13 | @throws RangeError 14 | */ 15 | external getCanonicalLocalesExn: string => array = "Intl.getCanonicalLocales" 16 | 17 | /** 18 | @throws RangeError 19 | */ 20 | external getCanonicalLocalesManyExn: array => array = "Intl.getCanonicalLocales" 21 | 22 | /** 23 | @throws RangeError 24 | */ 25 | external supportedValuesOfExn: string => array = "Intl.supportedValuesOf" 26 | -------------------------------------------------------------------------------- /src/Core__Iterator.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function forEach(iterator, f) { 5 | var iteratorDone = false; 6 | while(!iteratorDone) { 7 | var match = iterator.next(); 8 | f(match.value); 9 | iteratorDone = match.done; 10 | }; 11 | } 12 | 13 | export { 14 | forEach , 15 | } 16 | /* No side effect */ 17 | -------------------------------------------------------------------------------- /src/Core__Iterator.res: -------------------------------------------------------------------------------- 1 | type t<'a> 2 | 3 | type value<'a> = { 4 | done: bool, 5 | value: option<'a>, 6 | } 7 | 8 | @send external next: t<'a> => value<'a> = "next" 9 | external toArray: t<'a> => array<'a> = "Array.from" 10 | external toArrayWithMapper: (t<'a>, 'a => 'b) => array<'b> = "Array.from" 11 | 12 | let forEach = (iterator, f) => { 13 | let iteratorDone = ref(false) 14 | 15 | while !iteratorDone.contents { 16 | let {done, value} = iterator->next 17 | f(value) 18 | iteratorDone := done 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Core__Iterator.resi: -------------------------------------------------------------------------------- 1 | /*** 2 | Bindings to JavaScript iterators. 3 | 4 | See [`iterator protocols`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN. 5 | */ 6 | 7 | /** 8 | The type representing an iterator. 9 | */ 10 | type t<'a> 11 | 12 | /** 13 | The current value of an iterator. 14 | */ 15 | type value<'a> = { 16 | /** 17 | Whether there are more values to iterate on before the iterator is done. 18 | */ 19 | done: bool, 20 | /** 21 | The value of this iteration, if any. 22 | */ 23 | value: option<'a>, 24 | } 25 | 26 | /** 27 | Returns the next value of the iterator, if any. 28 | 29 | See [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN. 30 | 31 | ## Examples 32 | ```rescript 33 | @val external someIterator: Iterator.t = "someIterator" 34 | 35 | // Pulls out the next value of the iterator 36 | let {Iterator.done, value} = someIterator->Iterator.next 37 | ``` 38 | */ 39 | @send 40 | external next: t<'a> => value<'a> = "next" 41 | 42 | /** 43 | Turns an iterator into an array of the remaining values. 44 | Remember 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. 45 | 46 | See [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN. 47 | 48 | ## Examples 49 | ```rescript 50 | let map = Map.make() 51 | map->Map.set("someKey", "someValue") 52 | map->Map.set("someKey2", "someValue2") 53 | 54 | // `Map.keys` returns all keys of the map as an iterator. 55 | let mapKeysAsArray = map->Map.keys->Iterator.toArray 56 | 57 | Console.log(mapKeysAsArray) // Logs ["someKey", "someKey2"] to the console. 58 | ``` 59 | */ 60 | external toArray: t<'a> => array<'a> = "Array.from" 61 | 62 | /** 63 | `toArray(iterator)` turns `iterator` into an array of its remaining values, applying the provided mapper function on each item. 64 | Remember 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. 65 | 66 | See [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN. 67 | 68 | ## Examples 69 | ```rescript 70 | let map = Map.make() 71 | map->Map.set("someKey", "someValue") 72 | map->Map.set("someKey2", "someValue2") 73 | 74 | // `Map.keys` returns all keys of the map as an iterator. 75 | let mapKeysAsArray = map 76 | ->Map.keys 77 | ->Iterator.toArrayWithMapper(key => key->String.length) 78 | 79 | Console.log(mapKeysAsArray) // Logs [7, 8] to the console. 80 | ``` 81 | */ 82 | external toArrayWithMapper: (t<'a>, 'a => 'b) => array<'b> = "Array.from" 83 | 84 | /** 85 | `forEach(iterator, fn)` consumes all values in the iterator and runs the callback `fn` for each value. 86 | 87 | See [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN. 88 | 89 | ## Examples 90 | ```rescript 91 | @val external someIterator: Iterator.t = "someIterator" 92 | 93 | someIterator->Iterator.forEach(value => 94 | switch value { 95 | | Some(value) if value > 10 => Console.log("More than 10!") 96 | | _ => () 97 | } 98 | ) 99 | ``` 100 | */ 101 | let forEach: (t<'a>, option<'a> => unit) => unit 102 | -------------------------------------------------------------------------------- /src/Core__JSON.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function classify(value) { 5 | var match = Object.prototype.toString.call(value); 6 | switch (match) { 7 | case "[object Array]" : 8 | return { 9 | TAG: "Array", 10 | _0: value 11 | }; 12 | case "[object Boolean]" : 13 | return { 14 | TAG: "Bool", 15 | _0: value 16 | }; 17 | case "[object Null]" : 18 | return "Null"; 19 | case "[object Number]" : 20 | return { 21 | TAG: "Number", 22 | _0: value 23 | }; 24 | case "[object String]" : 25 | return { 26 | TAG: "String", 27 | _0: value 28 | }; 29 | default: 30 | return { 31 | TAG: "Object", 32 | _0: value 33 | }; 34 | } 35 | } 36 | 37 | var Classify = { 38 | classify: classify 39 | }; 40 | 41 | var Encode = {}; 42 | 43 | function bool(json) { 44 | if (typeof json === "boolean") { 45 | return json; 46 | } 47 | 48 | } 49 | 50 | function $$null(json) { 51 | if (json === null) { 52 | return null; 53 | } 54 | 55 | } 56 | 57 | function string(json) { 58 | if (typeof json === "string") { 59 | return json; 60 | } 61 | 62 | } 63 | 64 | function $$float(json) { 65 | if (typeof json === "number") { 66 | return json; 67 | } 68 | 69 | } 70 | 71 | function object(json) { 72 | if (typeof json === "object" && !Array.isArray(json) && json !== null) { 73 | return json; 74 | } 75 | 76 | } 77 | 78 | function array(json) { 79 | if (Array.isArray(json)) { 80 | return json; 81 | } 82 | 83 | } 84 | 85 | var Decode = { 86 | bool: bool, 87 | $$null: $$null, 88 | string: string, 89 | $$float: $$float, 90 | object: object, 91 | array: array 92 | }; 93 | 94 | export { 95 | Classify , 96 | Encode , 97 | Decode , 98 | } 99 | /* No side effect */ 100 | -------------------------------------------------------------------------------- /src/Core__Map.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__Map.res: -------------------------------------------------------------------------------- 1 | type t<'k, 'v> = Js.Map.t<'k, 'v> 2 | 3 | @new external make: unit => t<'k, 'v> = "Map" 4 | @new external fromArray: array<('k, 'v)> => t<'k, 'v> = "Map" 5 | @new external fromIterator: Core__Iterator.t<('k, 'v)> => t<'k, 'v> = "Map" 6 | 7 | @get external size: t<'k, 'v> => int = "size" 8 | 9 | @send external clear: t<'k, 'v> => unit = "clear" 10 | 11 | @send external forEach: (t<'k, 'v>, 'v => unit) => unit = "forEach" 12 | @send external forEachWithKey: (t<'k, 'v>, ('v, 'k) => unit) => unit = "forEach" 13 | 14 | @send external get: (t<'k, 'v>, 'k) => option<'v> = "get" 15 | @send external has: (t<'k, 'v>, 'k) => bool = "has" 16 | @send external set: (t<'k, 'v>, 'k, 'v) => unit = "set" 17 | @send external delete: (t<'k, 'v>, 'k) => bool = "delete" 18 | 19 | @send external keys: t<'k, 'v> => Core__Iterator.t<'k> = "keys" 20 | @send external values: t<'k, 'v> => Core__Iterator.t<'v> = "values" 21 | @send external entries: t<'k, 'v> => Core__Iterator.t<('k, 'v)> = "entries" 22 | -------------------------------------------------------------------------------- /src/Core__Math.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | function floor(f) { 7 | return Math.floor(f) | 0; 8 | } 9 | 10 | function ceil(f) { 11 | return Math.ceil(f) | 0; 12 | } 13 | 14 | function random(min, max) { 15 | var f = Math.random() * (max - min | 0); 16 | return (Math.floor(f) | 0) + min | 0; 17 | } 18 | 19 | var Int = { 20 | floor: floor, 21 | ceil: ceil, 22 | random: random 23 | }; 24 | 25 | export { 26 | Constants , 27 | Int , 28 | } 29 | /* No side effect */ 30 | -------------------------------------------------------------------------------- /src/Core__Math.res: -------------------------------------------------------------------------------- 1 | module Constants = { 2 | @val external e: float = "Math.E" 3 | @val external ln2: float = "Math.LN2" 4 | @val external ln10: float = "Math.LN10" 5 | @val external log2e: float = "Math.LOG2E" 6 | @val external log10e: float = "Math.LOG10E" 7 | @val external pi: float = "Math.PI" 8 | @val external sqrt1_2: float = "Math.SQRT1_2" 9 | @val external sqrt2: float = "Math.SQRT2" 10 | } 11 | 12 | @val external abs: float => float = "Math.abs" 13 | @val external acos: float => float = "Math.acos" 14 | @val external acosh: float => float = "Math.acosh" 15 | @val external asin: float => float = "Math.asin" 16 | @val external asinh: float => float = "Math.asinh" 17 | @val external atan: float => float = "Math.atan" 18 | @val external atanh: float => float = "Math.atanh" 19 | @val external atan2: (~y: float, ~x: float) => float = "Math.atan2" 20 | @val external cbrt: float => float = "Math.cbrt" 21 | @val external ceil: float => float = "Math.ceil" 22 | @val external cos: float => float = "Math.cos" 23 | @val external cosh: float => float = "Math.cosh" 24 | @val external exp: float => float = "Math.exp" 25 | @val external expm1: float => float = "Math.expm1" 26 | @val external floor: float => float = "Math.floor" 27 | @val external fround: float => float = "Math.fround" 28 | @val external hypot: (float, float) => float = "Math.hypot" 29 | @variadic @val external hypotMany: array => float = "Math.hypot" 30 | @val external log: float => float = "Math.log" 31 | @val external log1p: float => float = "Math.log1p" 32 | @val external log10: float => float = "Math.log10" 33 | @val external log2: float => float = "Math.log2" 34 | @val external min: (float, float) => float = "Math.min" 35 | @variadic @val external minMany: array => float = "Math.min" 36 | @val external max: (float, float) => float = "Math.max" 37 | @variadic @val external maxMany: array => float = "Math.max" 38 | @val external pow: (float, ~exp: float) => float = "Math.pow" 39 | @val external random: unit => float = "Math.random" 40 | @val external round: float => float = "Math.round" 41 | @val external sign: float => float = "Math.sign" 42 | @val external sin: float => float = "Math.sin" 43 | @val external sinh: float => float = "Math.sinh" 44 | @val external sqrt: float => float = "Math.sqrt" 45 | @val external tan: float => float = "Math.tan" 46 | @val external tanh: float => float = "Math.tanh" 47 | @val external trunc: float => float = "Math.trunc" 48 | 49 | module Int = { 50 | @val external abs: int => int = "Math.abs" 51 | @val external clz32: int => int = "Math.clz32" 52 | @val external imul: (int, int) => int = "Math.imul" 53 | @val external min: (int, int) => int = "Math.min" 54 | @variadic @val external minMany: array => int = "Math.min" 55 | @val external max: (int, int) => int = "Math.max" 56 | @variadic @val external maxMany: array => int = "Math.max" 57 | @val external pow: (int, ~exp: int) => int = "Math.pow" 58 | @val external sign: int => int = "Math.sign" 59 | let floor: float => int = f => f->floor->Core__Float.toInt 60 | let ceil: float => int = f => f->ceil->Core__Float.toInt 61 | let random: (int, int) => int = (min, max) => 62 | floor(random() *. Core__Int.toFloat(max - min)) + min 63 | } 64 | -------------------------------------------------------------------------------- /src/Core__Null.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_option from "rescript/lib/es6/caml_option.js"; 4 | import * as Core__Option from "./Core__Option.mjs"; 5 | 6 | function fromOption(option) { 7 | if (option !== undefined) { 8 | return Caml_option.valFromOption(option); 9 | } else { 10 | return null; 11 | } 12 | } 13 | 14 | function equal(a, b, eq) { 15 | return Core__Option.equal(a === null ? undefined : Caml_option.some(a), b === null ? undefined : Caml_option.some(b), eq); 16 | } 17 | 18 | function compare(a, b, cmp) { 19 | return Core__Option.compare(a === null ? undefined : Caml_option.some(a), b === null ? undefined : Caml_option.some(b), cmp); 20 | } 21 | 22 | function getOr(value, $$default) { 23 | if (value !== null) { 24 | return value; 25 | } else { 26 | return $$default; 27 | } 28 | } 29 | 30 | function getExn(value) { 31 | if (value !== null) { 32 | return value; 33 | } 34 | throw { 35 | RE_EXN_ID: "Invalid_argument", 36 | _1: "Null.getExn: value is null", 37 | Error: new Error() 38 | }; 39 | } 40 | 41 | function forEach(value, f) { 42 | if (value !== null) { 43 | return f(value); 44 | } 45 | 46 | } 47 | 48 | function map(value, f) { 49 | if (value !== null) { 50 | return f(value); 51 | } else { 52 | return null; 53 | } 54 | } 55 | 56 | function mapOr(value, $$default, f) { 57 | if (value !== null) { 58 | return f(value); 59 | } else { 60 | return $$default; 61 | } 62 | } 63 | 64 | function flatMap(value, f) { 65 | if (value !== null) { 66 | return f(value); 67 | } else { 68 | return null; 69 | } 70 | } 71 | 72 | var getWithDefault = getOr; 73 | 74 | var mapWithDefault = mapOr; 75 | 76 | export { 77 | equal , 78 | compare , 79 | fromOption , 80 | getOr , 81 | getWithDefault , 82 | getExn , 83 | forEach , 84 | map , 85 | mapOr , 86 | mapWithDefault , 87 | flatMap , 88 | } 89 | /* No side effect */ 90 | -------------------------------------------------------------------------------- /src/Core__Null.res: -------------------------------------------------------------------------------- 1 | @unboxed 2 | type t<'a> = Js.Null.t<'a> = 3 | | Value('a) 4 | | @as(null) Null 5 | 6 | external asNullable: t<'a> => Core__Nullable.t<'a> = "%identity" 7 | 8 | external null: t<'a> = "#null" 9 | 10 | external make: 'a => t<'a> = "%identity" 11 | 12 | external toOption: t<'a> => option<'a> = "#null_to_opt" 13 | 14 | let fromOption: option<'a> => t<'a> = option => 15 | switch option { 16 | | Some(x) => make(x) 17 | | None => null 18 | } 19 | 20 | let equal = (a, b, eq) => Core__Option.equal(a->toOption, b->toOption, eq) 21 | 22 | let compare = (a, b, cmp) => Core__Option.compare(a->toOption, b->toOption, cmp) 23 | 24 | let getOr = (value, default) => 25 | switch value->toOption { 26 | | Some(x) => x 27 | | None => default 28 | } 29 | 30 | let getWithDefault = getOr 31 | 32 | let getExn: t<'a> => 'a = value => 33 | switch value->toOption { 34 | | Some(x) => x 35 | | None => raise(Invalid_argument("Null.getExn: value is null")) 36 | } 37 | 38 | external getUnsafe: t<'a> => 'a = "%identity" 39 | 40 | let forEach = (value, f) => 41 | switch value->toOption { 42 | | Some(x) => f(x) 43 | | None => () 44 | } 45 | 46 | let map = (value, f) => 47 | switch value->toOption { 48 | | Some(x) => make(f(x)) 49 | | None => null 50 | } 51 | 52 | let mapOr = (value, default, f) => 53 | switch value->toOption { 54 | | Some(x) => f(x) 55 | | None => default 56 | } 57 | 58 | let mapWithDefault = mapOr 59 | 60 | let flatMap = (value, f) => 61 | switch value->toOption { 62 | | Some(x) => f(x) 63 | | None => null 64 | } 65 | -------------------------------------------------------------------------------- /src/Core__Nullable.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_option from "rescript/lib/es6/caml_option.js"; 4 | import * as Core__Option from "./Core__Option.mjs"; 5 | 6 | function fromOption(option) { 7 | if (option !== undefined) { 8 | return Caml_option.valFromOption(option); 9 | } 10 | 11 | } 12 | 13 | function equal(a, b, eq) { 14 | return Core__Option.equal((a == null) ? undefined : Caml_option.some(a), (b == null) ? undefined : Caml_option.some(b), eq); 15 | } 16 | 17 | function compare(a, b, cmp) { 18 | return Core__Option.compare((a == null) ? undefined : Caml_option.some(a), (b == null) ? undefined : Caml_option.some(b), cmp); 19 | } 20 | 21 | function getOr(value, $$default) { 22 | if (value == null) { 23 | return $$default; 24 | } else { 25 | return value; 26 | } 27 | } 28 | 29 | function getExn(value) { 30 | if (!(value == null)) { 31 | return value; 32 | } 33 | throw { 34 | RE_EXN_ID: "Invalid_argument", 35 | _1: "Nullable.getExn: value is null or undefined", 36 | Error: new Error() 37 | }; 38 | } 39 | 40 | function forEach(value, f) { 41 | if (!(value == null)) { 42 | return f(value); 43 | } 44 | 45 | } 46 | 47 | function map(value, f) { 48 | if (value == null) { 49 | return value; 50 | } else { 51 | return f(value); 52 | } 53 | } 54 | 55 | function mapOr(value, $$default, f) { 56 | if (value == null) { 57 | return $$default; 58 | } else { 59 | return f(value); 60 | } 61 | } 62 | 63 | function flatMap(value, f) { 64 | if (value == null) { 65 | return value; 66 | } else { 67 | return f(value); 68 | } 69 | } 70 | 71 | var getWithDefault = getOr; 72 | 73 | var mapWithDefault = mapOr; 74 | 75 | export { 76 | equal , 77 | compare , 78 | fromOption , 79 | getOr , 80 | getWithDefault , 81 | getExn , 82 | forEach , 83 | map , 84 | mapOr , 85 | mapWithDefault , 86 | flatMap , 87 | } 88 | /* No side effect */ 89 | -------------------------------------------------------------------------------- /src/Core__Nullable.res: -------------------------------------------------------------------------------- 1 | @unboxed 2 | type t<'a> = Js.Nullable.t<'a> = 3 | | Value('a) 4 | | @as(null) Null 5 | | @as(undefined) Undefined 6 | 7 | external null: t<'a> = "#null" 8 | 9 | external undefined: t<'a> = "#undefined" 10 | 11 | external isNullable: t<'a> => bool = "#is_nullable" 12 | 13 | external make: 'a => t<'a> = "%identity" 14 | 15 | external toOption: t<'a> => option<'a> = "#nullable_to_opt" 16 | 17 | let fromOption: option<'a> => t<'a> = option => 18 | switch option { 19 | | Some(x) => make(x) 20 | | None => undefined 21 | } 22 | 23 | let equal = (a, b, eq) => Core__Option.equal(a->toOption, b->toOption, eq) 24 | 25 | let compare = (a, b, cmp) => Core__Option.compare(a->toOption, b->toOption, cmp) 26 | 27 | let getOr = (value, default) => 28 | switch value->toOption { 29 | | Some(x) => x 30 | | None => default 31 | } 32 | 33 | let getWithDefault = getOr 34 | 35 | let getExn: t<'a> => 'a = value => 36 | switch value->toOption { 37 | | Some(x) => x 38 | | None => raise(Invalid_argument("Nullable.getExn: value is null or undefined")) 39 | } 40 | 41 | external getUnsafe: t<'a> => 'a = "%identity" 42 | 43 | let forEach = (value, f) => 44 | switch value->toOption { 45 | | Some(x) => f(x) 46 | | None => () 47 | } 48 | 49 | let map = (value, f) => 50 | switch value->toOption { 51 | | Some(x) => make(f(x)) 52 | | None => Obj.magic(value) 53 | } 54 | 55 | let mapOr = (value, default, f) => 56 | switch value->toOption { 57 | | Some(x) => f(x) 58 | | None => default 59 | } 60 | 61 | let mapWithDefault = mapOr 62 | 63 | let flatMap = (value, f) => 64 | switch value->toOption { 65 | | Some(x) => f(x) 66 | | None => Obj.magic(value) 67 | } 68 | -------------------------------------------------------------------------------- /src/Core__Object.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__Option.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_option from "rescript/lib/es6/caml_option.js"; 4 | import * as Core__Error from "./Core__Error.mjs"; 5 | 6 | function filter(opt, p) { 7 | if (opt !== undefined && p(Caml_option.valFromOption(opt))) { 8 | return opt; 9 | } 10 | 11 | } 12 | 13 | function forEach(opt, f) { 14 | if (opt !== undefined) { 15 | return f(Caml_option.valFromOption(opt)); 16 | } 17 | 18 | } 19 | 20 | function getExn(x, message) { 21 | if (x !== undefined) { 22 | return Caml_option.valFromOption(x); 23 | } else { 24 | return Core__Error.panic(message !== undefined ? message : "Option.getExn called for None value"); 25 | } 26 | } 27 | 28 | function mapOr(opt, $$default, f) { 29 | if (opt !== undefined) { 30 | return f(Caml_option.valFromOption(opt)); 31 | } else { 32 | return $$default; 33 | } 34 | } 35 | 36 | function map(opt, f) { 37 | if (opt !== undefined) { 38 | return Caml_option.some(f(Caml_option.valFromOption(opt))); 39 | } 40 | 41 | } 42 | 43 | function flatMap(opt, f) { 44 | if (opt !== undefined) { 45 | return f(Caml_option.valFromOption(opt)); 46 | } 47 | 48 | } 49 | 50 | function getOr(opt, $$default) { 51 | if (opt !== undefined) { 52 | return Caml_option.valFromOption(opt); 53 | } else { 54 | return $$default; 55 | } 56 | } 57 | 58 | function orElse(opt, other) { 59 | if (opt !== undefined) { 60 | return opt; 61 | } else { 62 | return other; 63 | } 64 | } 65 | 66 | function isSome(x) { 67 | return x !== undefined; 68 | } 69 | 70 | function isNone(x) { 71 | return x === undefined; 72 | } 73 | 74 | function equal(a, b, eq) { 75 | if (a !== undefined) { 76 | if (b !== undefined) { 77 | return eq(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); 78 | } else { 79 | return false; 80 | } 81 | } else { 82 | return b === undefined; 83 | } 84 | } 85 | 86 | function compare(a, b, cmp) { 87 | if (a !== undefined) { 88 | if (b !== undefined) { 89 | return cmp(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); 90 | } else { 91 | return 1; 92 | } 93 | } else if (b !== undefined) { 94 | return -1; 95 | } else { 96 | return 0; 97 | } 98 | } 99 | 100 | var mapWithDefault = mapOr; 101 | 102 | var getWithDefault = getOr; 103 | 104 | export { 105 | filter , 106 | forEach , 107 | getExn , 108 | mapOr , 109 | mapWithDefault , 110 | map , 111 | flatMap , 112 | getOr , 113 | getWithDefault , 114 | orElse , 115 | isSome , 116 | isNone , 117 | equal , 118 | compare , 119 | } 120 | /* No side effect */ 121 | -------------------------------------------------------------------------------- /src/Core__Option.res: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU Lesser General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * In addition to the permissions granted to you by the LGPL, you may combine 9 | * or link a "work that uses the Library" with a publicly distributed version 10 | * of this file to produce a combined library or application, then distribute 11 | * that combined work under the terms of your choosing, with no requirement 12 | * to comply with the obligations normally placed on you by section 4 of the 13 | * LGPL version 3 (or the corresponding section of a later version of the LGPL 14 | * should you choose to use a later version). 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 24 | 25 | let filter = (opt, p) => 26 | switch opt { 27 | | Some(x) as option if p(x) => option 28 | | _ => None 29 | } 30 | 31 | let forEach = (opt, f) => 32 | switch opt { 33 | | Some(x) => f(x) 34 | | None => () 35 | } 36 | 37 | let getExn = (x, ~message=?) => 38 | switch x { 39 | | Some(x) => x 40 | | None => 41 | Core__Error.panic( 42 | switch message { 43 | | None => "Option.getExn called for None value" 44 | | Some(message) => message 45 | }, 46 | ) 47 | } 48 | 49 | external getUnsafe: option<'a> => 'a = "%identity" 50 | 51 | let mapOr = (opt, default, f) => 52 | switch opt { 53 | | Some(x) => f(x) 54 | | None => default 55 | } 56 | 57 | let mapWithDefault = mapOr 58 | 59 | let map = (opt, f) => 60 | switch opt { 61 | | Some(x) => Some(f(x)) 62 | | None => None 63 | } 64 | 65 | let flatMap = (opt, f) => 66 | switch opt { 67 | | Some(x) => f(x) 68 | | None => None 69 | } 70 | 71 | let getOr = (opt, default) => 72 | switch opt { 73 | | Some(x) => x 74 | | None => default 75 | } 76 | 77 | let getWithDefault = getOr 78 | 79 | let orElse = (opt, other) => 80 | switch opt { 81 | | Some(_) as some => some 82 | | None => other 83 | } 84 | 85 | let isSome = x => 86 | switch x { 87 | | Some(_) => true 88 | | None => false 89 | } 90 | 91 | let isNone = x => x == None 92 | 93 | let equal = (a, b, eq) => 94 | switch (a, b) { 95 | | (Some(a), Some(b)) => eq(a, b) 96 | | (None, None) => true 97 | | (None, Some(_)) | (Some(_), None) => false 98 | } 99 | 100 | let compare = (a, b, cmp) => 101 | switch (a, b) { 102 | | (Some(a), Some(b)) => cmp(a, b) 103 | | (None, Some(_)) => Core__Ordering.less 104 | | (Some(_), None) => Core__Ordering.greater 105 | | (None, None) => Core__Ordering.equal 106 | } 107 | -------------------------------------------------------------------------------- /src/Core__Ordering.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function isLess(ord) { 5 | return ord < 0; 6 | } 7 | 8 | function isEqual(ord) { 9 | return ord === 0; 10 | } 11 | 12 | function isGreater(ord) { 13 | return ord > 0; 14 | } 15 | 16 | function invert(ord) { 17 | return - ord; 18 | } 19 | 20 | function fromInt(n) { 21 | if (n < 0) { 22 | return -1; 23 | } else if (n > 0) { 24 | return 1; 25 | } else { 26 | return 0; 27 | } 28 | } 29 | 30 | export { 31 | isLess , 32 | isEqual , 33 | isGreater , 34 | invert , 35 | fromInt , 36 | } 37 | /* No side effect */ 38 | -------------------------------------------------------------------------------- /src/Core__Ordering.res: -------------------------------------------------------------------------------- 1 | type t = float 2 | 3 | @inline let less = -1. 4 | @inline let equal = 0. 5 | @inline let greater = 1. 6 | 7 | let isLess = ord => ord < equal 8 | let isEqual = ord => ord == equal 9 | let isGreater = ord => ord > equal 10 | 11 | let invert = ord => -.ord 12 | 13 | let fromInt = n => n < 0 ? less : n > 0 ? greater : equal 14 | -------------------------------------------------------------------------------- /src/Core__Promise.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; 4 | 5 | function $$catch(promise, callback) { 6 | return promise.catch(function (err) { 7 | return callback(Caml_js_exceptions.internalToOCamlException(err)); 8 | }); 9 | } 10 | 11 | export { 12 | $$catch , 13 | } 14 | /* No side effect */ 15 | -------------------------------------------------------------------------------- /src/Core__Promise.res: -------------------------------------------------------------------------------- 1 | type t<+'a> = promise<'a> 2 | 3 | @new 4 | external make: (('a => unit, 'e => unit) => unit) => t<'a> = "Promise" 5 | 6 | type promiseAndResolvers<'a> = { 7 | promise: t<'a>, 8 | resolve: 'a => unit, 9 | reject: exn => unit, 10 | } 11 | 12 | @scope("Promise") @val 13 | external withResolvers: unit => promiseAndResolvers<_> = "withResolvers" 14 | 15 | @scope("Promise") @val 16 | external resolve: 'a => t<'a> = "resolve" 17 | 18 | @send external then: (t<'a>, 'a => t<'b>) => t<'b> = "then" 19 | 20 | @send 21 | external thenResolve: (t<'a>, 'a => 'b) => t<'b> = "then" 22 | 23 | @send external finally: (t<'a>, unit => unit) => t<'a> = "finally" 24 | 25 | @scope("Promise") @val 26 | external reject: exn => t<_> = "reject" 27 | 28 | @scope("Promise") @val 29 | external all: array> => t> = "all" 30 | 31 | @scope("Promise") @val 32 | external all2: ((t<'a>, t<'b>)) => t<('a, 'b)> = "all" 33 | 34 | @scope("Promise") @val 35 | external all3: ((t<'a>, t<'b>, t<'c>)) => t<('a, 'b, 'c)> = "all" 36 | 37 | @scope("Promise") @val 38 | external all4: ((t<'a>, t<'b>, t<'c>, t<'d>)) => t<('a, 'b, 'c, 'd)> = "all" 39 | 40 | @scope("Promise") @val 41 | external all5: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>)) => t<('a, 'b, 'c, 'd, 'e)> = "all" 42 | 43 | @scope("Promise") @val 44 | external all6: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>)) => t<('a, 'b, 'c, 'd, 'e, 'f)> = "all" 45 | 46 | @tag("status") 47 | type settledResult<+'a> = 48 | | @as("fulfilled") Fulfilled({value: 'a}) | @as("rejected") Rejected({reason: exn}) 49 | 50 | @scope("Promise") @val 51 | external allSettled: array> => promise>> = "allSettled" 52 | 53 | @scope("Promise") @val 54 | external allSettled2: ((promise<'a0>, promise<'a1>)) => promise<( 55 | settledResult<'a0>, 56 | settledResult<'a1>, 57 | )> = "allSettled" 58 | 59 | @scope("Promise") @val 60 | external allSettled3: ((promise<'a0>, promise<'a1>, promise<'a2>)) => promise<( 61 | settledResult<'a0>, 62 | settledResult<'a1>, 63 | settledResult<'a2>, 64 | )> = "allSettled" 65 | 66 | @scope("Promise") @val 67 | external allSettled4: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>)) => promise<( 68 | settledResult<'a0>, 69 | settledResult<'a1>, 70 | settledResult<'a2>, 71 | settledResult<'a3>, 72 | )> = "allSettled" 73 | 74 | @scope("Promise") @val 75 | external allSettled5: ( 76 | (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>) 77 | ) => promise<( 78 | settledResult<'a0>, 79 | settledResult<'a1>, 80 | settledResult<'a2>, 81 | settledResult<'a3>, 82 | settledResult<'a4>, 83 | )> = "allSettled" 84 | 85 | @scope("Promise") @val 86 | external allSettled6: ( 87 | (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>, promise<'a5>) 88 | ) => promise<( 89 | settledResult<'a0>, 90 | settledResult<'a1>, 91 | settledResult<'a2>, 92 | settledResult<'a3>, 93 | settledResult<'a4>, 94 | settledResult<'a5>, 95 | )> = "allSettled" 96 | 97 | @send 98 | external _catch: (t<'a>, exn => t<'a>) => t<'a> = "catch" 99 | 100 | let catch = (promise: promise<'a>, callback: exn => promise<'a>): promise<'a> => { 101 | _catch(promise, err => { 102 | callback(Js.Exn.anyToExnInternal(err)) 103 | }) 104 | } 105 | 106 | @scope("Promise") @val 107 | external race: array> => t<'a> = "race" 108 | 109 | @scope("Promise") @val 110 | external any: array> => t<'a> = "any" 111 | 112 | external done: promise<'a> => unit = "%ignore" 113 | -------------------------------------------------------------------------------- /src/Core__RegExp.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Result = {}; 5 | 6 | export { 7 | Result , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/Core__RegExp.res: -------------------------------------------------------------------------------- 1 | type t = Js.Re.t 2 | 3 | module Result = { 4 | type t = array> 5 | @get_index external fullMatch: (t, @as(0) _) => string = "" 6 | @send external matches: (t, @as(1) _) => array = "slice" 7 | @get external index: t => int = "index" 8 | @get external input: t => string = "input" 9 | } 10 | 11 | @new external fromString: string => t = "RegExp" 12 | @new external fromStringWithFlags: (string, ~flags: string) => t = "RegExp" 13 | 14 | @send external test: (t, string) => bool = "test" 15 | @return(nullable) @send external exec: (t, string) => option = "exec" 16 | 17 | @get external lastIndex: t => int = "lastIndex" 18 | @set external setLastIndex: (t, int) => unit = "lastIndex" 19 | @get external ignoreCase: t => bool = "ignoreCase" 20 | @get external global: t => bool = "global" 21 | @get external multiline: t => bool = "multiline" 22 | @get external source: t => string = "source" 23 | @get external sticky: t => bool = "sticky" 24 | @get external unicode: t => bool = "unicode" 25 | -------------------------------------------------------------------------------- /src/Core__Result.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function getExn(x) { 5 | if (x.TAG === "Ok") { 6 | return x._0; 7 | } 8 | throw { 9 | RE_EXN_ID: "Not_found", 10 | Error: new Error() 11 | }; 12 | } 13 | 14 | function mapOr(opt, $$default, f) { 15 | if (opt.TAG === "Ok") { 16 | return f(opt._0); 17 | } else { 18 | return $$default; 19 | } 20 | } 21 | 22 | function map(opt, f) { 23 | if (opt.TAG === "Ok") { 24 | return { 25 | TAG: "Ok", 26 | _0: f(opt._0) 27 | }; 28 | } else { 29 | return opt; 30 | } 31 | } 32 | 33 | function flatMap(opt, f) { 34 | if (opt.TAG === "Ok") { 35 | return f(opt._0); 36 | } else { 37 | return opt; 38 | } 39 | } 40 | 41 | function getOr(opt, $$default) { 42 | if (opt.TAG === "Ok") { 43 | return opt._0; 44 | } else { 45 | return $$default; 46 | } 47 | } 48 | 49 | function isOk(x) { 50 | if (x.TAG === "Ok") { 51 | return true; 52 | } else { 53 | return false; 54 | } 55 | } 56 | 57 | function isError(x) { 58 | if (x.TAG === "Ok") { 59 | return false; 60 | } else { 61 | return true; 62 | } 63 | } 64 | 65 | function equal(a, b, f) { 66 | if (a.TAG === "Ok") { 67 | if (b.TAG === "Ok") { 68 | return f(a._0, b._0); 69 | } else { 70 | return false; 71 | } 72 | } else if (b.TAG === "Ok") { 73 | return false; 74 | } else { 75 | return true; 76 | } 77 | } 78 | 79 | function compare(a, b, f) { 80 | if (a.TAG === "Ok") { 81 | if (b.TAG === "Ok") { 82 | return f(a._0, b._0); 83 | } else { 84 | return 1; 85 | } 86 | } else if (b.TAG === "Ok") { 87 | return -1; 88 | } else { 89 | return 0; 90 | } 91 | } 92 | 93 | function forEach(r, f) { 94 | if (r.TAG === "Ok") { 95 | return f(r._0); 96 | } 97 | 98 | } 99 | 100 | function mapError(r, f) { 101 | if (r.TAG === "Ok") { 102 | return r; 103 | } else { 104 | return { 105 | TAG: "Error", 106 | _0: f(r._0) 107 | }; 108 | } 109 | } 110 | 111 | var mapWithDefault = mapOr; 112 | 113 | var getWithDefault = getOr; 114 | 115 | export { 116 | getExn , 117 | mapOr , 118 | mapWithDefault , 119 | map , 120 | flatMap , 121 | getOr , 122 | getWithDefault , 123 | isOk , 124 | isError , 125 | equal , 126 | compare , 127 | forEach , 128 | mapError , 129 | } 130 | /* No side effect */ 131 | -------------------------------------------------------------------------------- /src/Core__Result.res: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU Lesser General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * In addition to the permissions granted to you by the LGPL, you may combine 9 | * or link a "work that uses the Library" with a publicly distributed version 10 | * of this file to produce a combined library or application, then distribute 11 | * that combined work under the terms of your choosing, with no requirement 12 | * to comply with the obligations normally placed on you by section 4 of the 13 | * LGPL version 3 (or the corresponding section of a later version of the LGPL 14 | * should you choose to use a later version). 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 24 | 25 | let getExn = x => 26 | switch x { 27 | | Ok(x) => x 28 | | Error(_) => raise(Not_found) 29 | } 30 | 31 | let mapOr = (opt, default, f) => 32 | switch opt { 33 | | Ok(x) => f(x) 34 | | Error(_) => default 35 | } 36 | 37 | let mapWithDefault = mapOr 38 | 39 | let map = (opt, f) => 40 | switch opt { 41 | | Ok(x) => Ok(f(x)) 42 | | Error(_) as result => result 43 | } 44 | 45 | let flatMap = (opt, f) => 46 | switch opt { 47 | | Ok(x) => f(x) 48 | | Error(_) as result => result 49 | } 50 | 51 | let getOr = (opt, default) => 52 | switch opt { 53 | | Ok(x) => x 54 | | Error(_) => default 55 | } 56 | 57 | let getWithDefault = getOr 58 | 59 | let isOk = x => 60 | switch x { 61 | | Ok(_) => true 62 | | Error(_) => false 63 | } 64 | 65 | let isError = x => 66 | switch x { 67 | | Ok(_) => false 68 | | Error(_) => true 69 | } 70 | 71 | let equal = (a, b, f) => 72 | switch (a, b) { 73 | | (Ok(a), Ok(b)) => f(a, b) 74 | | (Error(_), Ok(_)) 75 | | (Ok(_), Error(_)) => false 76 | | (Error(_), Error(_)) => true 77 | } 78 | 79 | let compare = (a, b, f) => 80 | switch (a, b) { 81 | | (Ok(a), Ok(b)) => f(a, b) 82 | | (Error(_), Ok(_)) => Core__Ordering.less 83 | | (Ok(_), Error(_)) => Core__Ordering.greater 84 | | (Error(_), Error(_)) => Core__Ordering.equal 85 | } 86 | 87 | let forEach = (r, f) => 88 | switch r { 89 | | Ok(ok) => f(ok) 90 | | Error(_) => () 91 | } 92 | 93 | let mapError = (r, f) => 94 | switch r { 95 | | Ok(_) as result => result 96 | | Error(e) => Error(f(e)) 97 | } 98 | -------------------------------------------------------------------------------- /src/Core__Set.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__Set.res: -------------------------------------------------------------------------------- 1 | type t<'a> = Js.Set.t<'a> 2 | 3 | @new external make: unit => t<'a> = "Set" 4 | @new external fromArray: array<'a> => t<'a> = "Set" 5 | @new external fromIterator: Core__Iterator.t<'a> => t<'a> = "Set" 6 | 7 | @get external size: t<'a> => int = "size" 8 | 9 | @send external clear: t<'a> => unit = "clear" 10 | 11 | @send external add: (t<'a>, 'a) => unit = "add" 12 | @send external delete: (t<'a>, 'a) => bool = "delete" 13 | @send external has: (t<'a>, 'a) => bool = "has" 14 | 15 | @send external forEach: (t<'a>, 'a => unit) => unit = "forEach" 16 | 17 | @send external values: t<'a> => Core__Iterator.t<'a> = "values" 18 | 19 | @send external difference: (t<'a>, t<'a>) => t<'a> = "difference" 20 | @send external intersection: (t<'a>, t<'a>) => t<'a> = "intersection" 21 | @send external union: (t<'a>, t<'a>) => t<'a> = "union" 22 | @send external symmetricDifference: (t<'a>, t<'a>) => t<'a> = "symmetricDifference" 23 | @send external isSubsetOf: (t<'a>, t<'a>) => bool = "isSubsetOf" 24 | @send external isSupersetOf: (t<'a>, t<'a>) => bool = "isSupersetOf" 25 | @send external isDisjointFrom: (t<'a>, t<'a>) => bool = "isDisjointFrom" 26 | 27 | external toArray: t<'a> => array<'a> = "Array.from" 28 | -------------------------------------------------------------------------------- /src/Core__String.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function indexOfOpt(s, search) { 5 | var index = s.indexOf(search); 6 | if (index !== -1) { 7 | return index; 8 | } 9 | 10 | } 11 | 12 | function lastIndexOfOpt(s, search) { 13 | var index = s.lastIndexOf(search); 14 | if (index !== -1) { 15 | return index; 16 | } 17 | 18 | } 19 | 20 | function searchOpt(s, re) { 21 | var index = s.search(re); 22 | if (index !== -1) { 23 | return index; 24 | } 25 | 26 | } 27 | 28 | export { 29 | indexOfOpt , 30 | lastIndexOfOpt , 31 | searchOpt , 32 | } 33 | /* No side effect */ 34 | -------------------------------------------------------------------------------- /src/Core__Symbol.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__Symbol.res: -------------------------------------------------------------------------------- 1 | type t = Js.Types.symbol 2 | 3 | @val external make: string => t = "Symbol" 4 | @val external getFor: string => t = "Symbol.for" 5 | @val external keyFor: t => option = "Symbol.keyFor" 6 | 7 | @val external asyncIterator: t = "Symbol.asyncIterator" 8 | @val external hasInstance: t = "Symbol.hasInstance" 9 | @val external isConcatSpreadable: t = "Symbol.isConcatSpreadable" 10 | @val external iterator: t = "Symbol.iterator" 11 | @val external match: t = "Symbol.match" 12 | @val external matchAll: t = "Symbol.matchAll" 13 | @val external replace: t = "Symbol.replace" 14 | @val external search: t = "Symbol.search" 15 | @val external species: t = "Symbol.species" 16 | @val external split: t = "Symbol.split" 17 | @val external toPrimitive: t = "Symbol.toPrimitive" 18 | @val external toStringTag: t = "Symbol.toStringTag" 19 | @val external unscopables: t = "Symbol.unscopables" 20 | -------------------------------------------------------------------------------- /src/Core__Type.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | function classify(value) { 5 | var match = Object.prototype.toString.call(value); 6 | switch (match) { 7 | case "[object BigInt]" : 8 | return { 9 | TAG: "BigInt", 10 | _0: value 11 | }; 12 | case "[object Boolean]" : 13 | return { 14 | TAG: "Bool", 15 | _0: value 16 | }; 17 | case "[object AsyncFunction]" : 18 | case "[object Function]" : 19 | case "[object GeneratorFunction]" : 20 | return { 21 | TAG: "Function", 22 | _0: value 23 | }; 24 | case "[object Null]" : 25 | return "Null"; 26 | case "[object Number]" : 27 | return { 28 | TAG: "Number", 29 | _0: value 30 | }; 31 | case "[object String]" : 32 | return { 33 | TAG: "String", 34 | _0: value 35 | }; 36 | case "[object Symbol]" : 37 | return { 38 | TAG: "Symbol", 39 | _0: value 40 | }; 41 | case "[object Undefined]" : 42 | return "Undefined"; 43 | default: 44 | return { 45 | TAG: "Object", 46 | _0: value 47 | }; 48 | } 49 | } 50 | 51 | var Classify = { 52 | classify: classify 53 | }; 54 | 55 | export { 56 | Classify , 57 | } 58 | /* No side effect */ 59 | -------------------------------------------------------------------------------- /src/Core__Type.res: -------------------------------------------------------------------------------- 1 | type t = [#undefined | #object | #boolean | #number | #bigint | #string | #symbol | #function] 2 | 3 | external typeof: 'a => t = "#typeof" 4 | 5 | module Classify = { 6 | type function = Js.Types.function_val 7 | type object = Js.Types.obj_val 8 | 9 | type t = 10 | | Bool(bool) 11 | | Null 12 | | Undefined 13 | | String(string) 14 | | Number(float) 15 | | Object(object) 16 | | Function(function) 17 | | Symbol(Core__Symbol.t) 18 | | BigInt(bigint) 19 | 20 | @val external _internalClass: 'a => string = "Object.prototype.toString.call" 21 | external _asBool: 'a => bool = "%identity" 22 | external _asString: 'a => string = "%identity" 23 | external _asFloat: 'a => float = "%identity" 24 | external _asObject: 'a => object = "%identity" 25 | external _asFunction: 'a => function = "%identity" 26 | external _asSymbol: 'a => Core__Symbol.t = "%identity" 27 | external _asBigInt: 'a => bigint = "%identity" 28 | 29 | let classify = value => { 30 | switch _internalClass(value) { 31 | | "[object Boolean]" => Bool(_asBool(value)) 32 | | "[object Null]" => Null 33 | | "[object Undefined]" => Undefined 34 | | "[object String]" => String(_asString(value)) 35 | | "[object Number]" => Number(_asFloat(value)) 36 | | "[object Function]" 37 | | "[object GeneratorFunction]" 38 | | "[object AsyncFunction]" => 39 | Function(_asFunction(value)) 40 | | "[object Symbol]" => Symbol(_asSymbol(value)) 41 | | "[object BigInt]" => BigInt(_asBigInt(value)) 42 | | _ => Object(_asObject(value)) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Core__Type.resi: -------------------------------------------------------------------------------- 1 | /*** 2 | Utilities for classifying the type of JavaScript values at runtime. 3 | */ 4 | 5 | /** 6 | The possible types of JavaScript values. 7 | */ 8 | type t = [#undefined | #object | #boolean | #number | #bigint | #string | #symbol | #function] 9 | 10 | /** 11 | `typeof(someValue)` 12 | 13 | Returns the underlying JavaScript type of any runtime value. 14 | 15 | See [`typeof`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) on MDN. 16 | 17 | ## Examples 18 | ```rescript 19 | Console.log(Type.typeof("Hello")) // Logs "string" to the console. 20 | 21 | let someVariable = true 22 | 23 | switch someVariable->Type.typeof { 24 | | #boolean => Console.log("This is a bool, yay!") 25 | | _ => Console.log("Oh, not a bool sadly...") 26 | } 27 | ``` 28 | */ 29 | external typeof: 'a => t = "#typeof" 30 | 31 | module Classify: { 32 | /*** 33 | Classifies JavaScript runtime values. 34 | */ 35 | 36 | /** 37 | An abstract type representing a JavaScript function. 38 | 39 | See [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) on MDN. 40 | */ 41 | type function 42 | 43 | /** 44 | An abstract type representing a JavaScript object. 45 | 46 | See [`object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) on MDN. 47 | */ 48 | type object 49 | 50 | /** 51 | The type representing a classified JavaScript value. 52 | */ 53 | type t = 54 | | Bool(bool) 55 | | Null 56 | | Undefined 57 | | String(string) 58 | | Number(float) 59 | | Object(object) 60 | | Function(function) 61 | | Symbol(Core__Symbol.t) 62 | | BigInt(bigint) 63 | 64 | /** 65 | `classify(anyValue)` 66 | Classifies a JavaScript value. 67 | 68 | ## Examples 69 | ```rescript 70 | switch %raw(`null`)->Type.Classify.classify { 71 | | Null => Console.log("Yup, that's null.") 72 | | _ => Console.log("This doesn't actually appear to be null...") 73 | } 74 | ``` 75 | */ 76 | let classify: 'a => t 77 | } 78 | -------------------------------------------------------------------------------- /src/Core__WeakMap.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__WeakMap.res: -------------------------------------------------------------------------------- 1 | type t<'k, 'v> = Js.WeakMap.t<'k, 'v> 2 | 3 | @new external make: unit => t<'k, 'v> = "WeakMap" 4 | 5 | @send external get: (t<'k, 'v>, 'k) => option<'v> = "get" 6 | @send external has: (t<'k, 'v>, 'k) => bool = "has" 7 | @send external set: (t<'k, 'v>, 'k, 'v) => t<'k, 'v> = "set" 8 | @send external delete: (t<'k, 'v>, 'k) => bool = "delete" 9 | -------------------------------------------------------------------------------- /src/Core__WeakSet.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/Core__WeakSet.res: -------------------------------------------------------------------------------- 1 | type t<'a> = Js.WeakSet.t<'a> 2 | 3 | @new external make: unit => t<'a> = "WeakSet" 4 | 5 | @send external add: (t<'a>, 'a) => t<'a> = "add" 6 | @send external delete: (t<'a>, 'a) => bool = "delete" 7 | @send external has: (t<'a>, 'a) => bool = "has" 8 | -------------------------------------------------------------------------------- /src/OCamlCompat.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var $$Array; 5 | 6 | var List; 7 | 8 | var $$Set; 9 | 10 | var $$Map; 11 | 12 | var $$String; 13 | 14 | export { 15 | $$Array , 16 | List , 17 | $$Set , 18 | $$Map , 19 | $$String , 20 | } 21 | /* No side effect */ 22 | -------------------------------------------------------------------------------- /src/OCamlCompat.res: -------------------------------------------------------------------------------- 1 | module Array = Array 2 | module List = List 3 | module Set = Set 4 | module Map = Map 5 | module String = String 6 | -------------------------------------------------------------------------------- /src/RescriptCore.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Core__Error from "./Core__Error.mjs"; 4 | 5 | var $$Array; 6 | 7 | var Console; 8 | 9 | var $$DataView; 10 | 11 | var $$Date; 12 | 13 | var Dict; 14 | 15 | var $$Error; 16 | 17 | var Float; 18 | 19 | var Int; 20 | 21 | var $$BigInt; 22 | 23 | var $$Math; 24 | 25 | var Null; 26 | 27 | var Nullable; 28 | 29 | var $$Object; 30 | 31 | var Ordering; 32 | 33 | var $$Promise; 34 | 35 | var $$RegExp; 36 | 37 | var $$String; 38 | 39 | var $$Symbol; 40 | 41 | var Type; 42 | 43 | var $$JSON; 44 | 45 | var Iterator; 46 | 47 | var AsyncIterator; 48 | 49 | var $$Map; 50 | 51 | var $$WeakMap; 52 | 53 | var $$Set; 54 | 55 | var $$WeakSet; 56 | 57 | var $$ArrayBuffer; 58 | 59 | var TypedArray; 60 | 61 | var $$Float32Array; 62 | 63 | var $$Float64Array; 64 | 65 | var $$Int8Array; 66 | 67 | var $$Int16Array; 68 | 69 | var $$Int32Array; 70 | 71 | var $$Uint8Array; 72 | 73 | var $$Uint16Array; 74 | 75 | var $$Uint32Array; 76 | 77 | var $$Uint8ClampedArray; 78 | 79 | var $$BigInt64Array; 80 | 81 | var $$BigUint64Array; 82 | 83 | var $$Intl; 84 | 85 | var Exn; 86 | 87 | var $$Option; 88 | 89 | var List; 90 | 91 | var Result; 92 | 93 | var panic = Core__Error.panic; 94 | 95 | export { 96 | $$Array , 97 | Console , 98 | $$DataView , 99 | $$Date , 100 | Dict , 101 | $$Error , 102 | Float , 103 | Int , 104 | $$BigInt , 105 | $$Math , 106 | Null , 107 | Nullable , 108 | $$Object , 109 | Ordering , 110 | $$Promise , 111 | $$RegExp , 112 | $$String , 113 | $$Symbol , 114 | Type , 115 | $$JSON , 116 | Iterator , 117 | AsyncIterator , 118 | $$Map , 119 | $$WeakMap , 120 | $$Set , 121 | $$WeakSet , 122 | $$ArrayBuffer , 123 | TypedArray , 124 | $$Float32Array , 125 | $$Float64Array , 126 | $$Int8Array , 127 | $$Int16Array , 128 | $$Int32Array , 129 | $$Uint8Array , 130 | $$Uint16Array , 131 | $$Uint32Array , 132 | $$Uint8ClampedArray , 133 | $$BigInt64Array , 134 | $$BigUint64Array , 135 | $$Intl , 136 | Exn , 137 | $$Option , 138 | List , 139 | Result , 140 | panic , 141 | } 142 | /* No side effect */ 143 | -------------------------------------------------------------------------------- /src/RescriptCore.res: -------------------------------------------------------------------------------- 1 | include Core__Global 2 | 3 | module Array = Core__Array 4 | module Console = Core__Console 5 | module DataView = Core__DataView 6 | module Date = Core__Date 7 | module Dict = Core__Dict 8 | module Error = Core__Error 9 | module Float = Core__Float 10 | module Int = Core__Int 11 | module BigInt = Core__BigInt 12 | module Math = Core__Math 13 | module Null = Core__Null 14 | module Nullable = Core__Nullable 15 | module Object = Core__Object 16 | module Ordering = Core__Ordering 17 | module Promise = Core__Promise 18 | module RegExp = Core__RegExp 19 | module String = Core__String 20 | module Symbol = Core__Symbol 21 | module Type = Core__Type 22 | module JSON = Core__JSON 23 | 24 | module Iterator = Core__Iterator 25 | module AsyncIterator = Core__AsyncIterator 26 | module Map = Core__Map 27 | module WeakMap = Core__WeakMap 28 | module Set = Core__Set 29 | module WeakSet = Core__WeakSet 30 | 31 | module ArrayBuffer = Core__ArrayBuffer 32 | module TypedArray = Core__TypedArray 33 | module Float32Array = Core__Float32Array 34 | module Float64Array = Core__Float64Array 35 | module Int8Array = Core__Int8Array 36 | module Int16Array = Core__Int16Array 37 | module Int32Array = Core__Int32Array 38 | module Uint8Array = Core__Uint8Array 39 | module Uint16Array = Core__Uint16Array 40 | module Uint32Array = Core__Uint32Array 41 | module Uint8ClampedArray = Core__Uint8ClampedArray 42 | module BigInt64Array = Core__BigInt64Array 43 | module BigUint64Array = Core__BigUint64Array 44 | 45 | module Intl = Core__Intl 46 | 47 | @val external window: Dom.window = "window" 48 | @val external document: Dom.document = "document" 49 | @val external globalThis: {..} = "globalThis" 50 | 51 | external null: Core__Nullable.t<'a> = "#null" 52 | external undefined: Core__Nullable.t<'a> = "#undefined" 53 | external typeof: 'a => Core__Type.t = "#typeof" 54 | 55 | /** 56 | `import(value)` dynamically import a value or function from a ReScript 57 | module. The import call will return a `promise`, resolving to the dynamically loaded 58 | value. 59 | 60 | ## Examples 61 | 62 | `Core__Array.res` file: 63 | 64 | ```rescript 65 | @send external indexOf: (array<'a>, 'a) => int = "indexOf" 66 | 67 | let indexOfOpt = (arr, item) => 68 | switch arr->indexOf(item) { 69 | | -1 => None 70 | | index => Some(index) 71 | } 72 | ``` 73 | In other file you can import the `indexOfOpt` value defined in `Core__Array.res` 74 | 75 | ```rescript 76 | let main = async () => { 77 | let indexOfOpt = await import(Core__Array.indexOfOpt) 78 | let index = indexOfOpt([1, 2], 2) 79 | Console.log(index) 80 | } 81 | ``` 82 | 83 | Compiles to: 84 | 85 | ```javascript 86 | async function main() { 87 | var add = await import("./Core__Array.mjs").then(function(m) { 88 | return m.indexOfOpt; 89 | }); 90 | var index = indexOfOpt([1, 2], 2); 91 | console.log(index); 92 | } 93 | ``` 94 | */ 95 | external import: 'a => promise<'a> = "#import" 96 | 97 | module Exn = Js.Exn 98 | module Option = Core__Option 99 | module List = Core__List 100 | module Result = Core__Result 101 | 102 | type null<+'a> = Js.null<'a> 103 | 104 | type undefined<+'a> = Js.undefined<'a> 105 | 106 | type nullable<+'a> = Js.nullable<'a> 107 | 108 | let panic = Core__Error.panic 109 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Collator.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Collator.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type usage = [#sort | #search] 4 | type sensitivity = [#base | #accent | #case | #variant] 5 | type caseFirst = [#upper | #lower | #"false"] 6 | 7 | type options = { 8 | localeMatcher?: Core__Intl__Common.localeMatcher, 9 | usage?: usage, 10 | sensitivity?: sensitivity, 11 | ignorePunctuation?: bool, 12 | numeric?: bool, 13 | caseFirst?: caseFirst, 14 | } 15 | 16 | type resolvedOptions = { 17 | locale: string, 18 | usage: usage, 19 | sensitivity: sensitivity, 20 | ignorePunctuation: bool, 21 | collation: [Core__Intl__Common.collation | #default], 22 | numeric?: bool, 23 | caseFirst?: caseFirst, 24 | } 25 | 26 | type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} 27 | 28 | @new external make: (~locales: array=?, ~options: options=?) => t = "Intl.Collator" 29 | 30 | @val 31 | external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = 32 | "Intl.Collator.supportedLocalesOf" 33 | 34 | @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" 35 | 36 | @send external compare: (t, string, string) => int = "compare" 37 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Common.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Common.res: -------------------------------------------------------------------------------- 1 | type localeMatcher = [#lookup | #"best fit"] 2 | 3 | type calendar = [ 4 | | #buddhist 5 | | #chinese 6 | | #coptic 7 | | #dangi 8 | | #ethioaa 9 | | #ethiopic 10 | | #gregory 11 | | #hebrew 12 | | #indian 13 | | #islamic 14 | | #"islamic-umalqura" 15 | | #"islamic-tbla" 16 | | #"islamic-civil" 17 | | #"islamic-rgsa" 18 | | #iso8601 19 | | #japanese 20 | | #persian 21 | | #roc 22 | ] 23 | 24 | type collation = [ 25 | | #compat // (Arabic) 26 | | #dict // (Sinhala) 27 | | #emoji // (root) 28 | | #eor // (root) 29 | | #phonebk // (German) 30 | | #phonetic // (Lingala) 31 | | #pinyin // (Chinese) 32 | | #stroke // (Chinese) 33 | | #trad 34 | | #unihan // (Chinese, Japanese, and Korean; not available in Chrome or Edge) 35 | | #zhuyin 36 | ] // (Chinese) 37 | 38 | type numberingSystem = [ 39 | | #adlm 40 | | #ahom 41 | | #arab 42 | | #arabext 43 | | #bali 44 | | #beng 45 | | #bhks 46 | | #brah 47 | | #cakm 48 | | #cham 49 | | #deva 50 | | #diak 51 | | #fullwide 52 | | #gong 53 | | #gonm 54 | | #gujr 55 | | #guru 56 | | #hanidec 57 | | #hmng 58 | | #hmnp 59 | | #java 60 | | #kali 61 | | #kawi 62 | | #khmr 63 | | #knda 64 | | #lana 65 | | #lanatham 66 | | #laoo 67 | | #latn 68 | | #lepc 69 | | #limb 70 | | #mathbold 71 | | #mathdbl 72 | | #mathmono 73 | | #mathsanb 74 | | #mathsans 75 | | #mlym 76 | | #modi 77 | | #mong 78 | | #mroo 79 | | #mtei 80 | | #mymr 81 | | #mymrshan 82 | | #mymrtlng 83 | | #nagm 84 | | #newa 85 | | #nkoo 86 | | #olck 87 | | #orya 88 | | #osma 89 | | #rohg 90 | | #saur 91 | | #segment 92 | | #shrd 93 | | #sind 94 | | #sinh 95 | | #sora 96 | | #sund 97 | | #takr 98 | | #talu 99 | | #tamldec 100 | | #telu 101 | | #thai 102 | | #tibt 103 | | #tirh 104 | | #tnsa 105 | | #vaii 106 | | #wara 107 | | #wcho 108 | ] 109 | 110 | type oneTo21 = [ 111 | | #1 112 | | #2 113 | | #3 114 | | #4 115 | | #5 116 | | #6 117 | | #7 118 | | #8 119 | | #9 120 | | #10 121 | | #11 122 | | #12 123 | | #13 124 | | #14 125 | | #15 126 | | #16 127 | | #17 128 | | #18 129 | | #19 130 | | #20 131 | | #21 132 | ] 133 | 134 | type zeroTo20 = [ 135 | | #0 136 | | #1 137 | | #2 138 | | #3 139 | | #4 140 | | #5 141 | | #6 142 | | #7 143 | | #8 144 | | #9 145 | | #10 146 | | #11 147 | | #12 148 | | #13 149 | | #14 150 | | #15 151 | | #16 152 | | #17 153 | | #18 154 | | #19 155 | | #20 156 | ] 157 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__DateTimeFormat.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__DateTimeFormat.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type dateStyle = [#full | #long | #medium | #short] 4 | type timeStyle = [#full | #long | #medium | #short] 5 | type dayPeriod = [#narrow | #short | #long] 6 | type weekday = [#narrow | #short | #long] 7 | type era = [#narrow | #short | #long] 8 | type year = [#numeric | #"2-digit"] 9 | type month = [#numeric | #"2-digit" | #narrow | #short | #long] 10 | type day = [#numeric | #"2-digit"] 11 | type hour = [#numeric | #"2-digit"] 12 | type minute = [#numeric | #"2-digit"] 13 | type second = [#numeric | #"2-digit"] 14 | 15 | /** 16 | Firefox also supports IANA time zone names here 17 | Node v19+ supports "shortOffset", "shortGeneric", "longOffset", and "longGeneric". 18 | */ 19 | type timeZoneName = [ 20 | | #short 21 | | #long 22 | | #shortOffset 23 | | #shortGeneric 24 | | #longOffset 25 | | #longGeneric 26 | ] 27 | 28 | type hourCycle = [#h11 | #h12 | #h23 | #h24] 29 | type formatMatcher = [#basic | #"best fit"] 30 | type fractionalSecondDigits = [#0 | #1 | #2 | #3] 31 | 32 | type options = { 33 | dateStyle?: dateStyle, // can be used with timeStyle, but not other options 34 | timeStyle?: timeStyle, // can be used with dateStyle, but not other options 35 | calendar?: Core__Intl__Common.calendar, 36 | dayPeriod?: dayPeriod, // only has an effect if a 12-hour clock is used 37 | numberingSystem?: Core__Intl__Common.numberingSystem, 38 | localeMatcher?: Core__Intl__Common.localeMatcher, 39 | timeZone?: string, 40 | hour12?: bool, 41 | hourCycle?: hourCycle, 42 | formatMatcher?: formatMatcher, 43 | // date-time components 44 | weekday?: weekday, 45 | era?: era, 46 | year?: year, 47 | month?: month, 48 | day?: day, 49 | hour?: hour, 50 | minute?: minute, 51 | second?: second, 52 | fractionalSecondDigits?: fractionalSecondDigits, 53 | timeZoneName?: timeZoneName, 54 | } 55 | 56 | type resolvedOptions = { 57 | dateStyle?: dateStyle, 58 | timeStyle?: timeStyle, 59 | weekday?: weekday, 60 | era?: era, 61 | year?: year, 62 | month?: month, 63 | day?: day, 64 | hour?: hour, 65 | minute?: minute, 66 | second?: second, 67 | fractionalSecondDigits?: fractionalSecondDigits, 68 | timeZoneName?: timeZoneName, 69 | calendar: Core__Intl__Common.calendar, 70 | hour12: bool, 71 | hourCycle: hourCycle, 72 | locale: string, 73 | numberingSystem: Core__Intl__Common.numberingSystem, 74 | timeZone: string, 75 | } 76 | 77 | type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} 78 | 79 | type dateTimeComponent = [ 80 | | #day 81 | | #dayPeriod 82 | | #era 83 | | #fractionalSecond 84 | | #hour 85 | | #literal 86 | | #minute 87 | | #month 88 | | #relatedYear 89 | | #second 90 | | #timeZone 91 | | #weekday 92 | | #year 93 | | #yearName 94 | ] 95 | 96 | type dateTimePart = { 97 | \"type": dateTimeComponent, 98 | value: string, 99 | } 100 | 101 | type dateTimeRangeSource = [#startRange | #shared | #endRange] 102 | type dateTimeRangePart = { 103 | \"type": dateTimeComponent, 104 | value: string, 105 | source: dateTimeRangeSource, 106 | } 107 | 108 | @new external make: (~locales: array=?, ~options: options=?) => t = "Intl.DateTimeFormat" 109 | 110 | @val 111 | external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = 112 | "Intl.DateTimeFormat.supportedLocalesOf" 113 | 114 | @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" 115 | 116 | @send external format: (t, Core__Date.t) => string = "format" 117 | @send 118 | external formatToParts: (t, Core__Date.t) => array = "formatToParts" 119 | 120 | @send 121 | external formatRange: (t, ~startDate: Core__Date.t, ~endDate: Core__Date.t) => string = 122 | "formatRange" 123 | 124 | @send 125 | external formatRangeToParts: ( 126 | t, 127 | ~startDate: Core__Date.t, 128 | ~endDate: Core__Date.t, 129 | ) => array = "formatRangeToParts" 130 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__ListFormat.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__ListFormat.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type listType = [ 4 | | #conjunction 5 | | #disjunction 6 | | #unit 7 | ] 8 | type style = [ 9 | | #long 10 | | #short 11 | | #narrow 12 | ] 13 | 14 | type options = { 15 | localeMatcher?: Core__Intl__Common.localeMatcher, 16 | \"type"?: listType, 17 | style?: style, 18 | } 19 | 20 | type listPartComponentType = [ 21 | | #element 22 | | #literal 23 | ] 24 | 25 | type listPart = { 26 | \"type": listPartComponentType, 27 | value: string, 28 | } 29 | 30 | type resolvedOptions = { 31 | locale: string, 32 | style: style, 33 | \"type": listType, 34 | } 35 | 36 | type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} 37 | 38 | @new external make: (~locales: array=?, ~options: options=?) => t = "Intl.ListFormat" 39 | 40 | @val 41 | external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = 42 | "Intl.ListFormat.supportedLocalesOf" 43 | 44 | @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" 45 | 46 | @send external format: (t, array) => string = "format" 47 | @send external formatToParts: (t, array) => array = "formatToParts" 48 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Locale.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Locale.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type options = { 4 | baseName?: string, 5 | calendar?: Core__Intl__Common.calendar, 6 | collation?: Core__Intl__Common.collation, 7 | hourCycle?: [#h11 | #h12 | #h23 | #h24], 8 | caseFirst?: [#upper | #lower | #"false"], 9 | numberingSystem?: Core__Intl__Common.numberingSystem, 10 | numeric?: bool, 11 | language?: string, 12 | script?: string, 13 | region?: string, 14 | } 15 | 16 | @new external make: (string, ~options: options=?) => t = "Intl.Locale" 17 | 18 | @get external baseName: t => string = "baseName" 19 | @get external calendar: t => option = "calendar" 20 | @get external caseFirst: t => option = "caseFirst" 21 | @get external collation: t => option = "collation" 22 | @get external hourCycle: t => option = "hourCycle" 23 | @get external language: t => string = "language" 24 | @get external numberingSystem: t => option = "numberingSystem" 25 | @get external numeric: t => bool = "numeric" 26 | @get external region: t => option = "region" 27 | @get external script: t => option = "script" 28 | 29 | @send external maximize: t => t = "maximize" 30 | @send external minimize: t => t = "minimize" 31 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__NumberFormat.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Grouping; 5 | 6 | export { 7 | Grouping , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__NumberFormat__Grouping.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Core__Type from "../Core__Type.mjs"; 4 | 5 | function parseJsValue(value) { 6 | var value$1 = Core__Type.Classify.classify(value); 7 | if (typeof value$1 !== "object") { 8 | return ; 9 | } 10 | switch (value$1.TAG) { 11 | case "Bool" : 12 | return { 13 | NAME: "bool", 14 | VAL: value$1._0 15 | }; 16 | case "String" : 17 | switch (value$1._0) { 18 | case "always" : 19 | return "always"; 20 | case "auto" : 21 | return "auto"; 22 | case "min2" : 23 | return "min2"; 24 | default: 25 | return ; 26 | } 27 | default: 28 | return ; 29 | } 30 | } 31 | 32 | export { 33 | parseJsValue , 34 | } 35 | /* No side effect */ 36 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__NumberFormat__Grouping.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type parsed = [#bool(bool) | #always | #auto | #min2] 4 | 5 | external fromBool: bool => t = "%identity" 6 | external fromString: [#always | #auto | #min2] => t = "%identity" 7 | 8 | let parseJsValue = value => 9 | switch Core__Type.Classify.classify(value) { 10 | | String("always") => Some(#always) 11 | | String("auto") => Some(#auto) 12 | | String("min2") => Some(#min2) 13 | | Bool(value) => Some(#bool(value)) 14 | | _ => None 15 | } 16 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__PluralRules.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__PluralRules.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type localeType = [#cardinal | #ordinal] 4 | 5 | type options = { 6 | localeMatcher?: Core__Intl__Common.localeMatcher, 7 | \"type"?: localeType, 8 | // use either this group 9 | minimumIntegerDigits?: Core__Intl__Common.oneTo21, 10 | minimumFractionDigits?: Core__Intl__Common.zeroTo20, 11 | maximumFractionDigits?: Core__Intl__Common.zeroTo20, 12 | // OR this group 13 | minimumSignificantDigits?: Core__Intl__Common.oneTo21, 14 | maximumSignificantDigits?: Core__Intl__Common.oneTo21, 15 | } 16 | 17 | type pluralCategories = [ 18 | | #zero 19 | | #one 20 | | #two 21 | | #few 22 | | #many 23 | | #other 24 | ] 25 | 26 | type resolvedOptions = { 27 | locale: string, 28 | pluralCategories: array, 29 | \"type": localeType, 30 | // either this group 31 | minimumIntegerDigits?: Core__Intl__Common.oneTo21, 32 | minimumFractionDigits?: Core__Intl__Common.zeroTo20, 33 | maximumFractionDigits?: Core__Intl__Common.zeroTo20, 34 | // OR this group 35 | minimumSignificantDigits?: Core__Intl__Common.oneTo21, 36 | maximumSignificantDigits?: Core__Intl__Common.oneTo21, 37 | } 38 | 39 | type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} 40 | 41 | @new external make: (~locales: array=?, ~options: options=?) => t = "Intl.PluralRules" 42 | 43 | @val 44 | external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = 45 | "Intl.PluralRules.supportedLocalesOf" 46 | 47 | @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" 48 | 49 | type rule = [#zero | #one | #two | #few | #many | #other] 50 | 51 | @send external select: (t, float) => rule = "select" 52 | @send external selectInt: (t, int) => rule = "select" 53 | @send external selectBigInt: (t, bigint) => rule = "select" 54 | 55 | @send 56 | external selectRange: (t, ~start: float, ~end: float) => rule = "selectRange" 57 | 58 | @send 59 | external selectRangeInt: (t, ~start: int, ~end: int) => rule = "selectRange" 60 | 61 | @send 62 | external selectRangeBigInt: (t, ~start: bigint, ~end: bigint) => rule = "selectRange" 63 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__RelativeTimeFormat.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__RelativeTimeFormat.res: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type numeric = [#always | #auto] 4 | type style = [#long | #short | #narrow] 5 | type timeUnit = [#year | #quarter | #month | #week | #day | #hour | #minute | #second] 6 | 7 | type options = { 8 | localeMatcher?: Core__Intl__Common.localeMatcher, 9 | numeric?: numeric, 10 | style?: style, 11 | } 12 | 13 | type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} 14 | 15 | type resolvedOptions = { 16 | locale: string, 17 | numeric: numeric, 18 | style: style, 19 | numberingSystem: string, 20 | } 21 | 22 | type relativeTimePartComponent = [#literal | #integer] 23 | type relativeTimePart = { 24 | \"type": relativeTimePartComponent, 25 | value: string, 26 | unit?: timeUnit, 27 | } 28 | 29 | @new 30 | external make: (~locales: array=?, ~options: options=?) => t = "Intl.RelativeTimeFormat" 31 | 32 | @val 33 | external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = 34 | "Intl.RelativeTimeFormat.supportedLocalesOf" 35 | 36 | @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" 37 | 38 | @send external format: (t, int, timeUnit) => string = "format" 39 | @send 40 | external formatToParts: (t, int, timeUnit) => array = "formatToParts" 41 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Segmenter.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Segmenter.res: -------------------------------------------------------------------------------- 1 | /*** 2 | Not supported in Firefox 3 | */ 4 | type t 5 | 6 | type granularity = [#grapheme | #word | #sentence] 7 | 8 | type options = { 9 | localeMatcher?: Core__Intl__Common.localeMatcher, 10 | granularity?: granularity, 11 | } 12 | 13 | type pluralCategories = [ 14 | | #zero 15 | | #one 16 | | #two 17 | | #few 18 | | #many 19 | | #other 20 | ] 21 | 22 | type resolvedOptions = {locale: string, granularity: granularity} 23 | 24 | type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} 25 | 26 | @new external make: (~locales: array=?, ~options: options=?) => t = "Intl.Segmenter" 27 | 28 | @val 29 | external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = 30 | "Intl.Segmenter.supportedLocalesOf" 31 | 32 | @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" 33 | 34 | @send external segment: (t, string) => Core__Intl__Segments.t = "segment" 35 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Segments.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/intl/Core__Intl__Segments.res: -------------------------------------------------------------------------------- 1 | /*** 2 | 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. 3 | https://tc39.es/ecma402/#sec-segments-objects 4 | */ 5 | type t 6 | 7 | type segmentData = { 8 | segment: string, 9 | index: int, 10 | isWordLike: option, 11 | input: string, 12 | } 13 | 14 | @send 15 | external containing: t => segmentData = "containing" 16 | 17 | @send 18 | external containingWithIndex: (t, int) => segmentData = "containing" 19 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__BigInt64Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__BigInt64Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "BigInt64Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "BigInt64Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "BigInt64Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "BigInt64Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "BigInt64Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "BigInt64Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "BigInt64Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t = "BigInt64Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__BigUint64Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__BigUint64Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "BigUint64Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "BigUint64Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "BigUint64Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "BigUint64Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "BigUint64Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "BigUint64Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "BigUint64Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t = "BigUint64Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Float32Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Float32Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Float32Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Float32Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Float32Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Float32Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Float32Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Float32Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Float32Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t = "Float32Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Float64Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Float64Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Float64Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Float64Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Float64Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Float64Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Float64Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Float64Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Float64Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t = "Float64Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Int16Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Int16Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Int16Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Int16Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Int16Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Int16Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Int16Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Int16Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Int16Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int16Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Int32Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Int32Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Int32Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Int32Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Int32Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Int32Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Int32Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Int32Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Int32Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int32Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Int8Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Int8Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Int8Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Int8Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Int8Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Int8Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Int8Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Int8Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Int8Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int8Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__TypedArray.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 3 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__TypedArray.res: -------------------------------------------------------------------------------- 1 | type t<'a> 2 | 3 | @get_index external get: (t<'a>, int) => option<'a> = "" 4 | @set_index external set: (t<'a>, int, 'a) => unit = "" 5 | 6 | @get external buffer: t<'a> => Core__ArrayBuffer.t = "buffer" 7 | @get external byteLength: t<'a> => int = "byteLength" 8 | @get external byteOffset: t<'a> => int = "byteOffset" 9 | 10 | @send external setArray: (t<'a>, array<'a>) => unit = "set" 11 | @send external setArrayFrom: (t<'a>, array<'a>, int) => unit = "set" 12 | 13 | @get external length: t<'a> => int = "length" 14 | 15 | @send external copyAllWithin: (t<'a>, ~target: int) => array<'a> = "copyWithin" 16 | @send external copyWithinToEnd: (t<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" 17 | @send 18 | external copyWithin: (t<'a>, ~target: int, ~start: int, ~end: int) => array<'a> = "copyWithin" 19 | 20 | @send external fillAll: (t<'a>, 'a) => t<'a> = "fill" 21 | @send external fillToEnd: (t<'a>, 'a, ~start: int) => t<'a> = "fill" 22 | @send external fill: (t<'a>, 'a, ~start: int, ~end: int) => t<'a> = "fill" 23 | 24 | @send external reverse: t<'a> => unit = "reverse" 25 | @send external toReversed: t<'a> => t<'a> = "toReversed" 26 | 27 | @send external sort: (t<'a>, ('a, 'a) => Core__Ordering.t) => unit = "sort" 28 | @send external toSorted: (t<'a>, ('a, 'a) => Core__Ordering.t) => t<'a> = "toSorted" 29 | 30 | @send external with: (t<'a>, int, 'a) => t<'a> = "with" 31 | 32 | @send external includes: (t<'a>, 'a) => bool = "includes" 33 | 34 | @send external indexOf: (t<'a>, 'a) => int = "indexOf" 35 | @send external indexOfFrom: (t<'a>, 'a, int) => int = "indexOf" 36 | 37 | @send external joinWith: (t<'a>, string) => string = "join" 38 | 39 | @send external lastIndexOf: (t<'a>, 'a) => int = "lastIndexOf" 40 | @send external lastIndexOfFrom: (t<'a>, 'a, int) => int = "lastIndexOf" 41 | 42 | @send external slice: (t<'a>, ~start: int, ~end: int) => t<'a> = "slice" 43 | @send external sliceToEnd: (t<'a>, ~start: int) => t<'a> = "slice" 44 | @send external copy: t<'a> => t<'a> = "slice" 45 | 46 | @send external subarray: (t<'a>, ~start: int, ~end: int) => t<'a> = "subarray" 47 | @send external subarrayToEnd: (t<'a>, ~start: int) => t<'a> = "subarray" 48 | 49 | @send external toString: t<'a> => string = "toString" 50 | @send external toLocaleString: t<'a> => string = "toLocaleString" 51 | 52 | @send external every: (t<'a>, 'a => bool) => bool = "every" 53 | @send external everyWithIndex: (t<'a>, ('a, int) => bool) => bool = "every" 54 | 55 | @send external filter: (t<'a>, 'a => bool) => t<'a> = "filter" 56 | @send external filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a> = "filter" 57 | 58 | @send external find: (t<'a>, 'a => bool) => option<'a> = "find" 59 | @send external findWithIndex: (t<'a>, ('a, int) => bool) => option<'a> = "find" 60 | 61 | @send external findIndex: (t<'a>, 'a => bool) => int = "findIndex" 62 | @send external findIndexWithIndex: (t<'a>, ('a, int) => bool) => int = "findIndex" 63 | 64 | @send external forEach: (t<'a>, 'a => unit) => unit = "forEach" 65 | @send external forEachWithIndex: (t<'a>, ('a, int) => unit) => unit = "forEach" 66 | 67 | @send external map: (t<'a>, 'a => 'b) => t<'b> = "map" 68 | @send external mapWithIndex: (t<'a>, ('a, int) => 'b) => t<'b> = "map" 69 | 70 | @send external reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduce" 71 | @send external reduceWithIndex: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduce" 72 | 73 | @send external reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduceRight" 74 | @send external reduceRightWithIndex: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduceRight" 75 | 76 | @send external some: (t<'a>, 'a => bool) => bool = "some" 77 | @send external someWithIndex: (t<'a>, ('a, int) => bool) => bool = "some" 78 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint16Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint16Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Uint16Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Uint16Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Uint16Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Uint16Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Uint16Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Uint16Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Uint16Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint16Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint32Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint32Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Uint32Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Uint32Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Uint32Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Uint32Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Uint32Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Uint32Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Uint32Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint32Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint8Array.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint8Array.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Uint8Array.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Uint8Array" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Uint8Array" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Uint8Array" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Uint8Array" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Uint8Array" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Uint8Array.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint8Array.from" 55 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint8ClampedArray.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | var Constants = {}; 5 | 6 | export { 7 | Constants , 8 | } 9 | /* No side effect */ 10 | -------------------------------------------------------------------------------- /src/typed-arrays/Core__Uint8ClampedArray.res: -------------------------------------------------------------------------------- 1 | /** 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) 2 | */ 3 | type t = Core__TypedArray.t 4 | 5 | module Constants = { 6 | /**`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) 7 | */ 8 | @val 9 | external bytesPerElement: int = "Uint8ClampedArray.BYTES_PER_ELEMENT" 10 | } 11 | 12 | /** `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) 13 | */ 14 | @new 15 | external fromArray: array => t = "Uint8ClampedArray" 16 | 17 | /** `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) 18 | 19 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 20 | */ 21 | @new 22 | external fromBuffer: Core__ArrayBuffer.t => t = "Uint8ClampedArray" 23 | 24 | /** `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) 25 | 26 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 27 | */ 28 | @new 29 | external fromBufferToEnd: (Core__ArrayBuffer.t, ~byteOffset: int) => t = "Uint8ClampedArray" 30 | 31 | /** `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) 32 | 33 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 34 | */ 35 | @new 36 | external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = 37 | "Uint8ClampedArray" 38 | 39 | /** `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) 40 | 41 | **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. 42 | */ 43 | @new 44 | external fromLength: int => t = "Uint8ClampedArray" 45 | 46 | /** `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) 47 | */ 48 | @val 49 | external fromArrayLikeOrIterable: 'a => t = "Uint8ClampedArray.from" 50 | 51 | /** `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) 52 | */ 53 | @val 54 | external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint8ClampedArray.from" 55 | -------------------------------------------------------------------------------- /test/ArrayTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | Test.run(__POS_OF__("make"), Array.make(~length=6, 7), eq, [7, 7, 7, 7, 7, 7]) 6 | 7 | Test.run(__POS_OF__("getUnsafe - existing"), [0, 1, 2]->Array.getUnsafe(1), eq, 1) 8 | Test.run(__POS_OF__("getUnsafe - missing"), [0, 1, 2]->Array.getUnsafe(10), eq, %raw(`undefined`)) 9 | 10 | Test.run( 11 | __POS_OF__("fromInitializer"), 12 | Array.fromInitializer(~length=7, i => i + 3), 13 | eq, 14 | [3, 4, 5, 6, 7, 8, 9], 15 | ) 16 | 17 | Test.run(__POS_OF__("reduce"), Array.reduce([1, 2, 3], list{}, List.add), eq, list{3, 2, 1}) 18 | Test.run(__POS_OF__("reduce - empty"), Array.reduce([], list{}, List.add), eq, list{}) 19 | 20 | Test.run( 21 | __POS_OF__("reduceWithIndex"), 22 | Array.reduceWithIndex([1, 2, 3], list{}, (acc, v, i) => list{v + i, ...acc}), 23 | eq, 24 | list{5, 3, 1}, 25 | ) 26 | Test.run( 27 | __POS_OF__("reduceWithIndex - empty"), 28 | Array.reduceWithIndex([], list{}, (acc, v, i) => list{v + i, ...acc}), 29 | eq, 30 | list{}, 31 | ) 32 | 33 | Test.run( 34 | __POS_OF__("reduceRight"), 35 | Array.reduceRight([1, 2, 3], list{}, List.add), 36 | eq, 37 | list{1, 2, 3}, 38 | ) 39 | Test.run(__POS_OF__("reduceRight - empty"), Array.reduceRight([], list{}, List.add), eq, list{}) 40 | 41 | Test.run( 42 | __POS_OF__("reduceEightWithIndex"), 43 | Array.reduceRightWithIndex([1, 2, 3], list{}, (acc, v, i) => list{v + i, ...acc}), 44 | eq, 45 | list{1, 3, 5}, 46 | ) 47 | Test.run( 48 | __POS_OF__("reduceWithIndex - empty"), 49 | Array.reduceRightWithIndex([], list{}, (acc, v, i) => list{v + i, ...acc}), 50 | eq, 51 | list{}, 52 | ) 53 | 54 | Test.run(__POS_OF__("toShuffled - length"), Array.toShuffled([1, 2, 3])->Array.length, eq, 3) 55 | 56 | Test.run( 57 | __POS_OF__("shuffle - length"), 58 | { 59 | let arr = [1, 2, 3] 60 | Array.shuffle(arr) 61 | arr->Array.length 62 | }, 63 | eq, 64 | 3, 65 | ) 66 | 67 | Test.run( 68 | __POS_OF__("filterMap"), 69 | Array.filterMap([1, 2, 3, 4, 5, 6], n => mod(n, 2) == 0 ? Some(n * n) : None), 70 | eq, 71 | [4, 16, 36], 72 | ) 73 | Test.run(__POS_OF__("filterMap - no match"), Array.filterMap([1, 2, 3, 4, 5, 6], _ => None), eq, []) 74 | Test.run( 75 | __POS_OF__("filterMap - empty"), 76 | Array.filterMap([], n => mod(n, 2) == 0 ? Some(n * n) : None), 77 | eq, 78 | [], 79 | ) 80 | 81 | Test.run(__POS_OF__("keepSome"), Array.keepSome([Some(1), None, Some(3)]), eq, [1, 3]) 82 | Test.run( 83 | __POS_OF__("keepSome - all Some"), 84 | Array.keepSome([Some(1), Some(2), Some(3)]), 85 | eq, 86 | [1, 2, 3], 87 | ) 88 | Test.run(__POS_OF__("keepSome - all None"), Array.keepSome([None, None, None]), eq, []) 89 | Test.run(__POS_OF__("keepSome - empty"), Array.keepSome([]), eq, []) 90 | 91 | Test.run( 92 | __POS_OF__("findMap"), 93 | Array.findMap([1, 2, 3, 4, 5, 6], n => mod(n, 2) == 0 ? Some(n - 8) : None), 94 | eq, 95 | Some(-6), 96 | ) 97 | Test.run(__POS_OF__("findMap - no match"), Array.findMap([1, 2, 3, 4, 5, 6], _ => None), eq, None) 98 | Test.run( 99 | __POS_OF__("findMap - empty"), 100 | Array.findMap([], n => mod(n, 2) == 0 ? Some(n * n) : None), 101 | eq, 102 | None, 103 | ) 104 | 105 | Test.run( 106 | __POS_OF__("fromIterator"), 107 | Array.fromIterator(Map.fromArray([(1, 3), (2, 4)])->Map.values), 108 | eq, 109 | [3, 4], 110 | ) 111 | 112 | Test.run(__POS_OF__("last - with items"), [1, 2, 3]->Array.last, eq, Some(3)) 113 | Test.run(__POS_OF__("last - empty"), []->Array.last, eq, None) 114 | -------------------------------------------------------------------------------- /test/DictTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; 5 | 6 | var eq = Caml_obj.equal; 7 | 8 | Test.run([ 9 | [ 10 | "DictTests.res", 11 | 5, 12 | 20, 13 | 26 14 | ], 15 | "make" 16 | ], {}, eq, {}); 17 | 18 | Test.run([ 19 | [ 20 | "DictTests.res", 21 | 7, 22 | 20, 23 | 31 24 | ], 25 | "fromArray" 26 | ], Object.fromEntries([[ 27 | "foo", 28 | "bar" 29 | ]]), eq, {foo: "bar"}); 30 | 31 | Test.run([ 32 | [ 33 | "DictTests.res", 34 | 10, 35 | 13, 36 | 35 37 | ], 38 | "getUnsafe - existing" 39 | ], Object.fromEntries([[ 40 | "foo", 41 | "bar" 42 | ]])["foo"], eq, "bar"); 43 | 44 | Test.run([ 45 | [ 46 | "DictTests.res", 47 | 16, 48 | 13, 49 | 34 50 | ], 51 | "getUnsafe - missing" 52 | ], ({})["foo"], eq, undefined); 53 | 54 | export { 55 | eq , 56 | } 57 | /* Not a pure module */ 58 | -------------------------------------------------------------------------------- /test/DictTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | Test.run(__POS_OF__("make"), Dict.make(), eq, %raw(`{}`)) 6 | 7 | Test.run(__POS_OF__("fromArray"), Dict.fromArray([("foo", "bar")]), eq, %raw(`{foo: "bar"}`)) 8 | 9 | Test.run( 10 | __POS_OF__("getUnsafe - existing"), 11 | Dict.fromArray([("foo", "bar")])->Dict.getUnsafe("foo"), 12 | eq, 13 | "bar", 14 | ) 15 | Test.run( 16 | __POS_OF__("getUnsafe - missing"), 17 | Dict.make()->Dict.getUnsafe("foo"), 18 | eq, 19 | %raw(`undefined`), 20 | ) 21 | -------------------------------------------------------------------------------- /test/ErrorTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | import * as Js_exn from "rescript/lib/es6/js_exn.js"; 5 | import * as RescriptCore from "../src/RescriptCore.mjs"; 6 | import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; 7 | 8 | function panicTest() { 9 | var caught; 10 | try { 11 | caught = RescriptCore.panic("uh oh"); 12 | } 13 | catch (raw_err){ 14 | var err = Caml_js_exceptions.internalToOCamlException(raw_err); 15 | if (err.RE_EXN_ID === Js_exn.$$Error) { 16 | caught = err._1.message; 17 | } else { 18 | throw err; 19 | } 20 | } 21 | Test.run([ 22 | [ 23 | "ErrorTests.res", 24 | 8, 25 | 22, 26 | 43 27 | ], 28 | "Should resolve test" 29 | ], caught, (function (prim0, prim1) { 30 | return prim0 === prim1; 31 | }), "Panic! uh oh"); 32 | } 33 | 34 | panicTest(); 35 | 36 | export { 37 | panicTest , 38 | } 39 | /* Not a pure module */ 40 | -------------------------------------------------------------------------------- /test/ErrorTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let panicTest = () => { 4 | let caught = try panic("uh oh") catch { 5 | | Exn.Error(err) => Error.message(err) 6 | } 7 | 8 | Test.run(__POS_OF__("Should resolve test"), caught, \"==", Some("Panic! uh oh")) 9 | } 10 | 11 | panicTest() 12 | -------------------------------------------------------------------------------- /test/FloatTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | Test.run(__POS_OF__("clamp"), Float.clamp(4.2), eq, 4.2) 6 | Test.run(__POS_OF__("clamp - < min"), Float.clamp(~min=4.3, 4.1), eq, 4.3) 7 | Test.run(__POS_OF__("clamp - > min"), Float.clamp(~min=4.1, 4.2), eq, 4.2) 8 | Test.run(__POS_OF__("clamp - < max"), Float.clamp(~max=4.3, 4.2), eq, 4.2) 9 | Test.run(__POS_OF__("clamp - > max"), Float.clamp(~max=4.1, 4.2), eq, 4.1) 10 | Test.run(__POS_OF__("clamp - < min, < max"), Float.clamp(~min=4.3, ~max=4.5, 4.2), eq, 4.3) 11 | Test.run(__POS_OF__("clamp - < min, > max"), Float.clamp(~min=4.3, ~max=4.1, 4.2), eq, 4.3) // min wins 12 | Test.run(__POS_OF__("clamp - > min, < max"), Float.clamp(~min=4.1, ~max=4.5, 4.2), eq, 4.2) 13 | Test.run(__POS_OF__("clamp - > min, > max"), Float.clamp(~min=4.1, ~max=4.1, 4.2), eq, 4.1) 14 | Test.run(__POS_OF__("clamp - nan"), Float.clamp(~min=4.1, ~max=4.3, nan)->Float.isNaN, eq, true) 15 | Test.run(__POS_OF__("clamp - infinity"), Float.clamp(~min=4.1, ~max=4.3, infinity), eq, 4.3) 16 | Test.run(__POS_OF__("clamp - -infinity"), Float.clamp(~min=4.1, ~max=4.3, neg_infinity), eq, 4.1) 17 | Test.run(__POS_OF__("clamp - min nan"), Float.clamp(~min=nan, 4.2), eq, 4.2) 18 | Test.run(__POS_OF__("clamp - max nan"), Float.clamp(~max=nan, 4.2), eq, 4.2) 19 | Test.run(__POS_OF__("clamp - min nan, max nan"), Float.clamp(~min=nan, ~max=nan, 4.2), eq, 4.2) 20 | Test.run(__POS_OF__("clamp - min infinity"), Float.clamp(~min=infinity, 4.2), eq, infinity) 21 | Test.run(__POS_OF__("clamp - max infinity"), Float.clamp(~max=infinity, 4.2), eq, 4.2) 22 | Test.run(__POS_OF__("clamp - min -infinity"), Float.clamp(~min=neg_infinity, 4.2), eq, 4.2) 23 | Test.run(__POS_OF__("clamp - max -infinity"), Float.clamp(~max=neg_infinity, 4.2), eq, neg_infinity) 24 | Test.run( 25 | __POS_OF__("clamp - min infinity, max infinity"), 26 | Float.clamp(~min=infinity, ~max=infinity, 4.2), 27 | eq, 28 | infinity, 29 | ) 30 | Test.run( 31 | __POS_OF__("clamp - min -infinity, max infinity"), 32 | Float.clamp(~min=neg_infinity, ~max=infinity, 4.2), 33 | eq, 34 | 4.2, 35 | ) 36 | Test.run( 37 | __POS_OF__("clamp - min infinity, max -infinity"), 38 | Float.clamp(~min=infinity, ~max=neg_infinity, 4.2), 39 | eq, 40 | infinity, // min wins 41 | ) 42 | Test.run( 43 | __POS_OF__("clamp - min -infinity, max -infinity"), 44 | Float.clamp(~min=neg_infinity, ~max=neg_infinity, 4.2), 45 | eq, 46 | neg_infinity, 47 | ) 48 | 49 | Test.run(__POS_OF__("Float.equal optimization"), Float.equal(1., 3.), eq, false) 50 | -------------------------------------------------------------------------------- /test/ImportTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | 5 | async function main() { 6 | var eq = await import("./IntTests.mjs").then(function (m) { 7 | return m.eq; 8 | }); 9 | return Test.run([ 10 | [ 11 | "ImportTests.res", 12 | 5, 13 | 22, 14 | 55 15 | ], 16 | "dynamic import - Int tests - eq" 17 | ], 1, eq, 1); 18 | } 19 | 20 | export { 21 | main , 22 | } 23 | /* Test Not a pure module */ 24 | -------------------------------------------------------------------------------- /test/ImportTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let main = async () => { 4 | let eq = await import(IntTests.eq) 5 | Test.run(__POS_OF__("dynamic import - Int tests - eq"), 1, eq, 1) 6 | } 7 | 8 | main->ignore 9 | -------------------------------------------------------------------------------- /test/IteratorTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; 5 | import * as Core__Iterator from "../src/Core__Iterator.mjs"; 6 | import * as Core__AsyncIterator from "../src/Core__AsyncIterator.mjs"; 7 | 8 | var eq = Caml_obj.equal; 9 | 10 | var iterator = ((() => { 11 | var array1 = ['a', 'b', 'c']; 12 | var iterator1 = array1[Symbol.iterator](); 13 | return iterator1 14 | })()); 15 | 16 | var syncResult = { 17 | contents: undefined 18 | }; 19 | 20 | Core__Iterator.forEach(iterator, (function (v) { 21 | if (v === "b") { 22 | syncResult.contents = "b"; 23 | return ; 24 | } 25 | 26 | })); 27 | 28 | Test.run([ 29 | [ 30 | "IteratorTests.res", 31 | 21, 32 | 20, 33 | 34 34 | ], 35 | "Sync forEach" 36 | ], syncResult.contents, eq, "b"); 37 | 38 | var asyncIterator = ((() => { 39 | var map1 = new Map(); 40 | 41 | map1.set('first', '1'); 42 | map1.set('second', '2'); 43 | 44 | var iterator1 = map1[Symbol.iterator](); 45 | return iterator1; 46 | })()); 47 | 48 | var asyncResult = { 49 | contents: undefined 50 | }; 51 | 52 | await Core__AsyncIterator.forEach(asyncIterator, (function (v) { 53 | if (v !== undefined && v[0] === "second") { 54 | asyncResult.contents = "second"; 55 | return ; 56 | } 57 | 58 | })); 59 | 60 | Test.run([ 61 | [ 62 | "IteratorTests.res", 63 | 44, 64 | 20, 65 | 35 66 | ], 67 | "Async forEach" 68 | ], asyncResult.contents, eq, "second"); 69 | 70 | var asyncResult$1 = { 71 | contents: undefined 72 | }; 73 | 74 | var count = { 75 | contents: 0 76 | }; 77 | 78 | var asyncIterator$1 = Core__AsyncIterator.make(async function () { 79 | var currentCount = count.contents; 80 | count.contents = currentCount + 1 | 0; 81 | if (currentCount === 3) { 82 | return Core__AsyncIterator.done(currentCount); 83 | } else { 84 | return Core__AsyncIterator.value(currentCount); 85 | } 86 | }); 87 | 88 | await Core__AsyncIterator.forEach(asyncIterator$1, (function (v) { 89 | if (v === 3) { 90 | asyncResult$1.contents = "done"; 91 | } else { 92 | console.log("next.."); 93 | } 94 | })); 95 | 96 | Test.run([ 97 | [ 98 | "IteratorTests.res", 99 | 69, 100 | 20, 101 | 54 102 | ], 103 | "Creating your own async iterator" 104 | ], asyncResult$1.contents, eq, "done"); 105 | 106 | export { 107 | eq , 108 | iterator , 109 | syncResult , 110 | asyncResult , 111 | asyncIterator$1 as asyncIterator, 112 | } 113 | /* iterator Not a pure module */ 114 | -------------------------------------------------------------------------------- /test/IteratorTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | let iterator: Iterator.t = %raw(` 6 | (() => { 7 | var array1 = ['a', 'b', 'c']; 8 | var iterator1 = array1[Symbol.iterator](); 9 | return iterator1 10 | })() 11 | `) 12 | 13 | let syncResult = ref(None) 14 | 15 | iterator->Iterator.forEach(v => { 16 | if v === Some("b") { 17 | syncResult.contents = Some("b") 18 | } 19 | }) 20 | 21 | Test.run(__POS_OF__("Sync forEach"), syncResult.contents, eq, Some("b")) 22 | 23 | let asyncIterator: AsyncIterator.t<(string, string)> = %raw(` 24 | (() => { 25 | var map1 = new Map(); 26 | 27 | map1.set('first', '1'); 28 | map1.set('second', '2'); 29 | 30 | var iterator1 = map1[Symbol.iterator](); 31 | return iterator1; 32 | })() 33 | `) 34 | 35 | let asyncResult = ref(None) 36 | 37 | await asyncIterator->AsyncIterator.forEach(v => { 38 | switch v { 39 | | Some(("second", _value)) => asyncResult.contents = Some("second") 40 | | _ => () 41 | } 42 | }) 43 | 44 | Test.run(__POS_OF__("Async forEach"), asyncResult.contents, eq, Some("second")) 45 | 46 | %%private( 47 | let asyncResult = ref(None) 48 | let count = ref(0) 49 | ) 50 | 51 | let asyncIterator = AsyncIterator.make(async () => { 52 | let currentCount = count.contents 53 | count := currentCount + 1 54 | 55 | if currentCount === 3 { 56 | AsyncIterator.done(~finalValue=currentCount) 57 | } else { 58 | AsyncIterator.value(currentCount) 59 | } 60 | }) 61 | 62 | await asyncIterator->AsyncIterator.forEach(v => { 63 | switch v { 64 | | Some(3) => asyncResult.contents = Some("done") 65 | | _ => Console.log("next..") 66 | } 67 | }) 68 | 69 | Test.run(__POS_OF__("Creating your own async iterator"), asyncResult.contents, eq, Some("done")) 70 | -------------------------------------------------------------------------------- /test/JsonTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | 5 | function decodeJsonTest() { 6 | var json = {"someProp":{"otherProp": null, "thirdProp": [true, false]}}; 7 | var decodedCorrectly; 8 | if (!Array.isArray(json) && (json === null || typeof json !== "object") && typeof json !== "number" && typeof json !== "string" && typeof json !== "boolean" || !(typeof json === "object" && !Array.isArray(json))) { 9 | decodedCorrectly = false; 10 | } else { 11 | var match = json["someProp"]; 12 | if (match !== undefined && !(!Array.isArray(match) && (match === null || typeof match !== "object") && typeof match !== "number" && typeof match !== "string" && typeof match !== "boolean" || !(typeof match === "object" && !Array.isArray(match)))) { 13 | var match$1 = match["thirdProp"]; 14 | if (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" || !(Array.isArray(match$1) && match$1.length === 2))) { 15 | var match$2 = match$1[0]; 16 | if (!Array.isArray(match$2) && (match$2 === null || typeof match$2 !== "object") && typeof match$2 !== "number" && typeof match$2 !== "string" && typeof match$2 !== "boolean" || !(typeof match$2 === "boolean" && match$2)) { 17 | decodedCorrectly = false; 18 | } else { 19 | var match$3 = match$1[1]; 20 | decodedCorrectly = !Array.isArray(match$3) && (match$3 === null || typeof match$3 !== "object") && typeof match$3 !== "number" && typeof match$3 !== "string" && typeof match$3 !== "boolean" || !(typeof match$3 === "boolean" && !match$3) ? false : true; 21 | } 22 | } else { 23 | decodedCorrectly = false; 24 | } 25 | } else { 26 | decodedCorrectly = false; 27 | } 28 | } 29 | Test.run([ 30 | [ 31 | "JsonTests.res", 32 | 19, 33 | 22, 34 | 55 35 | ], 36 | "Should decode JSON successfully" 37 | ], decodedCorrectly, (function (prim0, prim1) { 38 | return prim0 === prim1; 39 | }), true); 40 | } 41 | 42 | decodeJsonTest(); 43 | 44 | export { 45 | decodeJsonTest , 46 | } 47 | /* Not a pure module */ 48 | -------------------------------------------------------------------------------- /test/JsonTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let decodeJsonTest = () => { 4 | let json: JSON.t = %raw(`{"someProp":{"otherProp": null, "thirdProp": [true, false]}}`) 5 | 6 | let decodedCorrectly = switch json { 7 | | Object(dict) => 8 | switch dict->Dict.get("someProp") { 9 | | Some(Object(dict)) => 10 | switch dict->Dict.get("thirdProp") { 11 | | Some(Array([Boolean(true), Boolean(false)])) => true 12 | | _ => false 13 | } 14 | | _ => false 15 | } 16 | | _ => false 17 | } 18 | 19 | Test.run(__POS_OF__("Should decode JSON successfully"), decodedCorrectly, \"==", true) 20 | } 21 | 22 | decodeJsonTest() 23 | -------------------------------------------------------------------------------- /test/NullableTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | 5 | function shouldHandleNullableValues() { 6 | var tNull = null; 7 | var tUndefined = undefined; 8 | var tValue = "hello"; 9 | var tmp; 10 | tmp = (tNull === null || tNull === undefined) && tNull === null ? true : false; 11 | Test.run([ 12 | [ 13 | "NullableTests.res", 14 | 9, 15 | 15, 16 | 35 17 | ], 18 | "Should handle null" 19 | ], tmp, (function (prim0, prim1) { 20 | return prim0 === prim1; 21 | }), true); 22 | var tmp$1; 23 | tmp$1 = (tUndefined === null || tUndefined === undefined) && tUndefined !== null ? true : false; 24 | Test.run([ 25 | [ 26 | "NullableTests.res", 27 | 19, 28 | 15, 29 | 40 30 | ], 31 | "Should handle undefined" 32 | ], tmp$1, (function (prim0, prim1) { 33 | return prim0 === prim1; 34 | }), true); 35 | var tmp$2; 36 | tmp$2 = tValue === null || tValue === undefined || tValue !== "hello" ? false : true; 37 | Test.run([ 38 | [ 39 | "NullableTests.res", 40 | 29, 41 | 15, 42 | 36 43 | ], 44 | "Should handle value" 45 | ], tmp$2, (function (prim0, prim1) { 46 | return prim0 === prim1; 47 | }), true); 48 | } 49 | 50 | shouldHandleNullableValues(); 51 | 52 | export { 53 | shouldHandleNullableValues , 54 | } 55 | /* Not a pure module */ 56 | -------------------------------------------------------------------------------- /test/NullableTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let shouldHandleNullableValues = () => { 4 | let tNull: Nullable.t = %raw("null") 5 | let tUndefined: Nullable.t = %raw("undefined") 6 | let tValue: Nullable.t = %raw(`"hello"`) 7 | 8 | Test.run( 9 | __POS_OF__("Should handle null"), 10 | switch tNull { 11 | | Null => true 12 | | Value(_) | Undefined => false 13 | }, 14 | \"==", 15 | true, 16 | ) 17 | 18 | Test.run( 19 | __POS_OF__("Should handle undefined"), 20 | switch tUndefined { 21 | | Undefined => true 22 | | Value(_) | Null => false 23 | }, 24 | \"==", 25 | true, 26 | ) 27 | 28 | Test.run( 29 | __POS_OF__("Should handle value"), 30 | switch tValue { 31 | | Value("hello") => true 32 | | _ => false 33 | }, 34 | \"==", 35 | true, 36 | ) 37 | } 38 | 39 | shouldHandleNullableValues() 40 | -------------------------------------------------------------------------------- /test/ResultTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; 5 | import * as Core__Result from "../src/Core__Result.mjs"; 6 | 7 | var eq = Caml_obj.equal; 8 | 9 | function forEachIfOkCallFunction() { 10 | var called = { 11 | contents: [] 12 | }; 13 | Core__Result.forEach({ 14 | TAG: "Ok", 15 | _0: 3 16 | }, (function (i) { 17 | called.contents.push(i); 18 | })); 19 | Test.run([ 20 | [ 21 | "ResultTests.res", 22 | 12, 23 | 22, 24 | 72 25 | ], 26 | "forEach: if ok, call function with ok value once" 27 | ], called.contents, eq, [3]); 28 | } 29 | 30 | forEachIfOkCallFunction(); 31 | 32 | function forEachIfErrorDoNotCallFunction() { 33 | var called = { 34 | contents: [] 35 | }; 36 | Core__Result.forEach({ 37 | TAG: "Error", 38 | _0: 3 39 | }, (function (i) { 40 | called.contents.push(i); 41 | })); 42 | Test.run([ 43 | [ 44 | "ResultTests.res", 45 | 19, 46 | 22, 47 | 63 48 | ], 49 | "forEach: if error, do not call function" 50 | ], called.contents, eq, []); 51 | } 52 | 53 | forEachIfErrorDoNotCallFunction(); 54 | 55 | Test.run([ 56 | [ 57 | "ResultTests.res", 58 | 27, 59 | 20, 60 | 48 61 | ], 62 | "mapError: if ok, return it" 63 | ], Core__Result.mapError({ 64 | TAG: "Ok", 65 | _0: 5 66 | }, (function (i) { 67 | return Math.imul(i, 3); 68 | })), eq, { 69 | TAG: "Ok", 70 | _0: 5 71 | }); 72 | 73 | Test.run([ 74 | [ 75 | "ResultTests.res", 76 | 30, 77 | 13, 78 | 42 79 | ], 80 | "mapError: if error, apply f" 81 | ], Core__Result.mapError({ 82 | TAG: "Error", 83 | _0: 5 84 | }, (function (i) { 85 | return Math.imul(i, 3); 86 | })), eq, { 87 | TAG: "Error", 88 | _0: 15 89 | }); 90 | 91 | export { 92 | eq , 93 | forEachIfOkCallFunction , 94 | forEachIfErrorDoNotCallFunction , 95 | } 96 | /* Not a pure module */ 97 | -------------------------------------------------------------------------------- /test/ResultTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | // ======= 6 | // forEach 7 | // ======= 8 | 9 | let forEachIfOkCallFunction = () => { 10 | let called = ref([]) 11 | Ok(3)->Result.forEach(i => called.contents->Array.push(i)) 12 | Test.run(__POS_OF__("forEach: if ok, call function with ok value once"), called.contents, eq, [3]) 13 | } 14 | forEachIfOkCallFunction() 15 | 16 | let forEachIfErrorDoNotCallFunction = () => { 17 | let called = ref([]) 18 | Error(3)->Result.forEach(i => called.contents->Array.push(i)) 19 | Test.run(__POS_OF__("forEach: if error, do not call function"), called.contents, eq, []) 20 | } 21 | forEachIfErrorDoNotCallFunction() 22 | 23 | // ======== 24 | // mapError 25 | // ======== 26 | 27 | Test.run(__POS_OF__("mapError: if ok, return it"), Ok(5)->Result.mapError(i => i * 3), eq, Ok(5)) 28 | 29 | Test.run( 30 | __POS_OF__("mapError: if error, apply f"), 31 | Error(5)->Result.mapError(i => i * 3), 32 | eq, 33 | Error(15), 34 | ) 35 | -------------------------------------------------------------------------------- /test/StringTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; 5 | 6 | var eq = Caml_obj.equal; 7 | 8 | Test.run([ 9 | [ 10 | "StringTests.res", 11 | 5, 12 | 20, 13 | 47 14 | ], 15 | "String.equal optimization" 16 | ], false, eq, false); 17 | 18 | export { 19 | eq , 20 | } 21 | /* Not a pure module */ 22 | -------------------------------------------------------------------------------- /test/StringTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | Test.run(__POS_OF__("String.equal optimization"), String.equal("one", "three"), eq, false) 6 | -------------------------------------------------------------------------------- /test/Test.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Fs from "fs"; 4 | import * as Path from "path"; 5 | import * as Util from "util"; 6 | import * as Core__Option from "../src/Core__Option.mjs"; 7 | import * as CodeFrame from "@babel/code-frame"; 8 | 9 | var dirname = (new URL('.', import.meta.url).pathname); 10 | 11 | function print(value) { 12 | var match = typeof value; 13 | if (match === "object" || match === "bigint") { 14 | return Util.inspect(value); 15 | } else if (match === "string") { 16 | return Core__Option.getExn(JSON.stringify(value), undefined); 17 | } else { 18 | return String(value); 19 | } 20 | } 21 | 22 | function run(loc, left, comparator, right) { 23 | if (comparator(left, right)) { 24 | return ; 25 | } 26 | var match = loc[0]; 27 | var line = match[1]; 28 | var file = match[0]; 29 | var fileContent = Fs.readFileSync(Path.join(dirname, file), { 30 | encoding: "utf-8" 31 | }); 32 | var left$1 = print(left); 33 | var right$1 = print(right); 34 | var codeFrame = CodeFrame.codeFrameColumns(fileContent, { 35 | start: { 36 | line: line 37 | } 38 | }, { 39 | highlightCode: true 40 | }); 41 | var errorMessage = "\n \u001b[31mTest Failure!\n \u001b[36m" + file + "\u001b[0m:\u001b[2m" + String(line) + "\n" + codeFrame + "\n \u001b[39mLeft: \u001b[31m" + left$1 + "\n \u001b[39mRight: \u001b[31m" + right$1 + "\u001b[0m\n"; 42 | console.log(errorMessage); 43 | var obj = {}; 44 | Error.captureStackTrace(obj); 45 | console.log(obj.stack.replace(/\n /g, "\n ").replace(/^Error\n/, "").replace(/^.+\n/, "").replace(/\n at .+\(node:internal.+\n?/g, "")); 46 | } 47 | 48 | export { 49 | dirname , 50 | print , 51 | run , 52 | } 53 | /* dirname Not a pure module */ 54 | -------------------------------------------------------------------------------- /test/Test.res: -------------------------------------------------------------------------------- 1 | // Test "framework" 2 | 3 | open RescriptCore 4 | 5 | @scope("process") @val external exit: int => unit = "exit" 6 | @scope("Error") @val external captureStackTrace: {..} => unit = "captureStackTrace" 7 | @module("@babel/code-frame") @val 8 | external codeFrameColumns: (string, {..}, {..}) => string = "codeFrameColumns" 9 | @module("fs") @val external readFileSync: (string, {..}) => string = "readFileSync" 10 | @module("path") @val external join: (string, string) => string = "join" 11 | 12 | let dirname = %raw("new URL('.', import.meta.url).pathname") 13 | 14 | @val @module("util") external inspect: _ => string = "inspect" 15 | let print = value => 16 | switch Type.typeof(value) { 17 | | #string => JSON.stringifyAny(value)->Option.getExn // uses " instead of ' 18 | | #object | #bigint => inspect(value) 19 | | _ => String.make(value) 20 | } 21 | 22 | let run = (loc, left, comparator, right) => { 23 | if !comparator(left, right) { 24 | let ((file, line, _, _), _) = loc 25 | let fileContent = readFileSync(join(dirname, file), {"encoding": "utf-8"}) 26 | let left = print(left) 27 | let right = print(right) 28 | let codeFrame = codeFrameColumns( 29 | fileContent, 30 | {"start": {"line": line}}, 31 | {"highlightCode": true}, 32 | ) 33 | let errorMessage = ` 34 | \u001b[31mTest Failure! 35 | \u001b[36m${file}\u001b[0m:\u001b[2m${string_of_int(line)} 36 | ${codeFrame} 37 | \u001b[39mLeft: \u001b[31m${left} 38 | \u001b[39mRight: \u001b[31m${right}\u001b[0m 39 | ` 40 | Console.log(errorMessage) 41 | // API: https://nodejs.org/api/errors.html#errors_error_capturestacktrace_targetobject_constructoropt 42 | let obj = Object.make() 43 | captureStackTrace(obj) 44 | // clean up stack trace! Stack format: https://nodejs.org/api/errors.html#errors_error_stack 45 | obj["stack"] 46 | ->String.replaceRegExp(%re("/\n /g"), "\n ") // indent 2 spaces instead of 4, to align with code frame 47 | ->String.replaceRegExp(%re("/^Error\n/"), "") // first line is just the word "Error" 48 | ->String.replaceRegExp(%re("/^.+\n/"), "") // second line (now first) is this Test module's own stack frame 49 | ->String.replaceRegExp(%re("/\n at .+\(node:internal.+\n?/g"), "") // remove internal lines like " at ModuleJob.run (node:internal/modules/esm/module_job:193:25)" 50 | ->Console.log 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test/TestSuite.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as IntTests from "./IntTests.mjs"; 4 | import * as DictTests from "./DictTests.mjs"; 5 | import * as JsonTests from "./JsonTests.mjs"; 6 | import * as TestTests from "./TestTests.mjs"; 7 | import * as ArrayTests from "./ArrayTests.mjs"; 8 | import * as ErrorTests from "./ErrorTests.mjs"; 9 | import * as FloatTests from "./FloatTests.mjs"; 10 | import * as ObjectTests from "./ObjectTests.mjs"; 11 | import * as PromiseTest from "./PromiseTest.mjs"; 12 | import * as ResultTests from "./ResultTests.mjs"; 13 | import * as IteratorTests from "./IteratorTests.mjs"; 14 | import * as NullableTests from "./NullableTests.mjs"; 15 | import * as TypedArrayTests from "./TypedArrayTests.mjs"; 16 | 17 | var bign = TestTests.bign; 18 | 19 | var TestError = PromiseTest.TestError; 20 | 21 | var fail = PromiseTest.fail; 22 | 23 | var equal = PromiseTest.equal; 24 | 25 | var Creation = PromiseTest.Creation; 26 | 27 | var ThenChaining = PromiseTest.ThenChaining; 28 | 29 | var Rejection = PromiseTest.Rejection; 30 | 31 | var Catching = PromiseTest.Catching; 32 | 33 | var Concurrently = PromiseTest.Concurrently; 34 | 35 | var panicTest = ErrorTests.panicTest; 36 | 37 | var $$catch = IntTests.$$catch; 38 | 39 | var nums = ObjectTests.nums; 40 | 41 | var d = ObjectTests.d; 42 | 43 | var x = ObjectTests.x; 44 | 45 | var mkBig = ObjectTests.mkBig; 46 | 47 | var assignOverwritesTarget = ObjectTests.assignOverwritesTarget; 48 | 49 | var runGetTest = ObjectTests.runGetTest; 50 | 51 | var getSymbolTestWhenExists = ObjectTests.getSymbolTestWhenExists; 52 | 53 | var forEachIfOkCallFunction = ResultTests.forEachIfOkCallFunction; 54 | 55 | var forEachIfErrorDoNotCallFunction = ResultTests.forEachIfErrorDoNotCallFunction; 56 | 57 | var num1 = TypedArrayTests.num1; 58 | 59 | var num2 = TypedArrayTests.num2; 60 | 61 | var num3 = TypedArrayTests.num3; 62 | 63 | var assertTrue = TypedArrayTests.assertTrue; 64 | 65 | var assertWillThrow = TypedArrayTests.assertWillThrow; 66 | 67 | var areSame = TypedArrayTests.areSame; 68 | 69 | var o = TypedArrayTests.o; 70 | 71 | var decodeJsonTest = JsonTests.decodeJsonTest; 72 | 73 | var shouldHandleNullableValues = NullableTests.shouldHandleNullableValues; 74 | 75 | var eq = IteratorTests.eq; 76 | 77 | var iterator = IteratorTests.iterator; 78 | 79 | var syncResult = IteratorTests.syncResult; 80 | 81 | var asyncResult = IteratorTests.asyncResult; 82 | 83 | var asyncIterator = IteratorTests.asyncIterator; 84 | 85 | export { 86 | bign , 87 | TestError , 88 | fail , 89 | equal , 90 | Creation , 91 | ThenChaining , 92 | Rejection , 93 | Catching , 94 | Concurrently , 95 | panicTest , 96 | $$catch , 97 | nums , 98 | d , 99 | x , 100 | mkBig , 101 | assignOverwritesTarget , 102 | runGetTest , 103 | getSymbolTestWhenExists , 104 | forEachIfOkCallFunction , 105 | forEachIfErrorDoNotCallFunction , 106 | num1 , 107 | num2 , 108 | num3 , 109 | assertTrue , 110 | assertWillThrow , 111 | areSame , 112 | o , 113 | decodeJsonTest , 114 | shouldHandleNullableValues , 115 | eq , 116 | iterator , 117 | syncResult , 118 | asyncResult , 119 | asyncIterator , 120 | } 121 | /* IntTests Not a pure module */ 122 | -------------------------------------------------------------------------------- /test/TestSuite.res: -------------------------------------------------------------------------------- 1 | include TestTests 2 | include PromiseTest 3 | include ErrorTests 4 | include ArrayTests 5 | include IntTests 6 | include ObjectTests 7 | include ResultTests 8 | include TypedArrayTests 9 | include FloatTests 10 | include JsonTests 11 | include NullableTests 12 | include DictTests 13 | include IteratorTests 14 | -------------------------------------------------------------------------------- /test/TestTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | let bign = BigInt.fromFloat(Float.Constants.maxValue) 6 | let bign = BigInt.add(bign, bign) 7 | 8 | Test.run(__POS_OF__("print null"), Test.print(null), eq, "null") 9 | Test.run(__POS_OF__("print undefined"), Test.print(undefined), eq, "undefined") 10 | Test.run(__POS_OF__("print NaN"), Test.print(nan), eq, "NaN") 11 | Test.run(__POS_OF__("print infinity"), Test.print(infinity), eq, "Infinity") 12 | Test.run(__POS_OF__("print 0"), Test.print(0), eq, "0") 13 | Test.run(__POS_OF__("print int"), Test.print(42), eq, "42") 14 | Test.run(__POS_OF__("print float"), Test.print(4.2), eq, "4.2") 15 | Test.run(__POS_OF__("print string"), Test.print("foo"), eq, `"foo"`) 16 | Test.run(__POS_OF__("print bool"), Test.print(true), eq, "true") 17 | Test.run(__POS_OF__("print object"), Test.print({"x": 42}), eq, `{ x: 42 }`) 18 | Test.run(__POS_OF__("print array"), Test.print([1, 2, 3]), eq, "[ 1, 2, 3 ]") 19 | Test.run(__POS_OF__("print symbol"), Test.print(Symbol.make("foo")), eq, "Symbol(foo)") 20 | Test.run( 21 | __POS_OF__("print function"), 22 | Test.print(() => 42), 23 | eq, 24 | "function () {\n return 42;\n }", 25 | ) 26 | Test.run(__POS_OF__("print es6 function"), Test.print(%raw("() => 42")), eq, "() => 42") 27 | Test.run( 28 | __POS_OF__("print bigint"), 29 | Test.print(bign), 30 | eq, 31 | "359538626972463141629054847463408713596141135051689993197834953606314521560057077521179117265533756343080917907028764928468642653778928365536935093407075033972099821153102564152490980180778657888151737016910267884609166473806445896331617118664246696549595652408289446337476354361838599762500808052368249716736n", 32 | ) 33 | Test.run(__POS_OF__("print set"), Test.print(Set.fromArray([1, 2, 2, 3])), eq, "Set(3) { 1, 2, 3 }") 34 | -------------------------------------------------------------------------------- /test/TypedArrayTests.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Test from "./Test.mjs"; 4 | import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; 5 | import * as Core__Option from "../src/Core__Option.mjs"; 6 | 7 | var eq = Caml_obj.equal; 8 | 9 | Test.run([ 10 | [ 11 | "TypedArrayTests.res", 12 | 7, 13 | 20, 14 | 44 15 | ], 16 | "bytes per element is 8" 17 | ], BigInt64Array.BYTES_PER_ELEMENT, eq, 8); 18 | 19 | var num1 = BigInt("123456789"); 20 | 21 | var num2 = BigInt("987654321"); 22 | 23 | var num3 = BigInt("555555555"); 24 | 25 | function assertTrue(message, predicate) { 26 | try { 27 | if (predicate()) { 28 | return ; 29 | } 30 | throw new Error(message); 31 | } 32 | catch (exn){ 33 | throw new Error(message); 34 | } 35 | } 36 | 37 | function assertWillThrow(message, f) { 38 | var didThrow = false; 39 | try { 40 | f(); 41 | } 42 | catch (exn){ 43 | didThrow = true; 44 | } 45 | if (didThrow !== false) { 46 | return ; 47 | } 48 | throw new Error(message); 49 | } 50 | 51 | function areSame(x, y) { 52 | return x.toString() === y.toString(); 53 | } 54 | 55 | assertTrue("fromArray", (function () { 56 | return areSame(Core__Option.getExn(new BigInt64Array([ 57 | num1, 58 | num2 59 | ])[1], undefined), num2); 60 | })); 61 | 62 | assertTrue("fromBuffer", (function () { 63 | var x = new BigInt64Array(new ArrayBuffer(16)); 64 | x[1] = num2; 65 | return areSame(Core__Option.getExn(x[1], undefined), num2); 66 | })); 67 | 68 | assertWillThrow("fromBuffer when too short can throw when used", (function () { 69 | var x = new BigInt64Array(new ArrayBuffer(1)); 70 | x[0] = num1; 71 | areSame(Core__Option.getExn(x[0], undefined), num1); 72 | })); 73 | 74 | assertTrue("fromBufferWithRange", (function () { 75 | var x = new BigInt64Array(new ArrayBuffer(16), 0, 1); 76 | x[0] = num1; 77 | return areSame(Core__Option.getExn(x[0], undefined), num1); 78 | })); 79 | 80 | assertWillThrow("fromBufferWithRange is unsafe, out of range", (function () { 81 | var x = new BigInt64Array(new ArrayBuffer(16), 13, 1); 82 | x[0] = num1; 83 | areSame(Core__Option.getExn(x[0], undefined), num1); 84 | })); 85 | 86 | assertTrue("fromLength is NOT in bytes", (function () { 87 | var x = new BigInt64Array(1); 88 | return x.byteLength === 8; 89 | })); 90 | 91 | function o(prim0, prim1) { 92 | return BigInt64Array.from(prim0, prim1); 93 | } 94 | 95 | export { 96 | eq , 97 | num1 , 98 | num2 , 99 | num3 , 100 | assertTrue , 101 | assertWillThrow , 102 | areSame , 103 | o , 104 | } 105 | /* Not a pure module */ 106 | -------------------------------------------------------------------------------- /test/TypedArrayTests.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | let eq = (a, b) => a == b 4 | 5 | // ===== BigInt64Array Tests ===== 6 | 7 | Test.run(__POS_OF__("bytes per element is 8"), BigInt64Array.Constants.bytesPerElement, eq, 8) 8 | 9 | let num1 = BigInt.fromString("123456789") 10 | let num2 = BigInt.fromString("987654321") 11 | let num3 = BigInt.fromString("555555555") 12 | 13 | let assertTrue = (message, predicate) => { 14 | try { 15 | if !predicate() { 16 | message->Error.make->Error.raise 17 | } 18 | } catch { 19 | | _ => message->Error.make->Error.raise 20 | } 21 | } 22 | 23 | let assertWillThrow = (message, f) => { 24 | let didThrow = ref(false) 25 | try { 26 | f() 27 | } catch { 28 | | _ => didThrow := true 29 | } 30 | if didThrow.contents == false { 31 | message->Error.make->Error.raise 32 | } 33 | } 34 | 35 | let areSame = (x: bigint, y: bigint) => BigInt.toString(x) == BigInt.toString(y) 36 | 37 | // What's going on here? 38 | // assertTrue("big ints if different then not equal", () => num1 != num2) 39 | // assertTrue("big ints if same then equal", () => num1 == num1) 40 | 41 | assertTrue("fromArray", () => 42 | [num1, num2]->BigInt64Array.fromArray->TypedArray.get(1)->Option.getExn->areSame(num2) 43 | ) 44 | 45 | assertTrue("fromBuffer", () => { 46 | let x = ArrayBuffer.make(16)->BigInt64Array.fromBuffer 47 | x->TypedArray.set(1, num2) 48 | x->TypedArray.get(1)->Option.getExn->areSame(num2) 49 | }) 50 | 51 | assertWillThrow("fromBuffer when too short can throw when used", () => { 52 | let x = ArrayBuffer.make(1)->BigInt64Array.fromBuffer 53 | x->TypedArray.set(0, num1) 54 | x->TypedArray.get(0)->Option.getExn->areSame(num1)->ignore 55 | }) 56 | 57 | assertTrue("fromBufferWithRange", () => { 58 | let x = ArrayBuffer.make(16)->BigInt64Array.fromBufferWithRange(~byteOffset=0, ~length=1) 59 | x->TypedArray.set(0, num1) 60 | x->TypedArray.get(0)->Option.getExn->areSame(num1) 61 | }) 62 | 63 | // assertWillThrow("testing", () => {"a"->Error.make->Error.raise}) 64 | // assertWillThrow("testing", () => {Console.log("f")}) 65 | 66 | assertWillThrow("fromBufferWithRange is unsafe, out of range", () => { 67 | let x = ArrayBuffer.make(16)->BigInt64Array.fromBufferWithRange(~byteOffset=13, ~length=1) 68 | x->TypedArray.set(0, num1) 69 | x->TypedArray.get(0)->Option.getExn->areSame(num1)->ignore 70 | }) 71 | 72 | assertTrue("fromLength is NOT in bytes", () => { 73 | let x = BigInt64Array.fromLength(1) 74 | TypedArray.byteLength(x) == 8 75 | }) 76 | let o = BigInt64Array.fromArrayLikeOrIterableWithMap 77 | -------------------------------------------------------------------------------- /test/intl/IntlTests.res: -------------------------------------------------------------------------------- 1 | include Intl__CollatorTest 2 | include Intl__DateTimeFormatTest 3 | include Intl__ListFormatTest 4 | include Intl__LocaleTest 5 | include Intl__NumberFormatTest 6 | include Intl__PluralRulesTest 7 | include Intl__RelativeTimeFormatTest 8 | include Intl__SegmenterTest 9 | 10 | open RescriptCore 11 | 12 | Console.log("---") 13 | Console.log("Intl") 14 | 15 | Intl.getCanonicalLocalesExn("EN-US")->Console.log 16 | Intl.getCanonicalLocalesManyExn(["EN-US", "Fr"])->Console.log 17 | 18 | try { 19 | Intl.getCanonicalLocalesExn("bloop")->Console.log 20 | } catch { 21 | | Exn.Error(e) => Console.error(e) 22 | } 23 | 24 | try { 25 | Intl.supportedValuesOfExn("calendar")->Console.log 26 | Intl.supportedValuesOfExn("collation")->Console.log 27 | Intl.supportedValuesOfExn("currency")->Console.log 28 | Intl.supportedValuesOfExn("numberingSystem")->Console.log 29 | Intl.supportedValuesOfExn("timeZone")->Console.log 30 | Intl.supportedValuesOfExn("unit")->Console.log 31 | } catch { 32 | | Exn.Error(e) => Console.error(e) 33 | } 34 | 35 | try { 36 | Intl.supportedValuesOfExn("someInvalidKey")->ignore 37 | 38 | Console.error("Shouldn't have been hit") 39 | } catch { 40 | | Exn.Error(e) => 41 | switch Error.message(e)->Option.map(String.toLowerCase) { 42 | | Some("invalid key : someinvalidkey") => Console.log("Caught expected error") 43 | | message => { 44 | Console.warn(`Unexpected error message: "${message->Option.getUnsafe}"`) 45 | Error.raise(e) 46 | } 47 | } 48 | | e => 49 | switch Error.fromException(e) { 50 | | Some(e) => Error.raise(e) 51 | | None => Console.error("Unexpected error") 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/intl/Intl__CollatorTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | console.log("---"); 5 | 6 | console.log("Intl.Collator"); 7 | 8 | new Intl.Collator(); 9 | 10 | new Intl.Collator(["en-US"]); 11 | 12 | var _collator = new Intl.Collator([ 13 | "en-US", 14 | "en-GB" 15 | ]); 16 | 17 | var collator = new Intl.Collator(["en-US"], { 18 | sensitivity: "base", 19 | ignorePunctuation: true, 20 | numeric: true, 21 | caseFirst: "upper" 22 | }); 23 | 24 | Intl.Collator.supportedLocalesOf([ 25 | "en-US", 26 | "en-GB" 27 | ]); 28 | 29 | Intl.Collator.supportedLocalesOf([ 30 | "en-US", 31 | "en-GB" 32 | ], { 33 | localeMatcher: "lookup" 34 | }); 35 | 36 | console.log(collator.resolvedOptions()); 37 | 38 | console.log(collator.compare("hi", "hï")); 39 | 40 | console.log(Intl.Collator.supportedLocalesOf(["hi"])); 41 | 42 | export { 43 | _collator , 44 | collator , 45 | } 46 | /* Not a pure module */ 47 | -------------------------------------------------------------------------------- /test/intl/Intl__CollatorTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.Collator") 5 | 6 | let _collator = Intl.Collator.make() 7 | let _collator = Intl.Collator.make(~locales=["en-US"]) 8 | let _collator = Intl.Collator.make(~locales=["en-US", "en-GB"]) 9 | let collator = Intl.Collator.make( 10 | ~locales=["en-US"], 11 | ~options={caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true}, 12 | ) 13 | Intl.Collator.supportedLocalesOf(["en-US", "en-GB"])->ignore 14 | Intl.Collator.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore 15 | 16 | collator->Intl.Collator.resolvedOptions->Console.log 17 | collator->Intl.Collator.compare("hi", "hï")->Console.log 18 | Intl.Collator.supportedLocalesOf(["hi"])->Console.log 19 | -------------------------------------------------------------------------------- /test/intl/Intl__DateTimeFormatTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; 4 | 5 | console.log("---"); 6 | 7 | console.log("Intl.DateTimeFormat"); 8 | 9 | Intl.DateTimeFormat.supportedLocalesOf([ 10 | "en-US", 11 | "en-GB" 12 | ]); 13 | 14 | Intl.DateTimeFormat.supportedLocalesOf([ 15 | "en-US", 16 | "en-GB" 17 | ], { 18 | localeMatcher: "lookup" 19 | }); 20 | 21 | var formatter = new Intl.DateTimeFormat(undefined, { 22 | dateStyle: "full", 23 | timeStyle: "full" 24 | }); 25 | 26 | console.log(formatter.format(new Date(Date.now()))); 27 | 28 | console.log(formatter.formatRange(new Date(2023, 1, 1), new Date(2023, 12, 31))); 29 | 30 | var options = { 31 | timeZone: "UTC", 32 | hour12: false, 33 | hourCycle: "h24", 34 | weekday: "narrow", 35 | era: "narrow", 36 | year: "2-digit", 37 | month: "2-digit", 38 | day: "2-digit", 39 | hour: "2-digit", 40 | minute: "2-digit", 41 | second: "2-digit", 42 | fractionalSecondDigits: 3, 43 | timeZoneName: "longGeneric" 44 | }; 45 | 46 | var formatter$1 = new Intl.DateTimeFormat(undefined, options); 47 | 48 | console.log(formatter$1.format(new Date(Date.now()))); 49 | 50 | var newrecord = Caml_obj.obj_dup(options); 51 | 52 | var formatter$2 = new Intl.DateTimeFormat(undefined, (newrecord.timeZoneName = "long", newrecord)); 53 | 54 | console.log(formatter$2.format(new Date(Date.now()))); 55 | 56 | var newrecord$1 = Caml_obj.obj_dup(options); 57 | 58 | var formatter$3 = new Intl.DateTimeFormat(undefined, (newrecord$1.timeZoneName = "longOffset", newrecord$1)); 59 | 60 | console.log(formatter$3.format(new Date(Date.now()))); 61 | 62 | var newrecord$2 = Caml_obj.obj_dup(options); 63 | 64 | var formatter$4 = new Intl.DateTimeFormat(undefined, (newrecord$2.timeZoneName = "short", newrecord$2)); 65 | 66 | console.log(formatter$4.format(new Date(Date.now()))); 67 | 68 | var newrecord$3 = Caml_obj.obj_dup(options); 69 | 70 | var formatter$5 = new Intl.DateTimeFormat(undefined, (newrecord$3.timeZoneName = "shortGeneric", newrecord$3)); 71 | 72 | console.log(formatter$5.format(new Date(Date.now()))); 73 | 74 | var newrecord$4 = Caml_obj.obj_dup(options); 75 | 76 | var formatter$6 = new Intl.DateTimeFormat(undefined, (newrecord$4.timeZoneName = "shortOffset", newrecord$4)); 77 | 78 | console.log(formatter$6.format(new Date(Date.now()))); 79 | 80 | var resolvedOptions = new Intl.DateTimeFormat().resolvedOptions(); 81 | 82 | var timeZone = resolvedOptions.timeZone; 83 | 84 | export { 85 | options , 86 | formatter$6 as formatter, 87 | resolvedOptions , 88 | timeZone , 89 | } 90 | /* Not a pure module */ 91 | -------------------------------------------------------------------------------- /test/intl/Intl__DateTimeFormatTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.DateTimeFormat") 5 | 6 | Intl.DateTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore 7 | Intl.DateTimeFormat.supportedLocalesOf( 8 | ["en-US", "en-GB"], 9 | ~options={localeMatcher: #lookup}, 10 | )->ignore 11 | 12 | let formatter = Intl.DateTimeFormat.make(~options={dateStyle: #full, timeStyle: #full}) 13 | 14 | Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) 15 | 16 | Console.log( 17 | formatter->Intl.DateTimeFormat.formatRange( 18 | ~startDate=Date.makeWithYMD(~year=2023, ~date=1, ~month=1), 19 | ~endDate=Date.makeWithYMD(~year=2023, ~date=31, ~month=12), 20 | ), 21 | ) 22 | 23 | let options: Intl.DateTimeFormat.options = { 24 | hour12: false, 25 | hourCycle: #h24, 26 | timeZone: "UTC", 27 | weekday: #narrow, 28 | era: #narrow, 29 | year: #"2-digit", 30 | month: #"2-digit", 31 | day: #"2-digit", 32 | hour: #"2-digit", 33 | minute: #"2-digit", 34 | second: #"2-digit", 35 | fractionalSecondDigits: #3, 36 | timeZoneName: #longGeneric, 37 | } 38 | let formatter = Intl.DateTimeFormat.make(~options) 39 | 40 | Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) 41 | 42 | let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #long}) 43 | Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) 44 | 45 | let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #longOffset}) 46 | Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) 47 | 48 | let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #short}) 49 | Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) 50 | 51 | let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #shortGeneric}) 52 | Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) 53 | 54 | let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #shortOffset}) 55 | Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) 56 | 57 | let resolvedOptions = Intl.DateTimeFormat.make()->Intl.DateTimeFormat.resolvedOptions 58 | let {Intl.DateTimeFormat.timeZone: timeZone, _} = resolvedOptions 59 | -------------------------------------------------------------------------------- /test/intl/Intl__ListFormatTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | console.log("---"); 5 | 6 | console.log("Intl.ListFormat"); 7 | 8 | new Intl.ListFormat(); 9 | 10 | new Intl.ListFormat([ 11 | "en-US", 12 | "en-GB" 13 | ]); 14 | 15 | var _formatter = new Intl.ListFormat([ 16 | "en-US", 17 | "en-GB" 18 | ], { 19 | type: "conjunction", 20 | style: "long" 21 | }); 22 | 23 | Intl.ListFormat.supportedLocalesOf([ 24 | "en-US", 25 | "en-GB" 26 | ]); 27 | 28 | Intl.ListFormat.supportedLocalesOf([ 29 | "en-US", 30 | "en-GB" 31 | ], { 32 | localeMatcher: "lookup" 33 | }); 34 | 35 | var formatter = new Intl.ListFormat(undefined, { 36 | type: "conjunction", 37 | style: "long" 38 | }); 39 | 40 | console.log(formatter.resolvedOptions()); 41 | 42 | console.log(formatter.format([ 43 | "one", 44 | "two", 45 | "three" 46 | ])); 47 | 48 | console.log(formatter.formatToParts([ 49 | "one", 50 | "two", 51 | "three" 52 | ])); 53 | 54 | export { 55 | _formatter , 56 | formatter , 57 | } 58 | /* Not a pure module */ 59 | -------------------------------------------------------------------------------- /test/intl/Intl__ListFormatTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.ListFormat") 5 | 6 | let _formatter = Intl.ListFormat.make() 7 | let _formatter = Intl.ListFormat.make(~locales=["en-US", "en-GB"]) 8 | let _formatter = Intl.ListFormat.make( 9 | ~locales=["en-US", "en-GB"], 10 | ~options={style: #long, \"type": #conjunction}, 11 | ) 12 | Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore 13 | Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore 14 | 15 | let formatter = Intl.ListFormat.make(~options={style: #long, \"type": #conjunction}) 16 | 17 | formatter->Intl.ListFormat.resolvedOptions->Console.log 18 | formatter->Intl.ListFormat.format(["one", "two", "three"])->Console.log 19 | formatter->Intl.ListFormat.formatToParts(["one", "two", "three"])->Console.log 20 | -------------------------------------------------------------------------------- /test/intl/Intl__LocaleTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | console.log("---"); 5 | 6 | console.log("Intl.Locale"); 7 | 8 | var _locale = new Intl.Locale("en-US"); 9 | 10 | var locale = new Intl.Locale("en-US", { 11 | calendar: "hebrew", 12 | collation: "compat", 13 | hourCycle: "h24", 14 | caseFirst: "upper", 15 | numeric: true 16 | }); 17 | 18 | console.log(locale.baseName); 19 | 20 | console.log(locale.calendar); 21 | 22 | console.log(locale.caseFirst); 23 | 24 | console.log(locale.collation); 25 | 26 | console.log(locale.hourCycle); 27 | 28 | console.log(locale.language); 29 | 30 | console.log(locale.numberingSystem); 31 | 32 | console.log(locale.numeric); 33 | 34 | console.log(locale.region); 35 | 36 | console.log(locale.script); 37 | 38 | console.log(locale.maximize()); 39 | 40 | console.log(locale.minimize()); 41 | 42 | export { 43 | _locale , 44 | locale , 45 | } 46 | /* Not a pure module */ 47 | -------------------------------------------------------------------------------- /test/intl/Intl__LocaleTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.Locale") 5 | 6 | let _locale = Intl.Locale.make("en-US") 7 | let locale = Intl.Locale.make( 8 | "en-US", 9 | ~options={ 10 | calendar: #hebrew, 11 | collation: #compat, 12 | hourCycle: #h24, 13 | caseFirst: #upper, 14 | numeric: true, 15 | }, 16 | ) 17 | 18 | locale->Intl.Locale.baseName->Console.log 19 | locale->Intl.Locale.calendar->Console.log 20 | locale->Intl.Locale.caseFirst->Console.log 21 | locale->Intl.Locale.collation->Console.log 22 | locale->Intl.Locale.hourCycle->Console.log 23 | locale->Intl.Locale.language->Console.log 24 | locale->Intl.Locale.numberingSystem->Console.log 25 | locale->Intl.Locale.numeric->Console.log 26 | locale->Intl.Locale.region->Console.log 27 | locale->Intl.Locale.script->Console.log 28 | locale->Intl.Locale.maximize->Console.log 29 | locale->Intl.Locale.minimize->Console.log 30 | -------------------------------------------------------------------------------- /test/intl/Intl__NumberFormatTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | import * as Caml_option from "rescript/lib/es6/caml_option.js"; 4 | import * as Core__Intl__NumberFormat__Grouping from "../../src/intl/Core__Intl__NumberFormat__Grouping.mjs"; 5 | 6 | console.log("---"); 7 | 8 | console.log("Intl.NumberFormat"); 9 | 10 | var currencyFormatter = new Intl.NumberFormat(["fr-FR"], { 11 | currency: "EUR", 12 | style: "currency" 13 | }); 14 | 15 | console.log(Intl.NumberFormat.supportedLocalesOf([ 16 | "fr-FR", 17 | "en-US" 18 | ])); 19 | 20 | console.log(currencyFormatter.format(123.23)); 21 | 22 | var roundingFormatter = new Intl.NumberFormat(undefined, { 23 | roundingIncrement: 500, 24 | minimumFractionDigits: 2, 25 | maximumFractionDigits: 2 26 | }); 27 | 28 | var groupingFormatter1 = new Intl.NumberFormat(undefined, { 29 | useGrouping: Caml_option.some(true) 30 | }); 31 | 32 | var groupingFormatter2 = new Intl.NumberFormat(undefined, { 33 | useGrouping: "auto" 34 | }); 35 | 36 | var sigFormatter = new Intl.NumberFormat(undefined, { 37 | minimumIntegerDigits: 1, 38 | minimumFractionDigits: 1, 39 | maximumFractionDigits: 1, 40 | minimumSignificantDigits: 1, 41 | maximumSignificantDigits: 1 42 | }); 43 | 44 | var options = sigFormatter.resolvedOptions(); 45 | 46 | console.log(options); 47 | 48 | console.log(Core__Intl__NumberFormat__Grouping.parseJsValue(options.useGrouping)); 49 | 50 | export { 51 | currencyFormatter , 52 | roundingFormatter , 53 | groupingFormatter1 , 54 | groupingFormatter2 , 55 | sigFormatter , 56 | options , 57 | } 58 | /* Not a pure module */ 59 | -------------------------------------------------------------------------------- /test/intl/Intl__NumberFormatTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.NumberFormat") 5 | 6 | let currencyFormatter = Intl.NumberFormat.make( 7 | ~locales=["fr-FR"], 8 | ~options={currency: "EUR", style: #currency}, 9 | ) 10 | 11 | Console.log(Intl.NumberFormat.supportedLocalesOf(["fr-FR", "en-US"])) 12 | Console.log(currencyFormatter->Intl.NumberFormat.format(123.23)) 13 | 14 | let roundingFormatter = Intl.NumberFormat.make( 15 | ~options={ 16 | roundingIncrement: #500, 17 | minimumFractionDigits: #2, 18 | maximumFractionDigits: #2, 19 | }, 20 | ) 21 | 22 | let groupingFormatter1 = Intl.NumberFormat.make( 23 | ~options={ 24 | useGrouping: Intl.NumberFormat.Grouping.fromBool(true), 25 | }, 26 | ) 27 | let groupingFormatter2 = Intl.NumberFormat.make( 28 | ~options={ 29 | useGrouping: Intl.NumberFormat.Grouping.fromString(#auto), 30 | }, 31 | ) 32 | 33 | let sigFormatter = Intl.NumberFormat.make( 34 | ~options={ 35 | minimumIntegerDigits: #1, 36 | minimumFractionDigits: #1, 37 | maximumFractionDigits: #1, 38 | minimumSignificantDigits: #1, 39 | maximumSignificantDigits: #1, 40 | }, 41 | ) 42 | 43 | let options = sigFormatter->Intl.NumberFormat.resolvedOptions 44 | Console.log(options) 45 | options.useGrouping->Core__Intl__NumberFormat.Grouping.parseJsValue->Console.log 46 | -------------------------------------------------------------------------------- /test/intl/Intl__PluralRulesTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | console.log("---"); 5 | 6 | console.log("Intl.PluralRules"); 7 | 8 | new Intl.PluralRules(); 9 | 10 | new Intl.PluralRules([ 11 | "en-US", 12 | "en-GB" 13 | ]); 14 | 15 | var _formatter = new Intl.PluralRules(undefined, { 16 | type: "ordinal", 17 | minimumSignificantDigits: 3, 18 | maximumSignificantDigits: 5 19 | }); 20 | 21 | var formatter = new Intl.PluralRules(["en-US"], { 22 | type: "ordinal", 23 | minimumSignificantDigits: 3, 24 | maximumSignificantDigits: 5 25 | }); 26 | 27 | console.log(formatter.resolvedOptions()); 28 | 29 | console.log(formatter.select(2.0)); 30 | 31 | console.log(formatter.select(2)); 32 | 33 | export { 34 | _formatter , 35 | formatter , 36 | } 37 | /* Not a pure module */ 38 | -------------------------------------------------------------------------------- /test/intl/Intl__PluralRulesTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.PluralRules") 5 | 6 | let _formatter = Intl.PluralRules.make() 7 | let _formatter = Intl.PluralRules.make(~locales=["en-US", "en-GB"]) 8 | let _formatter = Intl.PluralRules.make( 9 | ~options={ 10 | \"type": #ordinal, 11 | maximumSignificantDigits: #5, 12 | minimumSignificantDigits: #3, 13 | }, 14 | ) 15 | let formatter = Intl.PluralRules.make( 16 | ~locales=["en-US"], 17 | ~options={ 18 | \"type": #ordinal, 19 | maximumSignificantDigits: #5, 20 | minimumSignificantDigits: #3, 21 | }, 22 | ) 23 | 24 | formatter->Intl.PluralRules.resolvedOptions->Console.log 25 | 26 | formatter->Intl.PluralRules.select(2.0)->Console.log 27 | formatter->Intl.PluralRules.selectInt(2)->Console.log 28 | 29 | // doesn't appear to work in node v16 30 | // formatter->Intl.PluralRules.selectBigInt(BigInt.fromInt(2))->Console.log 31 | // formatter 32 | // ->Intl.PluralRules.selectRangeBigInt(~start=BigInt.fromInt(1), ~end=BigInt.fromInt(3)) 33 | // ->Console.log 34 | // formatter->Intl.PluralRules.selectRange(~start=1., ~end=3.)->Console.log 35 | // formatter->Intl.PluralRules.selectRangeInt(~start=1, ~end=3)->Console.log 36 | -------------------------------------------------------------------------------- /test/intl/Intl__RelativeTimeFormatTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | console.log("---"); 5 | 6 | console.log("Intl.RelativeTimeFormat"); 7 | 8 | Intl.RelativeTimeFormat.supportedLocalesOf([ 9 | "en-US", 10 | "en-GB" 11 | ]); 12 | 13 | Intl.RelativeTimeFormat.supportedLocalesOf([ 14 | "en-US", 15 | "en-GB" 16 | ], { 17 | localeMatcher: "lookup" 18 | }); 19 | 20 | new Intl.RelativeTimeFormat(); 21 | 22 | new Intl.RelativeTimeFormat([ 23 | "en-US", 24 | "en-GB" 25 | ]); 26 | 27 | var _formatter = new Intl.RelativeTimeFormat(undefined, { 28 | numeric: "always", 29 | style: "narrow" 30 | }); 31 | 32 | var formatter = new Intl.RelativeTimeFormat(["en-US"], { 33 | numeric: "always", 34 | style: "narrow" 35 | }); 36 | 37 | console.log(formatter.resolvedOptions()); 38 | 39 | console.log(formatter.format(3, "hour")); 40 | 41 | console.log(formatter.formatToParts(3, "hour")); 42 | 43 | export { 44 | _formatter , 45 | formatter , 46 | } 47 | /* Not a pure module */ 48 | -------------------------------------------------------------------------------- /test/intl/Intl__RelativeTimeFormatTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.RelativeTimeFormat") 5 | 6 | Intl.RelativeTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore 7 | Intl.RelativeTimeFormat.supportedLocalesOf( 8 | ["en-US", "en-GB"], 9 | ~options={localeMatcher: #lookup}, 10 | )->ignore 11 | 12 | let _formatter = Intl.RelativeTimeFormat.make() 13 | let _formatter = Intl.RelativeTimeFormat.make(~locales=["en-US", "en-GB"]) 14 | let _formatter = Intl.RelativeTimeFormat.make( 15 | ~options={ 16 | numeric: #always, 17 | style: #narrow, 18 | }, 19 | ) 20 | let formatter = Intl.RelativeTimeFormat.make( 21 | ~locales=["en-US"], 22 | ~options={ 23 | numeric: #always, 24 | style: #narrow, 25 | }, 26 | ) 27 | 28 | formatter->Intl.RelativeTimeFormat.resolvedOptions->Console.log 29 | 30 | formatter->Intl.RelativeTimeFormat.format(3, #hour)->Console.log 31 | formatter->Intl.RelativeTimeFormat.formatToParts(3, #hour)->Console.log 32 | -------------------------------------------------------------------------------- /test/intl/Intl__SegmenterTest.mjs: -------------------------------------------------------------------------------- 1 | // Generated by ReScript, PLEASE EDIT WITH CARE 2 | 3 | 4 | console.log("---"); 5 | 6 | console.log("Intl.Segmenter"); 7 | 8 | Intl.Segmenter.supportedLocalesOf([ 9 | "en-US", 10 | "en-GB" 11 | ]); 12 | 13 | Intl.Segmenter.supportedLocalesOf([ 14 | "en-US", 15 | "en-GB" 16 | ], { 17 | localeMatcher: "lookup" 18 | }); 19 | 20 | new Intl.Segmenter(); 21 | 22 | new Intl.Segmenter([ 23 | "en-US", 24 | "en-GB" 25 | ]); 26 | 27 | var _formatter = new Intl.Segmenter(undefined, { 28 | granularity: "word" 29 | }); 30 | 31 | var formatter = new Intl.Segmenter(["en-US"], { 32 | granularity: "word" 33 | }); 34 | 35 | console.log(formatter.resolvedOptions()); 36 | 37 | var segments = formatter.segment("This is a sentence with several words"); 38 | 39 | console.log(segments); 40 | 41 | console.log(segments.containing()); 42 | 43 | console.log(segments.containing(1)); 44 | 45 | export { 46 | _formatter , 47 | formatter , 48 | segments , 49 | } 50 | /* Not a pure module */ 51 | -------------------------------------------------------------------------------- /test/intl/Intl__SegmenterTest.res: -------------------------------------------------------------------------------- 1 | open RescriptCore 2 | 3 | Console.log("---") 4 | Console.log("Intl.Segmenter") 5 | 6 | Intl.Segmenter.supportedLocalesOf(["en-US", "en-GB"])->ignore 7 | Intl.Segmenter.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore 8 | 9 | let _formatter = Intl.Segmenter.make() 10 | let _formatter = Intl.Segmenter.make(~locales=["en-US", "en-GB"]) 11 | let _formatter = Intl.Segmenter.make( 12 | ~options={ 13 | granularity: #word, 14 | }, 15 | ) 16 | let formatter = Intl.Segmenter.make( 17 | ~locales=["en-US"], 18 | ~options={ 19 | granularity: #word, 20 | }, 21 | ) 22 | 23 | formatter->Intl.Segmenter.resolvedOptions->Console.log 24 | let segments = formatter->Intl.Segmenter.segment("This is a sentence with several words") 25 | 26 | Console.log(segments) 27 | 28 | Intl.Segments.containing(segments)->Console.log 29 | Intl.Segments.containingWithIndex(segments, 1)->Console.log 30 | --------------------------------------------------------------------------------