Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cali

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cali

A FP-style lib

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
increased by1350%
Maintainers
1
Weekly downloads
 
Created
Source

Cali

A JS utility library in FP style

Installation

npm install cali

To be used in browsers, babel-polyfill is required

Usage

the module can be imported by AMD, CommonJS or ES6 loaders, or as the global variable 'cali'

example:

// ES6
import * as cali from 'cali';
// CommonJS
var cali = require('cali');

API

Functions

Curry

takes a function and returns a function that's automatically curried

let curriedSum = curry((a,b,c) => a + b + c);
curriedSum(1)(2)(3) === 6; // true
Identity

takes a value and returns it

let obj = {};
identity(obj) === obj; // true
Compose

composes functions, executes each sequentially starting from the right most function

compose(a => a * 2, a => a + 1)(5) === 12
Map

maps over a collection, automatically curried

map(a => a * 2)([1,2,3]) // [2,4,6]

Functors, Applicative, Monads

Functor

general functor

let functor = new Functor(1);
functor.fmap(a => a * 2) // Functor(2)

function functor

let functor = new Functor(a => a + 1);
let f = functor.fmap(a => a * 2) // f is equivalent to 'compose(a => a + 1, a => a * 2)'
f(2) === (2 + 1) * 2
Maybe

a container may have a value or nothing

Just(2).bind(x => Just(2 * x)) // Just(4)
Just(2).bind(x => Nothing).bind(x => Just(x)) // Nothing

Keywords

FAQs

Package last updated on 22 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc