3.4.1 • Published 3 years ago

fkit v3.4.1

Weekly downloads
70
License
MIT
Repository
github
Last release
3 years ago

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:

  • Why reinvent the wheel? FKit provides many functions for solving everyday problems to do with functions, arrays, objects, and strings.

  • FKit treats both strings and arrays as lists, which means you can apply the same list functions to both strings and arrays (e.g. head, tail, map, filter, fold, etc).

  • Most FKit functions are already curried by default, so you can partially apply them wherever you need to.

  • The ordering of arguments to FKit functions is carefully designed to be more natural, this makes them highly composable.

  • It's very compact, roughly 3 KB when minified and gzipped!

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.

3.4.1

3 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.17.1

6 years ago

0.17.0

6 years ago

0.16.3

6 years ago

0.16.2

9 years ago

0.16.1

9 years ago

0.16.0

9 years ago

0.15.0

10 years ago

0.14.0

10 years ago

0.13.1

10 years ago

0.13.0

10 years ago

0.12.0

10 years ago

0.11.1

10 years ago

0.11.0

10 years ago

0.10.0

10 years ago

0.9.0

10 years ago

0.8.2

10 years ago

0.8.1

10 years ago

0.8.0

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.0

10 years ago

0.5.4

10 years ago

0.5.3

10 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.6

10 years ago

0.4.5

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.4

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.1.0

10 years ago