1
- // Values marked with @internal are not part of the public API and may change
2
- // without notice.
3
-
4
1
export class CustomType {
5
2
withFields ( fields ) {
6
3
let properties = Object . keys ( this ) . map ( ( label ) =>
@@ -27,21 +24,18 @@ export class List {
27
24
return [ ...this ] ;
28
25
}
29
26
30
- // @internal
31
27
atLeastLength ( desired ) {
32
28
let current = this ;
33
29
while ( desired -- > 0 && current ) current = current . tail ;
34
30
return current !== undefined ;
35
31
}
36
32
37
- // @internal
38
33
hasLength ( desired ) {
39
34
let current = this ;
40
35
while ( desired -- > 0 && current ) current = current . tail ;
41
36
return desired === - 1 && current instanceof Empty ;
42
37
}
43
38
44
- // @internal
45
39
countLength ( ) {
46
40
let current = this ;
47
41
let length = 0 ;
@@ -53,7 +47,6 @@ export class List {
53
47
}
54
48
}
55
49
56
- // @internal
57
50
export function prepend ( element , tail ) {
58
51
return new NonEmpty ( element , tail ) ;
59
52
}
@@ -62,7 +55,6 @@ export function toList(elements, tail) {
62
55
return List . fromArray ( elements , tail ) ;
63
56
}
64
57
65
- // @internal
66
58
class ListIterator {
67
59
#current;
68
60
@@ -81,15 +73,9 @@ class ListIterator {
81
73
}
82
74
}
83
75
84
- export class Empty extends List { }
85
-
86
- export function List$Empty ( ) {
87
- return new Empty ( ) ;
88
- }
89
-
90
- export function List$isEmpty ( value ) {
91
- return value instanceof Empty ;
92
- }
76
+ export class Empty extends List { }
77
+ export const List$Empty = ( ) => new Empty ( ) ;
78
+ export const List$isEmpty = ( value ) => value instanceof Empty ;
93
79
94
80
export class NonEmpty extends List {
95
81
constructor ( head , tail ) {
@@ -98,21 +84,11 @@ export class NonEmpty extends List {
98
84
this . tail = tail ;
99
85
}
100
86
}
87
+ export const List$NonEmpty = ( head , tail ) => new NonEmpty ( head , tail ) ;
88
+ export const List$isNonEmpty = ( value ) => value instanceof NonEmpty ;
101
89
102
- export function List$NonEmpty ( head , tail ) {
103
- return new NonEmpty ( head , tail ) ;
104
- }
105
-
106
- export function List$isNonEmpty ( value ) {
107
- return value instanceof NonEmpty ;
108
- }
109
-
110
- export function List$NonEmpty$first ( value ) {
111
- return value . head ;
112
- }
113
- export function List$NonEmpty$rest ( value ) {
114
- return value . tail ;
115
- }
90
+ export const List$NonEmpty$first = ( value ) => value . head ;
91
+ export const List$NonEmpty$rest = ( value ) => value . tail ;
116
92
117
93
/**
118
94
* A bit array is a contiguous sequence of bits similar to Erlang's Binary type.
@@ -220,7 +196,6 @@ export class BitArray {
220
196
return bitArrayByteAt ( this . rawBuffer , this . bitOffset , index ) ;
221
197
}
222
198
223
- /** @internal */
224
199
equals ( other ) {
225
200
if ( this . bitSize !== other . bitSize ) {
226
201
return false ;
@@ -329,13 +304,8 @@ export class BitArray {
329
304
}
330
305
}
331
306
332
- export function BitArray$BitArray ( buffer , bitSize , bitOffset ) {
333
- return new BitArray ( buffer , bitSize , bitOffset ) ;
334
- }
335
-
336
- export function BitArray$isBitArray ( value ) {
337
- return value instanceof BitArray ;
338
- }
307
+ export const BitArray$BitArray = ( buffer , bitSize , bitOffset ) =>
308
+ new BitArray ( buffer , bitSize , bitOffset ) ;
339
309
340
310
/**
341
311
* Returns the nth byte in the given buffer, after applying the specified bit
@@ -363,18 +333,6 @@ export class UtfCodepoint {
363
333
}
364
334
}
365
335
366
- export function UtfCodepoint$UtfCodepoint ( value ) {
367
- return new UtfCodepoint ( value ) ;
368
- }
369
-
370
- export function UtfCodepoint$isUtfCodepoint ( value ) {
371
- return value instanceof UtfCodepoint ;
372
- }
373
-
374
- export function UtfCodepoint$UtfCodepoint$value ( value ) {
375
- return value . value ;
376
- }
377
-
378
336
const isBitArrayDeprecationMessagePrinted = { } ;
379
337
function bitArrayPrintDeprecationWarning ( name , message ) {
380
338
if ( isBitArrayDeprecationMessagePrinted [ name ] ) {
@@ -389,8 +347,6 @@ function bitArrayPrintDeprecationWarning(name, message) {
389
347
}
390
348
391
349
/**
392
- * @internal
393
- *
394
350
* Slices a bit array to produce a new bit array. If `end` is not supplied then
395
351
* all bits from `start` onward are returned.
396
352
*
@@ -599,8 +555,6 @@ export function bitArraySliceToInt(
599
555
}
600
556
601
557
/**
602
- * @internal
603
- *
604
558
* Joins the given segments into a new bit array, tightly packing them together.
605
559
* Each segment must be one of the following types:
606
560
*
@@ -635,7 +589,7 @@ export function toBitArray(segments) {
635
589
return new BitArray ( segment ) ;
636
590
}
637
591
638
- return new BitArray ( new Uint8Array ( /** @type {number[] } */ ( segments ) ) ) ;
592
+ return new BitArray ( new Uint8Array ( /** @type {number[] } */ ( segments ) ) ) ;
639
593
}
640
594
641
595
// Count the total number of bits and check if all segments are numbers, i.e.
@@ -657,7 +611,7 @@ export function toBitArray(segments) {
657
611
// If all segments are numbers then pass the segments array directly to the
658
612
// Uint8Array constructor
659
613
if ( areAllSegmentsNumbers ) {
660
- return new BitArray ( new Uint8Array ( /** @type {number[] } */ ( segments ) ) ) ;
614
+ return new BitArray ( new Uint8Array ( /** @type {number[] } */ ( segments ) ) ) ;
661
615
}
662
616
663
617
// Pack the segments into a Uint8Array
@@ -755,8 +709,6 @@ export function toBitArray(segments) {
755
709
}
756
710
757
711
/**
758
- * @internal
759
- *
760
712
* Encodes a floating point value into a `Uint8Array`. This is used to create
761
713
* float segments that are part of bit array expressions.
762
714
*
@@ -789,8 +741,6 @@ export function sizedFloat(value, size, isBigEndian) {
789
741
}
790
742
791
743
/**
792
- * @internal
793
- *
794
744
* Encodes an integer value into a `Uint8Array`, or a `BitArray` if the size in
795
745
* bits is not a multiple of 8. This is used to create integer segments used in
796
746
* bit array expressions.
@@ -1155,8 +1105,6 @@ function intFromUnalignedSliceUsingNumber(
1155
1105
}
1156
1106
1157
1107
/**
1158
- * @internal
1159
- *
1160
1108
* Reads an unaligned slice of any size as an integer. Uses the JavaScript
1161
1109
* `BigInt` type internally.
1162
1110
*
@@ -1380,8 +1328,6 @@ function bitArrayValidateRange(bitArray, start, end) {
1380
1328
let utf8Encoder ;
1381
1329
1382
1330
/**
1383
- * @internal
1384
- *
1385
1331
* Returns the UTF-8 bytes for a string.
1386
1332
*
1387
1333
* @param {string } string
@@ -1393,8 +1339,6 @@ export function stringBits(string) {
1393
1339
}
1394
1340
1395
1341
/**
1396
- * @internal
1397
- *
1398
1342
* Returns the UTF-8 bytes for a single UTF codepoint.
1399
1343
*
1400
1344
* @param {UtfCodepoint } codepoint
@@ -1405,8 +1349,6 @@ export function codepointBits(codepoint) {
1405
1349
}
1406
1350
1407
1351
/**
1408
- * @internal
1409
- *
1410
1352
* Returns the UTF-16 bytes for a string.
1411
1353
*
1412
1354
* @param {string } string
@@ -1425,8 +1367,6 @@ export function stringToUtf16(string, isBigEndian) {
1425
1367
}
1426
1368
1427
1369
/**
1428
- * @internal
1429
- *
1430
1370
* Returns the UTF-16 bytes for a single UTF codepoint.
1431
1371
*
1432
1372
* @param {UtfCodepoint } codepoint
@@ -1438,8 +1378,6 @@ export function codepointToUtf16(codepoint, isBigEndian) {
1438
1378
}
1439
1379
1440
1380
/**
1441
- * @internal
1442
- *
1443
1381
* Returns the UTF-32 bytes for a string.
1444
1382
*
1445
1383
* @param {string } string
@@ -1466,8 +1404,6 @@ export function stringToUtf32(string, isBigEndian) {
1466
1404
}
1467
1405
1468
1406
/**
1469
- * @internal
1470
- *
1471
1407
* Returns the UTF-32 bytes for a single UTF codepoint.
1472
1408
*
1473
1409
* @param {UtfCodepoint } codepoint
@@ -1479,7 +1415,6 @@ export function codepointToUtf32(codepoint, isBigEndian) {
1479
1415
}
1480
1416
1481
1417
export class Result extends CustomType {
1482
- // @internal
1483
1418
static isResult ( data ) {
1484
1419
return data instanceof Result ;
1485
1420
}
@@ -1491,47 +1426,27 @@ export class Ok extends Result {
1491
1426
this [ 0 ] = value ;
1492
1427
}
1493
1428
1494
- // @internal
1495
1429
isOk ( ) {
1496
1430
return true ;
1497
1431
}
1498
1432
}
1499
-
1500
- export function Result$Ok ( value ) {
1501
- return new Ok ( value ) ;
1502
- }
1503
-
1504
- export function Result$isOk ( value ) {
1505
- return value instanceof Ok ;
1506
- }
1507
-
1508
- export function Result$Ok$0 ( value ) {
1509
- return value [ 0 ] ;
1510
- }
1433
+ export const Result$Ok = ( value ) => new Ok ( value ) ;
1434
+ export const Result$isOk = ( value ) => value instanceof Ok ;
1435
+ export const Result$Ok$0 = ( value ) => value [ 0 ] ;
1511
1436
1512
1437
export class Error extends Result {
1513
1438
constructor ( detail ) {
1514
1439
super ( ) ;
1515
1440
this [ 0 ] = detail ;
1516
1441
}
1517
1442
1518
- // @internal
1519
1443
isOk ( ) {
1520
1444
return false ;
1521
1445
}
1522
1446
}
1523
-
1524
- export function Result$Error ( detail ) {
1525
- return new Error ( detail ) ;
1526
- }
1527
-
1528
- export function Result$isError ( value ) {
1529
- return value instanceof Error ;
1530
- }
1531
-
1532
- export function Result$Error$0 ( value ) {
1533
- return value [ 0 ] ;
1534
- }
1447
+ export const Result$Error = ( detail ) => new Error ( detail ) ;
1448
+ export const Result$isError = ( value ) => value instanceof Error ;
1449
+ export const Result$Error$0 = ( value ) => value [ 0 ] ;
1535
1450
1536
1451
export function isEqual ( x , y ) {
1537
1452
let values = [ x , y ] ;
@@ -1557,7 +1472,7 @@ export function isEqual(x, y) {
1557
1472
try {
1558
1473
if ( a . equals ( b ) ) continue ;
1559
1474
else return false ;
1560
- } catch { }
1475
+ } catch { }
1561
1476
}
1562
1477
1563
1478
let [ keys , get ] = getters ( a ) ;
@@ -1626,7 +1541,6 @@ function structurallyCompatibleObjects(a, b) {
1626
1541
return a . constructor === b . constructor ;
1627
1542
}
1628
1543
1629
- // @internal
1630
1544
export function remainderInt ( a , b ) {
1631
1545
if ( b === 0 ) {
1632
1546
return 0 ;
@@ -1635,12 +1549,10 @@ export function remainderInt(a, b) {
1635
1549
}
1636
1550
}
1637
1551
1638
- // @internal
1639
1552
export function divideInt ( a , b ) {
1640
1553
return Math . trunc ( divideFloat ( a , b ) ) ;
1641
1554
}
1642
1555
1643
- // @internal
1644
1556
export function divideFloat ( a , b ) {
1645
1557
if ( b === 0 ) {
1646
1558
return 0 ;
@@ -1649,7 +1561,6 @@ export function divideFloat(a, b) {
1649
1561
}
1650
1562
}
1651
1563
1652
- // @internal
1653
1564
export function makeError ( variant , file , module , line , fn , message , extra ) {
1654
1565
let error = new globalThis . Error ( message ) ;
1655
1566
error . gleam_error = variant ;
0 commit comments