Install
yarn add @chocolab/functional
Usage
import { capitalizeFirstLetter, compose, filterObject, memo, toSnakeCase, url } from '@chocolab/functional'
// Capitalize first letter
capitalizeFirstLetter('pain') // return 'Pain'
function add(n) {
return n + n
}
function square(n) {
return n * n
}
function cube(n) {
return n * n * n
}
// Compose
compose(cube, square, add)(2) // return 128
const game = {
top: 'Jax',
jg: 'Camille',
mid: 'Kassadin',
adc: 'Jhin',
support: 'Bard'
}
// Filter object
filterObject(game, ['adc', 'support'])
/*
* return {
* adc: 'Jhin',
* support: 'Bard',
* }
*/
// Memo
memo('pokemon potato', game)
memo('pokemon potato') // return game
// Camel case to snake case
toSnakeCase('pokemonPotato') // return 'pokemon_potato'
// URL
url('google.co.ve', '/path', '/subpath') // return 'google.co.ve/path/subpath'
Maintainers
jefer94 |