Newton's Programmatic Measurements

# npm

## bambi

1.6.2 • Public • Published

# bambi

Like a ram, but softer

## API

``````adjust: (a -> b) -> Int -> [a] -> [b]
``````

### always

``````always: a -> () -> a
``````

Returns a function that always returns the passed in value.

### assoc

``````assoc: a -> string -> Obj -> Obj
``````

Returns a shallow copy of the object, with the key associated with the value

### both

``````both: (a -> Boolean) -> (a -> Boolean) -> a -> Boolean
``````

### clone

``````clone: a -> a
``````

Performs a shallow clone of an array or object.

### compose

``````compose: (b -> c) -> (a -> b) -> (a -> c)
``````

Composes functions together into a single unary function, calling the passed in functions right-to-left order.

### composeP

``````composeP: (b -> Promise<c> | c) -> (a -> Promise<b> | b) -> (Promise<a> | a) -> Promise<c>
``````

Composes functions that may or may not return a promise into a function that returns a promise, given a value

### cond

``````cond: ([[(a -> boolean), (a -> b)]]) -> a -> b
``````

Applies the transformation function given at the first predicate that returns truthy

### curry

``````curry: ((a, b) -> c) -> (a -> b -> c)
``````

Returns a wrapped version of the passed in function, returning functions until all of the arguments are given.

### dec

``````dec: number -> number
``````

Returns the number passed in minus 1

### deepClone

``````deepClone: a -> a
``````

Performs a deep cloning of an object, recursively until getting to primitives.

### deepMerge

``````deepMerge: a -> a -> a
``````

Recursively merges keys on the objects.

### defaultTo

``````defaultTo: a -> b -> a | b
``````

Returns the passed in value if that value is not `null` or `undefined`. Returns the default value is not

### defer

``````defer: Array<a> -> (a -> b) -> () -> b
``````

Returns a function that will apply a function with the given arguments

### dissoc

``````dissoc: string -> Obj -> Obj
``````

Returns a shallow copy, with the given key deleted

### equals

``````equals: a -> b -> Boolean
``````

Returns whethere both values are strictly equal or not

### F

``````F: () -> boolean
``````

Returns `false`

### gt

``````gt: number -> number -> boolean
``````

Returns whether the first value is greater than the second

### gte

``````gte: number -> number -> boolean
``````

Returns whether the first value is greater or equal to the second

``````head: Array<a> -> a
``````

Returns the first item in the list or undefined if empty

### identity

``````identity: a -> a
``````

Returns the passed in value

### ifElse

``````ifElse: (a -> boolean) -> (a -> *) -> (a -> *) -> a -> *
``````

Returns the value of the second argument if the first function returns truthy, returns the third argument if not

### inc

``````inc: number -> number
``````

Returns the number plus one

### inserts

``````insert: a -> number -> Array<a> -> Array<a>
``````

### is

``````is: (Constructor | string) -> a -> Boolean
``````

Returns if the passed in value is of the same type as the passed in constructor or if the `typeof` of the passed in value is the same as the passed in string type.

### isNil

``````isNil: a -> Boolean
``````

Returns true if passed `undefined` or `null`. Returns false otherwise

### lens

``````lens: (a -> *) -> (* -> a) -> Lens
``````

Returns a `Bambi`-style `lens` object for using in `set`, `over`, and `view`.

### lensPath

``````lensPath: [string | number] -> Lens
``````

Returns a `Babmi`-style `lens` at the given path

### lensProp

``````lensProp: string | number -> Lens
``````

### lt

``````lt: number -> number -> boolean
``````

Returns true if the first value is less than the second, false if otherwise

### lte

``````lte: number -> number -> boolean
``````

### map

``````map: (a -> b) -> Iterator -> Iterator
``````

Iterates over a data structures items and applies the passed function to each

### not

``````not: (a -> b) -> args -> Boolean
``````

Returns a function that returns the opposite Boolean value as the passed in function

### over

``````over: Lens -> (a -> b) -> * -> *
``````

Returns the data structure passed in, with the value at the `lens` updated

### omit

``````omit: (Array<string>) -> a -> a
``````

Returns a shallow copy of the passed in object, with the given keys removed

### once

``````once: (* -> *) -> * -> *
``````

Returns a function that will call the passed in function only once, always returning the given value

### path

``````path: Array<string|number> -> DataStructure -> a
``````

Returns the value at the path, walking the data structure

### pathEq

``````pathEq: Array<string | number> -> a -> b -> Boolean
``````

Returns whether or not a path is equal to a value inside of an object or not

### pathOr

``````pathOr: a -> Array<string|number> -> DatStructure -> a
``````

Returns the value at the path or the passed in default

### pipe

``````pipe: (a -> b) -> (b -> c)
``````

Returns a function that is the functions passed in, called in right-to-left order.

### pipeP

``````pipe: (a -> Promise<b> | b) -> (b -> Promise<c> | c) -> (Promise<a> | a) -> Promise<c>
``````

### prop

``````prop: (string|number) -> DataStructure -> a
``````

Returns the value at the given key

### propEq

``````propEq: (string | number) -> a -> b -> Boolean
``````

Returns whether or not a prop is equal to a value inside of an object

### propOr

``````propOr: a -> (string|number) -> DataStructure -> a
``````

Returns the value at the prop or the default

### random

``````random: number -> number -> Integer
``````

Returns a random number between the min/max inclusively.

### reduce

``````reduce: (a -> b -> c) -> a -> a[] -> c
``````

Reduce a list into a single value given a reducer function.

### reverse

``````reverse: (Array<a> | string) -> Array<a> | string
``````

Returns a shallow copy of the passed in list or string but in reverse order

### T

``````T: () -> boolean
``````

Returns `true`

### tail

``````tail: Array<a> -> Array<a>
``````

Returns all but the first item in the list

### set

``````set: Lens -> * -> a -> a
``````
``````const data = { name: 'Tim', age: 29 }
const nameLens = lensProp('name')
const updated = set(nameLens, 'Joh', data) // { name: 'John', age: 29 }
``````

Sets the value at the location pointed to by the lens.

### uniq

``````uniq: Array<T> -> Array<T>
``````

Returns a copy of the passed in array, with only unique values.

### uppercase

``````uppercase: string -> string
``````

Returns the uppercased version of the passed string

### view

``````view: Lens -> a -> *
``````

Allows for reading or viewing of a Bambi-style lens

### zip

``````zip: (a -> b -> c) -> [a] -> [b] -> [c]
``````

Mixes two arrays by a given function

## Keywords

none

### Install

`npm i bambi`

### Repository

github.com/beardedtim/bambi

27

1.6.2

MIT

347 kB

121