npm package of individually importable TypeScript functions that reimplement standard-library behavior from PHP, Go, Python, Ruby, and other languages.
Overview
Locutus brings standard-library functions from other programming languages into TypeScript. Each routine is published as its own importable module so bundlers can tree-shake unused code, rather than pulling in a monolithic utility layer.
Hundreds of functions cover namespaces such as PHP strings and arrays, Go time and strings, Python math and itertools, Ruby collections, and additional languages including Perl, Lua, R, Rust, and Haskell. The project ports semantics and behavior while keeping JavaScript-native values at the API boundary, without recreating foreign data structures or runtime models in TypeScript.
Install via npm using deep paths per function, which is recommended for size-sensitive browser builds instead of importing whole category indexes. Optional PHP compatibility treats plain objects as associative arrays when locutus.objectsAsArrays is enabled. Published output targets modern Node and ES2022 module formats; snippets on function pages may need transpilation or polyfills on older browsers.
Locutus is not positioned as a broad drop-in utility framework like lodash; it fits when you need parity with another language’s stdlib call or a single familiar function. Function pages document maturity so adopters can judge fitness before use.
Key features
- Per-function deep npm imports
- Ports from many programming languages
- Tree-shakeable modular layout
- JavaScript-native API values
- PHP objects-as-arrays mode
- Browser and Node consumption
- MIT-licensed core functions
- Community-maintained function catalog
Use cases
- PHP-style string formatting in TypeScript
- Go or Python stdlib parity in JS
- Single-function browser bundles
- Learning cross-language stdlib design
- Legacy API behavior in new codebases