rubist

Write rubiful JavaScript.


Keywords
Ruby, Polyfill, Functional
License
MIT
Install
npm install rubist@0.0.0

Documentation

Rubist

Write rubiful JavaScript! It's especially useful when writing only expression- allowed things, eg. JSX.

Setup

npm i --save rubist

Examples

// Import rubist in ES5. If using ES201x, use `import 'rubist'`.
require('rubist')
// Yeah! Now you can use special operator `..` for integers!
// No more `for` and `++i`
6..forEach(i => console.log(i)) //=> prints 0, 1, 2, 3, 4, 5
// No more `Array(i).keys().map()`
const squares = 6..map(i => i * i) //=> [0, 1, 4, 9, 16, 25]
// Easily get a range!
10..to(15) //=> [10, 11, 12, 13, 14, 15]
// Control the step!
10..to(15, 2) //=> [10, 12, 14]
// Use only one `.` for floats.
10.5.toInt() //=> 10
// Say `Rubist` every second.
1000..setInterval(() => { console.log('Rubist!') })
// Not only Number, there are more useful shortcuts for other classes.
// Array!
[1, 3, 5].sum() //=> 9
// String!
'123.4'.toFloat() //=> 123.4

Wants more? Let's create a ISSUE or make a PULL REQUEST!

TODO

  • Add tests

License

MIT