https://github.com/lunatic-fox/lext
Extension methods to Lua language.
https://github.com/lunatic-fox/lext
array contains extension filter flat lua map module reduce replace reverse slice split string table trim
Last synced: 2 months ago
JSON representation
Extension methods to Lua language.
- Host: GitHub
- URL: https://github.com/lunatic-fox/lext
- Owner: lunatic-fox
- License: mit
- Created: 2022-04-26T00:15:43.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T08:16:45.000Z (about 2 years ago)
- Last Synced: 2024-10-04T18:41:44.613Z (8 months ago)
- Topics: array, contains, extension, filter, flat, lua, map, module, reduce, replace, reverse, slice, split, string, table, trim
- Language: Lua
- Homepage:
- Size: 204 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[//]: # (author: Lunatic Fox - Josélio Júnior )
[//]: # (copyright: Lunatic Fox - Josélio Júnior 2023)
[//]: # (license: MIT)# Lua extensions 
## Install
### Step 1
Download the [**`install.tar`**](https://github.com/lunatic-fox/lua-extensions/raw/develop/install/install.tar) file (Lua extensions directory), extract to your `LUA_PATH` (path where Lua is installed).Or you can also open a terminal in the same path where you downloaded `install.tar` and run the command line below to unzip to your ``.
```
tar -xf install.tar -C ""
```#### install.tar
> **SHA256:** *cb4df36c5d5f86f92cc27d72b8e5b3c4e7fe7b7c8181a1e9d66f5968bef1032f*\
> **MD5:** *bf6f95cd6d895dc0a5150ec738ad94eb*
>
> #### Content
> - `lext.lua`
> - `lua-extensions/dependencies/erros.lua`
> - `lua-extensions/dependencies/short-methods.lua`
> - `lua-extensions/docs/extlib.lua`
> - `lua-extensions/array.lua`
> - `lua-extensions/string.lua`
> - `lua-extensions/LICENSE.lua`### Step 2
On VSCode you will need [**Lua Language Server**](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) extension installed.### Step 3
Still on VSCode open `Preferences: Open User Settings (JSON)` with the command:
- On Windows: `Ctrl + Shift + P` or `F1`
- On MacOS: `⇧⌘P` or `F1`Inside the main object of `settings.json` add the code below changing `` to the path where Lua is installed on your machine.
```json
"Lua.workspace.library": [
"/lua-extensions/docs"
]
```All set! You're ready to go! 🚀
## Usage
Require Lua extensions module in whatever lua file you want with the code below.
```lua
require 'lext'
```Let's see an example with `array.reduce()`.
```lua
require 'lext'
local t = array{1, 2, 3, 4, 5}.reduce'+'print(t) -- 15
```## [Documentation](./docs/README.md)
### UTF8 terminal
If your terminal isn't displaying utf8 characters correctly, use the `utf8` option after the filename, just once. This argument triggers the `chcp 65001` command in the console.```lua
-- heart.lua
print 'Coração' -- Cora├º├úo
``````
> lua heart.lua utf8
```
Now let's take a look at some brief explanations about the powerful Lua extensions. You can also click on the method to see some examples in [documentation](./docs/README.md).
### [string](./docs/README.md#string)
- [`:split()`](./docs/README.md#stringsplit)\
*Splits a string into a string table.*- [`:slice()`](./docs/README.md#stringslice)\
*Splices the string with UTF8 support.*- [`:replace()`](./docs/README.md#stringreplace)\
*Replaces a string substring with no magic symbols.*- [`:tolowercase()`](./docs/README.md#stringtolowercase)\
*Lowercase all with UTF8 support.*- [`:touppercase()`](./docs/README.md#stringtouppercase)\
*Lowercase all with UTF8 support.*- [`:reverse()`](./docs/README.md#stringreverse)\
*Reverses the string with UTF8 support.*- [`:contains()`](./docs/README.md#stringcontains)\
*Checks if the given string contains a certain substring.*- [`:trim()`](./docs/README.md#stringtrim)\
*Removes the leading and trailing white space line terminator characters from a string.*- [`:trimstart()`](./docs/README.md#stringtrimstart)\
*Removes the leading white space characters from a string.*- [`:trimend()`](./docs/README.md#stringtrimend)\
*Removes the trailing white space line terminator characters from a string.*### [array](./docs/README.md#array)
- [`.join()`](./docs/README.md#arrayjoin)\
*Joins the table into a string.*- [`.slice()`](./docs/README.md#arrayslice)\
*Slices the table.*- [`.filter()`](./docs/README.md#arrayfilter)\
*Returns a table with items that meet a specified condition passed by a callback function.*- [`.map()`](./docs/README.md#arraymap)\
*Modifies each item of the table by a callback function.*- [`.reduce()`](./docs/README.md#arrayreduce)\
*Returns the accumulated result of all the elements in the array.*- [`.reverse()`](./docs/README.md#arrayreverse)\
*Reverses the order of the elements in the array.*- [`.flat()`](./docs/README.md#arrayflat)\
*Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.***Made with ❤️**
**Lunatic Fox - Josélio Júnior - 2023**