Skip to main content
Module

x/fae/mod.ts

A functional module for Deno inspired from Ramda.
Latest
import * as fae from "https://deno.land/x/fae@v1.1.1/mod.ts";

Variables

v
_

Placeholder for curried functions

Adds two numbers

Returns a new iteration function from the passed function by adding two more parameters to its callback function

  1. the current index
  2. the entire list The passed function must have first argument as the iteration functions and last arguments as the list

Applies a given function fn at given index of list, returning a new copy of list with element at index replaced with return value of fn.

Return true if all the elements of the functor match predicate false otherwise

Takes a list of predicates and returns a predicate that returns true for a given list of arguments if every one of the provided predicates is satisfied by those arguments.

Returns a function which that always returns value

Returns true if both arguments are true, false otherwise.

Returns the result of applying the onSuccess function to the value inside a successfully resolved promise. This is useful for working with promises inside function compositions.

Return true if any the elements of the list match predicate false otherwise

Takes a list of predicates and returns a predicate that returns true for a given list of arguments if at least one of the provided predicates is satisfied by those arguments.

Iit applies a list of functions to a list of values. Dispatches to the ap method of the second argument, if present. Also treats curried functions as applicatives.

Returns a new list, composed of n-tuples of consecutive elements. If n is greater than the length of the list, an empty list is returned.

Add the el to the end of list and returns new list without affecting original

Makes a shallow clone of obj, setting or overriding the specified property prop with the given val. All non-primitive properties are copied by reference.

Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and placing the specific value at the tail end of that path. Note that this copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

A function which calls the two provided functions and returns the && of the results. It returns the result of the first function if it is false and the result of the second function otherwise. Second function will not be invoked if the first returns a false value.

Restricts value between min and max. Returns min if value < min, max if value > max, value otherwise

complement of function(combining)

Concat two arrays or strings. Both the arguments passed must be of same type.

Returns true or false based on the element found or not.

Creates a new list out of the two supplied by creating each possible pair from the list passed as arguments.

Returns the curried function NOTE The passed function will be called as soon as expected number of arguments are received. Rest will be ignored.

Returns the second argument if it is not null, undefined or NaN; otherwise the first argument is returned.

Makes a shallow clone of obj, deleting props from the new object. All non-primitive properties are copied by reference.

Makes a shallow clone of an object obj, deleting value at at the given path. Note that this copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

Divides two numbers. Equivalent to a / b.

Returns all but first n elements of given list.

Returns all but last n elements of given list.

Returns a new list excluding the trailing elements of a list which satisfies predicate. Skips all the elements which on applied on predicate returns true. The new list ends with last false.

Returns a new list without any consecutively repeating elements. Fae.equals is used for comparison

Returns a new list without consecutively repeating elements. Equality is decided by predicate

Returns a new list excluding the leading elements of a functor which satisfies predicate. Skips all the elements which on applied on predicate returns true. The new list starts with first false.

A function wrapping calls to the two functions in an || operation, returning the result of the first function if it is true and the result of the second function otherwise. Second function will not be invoked if the first returns a true value.

checks if functor ends with suffix

Reports whether two objects have the same value, for the specified property. Useful as a curried predicate.

Filters the those elements from functor that satisfies predicate. The functor may be an array/object/iterable/iterator.

Returns the first element of the list which matches the predicate, or undefined if no element matches.

Takes in Array and Element as its 2 parameters Return the 1st index If element is matched or -1 is unmatched.

Returns the last element of the list which matches the predicate, or undefined if no element matches.

Returns index of last element of the list which matches the predicate, or -1 if no element matches.

Returns the first element of the given list or string. In some libraries this function is named first.

Returns the position of the first occurrence of value in list, or -1 if the item is not included in the array. Fae.equals is used to determine equality.

Returns a new array with element inserted at index to list without affecting original one.

Returns a string made by inserting the separator between each element and concatenating all the elements into a single string. The functor may be array-like/iterable/iterator.

Returns a lens for the given getter and setter functions. The getter "gets" the value of the focus; the setter "sets" the value of the focus. The setter should not mutate the data structure.

Returns a lens whose focus is the specified index.

Returns a lens whose focus is the specified path.

Returns a lens whose focus is the specified property

Lifts fn to a specified arity. The returned function applies the fn on arity number of lists in all possible combination of elements of the lists passe. The result is accumulated in a list

Applies fn to each of functor's value and returns functor of same shape

Returns the larger of its two arguments. Fae.max(1, 2) // => 2 Fae.max('abd', 'abc') // => 'abd' Fae.max(1000, NaN) // => NaN

Returns the mean of the given list of numbers.

Returns the median of the given list of numbers. NaNs are filtered out, if present. Returns NaN if the list is empty.

Returns the smaller of its two arguments.

Multiplies two numbers. Equivalent to a * b but curried.

Returns the not(complement) value of the given value

Returns indexth element of functor. Returns element counting from right end if index is -ve. Works in array-like/string/iterable/iterator

Returns true if one or both of its arguments are true. Returns false if both arguments are false.

Returns the result of "setting" the portion of the given data structure target focused by the given lens to the result of applying the given function fn to the focused value.

Retrieve the value at a given path. The path may be any array of keys or string of keys separated by / or . .

If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

Retrieves the values at given paths pathsArr of obj. Each path in the pathsArr may be any array of keys or string of keys separated by / or . .

Returns a new list by plucking the same named property off all objects in the list supplied.

Add the el to the start of list and returns new list without affecting original

Returns p property p on the obj if exists

Returns true if the specified object property is equal, to the given value; false otherwise.

Returns true if the specified object property is of the given type; false otherwise.

If the given, non-null object has an own property with the specified name, returns the value of that property. Otherwise returns the provided default value. const fae = { name: 'Fae', age: 15 } const Great = Fae.prop('GreatLibrary') const GreatWithDefault = Fae.propOr('FaeModule', 'GreatLibrary')

Returns an array of multiple on the obj. Order is preserved.

Returns true if the specified object property satisfies the given predicate; false otherwise.

Returns a list of numbers from from to to both inclusive.

Returns a list of numbers from from (inclusive) to to (exclusive).

Returns a single value by iterating though functor calling the iterator function func. func takes two arguments. First - acc, Second - value.

works as the complement of filter

Reverses given string or array without affecting the original.

Returns the result of "setting" the portion of the given data structure target focused by the given lens to the given value.

Returns the elements of the given list or string fromIndex (inclusive) to toIndex (exclusive).

Returns a copy of the list, sorted according to the comparator function, which should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal.

Subtracts its second argument from its first argument.

Returns all but the first element of functor. Accepts array-like(including string).

Returns first n elements of the array or string.

Runs the given function func with the supplied object obj, then returns obj.

Trims the string str from both end with t. Trims with white space if t is [''], with t otherwise.

Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as the initial value.

Returns a new array with copy of list and value replaced at index.

Applies func on value if the test predicate is true and returns it; returns value otherwise.

Takes a specs objects whose properties are predicate functions Each predicate is applied to the value of the corresponding property of the test object. Returns true if all the predicates are satisfied, false otherwise. NOTE returns false if there is no predicated functions

Takes a specs objects whose property is a predicate function Each predicate is applied to the value of the corresponding property of the test object. Returns true if any of the predicates is satisfied, false otherwise. NOTE returns false if there is no predicated functions

Takes a spec object and a test object, returns true if the test satisfies the spec, false otherwise. whereEq is a specialization of [where].

Exclusive Or - Returns true if one of the arguments is truthy and the other is falsy. Otherwise, it returns false.

Creates a new list out of two passed lists list1, list2 by pairing up equally-positioned pair in both the lists. The returned is truncated to the length of the shorter of the two input lists.

Returns a new object out of given list of keys and values. The returned is truncated to the length of the shorter of the two.

Creates a new list out of two passed lists list1, list2. Each item of new list is calculated by applying equally-positioned pair in both the lists. The returned is truncated to the length of the shorter of the two input lists.

Functions

Returns a comparator out of predicate which returns true when its first argument is less than the second, false otherwise

Performs a right-to-left function composition. The last function may have any number of arguments; the remaining must have single argument. Note: The returned function is automatically curried

Decreases its argument by 1.

Returns the empty value of its argument's type.

Returns a new function much like the supplied one, except that the first two arguments' order is reversed. The returned function is automatically curried. But the types are not preserved as of now due to TS limitations. The returned function will have all unknown in its parameters list and return type. To make it work properly, you need to use type assertion using Curry2 or Curry3.

Creates a new object from a list key-value pairs. If a key appears in multiple pairs, the rightmost pair is included in the object.

Returns the supplied parameter

Increases its argument by 1.

Returns true if the given value is its type's empty value, false otherwise.

Performs a left-to-right function composition. The first function may have any number of arguments; the remaining must have single argument. Note: The returned function is automatically curried.

Adds together all the elements of a list.

Initializes a transducer using supplied iterator function transformer2. Returns a single item by iterating through the list, successively calling the transformed transformer2 and passing it acc and the current value from the array, and then passing through transformer1 and then passing the result to the next call.

Gives a single-word string description of the (native) type of a value. The returned types are of type AllTypes

Interfaces

Function type for curried function of arity 1

Function type for curried function of arity 2

Function type for curried function of arity 3

Type Aliases

All the types which are returned by function typ

Comparator for functions like sort

Type of placeholder for curried functions

Predicate function type which checks one value v

Predicate function type which applies on two values a and b

Type for spec object which contains predicate functions of type {Predicate1}