This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Common | ||
====== | ||
|
||
env | ||
--- | ||
|
||
.. js:function:: env(key) | ||
|
||
:param string key: The environment key to get | ||
:return: The value of the environment variable, or "" if it doesn't exist | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
.. code-block:: guess | ||
env("FOO") // foo | ||
length | ||
------ | ||
|
||
.. js:function:: length(object) | ||
|
||
:param string/list/map object: The object to return the length of | ||
:return: The length of the object. | ||
If object is a string, it is the number of characters. | ||
If object is a list, it is the number of items in the list. | ||
If object is a map, it is the number of keys in the map. | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
.. code-block:: guess | ||
length("hello") // 5 | ||
length(["foo", "bar"]) // 2 | ||
length({"foo": "bar"}) // 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Maps | ||
==== | ||
|
||
has | ||
--- | ||
|
||
.. js:function:: has(map, key) | ||
|
||
:param map map: The map to perform the lookup on | ||
:param string key: The key to look for | ||
:return: A bool as to whether or not the key exists | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
.. code-block:: guess | ||
has({"foo": "bar"}, "foo") // true | ||
map | ||
--- | ||
|
||
.. js:function:: map(key, value, ...) | ||
|
||
:param string key: The key for the key/value pair | ||
:param any value: The value for the key/value/pair | ||
:return: A map object consisting of the provided key/value pairs | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
.. code-block:: guess | ||
map("foo", "bar") // {"foo": "bar"} | ||
map("foo", list(1, 2, 3), "bar", list(3, 2, 1)) // {"foo": [1, 2, 3], "bar": [3, 2, 1]} | ||
keys | ||
---- | ||
|
||
.. js:function:: keys(map) | ||
|
||
:param map map: The map to extract keys | ||
:return: The list of keys from the map | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
.. code-block:: guess | ||
keys(map("foo", "bar")) // ["foo"] | ||
merge | ||
----- | ||
|
||
.. js:function:: merge(map1, ...) | ||
|
||
:param map map1: One or many maps to merge | ||
:return: The result of the merge | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
.. code-block:: guess | ||
merge(map("foo", "bar"), map("foo", "bar2", "hello", "there")) // {"foo": "bar2", "hello": "there"} |