
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
kotlinscript
Advanced tools
🎯 Kotlin syntax that runs on Node.js. No JVM required!
KotlinScript is a transpiler that converts Kotlin-like syntax into JavaScript, allowing you to write code with Kotlin's modern syntax while leveraging the entire Node.js ecosystem.
npm install -g kotlinscript
Or use it locally:
npm install kotlinscript
Command Line:
# Run a KotlinScript file
kotlinscript myfile.kt
# Or use the short alias
kt myfile.kt
Programmatic:
const KotlinScript = require('kotlinscript');
const code = 'println("Hello from Kotlin!")';
KotlinScript.run(code);
Print/Output:
println("Hello, World!")
print("No newline")
println("Value: $value")
Variables:
val name = "Kotlin" // immutable
var age = 5 // mutable
val active: Boolean = true
val nothing: String? = null
Functions:
fun greet(name: String) {
println("Hello, $name!")
}
fun add(a: Int, b: Int): Int {
return a + b
}
// Single expression
fun multiply(a: Int, b: Int) = a * b
val result = add(5, 3)
greet("Developer")
String Templates:
val name = "Kotlin"
println("Hello, $name!")
println("2 + 2 = ${2 + 2}")
println("Length: ${name.length}")
Conditionals:
val max = if (a > b) a else b
when (x) {
1 -> println("One")
2 -> println("Two")
else -> println("Other")
}
if (age > 18) {
println("Adult")
} else if (age > 13) {
println("Teen")
} else {
println("Child")
}
Loops:
// Range
for (i in 1..5) {
println(i)
}
// Until (exclusive)
for (i in 0 until 10) {
println(i)
}
// Step
for (i in 0..10 step 2) {
println(i)
}
// Collection
val fruits = listOf("apple", "banana")
for (fruit in fruits) {
println(fruit)
}
// While
var count = 0
while (count < 5) {
println(count)
count++
}
Collections:
// List
val fruits = listOf("apple", "banana", "orange")
val mutableList = mutableListOf(1, 2, 3)
mutableList.add(4)
println(fruits[0])
println(fruits.size)
// Map
val person = mapOf(
"name" to "Alice",
"age" to 30
)
println(person["name"])
// Mutable Map
val mutableMap = mutableMapOf<String, Int>()
mutableMap["key"] = 42
Data Classes:
data class Person(val name: String, val age: Int) {
fun greet() {
println("Hi, I'm $name")
}
}
val p = Person("Alice", 30)
p.greet()
println(p.name)
Classes:
class Person(val name: String, var age: Int) {
fun greet() {
println("Hi, I'm $name, $age years old")
}
fun birthday() {
age++
}
}
val p = Person("Bob", 25)
p.greet()
p.birthday()
Lambda Functions:
val numbers = listOf(1, 2, 3, 4, 5)
numbers.forEach { num ->
println(num)
}
val doubled = numbers.map { it * 2 }
val evens = numbers.filter { it % 2 == 0 }
val sum = numbers.reduce { acc, num -> acc + num }
Null Safety:
var name: String? = null
println(name?.length) // Safe call
println(name ?: "Default") // Elvis operator
val length = name?.length ?: 0
Extension Functions:
fun String.shout(): String {
return this.uppercase() + "!"
}
println("hello".shout()) // "HELLO!"
Try/Catch:
try {
riskyOperation()
} catch (e: Exception) {
println("Error: ${e.message}")
} finally {
println("Cleanup")
}
Imports:
import "fs"
import "path" as pathModule
val content = fs.readFileSync("file.txt", "utf8")
Fibonacci:
fun fibonacci(n: Int): Int {
return if (n <= 1) n else fibonacci(n - 1) + fibonacci(n - 2)
}
fun main() {
for (i in 0..10) {
println("Fib($i) = ${fibonacci(i)}")
}
}
main()
Person Manager:
data class Person(val name: String, var age: Int) {
fun greet() = println("Hi, I'm $name")
fun haveBirthday() { age++ }
}
fun main() {
val people = mutableListOf(
Person("Alice", 30),
Person("Bob", 25),
Person("Charlie", 35)
)
people.forEach { it.greet() }
val adults = people.filter { it.age >= 30 }
println("Adults: ${adults.size}")
people.forEach { it.haveBirthday() }
println("After birthdays:")
people.forEach {
println("${it.name} is now ${it.age}")
}
}
main()
Simple Web Server:
import "http"
fun handleRequest(req: Any, res: Any) {
res.writeHead(200, mapOf("Content-Type" to "text/plain"))
res.end("Hello from KotlinScript!")
}
fun main() {
val server = http.createServer(::handleRequest)
server.listen(3000)
println("🎯 Server running on port 3000")
}
main()
Number Processing:
fun main() {
val numbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
println("Original: $numbers")
val doubled = numbers.map { it * 2 }
println("Doubled: $doubled")
val evens = numbers.filter { it % 2 == 0 }
println("Evens: $evens")
val sum = numbers.reduce { acc, n -> acc + n }
println("Sum: $sum")
val bigNumbers = numbers.filter { it > 5 }
.map { it * 3 }
println("Big numbers tripled: $bigNumbers")
}
main()
KotlinScript transpiles Kotlin-like syntax to JavaScript:
MIT License - Free to use in your projects!
🎯 Sintaxe Kotlin rodando no Node.js. Sem necessidade de JVM!
KotlinScript é um transpilador que converte sintaxe estilo Kotlin em JavaScript, permitindo que você escreva código com a sintaxe moderna do Kotlin enquanto aproveita todo o ecossistema do Node.js.
npm install -g kotlinscript
Ou use localmente:
npm install kotlinscript
Linha de comando:
# Execute um arquivo KotlinScript
kotlinscript meuarquivo.kt
# Ou use o alias curto
kt meuarquivo.kt
Programático:
const KotlinScript = require('kotlinscript');
const codigo = 'println("Olá do Kotlin!")';
KotlinScript.run(codigo);
Print/Saída:
println("Olá, Mundo!")
print("Sem quebra de linha")
println("Valor: $valor")
Variáveis:
val nome = "Kotlin" // imutável
var idade = 5 // mutável
val ativo: Boolean = true
val nada: String? = null
Funções:
fun saudar(nome: String) {
println("Olá, $nome!")
}
fun somar(a: Int, b: Int): Int {
return a + b
}
// Expressão única
fun multiplicar(a: Int, b: Int) = a * b
val resultado = somar(5, 3)
saudar("Desenvolvedor")
Coleções:
// Lista
val frutas = listOf("maçã", "banana", "laranja")
val listaEditavel = mutableListOf(1, 2, 3)
listaEditavel.add(4)
println(frutas[0])
println(frutas.size)
// Mapa
val pessoa = mapOf(
"nome" to "Alice",
"idade" to 30
)
Data Classes:
data class Pessoa(val nome: String, val idade: Int) {
fun saudar() {
println("Oi, eu sou $nome")
}
}
val p = Pessoa("Alice", 30)
p.saudar()
Lambdas:
val numeros = listOf(1, 2, 3, 4, 5)
numeros.forEach { num ->
println(num)
}
val dobrados = numeros.map { it * 2 }
val pares = numeros.filter { it % 2 == 0 }
Fibonacci:
fun fibonacci(n: Int): Int {
return if (n <= 1) n else fibonacci(n - 1) + fibonacci(n - 2)
}
fun main() {
for (i in 0..10) {
println("Fib($i) = ${fibonacci(i)}")
}
}
main()
Processamento de Números:
fun main() {
val numeros = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
println("Original: $numeros")
val dobrados = numeros.map { it * 2 }
println("Dobrados: $dobrados")
val pares = numeros.filter { it % 2 == 0 }
println("Pares: $pares")
val soma = numeros.reduce { acc, n -> acc + n }
println("Soma: $soma")
}
main()
KotlinScript transpila sintaxe Kotlin para JavaScript:
Licença MIT - Livre para usar nos seus projetos!
Made with 💙 by CapybaraScript Company 🦫
Part of the open source language distribution family
FAQs
🎯 Kotlin syntax running on Node.js | Write Kotlin, Execute JavaScript
We found that kotlinscript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.