Ramdasauce
Adds a few utilities based on the delicious Ramda library.
Installing
npm i ramdasauce --save
- Depends on
ramda 0.21.+
. - Targets ES5.
- Built with ES6.
Usage
Here's the quick list of functions and a simple example.
import RS from 'ramdasauce'
RS.toDate(1e12)
RS.toNumber('5')
const x = {a: 1, b: 2, c: {x: [5, 6]}}
RS.mapKeys(R.toUpper, x)
RS.dotPath('c.x.0', x)
RS.rangeStep(2, 2, 10)
RS.findByProp('id', 'a', [{id: 'a', id: 'b'}])
RS.findIndexByProp('id', 'a', [{id: 'a', id: 'b'}])
RS.isUndefined(qwerty)
RS.isNotNil(null)
RS.isNilOrEmpty(null)
RS.isWithin(1, 2, 2)
RS.isNotWithin(1, 2, 100)
RS.eqLength([1,2,3], 'abc')
RS.startsWith('h', 'hi')
RS.endsWith('i', 'hi')
RS.random(68, 70)
RS.sample(['red', 'blue'])
RS.log('x')
RS.trace('x', 1)
Tips For Debugging
import R from 'ramda'
import RS from 'ramdasauce'
R.pipe(
R.concat('!!')
RS.log,
R.toLower
)('HI')
R.pipe(
RS.trace('here'),
R.toLower
)('HI')
Prior Art
Most of these functions were lifted from stuff I wrote in real projects.
(leans in and whispers)
I did look at these tho:
Philosophy
These helper functions target that sweet spot between:
Not right for ramda
core.
and
Would never be used outside your app.
Functions being added here must be used in an app. Preferable more than once.
I hope this library won't turn into something like this:
RS.portmanteau('functor', 'wrecked')
RS.yearsForAnimalInAsianCalendars('monkey')
Feedback
Do you have any common ramda
patterns you use frequently? Drop some issues or PRs in!
Release Notes
1.2.0 - February 6, 2017
- Updates
isWithin
to play nice with Webpack - @hubciorz (#7) - Bumped dependencies - @skellock (#8)
1.1.1 - August 17th, 2016
1.1.0 - June 16th, 2016
1.0.0 - April 3rd, 2016