We use cookies to make our website more effective. By using our website you agree to our privacy policy.

Namespace: fn

fn

functions.js is part of Aloha Editor project http://www.alohaeditor.org

Aloha Editor ● JavaScript Content Editing Library
Copyright (c) 2010-2015 Gentics Software GmbH, Vienna, Austria.
Contributors http://www.alohaeditor.org/docs/contributing.html

Methods

and(){function}

Composes a predicate function made up of a chain of the given predicate
arguments.
Type Description
function

asMethod()

Wraps a function and passes `this` as the first argument.

The function that is wrapped is available on the returned method
as the fn property, which allows one to easily switch between
method and function invokation form.

The Function.length property of the given function is examined
and may be either 0, no matter how many arguments the function
expects, or if not 0, must be the actual number of arguments the
function expects.

comp(){*}

Composes the functions given as arguments.

comp(a, b, c)(value) === a(b(c(value)))
Type Description
function

complement(fn){function}

Generates the complement function for `fn`.
The complement function will return the opposite boolean result when
called with the same arguments as the given `fn` function.
Name Type Description
fn function

constantly()

Returns a function that constantly returns the given value.

extendType(Type, fnByName)

Adds functions to the given type's prototype.

The functions will be converted to methods using Fn.asMethod().
Name Type Description
Type *
fnByName Object.<string, function()>

identity(arg){*}

Returns its single argument.
Useful for composition when some default behaviour is needed.
Name Type Description
arg *
Returns:
given argument `arg`.
Returns true if the given value is a function.
Is null or undefined.
Does nothing.

or(){function}

Like and() but for boolean OR.
Type Description
function

partial(fn, thisArg){function}

Like function.prototype.bind except without the `this` argument.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/function/bind

Returns a function that concatenates the given arguments, and the
arguments given to the returned function and calls the given
function with it.

The returned function will have a length of 0, not a length of
fn.length - number of partially applied arguments. This is
important consideration for any code that introspects the arity
of the returned function. Function.prototype.bind() returns a
function with the correct number of arguments but is not
available across all browsers.
Name Type Description
fn function
thisArg Object

returnFalse(){boolean}

Always returns `false`.

returnTrue(){boolean}

Always returns `true`.

strictEquals(a, b){boolean}

Compare the given arguments using the strict equals operator.

Useful to pass as an arguments to other functions.
Name Type Description
a *
b *
comments powered by Disqus