Use a familiar PHP string or array function directly in JavaScript by importing just that one function from Locutus.
Port a PHP or Python script to JavaScript faster by relying on Locutus equivalents for standard library functions you already know.
Import a single Go-style date-formatting function into a TypeScript project without pulling in the entire library.
Learn how standard library functions from PHP, Python, Go, or Ruby work by reading the JavaScript port implementations.
Import functions by direct file path rather than by category index to keep your bundle size small.
Locutus is a TypeScript library that reimplements standard library functions from other programming languages. It brings about 500 functions from PHP, Python, Go, Ruby, and C into the JavaScript and TypeScript world, so you can call familiar patterns from those languages directly in your JavaScript or TypeScript code. Each function is separately importable, meaning your build tool can strip out the ones you do not use. The project's design philosophy is to port the behavior of each function without bringing along the underlying data structures that belong to the original language. For example, a port of a Go date-formatting function accepts a standard JavaScript Date object rather than a Go-specific time object. The idea is to get the same results as the source language while keeping the API natural for JavaScript users. The one exception is PHP, which has optional support for treating plain JavaScript objects as associative arrays to match PHP behavior more closely. You install it through npm with a single command. The recommended way to import functions is by path to the specific function you want, rather than importing an entire category index. This keeps bundle sizes small for browser applications where every extra kilobyte matters. The project started as a collection of programming puzzles and learning exercises. The maintainers note that some of these functions have genuine practical uses while others are simply interesting to write. Cross-language verification tests run against PHP 8.3 and Python 3.12 to confirm that the ports produce the same results as the originals. The library is MIT licensed, with a small exception for the PHP bcmath-related code, which carries an LGPL-2.1 license due to its origin in the PHP bcmath library.
← locutusjs on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.