Types
Last updated
new M.Enum(['SUN', 'MOON'])
new M.Enum({'SUN': {radius: 695700}, 'MOON': {radius: 1737.1}})
M.Enum.fromArray(['SUN', 'MOON'])
M.Enum.fromObject({'SUN': {radius: 695700}, 'MOON': {radius: 1737.1}})new M.Map(new Map([[1, 'a'], [2, 'b']]))
M.Map.fromMap(new Map([[1, 'a'], [2, 'b']]))
M.Map.fromArray([[1, 'a'], [2, 'b']])
M.Map.fromObject({1: 'a', 2: 'b'}) // 1 and 2 are strings in this case
M.Map.of(1, 'a', 2, 'b')const SolarSystem = M.Enum.fromArray(['SUN', 'MOON'])
const SUN = SolarSystem.SUN()
const MOON = SolarSystem.MOON()
new M.EnumMap(new Map([[SUN, 1], [MOON, 2]]))
M.EnumMap.fromMap(new Map([[SUN, 1], [MOON, 2]]))
M.EnumMap.fromArray([[SUN, 1], [MOON, 2]])
M.EnumMap.of(SUN, 1, MOON, 2)new M.StringMap(new Map([['a', 1], ['b', 2]]))
M.StringMap.fromMap(new Map([['a', 1], ['b', 2]]))
M.StringMap.fromArray([['a', 1], ['b', 2]])
M.StringMap.fromObject({a: 1, b: 2})
M.StringMap.of('a', 1, 'b', 2)new M.List([1, 5, 3, 5])
M.List.fromArray([1, 5, 3, 5])
M.List.of(1, 5, 3, 5)new M.Set([1, 5, 3])
M.Set.fromArray([1, 5, 3])
M.Set.of(1, 5, 3)M.Nothing.isEmpty() // => true
new M.Maybe(null).isEmpty() // => true
M.Maybe.of(null).isEmpty() // => true
new M.Just(2).isEmpty() // => false
M.Just.of(2).isEmpty() // => false
M.Maybe.of(2).isEmpty() // => false
M.Just.of(null).isEmpty() // => false (can wrap anything)
M.Just.of(2).map(x => 2 * x) // => M.Just.of(4)
M.Nothing.map(x => 2 * x).isEmpty() // => true