
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
redis-lua2js
Advanced tools
convert redis lua scripts to a useful node module
$ npm install --save-dev redis-lua2js
This module is not meant to be used on its own, but rather as part of another module, such as gulp-redis-lua2js or hook-redis-lua. In here, I will demonstrate the usage with the help of module-from-string:
index.js:
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import Redis from 'ioredis';
import lua2js from 'redis-lua2js';
import { requireFromString } from 'module-from-string';
const ioredis = new Redis();
const lua = readFileSync(join(__dirname, 'pdel.lua'));
const js = lua2js(lua); // This is a node module string, the template of which you can see in src/lua.js
const pdel = requireFromString(js); // Parse the module as a string
ioredis.defineCommand(pdel.name, {
lua: pdel.lua,
numberOfKeys: pdel.numberOfKeys,
});
ioredis.pdel('*');
pdel.lua:
--!/usr/bin/env lua
-- name pdel
-- nkeys 1
local function deleteKeys (keys)
for i, name in ipairs(keys) do
redis.call("DEL", name)
end
end
if type(redis.replicate_commands) == 'function' and redis.replicate_commands() then -- Redis 3.2+
local count = 0
local cursor = "0"
local keys
repeat
cursor, keys = unpack(redis.call("SCAN", cursor, "MATCH", KEYS[1]))
count = count + #keys
deleteKeys(keys)
until cursor == "0"
return count
else
local keys = redis.call("KEYS", KEYS[1])
deleteKeys(keys)
return #keys
end
Takes the contents of a lua script and outputs a node module, as a string, which can be used to load the script into a redis client such as ioredis easily.
Type: string, the contents of a lua script
Type: string?
By default it is parsed from the comments of the lua script, as demonstrated in the Usage section
The name of the redis command, will be used when installing to ioredis
Type: string?,
By default it is parsed from the comments of the lua script, as demonstrated in the Usage section
The number of keys that the redis command accepts
Type: "commonjs" | "module"
Whether the output module is commonjs or esm.
The parsed module will export the following:
Type: string | null, contains the name from the API above
Type: integer | null, contains the value of the number of keys argument from the API above
Type: string, contains the contents of the lua script, useful for manually installing the script, for example, with ioredis.defineCommand
See the LICENSE file for license rights and limitations (MIT).
FAQs
Convert a redis lua script into a simple node module
The npm package redis-lua2js receives a total of 31 weekly downloads. As such, redis-lua2js popularity was classified as not popular.
We found that redis-lua2js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.