-
add(…numbers) → {number}
-
Returns the sum of given arguments.
add() returns 0
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
and(…objs) → {boolean}
-
Variadic wrapper for the && operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
apply(f, args) → {*}
-
Applies a function to an array of arguments.
The first argument must be a function,
the context is set to void 8.
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply |
args |
Array.<*>
|
Arguments for f |
- Source:
- See:
-
Throws:
-
If f is not a function
-
-
Type
-
ArgumentError
Returns:
-
Type
-
*
-
applyWith(f, ctx, args) → {*}
-
Uses context and rebinds 'this',
it applies a function to an array of arguments.
The first argument must be a function,
and the second one the context.
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply |
ctx |
*
|
Binding for the 'this' variable |
args |
Array.<*>
|
Arguments for f |
- Source:
- See:
-
Throws:
-
If f is not a function
-
-
Type
-
ArgumentError
Returns:
-
Type
-
*
-
areArguments(x) → {boolean}
-
Returns true if x is an instance of Arguments
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
ArgumentError(message)
-
ArgumentError error class
Parameters:
Name |
Type |
Description |
message |
string
|
The message to display |
- Source:
-
arity(n) → {function}
-
Use with caution since arity may leads to cryptic errors!
Limit the arguments given to a function.
Parameters:
Name |
Type |
Description |
n |
number
|
Arity |
- Source:
- See:
-
Returns:
-
Type
-
function
Example
//In this example, the two first arguments only are passed to the function add.
arity(2)(add)(2, 7, 6) // returns 9
-
arity0(f) → {function}
-
Arity 0 for function f
Parameters:
Name |
Type |
Description |
f |
function
|
The function to set arity of |
- Source:
- See:
-
Returns:
A function with an arity set at 0
-
Type
-
function
-
arity1(f) → {function}
-
Arity 1 for function f
Parameters:
Name |
Type |
Description |
f |
function
|
The function to set arity of |
- Source:
- See:
-
Returns:
A function with an arity set at 1
-
Type
-
function
-
arity2(f) → {function}
-
Arity 2 for function f
Parameters:
Name |
Type |
Description |
f |
function
|
The function to set arity of |
- Source:
- See:
-
Returns:
A function with an arity set at 2
-
Type
-
function
-
arity3(f) → {function}
-
Arity 3 for function f
Parameters:
Name |
Type |
Description |
f |
function
|
The function to set arity of |
- Source:
- See:
-
Returns:
A function with an arity set at 3
-
Type
-
function
-
assoc(obj, key, value) → {object}
-
Assoc key/value to object.
Equivalent to `obj[k] = v` but doesn't modify obj.
assoc returns a shallow copy of the JS Object
Parameters:
Name |
Type |
Description |
obj |
object
|
|
key |
string
|
number
|
|
value |
*
|
|
- Source:
Returns:
-
Type
-
object
-
attrs(obj) → {object}
-
Returns a JS Object containing all the properties owned by obj.
You may get the attrs of everything.
Parameters:
Name |
Type |
Description |
obj |
*
|
Object to get attributes from |
- Source:
Returns:
A JS Object containing the attributes of obj
-
Type
-
object
-
bind(f, ctx) → {function}
-
Rebinds 'this' for function 'f'
Parameters:
Name |
Type |
Description |
f |
function
|
Function to bind |
ctx |
*
|
Binding for the 'this' variable |
- Source:
Returns:
-
Type
-
function
-
bitand() → {number}
-
Variadic wrapper for the & operator
Parameters:
Type |
Attributes |
Description |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
bitlshift() → {number}
-
Variadic wrapper for the << operator
Parameters:
Type |
Attributes |
Description |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
bitnot() → {number}
-
Variadic wrapper for the ~ operator
Parameters:
- Source:
- See:
-
Returns:
-
Type
-
number
-
bitor() → {number}
-
Variadic wrapper for the | operator
Parameters:
Type |
Attributes |
Description |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
bitrshift2() → {number}
-
Variadic wrapper for the >> operator
Parameters:
Type |
Attributes |
Description |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
bitrshift3() → {number}
-
Variadic wrapper for the >>> operator
Parameters:
Type |
Attributes |
Description |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
bitxor() → {number}
-
Variadic wrapper for the ^ operator
Parameters:
Type |
Attributes |
Description |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
butfirst() → {Array.<*>}
-
Returns all the elements of xs but except first one
butfirst returns a shallow copy of the array elements
Parameters:
Type |
Description |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
Array.<*>
-
butlast() → {Array.<*>}
-
Returns all the elements of xs except the last one
butlast returns a shallow copy of the array elements
Parameters:
Type |
Description |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
Array.<*>
-
call(f, …args) → {*}
-
Applies a function to a variable number of arguments.
The first argument must be a function,
the context is set to void 8.
Parameters:
Name |
Type |
Attributes |
Description |
f |
function
|
|
Function to call |
args |
*
|
<repeatable>
|
Arguments for f |
- Source:
- See:
-
Returns:
-
Type
-
*
-
callWith(f, ctx, …args) → {*}
-
Uses context and rebinds 'this',
It applies a function to a variable number of arguments.
The first argument must be a function,
and the second one is the context.
Parameters:
Name |
Type |
Attributes |
Description |
f |
function
|
|
Function to call |
ctx |
*
|
|
Binding for the 'this' variable |
args |
*
|
<repeatable>
|
Arguments for f |
- Source:
- See:
-
Returns:
-
Type
-
*
-
clone(x) → {*}
-
General purpose clone function.
The objects and arrays are mutable in JS
clone allows to bypass this with ease.
Nonetheless, for the moment, clone is very, very long, use with care.
Parameters:
Name |
Type |
Description |
x |
*
|
Object to clone |
- Source:
- See:
-
Returns:
Returns a clone of x
-
Type
-
*
-
comp(…fs) → {function}
-
Composes functions.
Parameters:
Name |
Type |
Attributes |
Description |
fs |
function
|
<repeatable>
|
Functions to compose |
- Source:
Returns:
-
Type
-
function
Example
comp(partial(add, 1), partial(mul, 2))(2) // returns 5
comp(partial(mul, 2), partial(add, 1), partial(mul, 3))(4) // returns 26
-
complement(f) → {function}
-
Takes a function and returns a function which does the exact thing
except it negates the returned boolean value.
Parameters:
Name |
Type |
Description |
f |
function
|
Function to get complement from |
- Source:
Returns:
Complement function
-
Type
-
function
-
concat(…arrays) → {Array.<*>}
-
Concats several arrays
concat returns a shallow copy of the array elements
Parameters:
Name |
Type |
Attributes |
Description |
arrays |
Array.<*>
|
<repeatable>
|
Arrays to concat |
- Source:
Returns:
-
Type
-
Array.<*>
Example
concat([1, 2, 3], [4, [5, 6]]) // returns [1, 2, 3, 4, [5, 6]]
-
concatMap(f, xs) → {Array.<*>}
-
Map f over xs then concats the result
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply on each element of xs |
xs |
Array.<*>
|
Consumed Array |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
-
concatMapkv(f, obj) → {Array.<*>}
-
Mapkv f over obj then concats the result
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply on each element of obj |
obj |
object
|
Consumed JS Object |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
-
conj(xs, …args) → {Array.<*>}
-
Appends arguments to xs.
conj returns a shallow copy of the array elements
Parameters:
Name |
Type |
Attributes |
Description |
xs |
Array.<*>
|
|
|
args |
*
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
Array.<*>
Example
conj([1, 2], 3) // returns [1, 2, 3]
conj([1, 2], 3, 4, 5) // returns [1, 2, 3, 4, 5]
-
cons(xs, x) → {Array.<*>}
-
Prepends x to xs.
cons returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
|
x |
*
|
|
- Source:
Returns:
-
Type
-
Array.<*>
Example
cons([2, 3], 1) // returns [1, 2, 3]
-
cs(method) → {function}
-
Wrapper for the console object.
The function returned by cs itself returns its arguments.
Parameters:
Name |
Type |
Description |
method |
string
|
The console's method to use |
- Source:
- See:
-
Returns:
The console[method] function
-
Type
-
function
Example
map(inc, cs('log')(1, 2)) // logs [1, 2] then returns [2, 3]
add(cs('log')(1), 2) // logs 1 then returns 3
-
curry(f, aritynullable) → {function}
-
Allows to curry a function.
The arity if by default f.length, but it can be set.
Parameters:
Name |
Type |
Attributes |
Description |
f |
function
|
|
Function to curry |
arity |
number
|
<nullable>
|
|
- Source:
- See:
-
Returns:
Curried function
-
Type
-
function
Examples
var cmap = curry(map)
var mapinc = cmap(inc)
mapinc([1, 2, 3]) // returns [2, 3, 4]
mapinc([2, 3, 4]) // returns [3, 4, 5]
var cadd = curry(add, 3)
cadd(1)(2)(3) // returns 6
cadd(1, 2)(3) // returns 6
cadd(1)(2, 3) // returns 6
cadd(1, 2, 3) // returns 6
-
curry1(f, aritynullable) → {function}
-
Similar to curry but with arity fixed to 1 for each call.
The arity if by default f.length, but it can be set.
Parameters:
Name |
Type |
Attributes |
Description |
f |
function
|
|
Function to curry |
arity |
number
|
<nullable>
|
|
- Source:
- See:
-
Returns:
Curried function
-
Type
-
function
Examples
var cmap = curry(map)
var mapinc = cmap(inc)
mapinc([1, 2, 3]) // returns [2, 3, 4]
mapinc([2, 3, 4]) // returns [3, 4, 5]
var cadd = curry(add, 3)
cadd(1)(2)(3) // returns 6
cadd(1)(2, 3) // wrong: the second argument here is ignored
cadd(1)(2)() // returns NaN (unlike curry, curry1 decreases arity at each call
// So cadd does 1 + 2 + undefined here)
-
cycle(n, xs) → {Array.<*>}
-
Returns an array containing n repetitions of the items in xs
cycle returns an array containing shallow copies of the elements of xs
Parameters:
Name |
Type |
Description |
n |
number
|
|
xs |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
Array.<*>
Example
cycle(3, [1, 2, 3]) // returns [1, 2, 3, 1, 2, 3, 1, 2, 3]
-
dec(x) → {number}
-
Returns a number one less than x
Parameters:
Name |
Type |
Description |
x |
number
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
del(varnames) → {undefined}
-
May be really messy!
Deletes variables in the main scope.
Handy when you want to clean the scope after using fjs variables.
del is a side-effect only function
Parameters:
Name |
Type |
Description |
varnames |
string
|
Array.<(string|object)>
|
= Can be a variable number of strings |
- Source:
- See:
-
Returns:
-
Type
-
undefined
-
dir(…arguments) → {*|Array.<*>}
-
console.dir and returns the given argument(s)
Parameters:
Name |
Type |
Attributes |
Description |
arguments |
*
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
*
|
Array.<*>
-
dir1(obj) → {*}
-
console.dir and returns the first argument given
Parameters:
Name |
Type |
Description |
obj |
*
|
|
- Source:
Returns:
-
Type
-
*
-
div(…numbers) → {number}
-
Divides the first argument with the others.
div() returns 1
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
doc(obj) → {*|undefined}
-
Returns the attribute doc of an object
Parameters:
Name |
Type |
Description |
obj |
*
|
Object to get doc from
Properties
Name |
Type |
Description |
doc |
|
Contains the doc of obj |
|
- Source:
Returns:
Doc (usely a string) or undefined
-
Type
-
*
|
undefined
-
drop(n, xs) → {Array.<*>}
-
Drops the n first elements of xs
drop returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
n |
number
|
|
xs |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
Array.<*>
-
dropWhile(pred, xs) → {Array.<*>}
-
Drops all the items of xs while pred(item) is true
and returns all the remaining items as an Array
dropWhile returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
pred |
function
|
Predicate function |
xs |
Array.<*>
|
Array to consume |
- Source:
- See:
-
Returns:
Filtered Array
-
Type
-
Array.<*>
-
eq(x, y) → {boolean}
-
Returns wether x equals y or not.
eq does a deep comparison of x and y.
Parameters:
Name |
Type |
Description |
x |
*
|
|
y |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
eq2(…objs) → {boolean}
-
Variadic wrapper for the == operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
eq3(…objs) → {boolean}
-
Variadic wrapper for the === operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
eqOne(x) → {boolean}
-
Returns true if x equals 1
Parameters:
Name |
Type |
Description |
x |
number
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
eqZero(x) → {boolean}
-
Returns true if x equals 0
Parameters:
Name |
Type |
Description |
x |
number
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
error(…arguments) → {*|Array.<*>}
-
console.error and returns the given argument(s)
Parameters:
Name |
Type |
Attributes |
Description |
arguments |
*
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
*
|
Array.<*>
-
error1(obj) → {*}
-
console.error and returns the first argument given
Parameters:
Name |
Type |
Description |
obj |
*
|
|
- Source:
Returns:
-
Type
-
*
-
even(x) → {boolean}
-
Returns true if x is even
Parameters:
Name |
Type |
Description |
x |
number
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
every(pred, xs) → {boolean}
-
Applies pred to each items of xs.
If pred(item) is true every time, return true.
Parameters:
Name |
Type |
Description |
pred |
function
|
Predicate function |
xs |
Array.<*>
|
Array to consume |
- Source:
Returns:
-
Type
-
boolean
Example
var f = function(x) { return x == 1 };
every(f, [1, 1, 1, 1]) // returns true
every(f, [1, 1, 1, 2]) // returns false
-
fdrop(xs, n) → {Array.<*>}
-
Flips the arguments given to drop
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
|
n |
number
|
|
- Source:
Returns:
-
Type
-
Array.<*>
-
fget(i, obj) → {*}
-
Flips the arguments given to get
Parameters:
Name |
Type |
Description |
i |
*
|
Index or Key |
obj |
Array.<*>
|
object
|
Array or JS Object |
- Source:
Returns:
-
Type
-
*
-
filter(pred, xs) → {Array.<*>}
-
Returns an array of the items in coll for which pred(x) returns true
fitler returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
pred |
function
|
Function to apply on each element of xs |
xs |
Array.<*>
|
Array to filter |
- Source:
Returns:
Filtered Array
-
Type
-
Array.<*>
-
first(xs) → {*}
-
Returns the first element of xs
first returns a shallow copy of the first array element
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
*
-
flatten(xs) → {Array.<*>}
-
Flattens an ArrayLike object
flatten returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
Argument.<*>
|
ArrayLike object to flatten |
- Source:
- See:
-
Returns:
ArrayLike object flattened
-
Type
-
Array.<*>
-
flip(f) → {function}
-
Flips the arguments given to a function.
Parameters:
Name |
Type |
Description |
f |
function
|
|
- Source:
Returns:
-
Type
-
function
Example
div(10, 2) // returns 5
flip(div)(10, 2) // returns 0.2
-
fmap(xs, f) → {Array.<*>}
-
Flips the arguments given to map
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
Consumed Array |
f |
function
|
Function to apply on each element of xs |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
Example
map(partial(add, 2), [1, 2, 4]) // returns [3, 4, 6]
-
fmapkv(obj, f) → {Array.<*>}
-
Flips the arguments given to mapkv
Parameters:
Name |
Type |
Description |
obj |
object
|
Consumed JS Object |
f |
function
|
Function to apply on each element of obj |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
-
fmapkvo(obj, f) → {Array.<*>}
-
Flips the arguments given to mapkvo
Parameters:
Name |
Type |
Description |
obj |
object
|
Consumed JS Object |
f |
function
|
Function to apply on each element of obj |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
-
fmapo(obj, f) → {Array.<*>}
-
Flips the arguments given to mapo
Parameters:
Name |
Type |
Description |
obj |
object
|
Consumed JS Object |
f |
function
|
Function to apply on each element of obj |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
-
fn(…docs, f) → {function}
-
Create a function with doc
Parameters:
Name |
Type |
Attributes |
Description |
docs |
string
|
<repeatable>
|
Documents string (joined with \\n) |
f |
function
|
|
The function to document |
- Source:
Throws:
-
If f is not a function
-
-
Type
-
ArgumentError
Returns:
Documented function
-
Type
-
function
-
freduce(xs, f, aggnullable) → {*}
-
Flips the arguments given to reduce.
The aggregator remains the third and last argument.
Parameters:
Name |
Type |
Attributes |
Description |
xs |
Array.<*>
|
|
Array to consume |
f |
function
|
|
Reducer function, the first arguments is the aggregator, the second one the next value |
agg |
*
|
<nullable>
|
Defined aggregator |
- Source:
- See:
-
Returns:
Reduced value
-
Type
-
*
Example
freduce([2, 3], mul) // returns 6
freduce([2, 3], mul, 2) // returns 12
-
freducekv(obj, f, aggnullable) → {*}
-
Flips the arguments given to reducekv.
The aggregator remains the third and last argument.
Parameters:
Name |
Type |
Attributes |
Description |
obj |
object
|
|
JS Object to consume |
f |
function
|
|
Reducer function, the first arguments is the aggregator, the second one the next key, the last one the next value |
agg |
*
|
<nullable>
|
Defined aggregator |
- Source:
- See:
-
Returns:
Reduced value
-
Type
-
*
Example
var obj = {foo: 1, bar: 2, baz: 3}
var f = function(agg, _, v) { return agg * v }
freducekv(obj, f, 1) // returns 6
freducekv(obj, f, 2) // returns 12
-
freducer(xs, f, aggnullable) → {*}
-
Flips the argument given to reducer.
The aggregator remains the third and last argument.
Parameters:
Name |
Type |
Attributes |
Description |
xs |
Array.<*>
|
|
Array to consume |
f |
function
|
|
Reducer function, the first arguments is the aggregator, the second one the next value |
agg |
*
|
<nullable>
|
Defined aggregator |
- Source:
- See:
-
Returns:
Reduced value
-
Type
-
*
Example
freducer([3, 2, 10], sub) // returns 5
-
get(obj, i) → {*}
-
Similar to obj[i]
Parameters:
Name |
Type |
Description |
obj |
Array.<*>
|
object
|
Array or JS Object |
i |
*
|
Index or Key |
- Source:
Returns:
-
Type
-
*
-
gt(…objs) → {boolean}
-
Variadic wrapper for the > operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
gte(…objs) → {boolean}
-
Variadic wrapper for the >= operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
id(x) → {*}
-
Returns self
Parameters:
Name |
Type |
Description |
x |
*
|
Object to return |
- Source:
Returns:
Returns x
-
Type
-
*
-
inc(x) → {number}
-
Returns a number one greater than x
Parameters:
Name |
Type |
Description |
x |
number
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
interleave(…arrays) → {Array.<*>}
-
Returns an array of the first item in each array, then the second etc
interleave returns a shallow copy of the array elements
Parameters:
Name |
Type |
Attributes |
Description |
arrays |
Array.<*>
|
<repeatable>
|
Arrays to interleave |
- Source:
Returns:
Interleaved Array
-
Type
-
Array.<*>
Example
interleave([1, 2], [4, 5], [7, 8]) // returns [1, 4, 7, 2, 5, 8]
-
interpose(sep, xs) → {Array.<*>}
-
Returns an array of the elements of xs separated of sep
interpose returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
sep |
*
|
The separator object |
xs |
Array.<*>
|
Array to separate |
- Source:
Returns:
Separated Array
-
Type
-
Array.<*>
Example
interpose(0, [1, 2, 3]) // returns [1, 0, 2, 0, 3]
-
is(type) → {function}
-
General purpose type checker
Parameters:
Name |
Type |
Description |
type |
string
|
The type to check |
- Source:
- See:
-
Returns:
-
Type
-
function
-
isa(obj, …classes) → {boolean}
-
Wrapper for instanceof operator
Parameters:
Name |
Type |
Attributes |
Description |
obj |
*
|
|
Object to check |
classes |
*
|
<repeatable>
|
Classes to check against obj |
- Source:
- See:
-
Returns:
-
Type
-
boolean
Examples
isa({}, Object) // returns true
var Foo = function() {}
var foo = new Foo
isa(foo, Foo) // returns true
isa(foo, Foo, Object) // returns true
-
isArray(x) → {boolean}
-
Returns true if x is an Array
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isArrayLike(x) → {boolean}
-
Returns true if x is an Array or an instance of Arguments
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isBoolean(x) → {boolean}
-
Returns true if x is a Boolean
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isDate(x) → {boolean}
-
Returns true if x is a Date
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isEmpty(x) → {boolean}
-
Returns true if x is empty.
Works on objects, arrays and strings.
Parameters:
Name |
Type |
Description |
x |
Array.<*>
|
object
|
string
|
|
- Source:
- See:
-
Throws:
-
If x is not an Array, a String or a JS Object
-
-
Type
-
ArgumentError
Returns:
-
Type
-
boolean
-
isFalse(x) → {boolean}
-
Returns true if x is false
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isFloat(x) → {boolean}
-
Returns true if x is a Float.
Notice: isFloat(1.0) returns false.
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isFunction(x) → {boolean}
-
Returns true if x is a Function
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isInt(x) → {boolean}
-
Returns true if x is an Int
Notice: isInt(1.0) returns true.
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isNull(x) → {boolean}
-
Returns true if x is null
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isNumber(x) → {boolean}
-
Returns true if x is a Number
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isObject(x) → {boolean}
-
Returns true if x is an Object
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isString(x) → {boolean}
-
Returns true if x is a String
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isTrue(x) → {boolean}
-
Returns true if x is true
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
isUndefined(x) → {boolean}
-
Returns true if x is undefined
Parameters:
Name |
Type |
Description |
x |
*
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
join(xs, sepopt) → {string}
-
Wrapper for the Array.prototype.join function
join replaces ',' with ''
Parameters:
Name |
Type |
Attributes |
Default |
Description |
xs |
Array.<*>
|
|
|
Array to join |
sep |
*
|
<optional>
|
Empty string
|
Separator |
- Source:
Returns:
Joined array
-
Type
-
string
Example
join(['foo', 'bar']) // returns 'foobar'
join(['foo', 'bar'], '!') // returns 'foo!bar'
-
juxt(…functions) → {function}
-
Sequentially applies each function to a variadic number of arguments
then returns an array with the results.
Parameters:
Name |
Type |
Attributes |
Description |
functions |
function
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
function
Example
juxt(inc, dec)(2) // returns [3, 1]
-
keys(obj) → {Array.<*>}
-
Returns the keys of a JS Object
Parameters:
Name |
Type |
Description |
obj |
object
|
|
- Source:
Returns:
-
Type
-
Array.<*>
Example
keys({a: 1, b: 2, c: 3}) // ['a', 'b', 'c']
-
last() → {*}
-
Returns the last elements of xs
last returns a shallow copy of the last element of the array
Parameters:
Type |
Description |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
*
-
len(obj) → {number|undefined}
-
Return the length attribute of obj
Parameters:
Name |
Type |
Description |
obj |
*
|
Object to get doc from
Properties
Name |
Type |
Description |
length |
|
Contains the length of obj |
|
- Source:
Returns:
The length or undefined
-
Type
-
number
|
undefined
-
log(…arguments) → {*|Array.<*>}
-
console.log and returns the given argument(s)
Parameters:
Name |
Type |
Attributes |
Description |
arguments |
*
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
*
|
Array.<*>
-
log1(obj) → {*}
-
console.log and returns the first argument given
Parameters:
Name |
Type |
Description |
obj |
*
|
|
- Source:
Returns:
-
Type
-
*
-
lookup(obj, ks, notFoundnullable) → {*}
-
Object, Array, String and arguments lookup.
lookup returns a shallow copy of the found elements
Parameters:
Name |
Type |
Attributes |
Description |
obj |
Array.<*>
|
object
|
string
|
|
Object to look up into |
ks |
Array.<*>
|
*
|
|
Key(s) to look up |
notFound |
*
|
<nullable>
|
Returned if key(s) is/are not found |
- Source:
Returns:
-
Type
-
*
Example
lookup([1, 2, 3], 0) // returns 1
lookup({foo: {bar: [1, 2]}}, ['foo', 'bar', 1]) // returns 2
lookup([1, 2], 4, 'Not Found...') // returns 'Not Found...'
-
loop(f, xs) → {undefined}
-
Wrapper for the for statement.
loop also checks hasOwnProperty before calling given function.
loop is a side-effect only function
Parameters:
Name |
Type |
Description |
f |
function
|
Function used in iteration |
xs |
Array.<*>
|
Array to iterate over |
- Source:
Returns:
-
Type
-
undefined
-
lt(…objs) → {boolean}
-
Variadic wrapper for the < operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
lte(…objs) → {boolean}
-
Variadic wrapper for the <= operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
map(f, xs) → {Array.<*>}
-
Applies f to each item of xs and returns the results as an array.
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply on each element of xs |
xs |
Array.<*>
|
Consumed Array |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
Example
map(partial(add, 2), [1, 2, 4]) // returns [3, 4, 6]
-
mapkv(f, obj) → {Array.<*>}
-
Like map but mapkv also passes the key to the given function.
Notice that if xs is an Array its indexes are automatically casted into Int.
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply on each element of obj |
obj |
object
|
Consumed JS Object |
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
-
mapkvo(f, obj) → {object}
-
Like mapkv but returns an object.
f must returns an array of length two, since the first element is used a key and the second as a value.
Be careful, keys can be overwritten.
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply on each element of obj (must return a pair) |
obj |
object
|
Consumed JS Object |
- Source:
- See:
-
Returns:
-
Type
-
object
-
mapo(f, xs) → {object}
-
Applies f to each item of xs and returns the results as a JS Object.
f must returns an array of length two, since the first element is used a key and the second as a value.
Parameters:
Name |
Type |
Description |
f |
function
|
Function to apply on each element of xs |
xs |
Array.<*>
|
Consumed Array |
- Source:
- See:
-
Returns:
-
Type
-
object
Example
map(partial(add, 2), [1, 2, 4]) // returns [3, 4, 6]
-
marshal(xs) → {object}
-
Converts an array of pairs into an object
marshal returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
xs |
Array.<Array(2)>
|
Array of pairs |
- Source:
Returns:
Marshalized object
-
Type
-
object
Example
marshal([['a', 1], ['b', 2], ['c', 3]]) // returns {a: 1, b: 2, c: 3}
-
max(…numbers) → {number}
-
Returns max value
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
number
-
merge(…jsObjects) → {object}
-
Merges a variable number of objects
merge returns a shallow copy of the objects values
Parameters:
Name |
Type |
Attributes |
Description |
jsObjects |
object
|
<repeatable>
|
JS Objects to merge |
- Source:
Returns:
Merged object
-
Type
-
object
-
min(…numbers) → {number}
-
Returns min value
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
number
-
mul(…numbers) → {number}
-
Returns the product of given arguments.
mul() returns 1
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
neq2(…objs) → {boolean}
-
Variadic wrapper for the != operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
neq3(…objs) → {boolean}
-
Variadic wrapper for the !== operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
not(bool) → {boolean}
-
Negates boolean value
Parameters:
Name |
Type |
Description |
bool |
boolean
|
Value to negate |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
NotImplementedError(message)
-
NotImplementedError error class
Parameters:
Name |
Type |
Description |
message |
string
|
The message to display |
- Source:
-
odd(x) → {boolean}
-
Returns true if x is odd
Parameters:
Name |
Type |
Description |
x |
number
|
|
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
or(…objs) → {boolean}
-
Variadic wrapper for the || operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
owns(xs, prop) → {boolean}
-
Wrapper for the hasOwnProperty method
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
Array of any type |
prop |
*
|
Property to check |
- Source:
Returns:
-
Type
-
boolean
-
partial(f, …arguments) → {function}
-
Partially applies a function to a variable number of arguments
Parameters:
Name |
Type |
Attributes |
Description |
f |
function
|
|
Function to partially apply |
arguments |
*
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
Partially applied function
-
Type
-
function
Example
partial(add, 1)(2) // returns 3
-
pow(…numbers) → {number}
-
Wrapper for the Math.pow function
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
product(xs) → {number}
-
Returns the product of the elements of an array
Parameters:
Name |
Type |
Description |
xs |
Array.<number>
|
|
- Source:
Returns:
-
Type
-
number
-
rand(nopt) → {number}
-
Wrapper for the Math.random function.
rand returns a random floating point number between 0 and n (default 1).
Parameters:
Name |
Type |
Attributes |
Default |
Description |
n |
number
|
<optional>
|
1
|
Random number max limit |
- Source:
- See:
-
Returns:
-
Type
-
number
-
randIndex(xs) → {*}
-
Returns a random item of xs
randIndex returns a shallow copy of the array element
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
|
- Source:
- See:
-
Returns:
Random element of xs
-
Type
-
*
-
randInt(n) → {number}
-
Returns a random integer between 0 and n.
randInt() always returns 0.
Parameters:
Name |
Type |
Description |
n |
number
|
Random number max limit |
- Source:
- See:
-
Returns:
-
Type
-
number
-
range(min_or_max, maxnullable, stepopt, nullable) → {Array.<number>}
-
Returns an array.
Step must be positive.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
min_or_max |
number
|
|
|
Minimum value if max is provided, otherwise, Maximum value |
max |
number
|
<nullable>
|
|
Maximum value (not included) |
step |
number
|
<optional>
<nullable>
|
1
|
Step |
- Source:
Returns:
-
Type
-
Array.<number>
Example
range(5) // returns [0, 1, 2, 3, 4]
range(3, 6) // returns [3, 4, 5]
range(3, 10, 2) // returns [3, 5, 7, 9]
-
reduce(f, xs, aggnullable) → {*}
-
The first argument is a function which takes two arguments,
the second one is an array and you may pass a third argument which is an aggregator
the aggregator is the first element of xs by default.
Parameters:
Name |
Type |
Attributes |
Description |
f |
function
|
|
Reducer function, the first arguments is the aggregator, the second one the next value |
xs |
Array.<*>
|
|
Array to consume |
agg |
*
|
<nullable>
|
Defined aggregator |
- Source:
- See:
-
Returns:
Reduced value
-
Type
-
*
Example
reduce(add, [1, 2, 3]) // returns 6
reduce(add, [1, 2, 3], 2) // returns 8
-
reducekv(f, obj, agg) → {*}
-
The first argument is a function which takes three arguments,
the second one is an array and the third one is an aggregator
Parameters:
Name |
Type |
Description |
f |
function
|
Reducer function, the first arguments is the aggregator, the second one the next key, the last one the next value |
obj |
object
|
JS Object to consume |
agg |
*
|
Defined aggregator |
- Source:
- See:
-
Returns:
Reduced value
-
Type
-
*
Example
var f = function(agg, _, v) { return agg + v }
reducekv(f, {foo: 1, bar: 2, baz: 3}, 0) // returns 6
reducekv(f, {foo: 1, bar: 2, baz: 3}, 2) // returns 8
-
reducer(f, xs, aggnullable) → {*}
-
Similar to reduce but starts iteration at the end of the array.
Parameters:
Name |
Type |
Attributes |
Description |
f |
function
|
|
Reducer function, the first arguments is the aggregator, the second one the next value |
xs |
Array.<*>
|
|
Array to consume |
agg |
*
|
<nullable>
|
Defined aggregator |
- Source:
- See:
-
Returns:
Reduced value
-
Type
-
*
Example
reduce(sub, [10, 2, 5]) // returns 3
reducer(sub, [13, 2, 5]) // returns -7
-
repeat(n, x) → {Array.<*>}
-
Returns an array containing n times x
repeat returns an array containing shallow copies of x
Parameters:
Name |
Type |
Description |
n |
number
|
|
x |
*
|
|
- Source:
Returns:
-
Type
-
Array.<*>
Example
repeat(3, 'a') // returns ['a', 'a', 'a']
-
repeatedly(n, f, …args) → {Array.<*>}
-
Returns an array containing n times f()
Parameters:
Name |
Type |
Attributes |
Description |
n |
number
|
|
|
f |
function
|
|
Called function |
args |
*
|
<repeatable>
|
Arguments for f |
- Source:
Returns:
-
Type
-
Array.<*>
Example
repeatedly(3, function() { return 1 }) // returns [1, 1, 1]
repeatedly(3, function(x, y) { return 1 + x + y }, 1, 2) // returns [4, 4, 4]
-
reverse(xs) → {Array.<*>}
-
Reverses the elements of an array.
reverse returns shallow copy of the elements of array
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
Array.<*>
-
second() → {*}
-
Returns the second element of xs
second returns a shallow copy of the second element of the array
Parameters:
Type |
Description |
Array.<*>
|
|
- Source:
Returns:
-
Type
-
*
-
shuffle(xs) → {Array.<*>}
-
Returns a shuffled Array
shuffle returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
xs |
Array.<*>
|
Array to shuffle |
- Source:
Returns:
Shuffled Array
-
Type
-
Array.<*>
-
slice(xs, begin, endopt) → {Array.<*>}
-
Wrapper for the Array.prototype.slice function
slice returns a shallow copy of the array elements
Parameters:
Name |
Type |
Attributes |
Default |
Description |
xs |
Array.<*>
|
|
|
Array to slice |
begin |
number
|
|
|
|
end |
number
|
<optional>
|
End of the sequence
|
|
- Source:
- See:
-
Returns:
-
Type
-
Array.<*>
Example
slice(arguments) // similar to [].slice.call(arguments)
slice([1, 2, 3, 4], 1, 3) // returns [2, 3]
slice([1, 2, 3], -1) // returns [3]
-
some(pred, xs) → {boolean}
-
Applies pred to each items of xs.
If pred(item) is true, returns true.
Parameters:
Name |
Type |
Description |
pred |
function
|
Predicate function |
xs |
Array.<*>
|
Array to consume |
- Source:
Returns:
-
Type
-
boolean
Example
var f = function(x) { return x == 1 };
some(f, [1, 0, 0, 0]) // returns true
some(f, [0, 0, 0, 0]) // returns false
-
sort(predopt, xs) → {Array.<*>}
-
Sort element of an array.
You can pass a sorter function to sort.
Wrapper for the [].sort function.
sort returns a shallow copy of the array elements
Parameters:
Name |
Type |
Attributes |
Default |
Description |
pred |
function
|
<optional>
|
undefined
|
Function to apply on each element of xs |
xs |
Array.<*>
|
|
|
Array to sort |
- Source:
- See:
-
Returns:
Sorted Array
-
Type
-
Array.<*>
-
sqrt(…numbers) → {number}
-
Wrapper for the Math.sqrt function
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
sub(…numbers) → {number}
-
Subtracts the remaining arguments to the first one.
sub() returns 0
Parameters:
Name |
Type |
Attributes |
Description |
numbers |
number
|
<repeatable>
|
|
- Source:
- See:
-
Returns:
-
Type
-
number
-
sum(xs) → {number}
-
Sums the elements of an array
Parameters:
Name |
Type |
Description |
xs |
Array.<number>
|
|
- Source:
Returns:
-
Type
-
number
-
takeWhile(pred, xs) → {Array.<*>}
-
Returns an Array containing the items of xs
while pred(item) is true.
takeWhile returns a shallow copy of the array elements
Parameters:
Name |
Type |
Description |
pred |
function
|
Predicate function |
xs |
Array.<*>
|
Array to consume |
- Source:
- See:
-
Returns:
Filtered Array
-
Type
-
Array.<*>
-
thread(obj, …functions) → {*}
-
Targeting readability, thread looks like OOP writting.
Parameters:
Name |
Type |
Attributes |
Description |
obj |
*
|
|
|
functions |
function
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
*
Example
inc(first([1, 3]))
// becomes
thread([1, 3], first, inc) // returns 2
-
time(f, fnameopt, …arguments) → {*}
-
Uses console.time and console.timeEnd to calculate
the time taken by a given function and returns its value.
Remainings arguments are given to function.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
f |
function
|
|
|
|
fname |
string
|
<optional>
|
f.name
|
Name of the function |
arguments |
*
|
<repeatable>
|
|
Arguments given to f (if provided, fname is mandatory) |
- Source:
Returns:
-
Type
-
*
-
times(n, f) → {undefined}
-
Calls function f n times.
times is a side-effects only function
Parameters:
Name |
Type |
Description |
n |
number
|
|
f |
function
|
|
- Source:
Returns:
-
Type
-
undefined
-
unmarshal(obj) → {Array.<Array(2)>}
-
Converts an object into an array of pairs
unmarshal returns a shallow copy of the object elements
Parameters:
Name |
Type |
Description |
obj |
object
|
JS Object |
- Source:
Returns:
- Unmarshalized object
-
Type
-
Array.<Array(2)>
Example
unmarshal({a: 1, b: 2, c: 3}) // returns [['a', 1], ['b', 2], ['c', 3]]
-
use(varnames) → {undefined}
-
May be really messy!
Uses in main scope some of the fjs functions.
use is a side-effect only function
Parameters:
Name |
Type |
Description |
varnames |
string
|
Array.<(string|object)>
|
= Can be a variable number of strings |
- Source:
- See:
-
Throws:
-
If fjs does not include a required variable
-
-
Type
-
Error
Returns:
-
Type
-
undefined
Examples
fjs.use('map', 'inc')
map(inc, [1, 2, 3]) // returns [2, 3, 4]
fjs.del('map', 'inc')
map(inc, [1, 2, 3]) // throws exceptions
var vars = ['fmap', 'dec']
fjs.use(vars)
fmap([1, 2, 3], dec) // returns [0, 1, 2]
fjs.del(vars)
fmap([1, 2, 3], dec) // throws exceptions
var vars = [{inc: 'inc2', dec: 'dec2'}, 'map']
fjs.use(vars)
map(inc2, [1, 2, 3]) // returns [2, 3, 4]
map(dec2, [1, 2, 3]) // returns [0, 1, 2]
fjs.del(vars)
map(inc2, [1, 2, 3]) // throws exceptions
map(dec2, [1, 2, 3]) // throws exceptions
-
useAll() → {undefined}
-
May be really messy!
Uses all the exported function of fjs in the current scope.
useAll is a side-effect only function
- Source:
- See:
-
Returns:
-
Type
-
undefined
-
values(obj) → {Array.<*>}
-
Returns the values of a JS Object
values returns a shallow copy of the object values
Parameters:
Name |
Type |
Description |
obj |
object
|
|
- Source:
Returns:
-
Type
-
Array.<*>
Example
values({a: 1, b: 2, c: 3}) // [1, 2, 3]
-
version() → {string}
-
Returns the current version of fjs
- Source:
Returns:
-
Type
-
string
-
warn(…arguments) → {*|Array.<*>}
-
console.warn and returns the given argument(s)
Parameters:
Name |
Type |
Attributes |
Description |
arguments |
*
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
*
|
Array.<*>
-
warn1(obj) → {*}
-
console.warn and returns the first argument given
Parameters:
Name |
Type |
Description |
obj |
*
|
|
- Source:
Returns:
-
Type
-
*
-
xor(…objs) → {boolean}
-
xor operator
Parameters:
Name |
Type |
Attributes |
Description |
objs |
*
|
<repeatable>
|
Objects to test |
- Source:
- See:
-
Returns:
-
Type
-
boolean
-
xrange(min_or_max, maxnullable, stepopt, nullable) → {function}
-
Pending version of range.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
min_or_max |
number
|
|
|
Minimum value if max is provided, otherwise, Maximum value |
max |
number
|
<nullable>
|
|
Maximum value (not included) |
step |
number
|
<optional>
<nullable>
|
1
|
Step |
- Source:
Returns:
-
Type
-
function
Example
var r = xrange(3) // returns function() {...}
r() // returns [0, 1, 2]
-
zip(…arrays) → {Array.<*>}
-
Zips arrays together.
zip returns a shallow copy of the array elements
Parameters:
Name |
Type |
Attributes |
Description |
arrays |
Array.<*>
|
<repeatable>
|
Arrays to zip |
- Source:
Returns:
Zipped arrays
-
Type
-
Array.<*>
Example
zip([1, 2, 3], [4, 5, 6]) // returns [[1, 4], [2, 5], [3, 6]]