Coder Social home page Coder Social logo

fp's Introduction

fp λ

Readable, debbuggable & fast ES6 Functional Programming

fp offers a collection of usefull functions :

  • compose, curry, partial higher-order functions
  • map function to iterate over any object
  • not, arity & path helper functions to use with compose & map
  • identity, constant, noop & other utilities functions

Usage

Source are written as ES6 modules, just include the sources

  • import fp library
import fp from 'fp/src'
  • import fp.compose function
import compose from 'fp/src/compose'

! source functions are not auto curried

fp.js file is an ES5 umd bundle (including amd, commonjs & global definitions)

amd

define(['fp'], function (fp) { ... })

commonjs

var fp = require('fp')

global

global.fp // just `fp` or `window.fp`

Tests

partial, curry & compose functions are unit-tested, to run all tests :

npm test

or run tests for a specific function :

npm run test:partial
npm run test:curry
npm run test:compose

Benchmarks

curry function is benchmarked against Ramda and Lodash implementations, to run benchmarks :

npm run bench

curried functions are 1.7× faster than Lodash and 7× faster than Ramda ;) not true anymore

Documentation

doc function allow to get Hindley-Milner signature of every fp function

console.log(fp.doc(fp.compose))

Contribute

Clone & rollup

git clone [email protected]:adriengibrat/fp.git
cd fp
npm install --no-optional # optional dependencies are only used for benchmarks
npm start # watch `src` directory and bundle `fp.js` on change

Platform support

This library assumes an ES5 environment, it may be supported in older browsers : add ES5 shims in your js dependencies or include Polyfills script in your html <script src="https://cdn.jsdelivr.net/polyfills/polyfill.js+es5"></script>.

Credits & inspirations

In no particular order :

Licence

Copyright © 2016 Adrien Gibrat.

Released under the MIT licence.

fp's People

Contributors

adriengibrat avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tomhorak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.