@chocolab/functional
TypeScript icon, indicating that this package has built-in type declarations

1.0.4-alpha.0 • Public • Published


deps dev-deps chat Maintainability Codacy Badge License: GPL v3 npm version npm size npm downloads npm vulnerabilities


@chocolab/functional

Functional utilities.

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

Readme

Keywords

none

Package Sidebar

Install

npm i @chocolab/functional

Weekly Downloads

1

Version

1.0.4-alpha.0

License

MIT

Unpacked Size

16.1 kB

Total Files

27

Last publish

Collaborators

  • jefer94