@@ -9,6 +9,9 @@ import gleam/dict
99/// into Gleam data with known types. You will likely mostly use the other
1010/// module in your projects.
1111///
12+ /// The exact runtime representation of dynamic values will depend on the
13+ /// compilation target used.
14+ ///
1215pub type Dynamic
1316
1417/// Return a string indicating the type of the dynamic value.
@@ -32,31 +35,39 @@ pub fn classify(data: Dynamic) -> String
3235pub fn from ( a : anything) -> Dynamic
3336
3437/// Create a dynamic value from a bool.
38+ ///
3539@ external ( erlang , "gleam_stdlib" , "identity" )
3640@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
3741pub fn bool ( a : Bool ) -> Dynamic
3842
3943/// Create a dynamic value from a string.
44+ ///
45+ /// On Erlang this will be a binary string rather than a character list.
46+ ///
4047@ external ( erlang , "gleam_stdlib" , "identity" )
4148@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
4249pub fn string ( a : String ) -> Dynamic
4350
4451/// Create a dynamic value from a float.
52+ ///
4553@ external ( erlang , "gleam_stdlib" , "identity" )
4654@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
4755pub fn float ( a : Float ) -> Dynamic
4856
4957/// Create a dynamic value from an int.
58+ ///
5059@ external ( erlang , "gleam_stdlib" , "identity" )
5160@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
5261pub fn int ( a : Int ) -> Dynamic
5362
5463/// Create a dynamic value from a bit array.
64+ ///
5565@ external ( erlang , "gleam_stdlib" , "identity" )
5666@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
5767pub fn bit_array ( a : BitArray ) -> Dynamic
5868
5969/// Create a dynamic value from a list.
70+ ///
6071@ external ( erlang , "gleam_stdlib" , "identity" )
6172@ external ( javascript , "../gleam_stdlib.mjs" , "identity" )
6273pub fn list ( a : List ( Dynamic ) ) -> Dynamic
@@ -72,12 +83,19 @@ pub fn array(a: List(Dynamic)) -> Dynamic
7283
7384/// Create a dynamic value made an unordered series of keys and values, where
7485/// 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 {
7690 cast ( dict . from_list ( entries ) )
7791}
7892
7993/// 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 {
8199 cast ( Nil )
82100}
83101
0 commit comments