gleam/javascript/symbol

Types

Symbols are special unique values in JavaScript.

For further information view the MDN documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol

pub type Symbol

Functions

pub fn description(symbol: Symbol) -> Result(String, Nil)

Get the description of the symbol, if it has one.

Examples

symbol.new("wibble")
|> symbol.description
// -> Ok("wibble")
pub fn get_or_create_global(key: String) -> Symbol

Returns the symbol for the given key from the global symbol registry, creating and registering a new one if one did not already exist.

Uses the JavaScript Symbol.for internally.

For further information see the MDN documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for

pub fn new(description: String) -> Symbol

Creates a new symbol with the given description.

Symbols created with this function are “local”, they are not in the global symbol registry.

For further information see the MDN documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/Symbol

Search Document