What is locutus?
Locutus is a JavaScript library that provides a collection of functions from various programming languages like PHP, Python, Ruby, and Go. It allows developers to use these functions in JavaScript, making it easier to port code from these languages to JavaScript or to use familiar functions in a JavaScript environment.
What are locutus's main functionalities?
PHP Functions
Locutus provides a variety of PHP functions that can be used in JavaScript. For example, the `strlen` function from PHP can be used to get the length of a string.
const { strlen } = require('locutus/php/strings');
console.log(strlen('Hello World')); // Output: 11
Python Functions
Locutus includes functions from Python, such as the `len` function, which returns the length of an array.
const { len } = require('locutus/python');
console.log(len([1, 2, 3, 4])); // Output: 4
Ruby Functions
Locutus also offers Ruby functions. For instance, the `capitalize` function from Ruby can be used to capitalize the first letter of a string.
const { capitalize } = require('locutus/ruby/strings');
console.log(capitalize('hello world')); // Output: 'Hello world'
Go Functions
Locutus includes functions from Go, such as the `parseInt` function, which can be used to parse a string and return an integer.
const { parseInt } = require('locutus/go/strconv');
console.log(parseInt('42', 10)); // Output: 42
Other packages similar to locutus
underscore
Underscore is a JavaScript library that provides utility functions for common programming tasks. It offers a wide range of functions for manipulating arrays, objects, and other data types. Unlike Locutus, which ports functions from other languages, Underscore is designed specifically for JavaScript.
lodash
Lodash is a modern JavaScript utility library delivering modularity, performance, and extras. It provides a wide range of utility functions for common programming tasks, similar to Underscore but with additional features and optimizations. Lodash is focused on JavaScript and does not port functions from other languages like Locutus.
ramda
Ramda is a functional programming library for JavaScript that emphasizes immutability and side-effect-free functions. It provides a wide range of utility functions for functional programming. Unlike Locutus, which ports functions from other languages, Ramda is designed specifically for functional programming in JavaScript.
Locutus
All your standard libraries will be assimilated into our JavaScript collective. Resistance is futile.
Welcome to Locutus, where the boundaries of coding languages blur. We're a dedicated collective developers on a mission
to explore the possibilities of porting standard libraries from various programming language (Go, Ruby, PHP, C) to
JavaScript. Our journey is one of discovery, innovation, and sometimes, delightful chaos.
From the complex to the quirky, we assimilate libraries with a spirit of curiosity and a penchant for experimentation.
Our creations typically start as rainy Sunday afternoon puzzles, and end up ranging from groundbreaking functions that
enhance the JavaScript ecosystem, to unique oddities that challenge the norms of coding.
As we navigate through this uncharted territory, we invite you to join us. Whether to contribute, learn, or simply
marvel at the wonders of cross-language integration and portability, your presence on GitHub is valued.
Embark on this journey with us at locutus.io.
Use our creations at your own risk, and may they inspire you to push the boundaries of what's possible with JavaScript.
Table of contents
Install
yarn add locutus
Use
$ vim php.js
const sprintf = require('locutus/php/strings/sprintf')
const echo = require('locutus/php/strings/echo')
const effectiveness = 'futile'
echo(sprintf('Resistance is %s', effectiveness))
$ node php.js
Resistance is futile
$ vim go.js
const strings = require('locutus/golang/strings')
console.log(strings.Contains('Locutus', 'cut'))
$ node go.js
true
Development
Some guidelines and instructions can be found in CONTRIBUTING.md