A lightweight, embeddable scripting language for JavaScript/TypeScript applications
npm install @issadicko/kodi-scriptA lightweight, embeddable scripting language for JavaScript/TypeScript applications.

š Full Documentation: docs-kodiscript.dickode.net
``bash`
npm install @issadicko/kodi-scriptor
yarn add @issadicko/kodi-scriptor
pnpm add @issadicko/kodi-script
`typescript
import { KodiScript } from '@issadicko/kodi-script';
const result = KodiScript.run(
let name = "World"
print("Hello " + name));
console.log(result.output); // ['Hello World']
`
`typescript
const result = KodiScript.run(
let greeting = "Hello " + user.name
let status = user?.active ?: "offline"
print(greeting), {`
user: { name: 'Alice', active: true }
});
`typescript
const result = KodiScript.builder(
let greeting = customGreet("World")
print(greeting))Hello, ${name}!
.withVariable('version', '1.0')
.registerFunction('customGreet', (name) => )`
.execute();
- Variables: let name = "value"user?.name
- Null-safety: , value ?: "default"if/else
- Control flow: , return
- Native functions: String, Math, JSON, Crypto, Arrays
- Extensible: Register your own native functions
- TypeScript support: Full type definitions included
KodiScript is designed to be extensible. You can enrich the language by adding your own native functions, allowing scripts to interact with your system.
`typescript
const result = KodiScript.builder(
let greeting = greet("World")
let price = calculatePrice(100, 0.2)
print(greeting + " - Total: $" + price))Hello, ${name}!
.registerFunction('greet', (name) => )`
.registerFunction('calculatePrice', (amount, taxRate) => amount * (1 + taxRate))
.execute();
`typescript
import express from 'express';
import { KodiScript } from '@issadicko/kodi-script';
const app = express();
// Create a script engine with business functions
function createScriptEngine(context: Record
return KodiScript.builder('')
.withVariables(context)
.registerFunction('fetchUser', async (id) => {
// Call your database
return { id, name: 'Alice', tier: 'gold' };
})
.registerFunction('calculateDiscount', (tier, amount) => {
const discounts = { gold: 0.2, silver: 0.1, bronze: 0.05 };
return amount * (discounts[tier] || 0);
})
.registerFunction('sendEmail', (to, subject, body) => {
// Send email via your service
console.log(Email sent to ${to});
return true;
});
}
app.post('/api/execute', (req, res) => {
const { script, context } = req.body;
const engine = createScriptEngine(context);
const result = engine.withSource(script).execute();
res.json(result);
});
`
This allows your users to write powerful scripts while you maintain control over exposed functionality.
, toString, toNumber, length, substring, toUpperCase, toLowerCase, trim, replace, split, join, contains, startsWith, endsWith, indexOf$3
abs, floor, ceil, round, min, max, pow, sqrt, sin, cos, tan, log, log10, exp$3
random, randomInt, randomUUID$3
jsonParse, jsonStringify, base64Encode, base64Decode, urlEncode, urlDecode$3
size, first, last, slice, reverse, sort, sortBy$3
typeOf, isNull, isNumber, isString, isBool$3
md5, sha1, sha256$3
now, date, time, datetime, timestamp, formatDate, year, month, day, hour, minute, second, dayOfWeek, addDays, addHours, diffDaysSyntax
`javascript
// Variables
let name = "Kodi"
let version = 1.0// Null-safety
let status = user?.active ?: "offline"
// Conditions
if (version > 1.0) {
print("Modern version")
} else {
print("Legacy version")
}
// Return
return "result"
// Arrays and Objects
let arr = [1, 2, 3]
let obj = { name: "Alice", age: 30 }
``| Language | Package |
|----------|---------|
| Kotlin | Maven Central |
| Go | pkg.go.dev |
| Dart | pub.dev |
MIT