Home

Awesome

<h1 align="center"><img alt="FKit" src="https://raw.githubusercontent.com/nullobject/fkit/master/logo.png" width="256px" /></h1>

Build Status

FKit (pronounced eff-kit) is a functional programming toolkit for JavaScript. It provides many functions for solving common problems with functions, objects, arrays, and strings. It aims to provide reusable building blocks while maintaining a laser focus on everyday utility.

Features:

Table of Contents

Getting Started

Node

Install the npm package:

> npm install fkit

Import just the functions you need:

import { add } from 'fkit'
console.log(add(1, 2))

Or import the whole library:

import * as F from 'fkit'
console.log(F.add(1, 2))

Browser

The easiest way to start using FKit in your browser is to include it with a <script> tag in your HTML file:

<script src="https://unpkg.com/fkit/dist/fkit.min.js"></script>

Documentation

Examples

Sum the numbers in a list:

import { sum } from 'fkit'
sum([1, 2, 3]) // 6

Stash a string:

import { map, surround } from 'fkit'
map(surround('{', '}'), 'hello') // '{h}{e}{l}{l}{o}'

Intersperse the numbers in a list with another number:

import { intersperse } from 'fkit'
intersperse(4, [1, 2, 3]) // [1, 4, 2, 4, 3]

Filter the numbers in a list where 1 <= n <= 5:

import { between } from 'fkit'
[1, 2, 3, 4, 5].filter(between(2, 4)) // [2, 3, 4]

Calculate the Cartesian product of two lists:

import { cartesian } from 'fkit'
cartesian([1, 2], [3, 4]) // [[1, 3], [1, 4], [2, 3], [2, 4]]

Calculate the permutations of a list:

import { permutations } from 'fkit'
permutations('abc') // ['abc', 'bac', 'cba', 'bca', 'cab', 'acb']

Check out some more examples:

Licence

FKit is licensed under the MIT licence. See the LICENCE file for more details.