summaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-11-16 12:58:26 +0100
committerJo-Philipp Wich <jo@mein.io>2020-11-16 13:05:28 +0100
commit1e399df30ed1e8e1b2c609e90a152d6dab9977e1 (patch)
tree66dc57aaaac305747bf6196299e2b4cfbba04f87 /README.md
parent814cb1ffb1a7bd6224e8e716505069bdf0c08b81 (diff)
lib: extend ord() to allow reading byte values at arbitrary indexes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'README.md')
-rw-r--r--README.md17
1 files changed, 14 insertions, 3 deletions
diff --git a/README.md b/README.md
index 74bf865..1a2051f 100644
--- a/README.md
+++ b/README.md
@@ -681,12 +681,23 @@ a = map(["foo", 1, true, null, 2.2], type);
// a = ["string", "int", "bool", null, "double"]
```
-#### 6.22. `ord(s)`
+#### 6.22. `ord(s, ...)`
-Returns the byte value of the first character in the given string.
+Without further arguments, this function returns the byte value of the first
+character in the given string.
+
+If one or more index arguments are supplied, an array containing the byte
+values at each given index is returned. If an invalid index is supplied, the
+corresponding array entry will be `null`. Negative index entries are counted
+towards the end of the string, e.g. `-2` will return the value of the second
+last character.
```javascript
-ord("Abc"); // 65
+ord("Abc"); // 65
+ord("Abc", 0); // [ 65 ]
+ord("Abc", 1, -1); // [ 98, 99 ]
+ord("Abc", 2, 1, 0); // [ 99, 98, 65 ]
+ord("Abc", 10, -10, "nan"); // [ null, null, null ]
```
#### 6.23. `pop(arr)`