Skip to content

OmyDaGreat/MaleficExtensions

Repository files navigation

Malefic Extensions

Malefic Extensions accelerates Kotlin Multiplatform and Compose projects with a curated toolkit of pragmatic extensions. Ship faster by relying on:

  • KMP-first coverage – Android, JVM, JS, Native, and Web source sets share the same APIs.

  • Compose-aware utilities – Dedicated helpers for system trays, menus, and Modifier ergonomics.

  • Battle-tested primitives – Collections, math helpers, tuples, lazy sequences, and safe function composition.

Targets & Distribution

Artifact Targets Notes

xyz.malefic:extensions

commonMain, androidMain, jvmMain (Desktop), iosX64/Arm64, iosSimulatorArm64, js (browser + node), wasmJs

Single multiplatform bundle that includes core language utilities plus Compose-aware helpers on the targets that support them.

Need a refresher on the code layout? Start with extensions/src/commonMain/…​.

Feature Matrix

Category Highlights

any

Nullability helpers and fluent predicates for Any.

bool

Boolean combinators (ifTrue, ifFalse, guards).

collection

AccessOrderLinkedHashMap, multiplatform ConcurrentHashMap, and expressive list utilities.

func

Memoization (Cache), composition operators, safe invocation wrappers, infix DSLs.

lazy

Lightweight lazy list builder for streamed evaluation.

modifier

Compose Modifier operators (showIf, roundedBackgroundWithPadding, modifyIfElse, clickableIf).

num

Infix math DSL, factorial/triangular sequences, prime and gcd utilities.

tree

TreeNode structure with traversal helpers.

tuple

Extended tuples (Triple → Decuple) with destructuring support.

application

Compose Desktop tray/menu helpers (Tray, Item).

file, stream, string

File-tree builders, stream transformations, and string predicates.

Installation

Add the single artifact wherever you need it. Replace $version with the desired release (see releases or git tag -l).

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
}

Multiplatform build.gradle.kts

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("xyz.malefic:extensions:$version")
            }
        }
        val jvmMain by getting {
            dependencies {
                // Compose dependencies remain yours to configure
                implementation(compose.desktop.currentOs)
            }
        }
    }
}

Compose-aware helpers (tray/menu, Modifier, etc.) live in the same artifact—just add the Compose runtime/foundation dependencies to the targets where you use them.

Usage

Core snippets

// Function composition DSL
val increment = { x: Int -> x + 1 }
val double = { x: Int -> x * 2 }
val pipeline = increment andThen double
val composed = pipeline(3) // 8

// Numeric helpers
val factorial = 5.factorial()         // 120
val triangular = 7.triangular()       // 28
val isPrime = 97.isPrime()            // true

// String predicates
val containsAny = "Hello World".containsAny("Hello", "Goodbye") // true

Compose snippets

// Tray + menu setup (Compose Desktop)
ApplicationScope.tray {
    icon = painterResource("icon.png")
    tooltip = "My Application"
    onAction = { println("Tray clicked") }
    menu {
        Item("Settings") { openSettings() }
        Item("Exit") { exitApplication() }
    }
}

// Modifier helpers
Box(
    modifier = Modifier
        .showIf(isVisible)
        .roundedBackgroundWithPadding(Color.Gray, 8.dp, 16.dp)
        .clickableIf(isEnabled) { handleClick() }
)

Documentation & Support

  • Browse the source: extensions/src/…​.

  • Dokka HTML is generated via ./gradlew dokkaGenerateModuleHtml and published under build/dokka.

  • Issues and questions: open a GitHub issue with reproduction steps and target platform info.

Contributing

  1. Fork, branch (feature/my-improvement), and keep changes scoped.

  2. Add or update tests/examples alongside new extensions.

  3. Run ./gradlew build (plus dokkaGenerateModuleHtml if docs change) before opening a PR.

  4. Describe intent, affected modules, and testing notes in the pull request template.

License

Malefic Extensions is distributed under the MIT License. See LICENSE for the full text.

About

A Compose Desktop library containing common extensions

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages