Skip to content

All your standard libraries will be assimilated into our JavaScript collective. Resistance is futile.

License

Notifications You must be signed in to change notification settings

coderofsalvation/locutus

 
 

Repository files navigation

Locutus

Join the chat at https://gitter.im/kvz/locutus Build Status

Locutus other languages' stadard libraries to JavaScript for fun and educational purposes

More info at: http://locutusjs.io/about

Install

npm install --save --save-exact locutus

For ease of development, we recommend these global installs:

npm install --global mocha babel-cli

Use

${EDITOR} try.js
var php = require('locutus/php/strings/sprintf')
var effectiveness = 'futile'
php.echo(php.sprintf('Resistance is %s', effectiveness))
var strings = require('locutus/golang/strings')
console.log(strings.Contains('Locutus', 'cut'))
$ node try.js
Resistance is futile
true

Test

npm run test

Single out one function: natsort

TEST_GREP=natsort npm run test:languages

This startes by rewriting the test-cases, which is useful if you're changing the tests themselves as well. If that's not needed as you're iterating purely on the implementation, here's a speedier way of singling out natsort:

env DEBUG=locutus:* mocha \
  --compilers js:babel-register \
  --reporter spec \
test/languages/php/array/test-natsort.js

Website

We keep the website in ./website for so it's easy to keep docs & code in sync. For those reading this screaming murder, HashiCorp does this for all their projects, and it's working pretty well for them on a scale more impressive than ours.

Our website is built with Jekyll.

To install the prerequisites type npm run website:start.

Here's the flow that takes written functions to the website:

  • npm run website:inject runs src/_util/util.js's injectweb method
  • injectweb iterates over functions and parses them via the _load and _parse methods, specifically: the header comments that declare authors, tests, and dependencies
  • injectweb then writes each function to website/_functions. This is a Jekyll Collection. The code is written as the content. The other parsed properties are prepended as YAML front matter
  • Jekyll uses website/_layouts/function.html as the layout template for the function collection, this determines how all the properties are rendered.

Blog posts can be found in website/_posts.

At the time of writing, the Jekyll Asset pipeline is in a bad place, and so SASS / ES6 asset transpiling is handled separately via npm scripts. Unfortunately we don't have the theme of the website in SASS, so it's included in app.scss as a plain CSS _screen.scss file for now. You can find all the transpiling options in website/package.json.

If you want to preview locally use npm run website:start.

Typing npm run website:deploy in the root of the project takes care of all the building steps, and then force pushes the generated HTML to the gh-pages branch of this repo.

Sponsor development

Gittip donate button Flattr donate button PayPal donate button BitCoin donate button

About

All your standard libraries will be assimilated into our JavaScript collective. Resistance is futile.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 48.0%
  • HTML 46.2%
  • CSS 5.4%
  • Other 0.4%