A modern functionnal programming library based on 101. (This library is still in developpment.)
Run npm install 102f
To add this npm package to your local machine, type the above into your command line.
Youβll notice a node_modules directory appear in your root where the package is now installed.
Apply a function to an argument list.
Parameters
fn: function
args: array
Returns: any
Example:
let apply = require('102f/src/apply')
let arr = [0, 1, 2, 3]
apply(Math.max, arr) // 3
Performs right-to-left function composition.
Parameters
f: function
g: function
Returns: function
Example:
let compose = require('102f/src/compose')
var f = function(x){ return x * x}
var g = function(x){ return x + 2}
let composed = compose(f,g)
Returns a curried equivalent of the provided function.
Parameters
f: function
Returns: function
Example:
let multiply = require('102f/src/multiply')
var multiplyFunction = function(x,y) { return x * y }
var curried = curry(f)
curried(2)(3) //6
Returns true if the parameter is empty.
Parameters
val: any
Returns: boolean
Example:
let isEmpty = require('102f/src/isEmpty')
var val = '';
isEmpty(val) // true
Returns true if the argument is an Integer.
Parameters
val: any
Returns: boolean
Example:
let isInteger = require('102f/src/isInteger')
var val = 15;
isInteger(val) // true
Returns true if the argument is a Number.
Parameters
val: any
Returns: boolean
Example:
let isNumber = require('102f/src/isNumber')
var val = 15.3;
isNumber(val)
Parameters
f: function
array: Array
Returns: Array
Example:
let map = require('102f/src/map')
var array = [0,1,2,3]
var result = map(x => x * 2, array) //[0,2,4,6]
Returns a new Functor.
Returns: Container
Returns the multiplication of two Numbers.
Parameters
a: Number
b: Number
Returns: Number
Example:
let multiply = require('102f/src/multiply')
var a = 2
var b = 3
var result = multiply(a)(b) //6
Returns a new Container
Parameters
arg: any
Returns: Container
Example:
let newContainer = require('102f/src/newContainer')
var Container1 = newContainer(2) //Container { _value: 2 }