|
| 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: Js_types.window = "window" |
| 48 | +@val external document: Js_types.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 | +type t<'a> = Js.t<'a> |
| 98 | +// TODO |
| 99 | +// module MapperRt = Js.MapperRt |
| 100 | +// module Internal = Js.Internal |
| 101 | +module Re = Core__RegExp // needed for the %re sugar |
| 102 | +// TODO |
| 103 | +// module Exn = Js.Exn |
| 104 | +module Option = Core__Option |
| 105 | +module List = Core__List |
| 106 | +module Result = Core__Result |
| 107 | + |
| 108 | +type null<+'a> = Js_types.null<'a> |
| 109 | + |
| 110 | +type undefined<+'a> = Js_types.undefined<'a> |
| 111 | + |
| 112 | +type nullable<+'a> = Js_types.nullable<'a> |
| 113 | + |
| 114 | +let panic = Core__Error.panic |
0 commit comments