luaload
A Node.js library for concatenating and loading lua script files in redis
Please, refer to the Installation, Usage, API, Requirements and License sections for more information.
Installation
npm install luaload
Usage
./usage.js
const luaload = const redis = const client = redisconst sourceDirectory = pathconst mappings = ninja_turtles: 'leonardo' 'michelangelo' 'donatello' 'raphael' 'list_ninja_turtles' const shouldOutput = true const loader = loader
./lua/donatello.lua
local function donatello() return 'Donatello'end
./lua/leonardo.lua
local function leonardo() return 'Leonardo'end
./lua/michelangelo.lua
local function michelangelo() return 'Michelangelo'end
./lua/raphael.lua
local function raphael() return 'Raphael'end
./lua/list_ninja_turtles.lua
local return_value = {} table.insert(return_value, donatello())table.insert(return_value, leonardo())table.insert(return_value, michelangelo())table.insert(return_value, raphael()) return return_value
API
Classes
- LUAScriptLoader
The script loader.
Functions
- luaload(client, sourceDirectory, mappings, shouldOutput)
The factory method for the LuaScriptLoader.
LUAScriptLoader
The script loader.
luaScriptLoader.load(key, done)
Concatenates and loads a script from files. Returns the SHA-1 digest of the script.
Kind: instance method of LUAScriptLoader
Param | Type | Description |
---|---|---|
key | String |
The key from the mappings. |
done | function |
The final callback. Invoked with (err, sha) . |
luaload(client, sourceDirectory, mappings, shouldOutput)
The factory method for the LuaScriptLoader.
Kind: global function
Param | Type | Description |
---|---|---|
client | Object |
The redis client. |
sourceDirectory | String |
The absolute path to the directory containing the lua script files to concatenate and load. The directory should exist. The Directory should be readable. If shouldOutput is set to true, then the directory should also be writable. |
mappings | Object |
An object whose keys are aliases to arrays of file paths to concatenate. |
shouldOutput | Boolean |
If set to true , the concatenated script file will be written to sourceDirectory . |
Requirements
- Node.js 6+
- Redis 2.8.9+
License
This project is MIT-licensed