Skip to content

Commit b5535d1

Browse files
committed
Flip/flop
1 parent 353bc1c commit b5535d1

15 files changed

+80
-79
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- The `function` module gains the `constant` function.
6+
- The internal `gleam_stdlib.js` module has been renamed to `gleam_stdlib.mjs`.
67

78
## v0.18.0 - 2021-11-23
89
## v0.18.0-rc1 - 2021-11-23

bin/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ set -eu
33
OUT=gen/javascript
44
rm -fr $OUT
55
gleam compile-package --name gleam_stdlib --target javascript --src src --test test --out $OUT
6-
cp src/*.js $OUT/
6+
cp src/*.*js $OUT/
77
node bin/run-tests.js

src/gleam/base.gleam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if erlang {
1818

1919
if javascript {
2020
external fn do_encode64(BitString) -> String =
21-
"../gleam_stdlib.js" "encode64"
21+
"../gleam_stdlib.mjs" "encode64"
2222
}
2323

2424
/// Decodes a base 64 encoded string into a `BitString`.
@@ -38,7 +38,7 @@ if erlang {
3838

3939
if javascript {
4040
external fn do_decode64(String) -> Result(BitString, Nil) =
41-
"../gleam_stdlib.js" "decode64"
41+
"../gleam_stdlib.mjs" "decode64"
4242
}
4343

4444
/// Encodes a `BitString` into a base 64 encoded string with URL and filename safe alphabet.

src/gleam/bit_string.gleam

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if erlang {
1515

1616
if javascript {
1717
external fn do_from_string(String) -> BitString =
18-
"../gleam_stdlib.js" "bit_string_from_string"
18+
"../gleam_stdlib.mjs" "bit_string_from_string"
1919
}
2020

2121
/// Returns an integer which is the number of bytes in the bit string.
@@ -31,7 +31,7 @@ if erlang {
3131

3232
if javascript {
3333
external fn do_byte_size(BitString) -> Int =
34-
"../gleam_stdlib.js" "length"
34+
"../gleam_stdlib.mjs" "length"
3535
}
3636

3737
/// Creates a new bit string by joining two binaries.
@@ -76,7 +76,7 @@ if javascript {
7676
position: Int,
7777
length: Int,
7878
) -> Result(BitString, Nil) =
79-
"../gleam_stdlib.js" "bit_string_slice"
79+
"../gleam_stdlib.mjs" "bit_string_slice"
8080
}
8181

8282
/// Tests to see whether a bit string is valid UTF-8.
@@ -126,7 +126,7 @@ if erlang {
126126

127127
if javascript {
128128
external fn do_to_string(BitString) -> Result(String, Nil) =
129-
"../gleam_stdlib.js" "bit_string_to_string"
129+
"../gleam_stdlib.mjs" "bit_string_to_string"
130130
}
131131

132132
/// Creates a new bit string by joining multiple binaries.
@@ -147,5 +147,5 @@ if erlang {
147147

148148
if javascript {
149149
external fn do_concat(List(BitString)) -> BitString =
150-
"../gleam_stdlib.js" "bit_string_concat"
150+
"../gleam_stdlib.mjs" "bit_string_concat"
151151
}

src/gleam/dynamic.gleam

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if erlang {
3434

3535
if javascript {
3636
external fn do_from(anything) -> Dynamic =
37-
"../gleam_stdlib.js" "identity"
37+
"../gleam_stdlib.mjs" "identity"
3838
}
3939

4040
/// Unsafely casts a Dynamic value into any other type.
@@ -55,7 +55,7 @@ if erlang {
5555

5656
if javascript {
5757
external fn do_unsafe_coerce(Dynamic) -> a =
58-
"../gleam_stdlib.js" "identity"
58+
"../gleam_stdlib.mjs" "identity"
5959
}
6060

6161
/// Checks to see whether a `Dynamic` value is a bit_string, and returns that bit string if
@@ -80,7 +80,7 @@ if erlang {
8080

8181
if javascript {
8282
external fn decode_bit_string(Dynamic) -> Result(BitString, DecodeError) =
83-
"../gleam_stdlib.js" "decode_bit_string"
83+
"../gleam_stdlib.mjs" "decode_bit_string"
8484
}
8585

8686
/// Checks to see whether a `Dynamic` value is a string, and returns that string if
@@ -113,7 +113,7 @@ if erlang {
113113

114114
if javascript {
115115
external fn decode_string(Dynamic) -> Result(String, DecodeError) =
116-
"../gleam_stdlib.js" "decode_string"
116+
"../gleam_stdlib.mjs" "decode_string"
117117
}
118118

119119
/// Return a string indicating the type of the dynamic value.
@@ -134,7 +134,7 @@ if erlang {
134134

135135
if javascript {
136136
external fn do_classify(Dynamic) -> String =
137-
"../gleam_stdlib.js" "classify_dynamic"
137+
"../gleam_stdlib.mjs" "classify_dynamic"
138138
}
139139

140140
/// Checks to see whether a `Dynamic` value is an int, and returns that int if it
@@ -159,7 +159,7 @@ if erlang {
159159

160160
if javascript {
161161
external fn decode_int(Dynamic) -> Result(Int, DecodeError) =
162-
"../gleam_stdlib.js" "decode_int"
162+
"../gleam_stdlib.mjs" "decode_int"
163163
}
164164

165165
/// Checks to see whether a `Dynamic` value is a float, and returns that float if
@@ -184,7 +184,7 @@ if erlang {
184184

185185
if javascript {
186186
external fn decode_float(Dynamic) -> Result(Float, DecodeError) =
187-
"../gleam_stdlib.js" "decode_float"
187+
"../gleam_stdlib.mjs" "decode_float"
188188
}
189189

190190
/// Checks to see whether a `Dynamic` value is a bool, and returns that bool if
@@ -209,7 +209,7 @@ if erlang {
209209

210210
if javascript {
211211
external fn decode_bool(Dynamic) -> Result(Bool, DecodeError) =
212-
"../gleam_stdlib.js" "decode_bool"
212+
"../gleam_stdlib.mjs" "decode_bool"
213213
}
214214

215215
/// Checks to see whether a `Dynamic` value is a list, and returns that list if it
@@ -237,7 +237,7 @@ if erlang {
237237

238238
if javascript {
239239
external fn decode_list(Dynamic) -> Result(List(Dynamic), DecodeError) =
240-
"../gleam_stdlib.js" "decode_list"
240+
"../gleam_stdlib.mjs" "decode_list"
241241
}
242242

243243
/// Checks to see whether a `Dynamic` value is a result, and returns that result if
@@ -267,7 +267,7 @@ if erlang {
267267

268268
if javascript {
269269
external fn decode_result(Dynamic) -> Result(Result(a, e), DecodeError) =
270-
"../gleam_stdlib.js" "decode_result"
270+
"../gleam_stdlib.mjs" "decode_result"
271271
}
272272

273273
/// Checks to see whether a `Dynamic` value is a result of a particular type, and
@@ -379,7 +379,7 @@ if javascript {
379379
Dynamic,
380380
Decoder(a),
381381
) -> Result(Option(a), DecodeError) =
382-
"../gleam_stdlib.js" "decode_option"
382+
"../gleam_stdlib.mjs" "decode_option"
383383
}
384384

385385
/// Checks to see if a `Dynamic` value is a map with a specific field, and returns
@@ -407,7 +407,7 @@ if erlang {
407407

408408
if javascript {
409409
external fn decode_field(Dynamic, name) -> Result(Dynamic, DecodeError) =
410-
"../gleam_stdlib.js" "decode_field"
410+
"../gleam_stdlib.mjs" "decode_field"
411411
}
412412

413413
/// Checks to see if a `Dynamic` value is a tuple large enough to have a certain
@@ -487,13 +487,13 @@ if erlang {
487487

488488
if javascript {
489489
external fn decode_tuple(Dynamic) -> Result(UnknownTuple, DecodeError) =
490-
"../gleam_stdlib.js" "decode_tuple"
490+
"../gleam_stdlib.mjs" "decode_tuple"
491491

492492
external fn tuple_get(UnknownTuple, Int) -> Result(Dynamic, DecodeError) =
493-
"../gleam_stdlib.js" "tuple_get"
493+
"../gleam_stdlib.mjs" "tuple_get"
494494

495495
external fn tuple_size(UnknownTuple) -> Int =
496-
"../gleam_stdlib.js" "length"
496+
"../gleam_stdlib.mjs" "length"
497497
}
498498

499499
/// Checks to see if a `Dynamic` value is a 2-element tuple.
@@ -840,7 +840,7 @@ if erlang {
840840

841841
if javascript {
842842
external fn decode_map(Dynamic) -> Result(Map(Dynamic, Dynamic), DecodeError) =
843-
"../gleam_stdlib.js" "decode_map"
843+
"../gleam_stdlib.mjs" "decode_map"
844844
}
845845

846846
if erlang {

src/gleam/float.gleam

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if erlang {
2222

2323
if javascript {
2424
external fn do_parse(String) -> Result(Float, Nil) =
25-
"../gleam_stdlib.js" "parse_float"
25+
"../gleam_stdlib.mjs" "parse_float"
2626
}
2727

2828
/// Returns the string representation of the provided `Float`.
@@ -115,7 +115,7 @@ if erlang {
115115

116116
if javascript {
117117
external fn do_ceiling(Float) -> Float =
118-
"../gleam_stdlib.js" "ceiling"
118+
"../gleam_stdlib.mjs" "ceiling"
119119
}
120120

121121
/// Rounds the value to the next lowest whole number as a `Float`.
@@ -136,7 +136,7 @@ if erlang {
136136

137137
if javascript {
138138
external fn do_floor(Float) -> Float =
139-
"../gleam_stdlib.js" "floor"
139+
"../gleam_stdlib.mjs" "floor"
140140
}
141141

142142
/// Rounds the value to the nearest whole number as an `Int`.
@@ -167,7 +167,7 @@ if javascript {
167167
}
168168

169169
external fn js_round(Float) -> Int =
170-
"../gleam_stdlib.js" "round"
170+
"../gleam_stdlib.mjs" "round"
171171
}
172172

173173
/// Returns the value as an `Int`, truncating all decimal digits.
@@ -188,7 +188,7 @@ if erlang {
188188

189189
if javascript {
190190
external fn do_truncate(Float) -> Int =
191-
"../gleam_stdlib.js" "truncate"
191+
"../gleam_stdlib.mjs" "truncate"
192192
}
193193

194194
/// Returns the absolute value of the input as a `Float`.
@@ -230,7 +230,7 @@ if erlang {
230230

231231
if javascript {
232232
external fn do_power(Float, Float) -> Float =
233-
"../gleam_stdlib.js" "power"
233+
"../gleam_stdlib.mjs" "power"
234234
}
235235

236236
/// Returns the square root of the input as a `Float`.

src/gleam/int.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if erlang {
3838

3939
if javascript {
4040
external fn do_parse(String) -> Result(Int, Nil) =
41-
"../gleam_stdlib.js" "parse_int"
41+
"../gleam_stdlib.mjs" "parse_int"
4242
}
4343

4444
/// Prints a given int to a string.
@@ -59,7 +59,7 @@ if erlang {
5959

6060
if javascript {
6161
external fn do_to_string(Int) -> String =
62-
"../gleam_stdlib.js" "to_string"
62+
"../gleam_stdlib.mjs" "to_string"
6363
}
6464

6565
/// For use in `to_base_string` when base is outside of the allowed range.
@@ -102,7 +102,7 @@ if erlang {
102102

103103
if javascript {
104104
external fn do_to_base_string(Int, Int) -> String =
105-
"../gleam_stdlib.js" "int_to_base_string"
105+
"../gleam_stdlib.mjs" "int_to_base_string"
106106
}
107107

108108
/// Prints a given int to a string using base2.
@@ -173,7 +173,7 @@ if erlang {
173173

174174
if javascript {
175175
external fn do_to_float(a: Int) -> Float =
176-
"../gleam_stdlib.js" "identity"
176+
"../gleam_stdlib.mjs" "identity"
177177
}
178178

179179
/// Restricts an int between a lower and upper bound.

src/gleam/io.gleam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if erlang {
2323

2424
if javascript {
2525
external fn do_print(String) -> Nil =
26-
"../gleam_stdlib.js" "print"
26+
"../gleam_stdlib.mjs" "print"
2727
}
2828

2929
/// Writes a string to standard output, appending a newline to the end.
@@ -47,7 +47,7 @@ if erlang {
4747

4848
if javascript {
4949
external fn do_println(String) -> Nil =
50-
"../gleam_stdlib.js" "log"
50+
"../gleam_stdlib.mjs" "log"
5151
}
5252

5353
/// Prints a value to standard output using Erlang syntax.
@@ -85,7 +85,7 @@ if erlang {
8585

8686
if javascript {
8787
external fn debug_print(anything) -> Nil =
88-
"../gleam_stdlib.js" "debug"
88+
"../gleam_stdlib.mjs" "debug"
8989
}
9090

9191
if erlang {

src/gleam/map.gleam

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if erlang {
4242

4343
if javascript {
4444
external fn do_size(Map(k, v)) -> Int =
45-
"../gleam_stdlib.js" "map_size"
45+
"../gleam_stdlib.mjs" "map_size"
4646
}
4747

4848
/// Converts the map to a list of 2-element tuples `#(key, value)`, one for
@@ -69,7 +69,7 @@ if erlang {
6969

7070
if javascript {
7171
external fn do_to_list(Map(key, value)) -> List(#(key, value)) =
72-
"../gleam_stdlib.js" "map_to_list"
72+
"../gleam_stdlib.mjs" "map_to_list"
7373
}
7474

7575
/// Converts a list of 2-element tuples `#(key, value)` to a map.
@@ -130,7 +130,7 @@ if erlang {
130130

131131
if javascript {
132132
external fn do_new() -> Map(key, value) =
133-
"../gleam_stdlib.js" "new_map"
133+
"../gleam_stdlib.mjs" "new_map"
134134
}
135135

136136
/// Fetches a value from a map for a given key.
@@ -157,7 +157,7 @@ if erlang {
157157

158158
if javascript {
159159
external fn do_get(Map(key, value), key) -> Result(value, Nil) =
160-
"../gleam_stdlib.js" "map_get"
160+
"../gleam_stdlib.mjs" "map_get"
161161
}
162162

163163
/// Inserts a value into the map with the given key.
@@ -184,7 +184,7 @@ if erlang {
184184

185185
if javascript {
186186
external fn do_insert(key, value, Map(key, value)) -> Map(key, value) =
187-
"../gleam_stdlib.js" "map_insert"
187+
"../gleam_stdlib.mjs" "map_insert"
188188
}
189189

190190
/// Updates all values in a given map by calling a given function on each key
@@ -401,7 +401,7 @@ if erlang {
401401

402402
if javascript {
403403
external fn do_delete(k, Map(k, v)) -> Map(k, v) =
404-
"../gleam_stdlib.js" "map_remove"
404+
"../gleam_stdlib.mjs" "map_remove"
405405
}
406406

407407
/// Creates a new map from a given map with all the same entries except any with

0 commit comments

Comments
 (0)