See docs/Function-Signatures.md
-
Root functions
-
List
functions -
Object
functions
Returns firstArgument
.
f.done = Fn(firstArgument: Generic) -> Generic;
Returns a function that;
- Applies
args
tocallbacks
. - Returns
args
as aList
. - Ignores the results from
callbacks
.
f.tee = Fn(
callbacks: ...Fn(args: ...Generic) -> Generic = [function(){}],
) -> Fn(args: ...Generic) -> List;
Returns a function that;
- Maps
input
toiterator
then passes the the result tocallback
. - Returns the result from
callback
.
f.List.map = Fn(
iterator: Fn(
element: Generic,
index: Int,
array: List,
) -> Generic,
callback: Fn(output: List) -> Generic = f.done,
) -> Fn(input: List) -> Generic;
var addOne = function(n) { return n + 1 };
var double = function(n) { return n * 2 };
var addOneEach = f.List.map(addOne);
addOneEach([1, 2, 3]); // [2, 3, 4]
var doubleEach = f.List.map(double);
doubleEach([1, 2, 3]); // [1, 4, 6]
var addOneThenDoubleEach = f.List.map(addOne, f.List.map(double));
addOneThenDoubleEach([1, 2, 3]); // [4, 6, 8]
Returns a function that;
- Reduces
input
throughiterator
then passes the the result tocallback
. - Returns the result from
callback
.
f.List.reduce = Fn(
iterator: Fn(
previousValue: Generic,
currentValue: Generic,
index: Int,
array: List,
) -> Generic,
firstValue: Generic = null,
callback: Fn(output: List) -> Generic = f.done,
) -> Fn(input: List) -> Generic;
Returns a function that;
- Deletes
properties
frominput
then passes the result tocallback
. - Returns the result from
callback
.
f.Object.filterProperties = Fn(
properties: ...String,
callback: Fn(output: Object) -> Generic = f.done,
) -> Fn(input: Object) -> Generic;
var removeSensitiveFields = f.Object.filterProperties('password', 'isAdmin');
Object.keys(removeSensitiveFields({
id: 1,
username: 'Elijah',
password: '$2y$10$bpI4uLZfRG39MLVuWexVvuzWK2kXI1FEmFrgVVZn1FMwxeYMQoEE2',
isAdmin: true,
createdAt: 1422409318922,
updatedAt: 1422409318922,
})); // ['id', 'username', 'createdAt', 'updatedAt']
Express.js + Knex.js example (http://expressjs.com/, http://knexjs.org/)
app.route('/api/users').get(function(request, response) {
knex('Users').select().then(
f.List.map(
f.Object.filterProperties('password', 'isAdmin'),
response.json
)
);
});