Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/src/modules/is.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ ok = is("hello", "string") --> true
ok = is.table({}) --> true
```

> [!NOTE] Function names exist in both lowercase and capitalized forms, and `is`
> is also callable as `is(v, tp)`.
> [!NOTE]
>
> Function names exist in both lowercase and capitalized forms, and `is` is also
> callable as `is(v, tp)`.
>
> ```lua
> is.table({}) --> true
Expand Down
26 changes: 19 additions & 7 deletions docs/src/modules/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ is_even = function(v) return v % 2 == 0 end
ok = List({ 2, 4 }):all(is_even) --> true
```

> [!NOTE] Empty lists return `true`.
> [!NOTE]
>
> Empty lists return `true`.

#### `any`

Expand Down Expand Up @@ -275,8 +277,10 @@ Return the number of elements in the list.
n = List({ "a", "b", "c" }):len() --> 3
```

> [!NOTE] Uses Lua's `#` operator, so length is reliable for contiguous
> array-like lists.
> [!NOTE]
>
> Uses Lua's `#` operator, so length is reliable for contiguous array-like
> lists.

### Access

Expand Down Expand Up @@ -363,7 +367,9 @@ i = List({ "a", "b", "a", "c" }):intersection({ "a", "c" })
--> { "a", "a", "c" }
```

> [!NOTE] Order is preserved from the original list.
> [!NOTE]
>
> Order is preserved from the original list.

#### `invert`

Expand Down Expand Up @@ -421,7 +427,9 @@ Convert the list to a set.
s = List({ "a", "b", "a" }):toset() --> { a = true, b = true }
```

> [!NOTE] Order is preserved from the original list.
> [!NOTE]
>
> Order is preserved from the original list.

#### `slice`

Expand All @@ -431,7 +439,9 @@ Return a new list containing items from i to j (inclusive).
t = List({ "a", "b", "c", "d" }):slice(2, 3) --> { "b", "c" }
```

> [!NOTE] Supports negative indices (-1 is last element).
> [!NOTE]
>
> Supports negative indices (-1 is last element).

#### `take`

Expand All @@ -457,4 +467,6 @@ Zip two lists into a list of 2-element tables.
z = List({ "a", "b" }):zip({ 1, 2 }) --> { {"a",1}, {"b",2} }
```

> [!NOTE] Length is the minimum of both lists.
> [!NOTE]
>
> Length is the minimum of both lists.
26 changes: 18 additions & 8 deletions docs/src/modules/str.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ n = count("abcd", "")

Return true if string ends with suffix.

> [!NOTE] If suffix is a list, returns `true` when any suffix matches.
> [!NOTE]
>
> If suffix is a list, returns `true` when any suffix matches.

```lua
ok = endswith("hello.lua", ".lua")
Expand Down Expand Up @@ -175,8 +177,9 @@ ok = isalnum("abc123")
--result: true
```

> [!NOTE] Lua letters are ASCII by default, so non-ASCII letters are not
> alphanumeric.
> [!NOTE]
>
> Lua letters are ASCII by default, so non-ASCII letters are not alphanumeric.
>
> ```lua
> isalnum("á1")` --> `false`
Expand All @@ -191,8 +194,9 @@ ok = isalpha("abc")
--result: true
```

> [!NOTE] Lua letters are ASCII by default, so non-ASCII letters are not
> alphabetic.
> [!NOTE]
>
> Lua letters are ASCII by default, so non-ASCII letters are not alphabetic.
>
> ```lua
> isalpha("á")` --> `false`
Expand All @@ -207,7 +211,9 @@ ok = isascii("hello")
--result: true
```

> [!NOTE] The empty string returns `true`.
> [!NOTE]
>
> The empty string returns `true`.

#### `isdecimal`

Expand Down Expand Up @@ -270,7 +276,9 @@ ok = isprintable("abc!")
--result: true
```

> [!NOTE] The empty string returns `true`.
> [!NOTE]
>
> The empty string returns `true`.

#### `isspace`

Expand Down Expand Up @@ -472,7 +480,9 @@ s = swapcase("AbC")

Return true if string starts with prefix.

> [!NOTE] If prefix is a list, returns `true` when any prefix matches.
> [!NOTE]
>
> If prefix is a list, returns `true` when any prefix matches.

```lua
ok = startswith("hello.lua", "he")
Expand Down
14 changes: 10 additions & 4 deletions docs/src/modules/tbl.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ t = copy({ a = 1, b = 2 }) --> { a = 1, b = 2 }

Create a deep copy of a value.

> [!NOTE] If `v` is a table, all nested tables are copied recursively; other
> types are returned as-is.
> [!NOTE]
>
> If `v` is a table, all nested tables are copied recursively; other types are
> returned as-is.

```lua
t = deepcopy({ a = { b = 1 } }) --> { a = { b = 1 } }
Expand Down Expand Up @@ -138,7 +140,9 @@ v1 = get(t, "a", "b", "c") --> 1
v2 = get(t) --> { a = { b = { c = 1 } } }
```

> [!NOTE] If no keys are provided, returns the input table.
> [!NOTE]
>
> If no keys are provided, returns the input table.

### Transforms

Expand Down Expand Up @@ -182,7 +186,9 @@ end) --> { a = 10, b = 20 }

Return a new table by mapping each key-value pair.

> [!NOTE] Output keeps original keys; only values are transformed by `fn`.
> [!NOTE]
>
> Output keeps original keys; only values are transformed by `fn`.

```lua
t = pairmap({ a = 1, b = 2 }, function(k, v)
Expand Down
6 changes: 4 additions & 2 deletions docs/src/modules/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ print(utils.quote('say "hi" and \\'bye\\'')) -- "say \"hi\" and 'bye'"

Render any Lua value as a string.

> [!NOTE] Uses [`inspect`](https://github.com/kikito/inspect.lua) when
> available, otherwise falls back to
> [!NOTE]
>
> Uses [`inspect`](https://github.com/kikito/inspect.lua) when available,
> otherwise falls back to
> [`mods.repr`](https://luamod.github.io/mods/modules/repr).

```lua
Expand Down