Bobda
It's an add-on module for Ramda, so all functions are curry.
Table of Contents
Installation
$ yarn add bobda
or
$ npm install bobda
Documentation
Async Functions
promiseMap
promiseMap(asyncFn : Function, array : Array): Promise
This function allows to apply a map but with an asynchronous function
Arguments
asyncFn: The asynchronous function who whant to apply
array: The array who want to apply a map
Exemple
const promiseMap = ; const squareAsync = async ; const array = 2 3 4 5;array; //=> Promise
promiseAll
promiseAll(array : Array<Promise>): Promise
This function allows you to wait until all the promises contained in an array are resolved
Arguments
array: The array of promise
Exemple
const R = ;const promiseAll = ; const incrementAsync = async ; const squareAsync = async ; const value = 2;value; //=> Promise
promiseProps
promiseProps(object : Object): Promise
This function allows you to wait until all the promises contained in an object as key are resolved
Arguments
object: The array of promise
Exemple
const R = ;const promiseProps = ; const incrementAsync = async ; const squareAsync = async ; const value = 2; value //=> Promise
Object properties functions
renameProp
renameProp(from : String ,to : String): object
This function allows you to rename a prop into the given object.
Argments
- from : Name of the prop you want to rename
- to : New name you want to give to this prop
- object : This function is curried by default, last argument (not explicitly given) is the object
Exemple
const myAwesomeObj = prop1 : 'chapi' prop2 : 'chapo'const myAwesomePipe = R /* =>{ readTheDoc : 'chapi', prop2 : 'chapo'} */
Note Read test for other examples.
renamePath
renamePath(from : [String] ,to : [String]): object
This function allows you to rename a path into the given object.
Argments
- from : Name of the path you want to rename
- to : New name you want to give to this path
- object : This function is curried by default, last argument (not explicitly given) is the object
Exemple
const myAwesomeObj = prop1 : 'chapi' prop2 : chapo : patapo : true const myAwesomePipe = R /* =>{ prop1 : 'chapi', chapi : { chapo : { patapo : true } }} */
Note Read test for other examples.
multiPath
multiPath(mappingRename : [[[String],[String]]] ,object : Object): object
Argments
- mappingRename : Name of the path you want to rename
- object : New name you want to give to this path
This function take list of tuples and recursively replace the path [0] with the path [1] into the given object.
Exemple
const listOfPaths = 'une' 'souris' 'verte' 'qui' 'courait' 'dans' 'l' 'herbe' 'je' 'la' 'montre' 'a' 'ces' 'messieurs'; const inObj = une: souris: verte: true l: herbe: false a: ces: 0; /* =>{ qui: {courait: {dans: true}}, je: {la: {montre: false}}, messieurs: 0, a: {}, l: {}, une: {souris: {}}}; */
Note
Read test for other examples.