Tiny functional programming suite for JavaScript.
The missing standard library for JavaScript. This lightweight library is meant to fill the gap between Ramda (functional) and Lodash (performance) while providing you with the tools you need to write sane JavaScript. This means that all functions treat data as immutable structures, compare objects by value instead of by reference, and offer the right mix of flexibility and composability.
Redash is designed to encourage functional programming styles without sacrificing the utility you're used to. What sets it apart is that, unlike some other libraries that simply offer FP-ish wrappers, functional programming is a first class citizen in Redash. Here's what that means for you:
get('foo.bar.baz')
becomes getIn(['foo', 'bar', 'baz'])
, which is closer to Ramda's path(['foo', 'bar', 'baz'])
. This helps to eliminate confusion for less common cases that are nevertheless valid.The Redash codebase is written with ES2015 modules and packaged with rollup so you to take advantage of tree shaking without the need for extra tooling. Redash also offers complete typings for TypeScript users so that you can work with its API with complete confidence.
# Yarn (Recommended)
yarn add redash
# NPM (Alternative)
npm install --save redash
After that's done, just import it in your code and get on to building awesome stuff. If you haven't already done so, you should check out the API documentation to see what functions are available and learn how to use them. Here are a few of the most common ways to use Redash:
import * as _ from 'redash' // import everything
import { map, get } from 'redash' // or just what you need
const _ = require('redash') // import everything
const { map, get } = require('redash') // or just what you need
If you have full control over your codebase and don't want to continually import/prefix all of the functions, you can install the library to a context.
import install from 'redash/installer'
install(global)
// Now all of the functions are available on the scope you installed it to:
get('name', { name: 'Michael' }) // => 'Michael'
Category | Redash | Ramda | Lodash | Lodash/FP |
---|---|---|---|---|
Minified (kb) | 12.6 | 44.7 | 71.4 | 71.4 |
100% Immutable | Yes | Yes | No | Yes |
Auto-Curry | No | Yes | No | Yes |
Object Equality | Value | Value | Reference | Reference |
IE 9+ | Yes | Yes | Yes | Yes |