@@ -9,6 +9,9 @@ import gleam/dict
9
9
/// into Gleam data with known types. You will likely mostly use the other
10
10
/// module in your projects.
11
11
///
12
+ /// The exact runtime representation of dynamic values will depend on the
13
+ /// compilation target used.
14
+ ///
12
15
pub type Dynamic
13
16
14
17
/// Return a string indicating the type of the dynamic value.
@@ -32,31 +35,39 @@ pub fn classify(data: Dynamic) -> String
32
35
pub fn from ( a : anything) -> Dynamic
33
36
34
37
/// Create a dynamic value from a bool.
38
+ ///
35
39
@ external ( erlang , "gleam_stdlib" , "identity" )
36
40
@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
37
41
pub fn bool ( a : Bool ) -> Dynamic
38
42
39
43
/// Create a dynamic value from a string.
44
+ ///
45
+ /// On Erlang this will be a binary string rather than a character list.
46
+ ///
40
47
@ external ( erlang , "gleam_stdlib" , "identity" )
41
48
@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
42
49
pub fn string ( a : String ) -> Dynamic
43
50
44
51
/// Create a dynamic value from a float.
52
+ ///
45
53
@ external ( erlang , "gleam_stdlib" , "identity" )
46
54
@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
47
55
pub fn float ( a : Float ) -> Dynamic
48
56
49
57
/// Create a dynamic value from an int.
58
+ ///
50
59
@ external ( erlang , "gleam_stdlib" , "identity" )
51
60
@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
52
61
pub fn int ( a : Int ) -> Dynamic
53
62
54
63
/// Create a dynamic value from a bit array.
64
+ ///
55
65
@ external ( erlang , "gleam_stdlib" , "identity" )
56
66
@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
57
67
pub fn bit_array ( a : BitArray ) -> Dynamic
58
68
59
69
/// Create a dynamic value from a list.
70
+ ///
60
71
@ external ( erlang , "gleam_stdlib" , "identity" )
61
72
@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
62
73
pub fn list ( a : List ( Dynamic ) ) -> Dynamic
@@ -72,12 +83,19 @@ pub fn array(a: List(Dynamic)) -> Dynamic
72
83
73
84
/// Create a dynamic value made an unordered series of keys and values, where
74
85
/// the keys are unique.
75
- pub fn object ( entries : List ( # ( Dynamic , Dynamic ) ) ) -> Dynamic {
86
+ ///
87
+ /// On Erlang this will be a map, on JavaScript this wil be a Gleam dict object.
88
+ ///
89
+ pub fn properties ( entries : List ( # ( Dynamic , Dynamic ) ) ) -> Dynamic {
76
90
cast ( dict . from_list ( entries ) )
77
91
}
78
92
79
93
/// A dynamic value representing nothing.
80
- pub fn null ( ) -> Dynamic {
94
+ ///
95
+ /// On Erlang this will be the atom `nil`, on JavaScript this wil be
96
+ /// `undefined`.
97
+ ///
98
+ pub fn nil ( ) -> Dynamic {
81
99
cast ( Nil )
82
100
}
83
101
0 commit comments