stralo
v1.0.0
Published
Next-generation, zero-dependency, tree-shakable TS/JS utility suite.
Readme
stralo
Next-generation, zero-dependency, ultra-lightweight utility suite built for modern JavaScript and TypeScript environments.
stralo is an alternative to legacy utility libraries like Lodash. Engineered from the ground up for V8 execution speed, zero-allocation hot paths, strict type safety, and zero-overhead tree-shaking across Node.js, Bun, Deno, and Edge runtimes.
Key Features
- Zero Dependencies: Built entirely with native ES2022+ primitives and type-safe abstractions.
- Subpath ESM/CJS Exports: Import only what you need (
stralo/array,stralo/deep) for minimal bundle footprint. - First-Class TypeScript: Deep type inference including string-path autocomplete (
Path<T>), variadic tuple preservation, and strict type guards. - Prototype Pollution Protected: Built-in protection against dynamic property overrides (
__proto__,constructor,prototype) across all deep and object utilities. - V8 JIT Optimized: Tailored to avoid hidden class mutations, maintain monomorphic inline caching (IC), and reduce garbage collection churn.
Installation
Bash
# pnpm
pnpm add stralo
# npm
npm install stralo
# yarn
yarn add stralo
# bun
bun add straloQuickstart
1. Subpath Import (Recommended for Optimal Bundle Size)
TypeScript
import { chunk, groupBy } from 'stralo/array';
import { get, deepClone } from 'stralo/deep';
import { pipe } from 'stralo/fp';
// Deep property access with strict autocomplete
const user = { profile: { addresses: [{ city: 'Jakarta' }] } };
const city = get(user, 'profile.addresses[0].city'); // Typed as string
// Functional pipeline execution
const activeUsers = pipe(
[
{ name: 'Alice', role: 'admin', active: true },
{ name: 'Bob', role: 'user', active: false },
],
(list) => list.filter((u) => u.active),
(list) => groupBy(list, (u) => u.role)
);2. Root Barrel Import
Modern bundlers (Vite, Webpack 5, Rollup, esbuild) automatically tree-shake unused functions when imported from the root barrel.
TypeScript
import { deepClone, pipe, camelCase } from 'stralo';
const cloned = deepClone({ key: new Set([1, 2, 3]) });
const keyName = camelCase('user-first-name'); // 'userFirstName'Module Map & API Overview
| Module | Core Exports | Subpath Export |
| ---------------------- | ------------------------------------------------------------------------ | ---------------------------------------- |
| stralo/array | chunk, difference, groupBy, partition, uniq, zip | import { ... } from 'stralo/array' |
| stralo/object | pick, omit, mapKeys, mapValues, invert | import { ... } from 'stralo/object' |
| stralo/string | camelCase, kebabCase, snakeCase, pascalCase, truncate, words | import { ... } from 'stralo/string' |
| stralo/number | clamp, inRange, randomInt, round, sum, mean | import { ... } from 'stralo/number' |
| stralo/date | addDays, diffInDays, endOf, format, isLeapYear, startOf | import { ... } from 'stralo/date' |
| stralo/predicate | isEmpty, isEqual, isNil, isObject, isPromise | import { ... } from 'stralo/predicate' |
| stralo/deep | deepClone, deepMerge, get, set | import { ... } from 'stralo/deep' |
| stralo/fp | compose, curry, debounce, memoize, pipe | import { ... } from 'stralo/fp' |
TypeScript Capabilities
Autocompleted String Paths (get / set)
stralo/deep provides compile-time type validation for object paths up to 5 levels deep.
TypeScript
import { get, set } from 'stralo/deep';
interface Config {
database: {
connection: {
host: string;
port: number;
};
};
}
const config: Config = {
database: { connection: { host: 'localhost', port: 5432 } },
};
// IDE Autocompletes: 'database' | 'database.connection' | 'database.connection.host' | ...
const host = get(config, 'database.connection.host'); // Inferenced return type: stringPerformance Benchmark Metrics
stralo is continuously benchmarked using mitata against standard utilities on Node.js v20 (V8 v11.3).
| Benchmark Operation | stralo Performance | Lodash Performance | Improvement |
| ----------------------------------------- | ---------------------- | ---------------------- | --------------- |
| Array Chunking (10,000 items) | ~1.45 M ops/sec | ~420 K ops/sec | 3.4x faster |
| Deep Object Cloning (Nested Map/Set) | ~1.12 M ops/sec | ~380 K ops/sec | 2.9x faster |
| Array Difference (5,000 vs 2,500) | ~2.80 M ops/sec | ~1.10 M ops/sec | 2.5x faster |
| Deep Path Retrieval (get) | ~18.5 M ops/sec | ~9.2 M ops/sec | 2.0x faster |
To run benchmarks locally:
Bash
pnpm benchSecurity Protocol
All stralo object mutation and deep traversal utilities feature built-in runtime guards against Prototype Pollution. Attempting to pass objects containing malicious prototype keys (__proto__, constructor, prototype) will be safely ignored without throwing exceptions or corrupting global object prototypes.
TypeScript
import { deepMerge, set } from 'stralo/deep';
const maliciousPayload = JSON.parse('{"__proto__": {"admin": true}}');
// Safe merge: Prototype modification attempts are blocked
const cleanObject = deepMerge({}, maliciousPayload);
console.log(({} as any).admin); // undefined (safe)Migration Quick Reference (from Lodash)
| Lodash | stralo Equivalent | Notes |
| ------------------------------------------ | ----------------------------------------- | ------------------------------------------- |
| import cloneDeep from 'lodash/cloneDeep' | import { deepClone } from 'stralo/deep' | Native circular structure & Set/Map support |
| import get from 'lodash/get' | import { get } from 'stralo/deep' | Strongly typed string path autocomplete |
| import merge from 'lodash/merge' | import { deepMerge } from 'stralo/deep' | Prototype pollution guarded by default |
| import flow from 'lodash/flow' | import { pipe } from 'stralo/fp' | Variadic argument type preservation |
| import debounce from 'lodash/debounce' | import { debounce } from 'stralo/fp' | Exposes .cancel() and .flush() |
Target Support Matrix
- Runtimes: Node.js >= 18.0.0, Bun >= 1.0, Deno >= 1.30, Edge Workers (Cloudflare, Vercel Edge).
- Browsers: ES2022+ targets (Chrome >= 104, Safari >= 15.4, Firefox >= 102).
- Module Formats: Dual Dual ESM (
.mjs) & CommonJS (.cjs) outputs with native type declarations (.d.ts).
License
MIT © stralo Authors
