0.0.15 • Published 10 years ago

carrying v0.0.15

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
10 years ago

Carrying

Build Status

A functional JavaScript library that carries you towards happier and better code.

Why?

Because JavaScript (as is at the moment) lacks some great functions built into the language. A lot of other languages provides similar functions that this library provides. Mainly functional languages, which this library has taken it's inspiration from. So this is simply a functional JavaScript library which provides some useful functions that JavaScript currently lacks.

Installation

npm install --save carrying

Usage

Just import the functions you want to use:

import {concat, intersperse, uncons, range, transpose} from 'carrying'

uncons(range(1, 11)) // => [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10]]
uncons([1, 2, 3]) //=> [[1], [2, 3]]
uncons([]) //=> undefined

uncons('abc') //=> [['a'], ['b', 'c']]
uncons('ze') // => [['z'], ['e']]
uncons('q') // => ['q']
uncons('') //=> undefined

range(1, 3) // => [1, 2]
range(5, 11) // => [5, 6, 7, 8, 9, 10]

range(10, 9) // => []
range(2, 2) // => []

range(1, 10, 2) // => [1, 3, 5, 7, 9]

transpose([[1, 2, 3], [4, 5, 6]]) // => [[1, 4], [2, 5], [3, 6]]
transpose([[10, 11], [20], [], [30, 31, 32]]) // => [[10, 20, 30], [11, 31], [32]]

concat(intersperse(' ', ['intersperse', 'is', 'a', 'fun', 'function', '!'])) // => 'intersperse is a fun function !'

Any carrying module can be imported individually if you prefer that:

import {takeWhile} from 'carrying/lib/takeWhile'

takeWhile(a => a < 3, [1, 2, 3, 4, 1, 2, 3, 4]) // => [1, 2]

Documentation

Documentation is available online at: http://drager.github.io/carrying/

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago