Functor
class Functor is the primitive class for composing higher functor based class. This class wrap Ramda for providing Functional programming style method.
Example:
import { Functor } from 'causal-net.core';
(async ()=>{
let functor = new Functor();
console.log(functor.range(10));
console.log(functor.zeros(10));
console.log(functor.ones(10));
})();
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public get |
CoreFunctor: * This method return core Ramda instance |
Private Members | ||
private |
R: * |
|
private |
logger: * |
Method Summary
Public Methods | ||
public |
enumerate(array: *): * |
|
public |
getIn(keys: Array , item: Object , defaultValue: Any ): Any |
|
public |
ones(range: *): * |
|
public |
range(size: Array ): [Array] Return an array with the given range |
|
public |
setIn(keys: Array , value: Object , item: Object ): Any set value into object by the keys list |
|
public |
unzip(pairs: Array ): [Array1, Array2] Unzip array of pairs to two arrays |
|
public |
zeros(range: *): * |
|
public |
zip(pairs: Array ): Array zip two array |
Public Constructors
public constructor() source
Public Methods
public getIn(keys: Array , item: Object , defaultValue: Any ): Any source
Params:
Name | Type | Attribute | Description |
keys | Array | ||
item | Object | ||
defaultValue | Any | return value in case of not found |
Return:
Any | return found value or defaultValue |
public range(size: Array ): [Array] source
Return an array with the given range
Params:
Name | Type | Attribute | Description |
size | Array | array of pairs to unzip |
Return:
[Array] | arrays from [beginAt, ...size] |
public setIn(keys: Array , value: Object , item: Object ): Any source
set value into object by the keys list
Params:
Name | Type | Attribute | Description |
keys | Array | ||
value | Object | ||
item | Object | item to set |
Return:
Any | return found value or defaultValue |
public unzip(pairs: Array ): [Array1, Array2] source
Unzip array of pairs to two arrays
Params:
Name | Type | Attribute | Description |
pairs | Array | array of pairs to unzip |
Return:
[Array1, Array2] | two arrays |
public zip(pairs: Array ): Array source
zip two array
Params:
Name | Type | Attribute | Description |
pairs | Array | two arrays to zip |
Return:
Array | array after zip |