# toolkit

Basic-functions toolkit: 172 small, self-contained, data-in→data-out functions combined + de-duplicated from the legacy a.functions (algorithms) + a.helpers (utilities) + a.algorithms (geometry)...


A de-duplicated library of **129 small, self-contained, data-in→data-out functions** — combined from
the legacy `a.functions` (algorithms) and `a.helpers` (utilities) middleware libraries. Every tool
takes one JSON args object and returns a plain result, so each is trivially a **mini-microservice**,
an **MCP tool**, a **chatbot functioncall**, or a **multi-page-form action**.

## Categories (`src/`)

| Module | ~count | Examples |
|---|---|---|
| `numberTheory` | 40 | isPrime, primeFactors, gcd, lcm, sieveOfEratosthenes, modularPow, modInverse, fibonacci, collatz, eulerTotient, digitalRoot, integerSqrt |
| `combinatorics` | 17 | permutations, combinations, powerSet, nPr, nCr, catalan, partitions, derangements, cartesianProduct, multisetPermutations |
| `graph` | 12 | dijkstra, aStar, bfsLevels, pageRank, topologicalSort, connectedComponents, hasCycle, reachable |
| `sortSearch` | 13 | mergeSort, quickSort, heapSort, binarySearch, quickselect, kthLargest, lowerBound, isSorted |
| `dataAlgos` | 22 | shannonEntropy, huffmanEncode/Decode, kMeans, markovChainBuild/Generate, reservoirSample, bloomFilter, levenshtein, hammingDistance, jaccardSimilarity, runLength, deltaEncode, normalize01, slidingWindow |
| `objectUtils` | 26 | get, set, pick, omit, merge, mergeDeep, cloneDeep, invert, groupBy, countBy, keyBy, flattenObject, unflattenObject, deepEqual |

## Design & DRY boundaries
- **Selection rule:** only JSON-serializable, data-in→data-out functions are here. Code-composition
  helpers that take a function/callback (compose, curry, memoize, debounce, asyncMap, promisify,
  semaphore, pLimit, …) were intentionally **excluded** — you can't submit a function through a form
  or an MCP tool call.
- **De-duplicated:** nothing re-implements a capability already owned by another pack —
  `numbers` (basic math / unit / base convert), `statistics` (mean/std/regression/tests),
  `array` (chunk/flatten/unique/set ops), `a-text` (string ops/ciphers), `a-file-actions` (fs),
  `datetime` (date math), `validation` (luhn/email), `crypto` (aes/rsa/jwt), `matrix` (linear
  algebra), `hz` (fft), `dice` (shuffle/random), `word` (palindrome/anagram).

## Usage
`POST /api/adapters/toolkit/<fn>` with the function's args, e.g.
`POST /api/adapters/toolkit/gcd { "a": 12, "b": 18 }` → `{ "result": { "gcd": 6 } }`.
Discover them all via `GET /api/adapters/toolkit` or the universal `GET /api/adapters/search?q=…`.


---
Source: shared/engines/adapters/domain/toolkit/README.md
Canonical: https://docs.leumas.tech/p/adapters/domain/toolkit
