Home > Javascript > lodash fp -1

lodash fp -1

dropRightWhile array dropElements in array at the end based on predicate Take the last array element and apply the predicate, if that returns false return entire array else drop from end and continue till predicate becomes false from end of array and return remaining array
dropWhile array dropElements in array at the begining based on predicate Take the first array element and apply the predicate, if that returns false return entire array else drop from begining and continue till predicate becomes false from begin of array and return remaining array
every array return true if predicate returns true for all elements of array else return false Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate returns falsey
filter array return all array elements for which predicate returns true Iterates over elements of collection, returning an array of all elements predicate returns truthy for.
find array return first element and whole element that matches the predicate Iterates over elements of collection, returning the first element predicate returns truthy for. undefined if not found
findIndex array return first element index that matches the predicate returns the index of the first element predicate returns truthy for instead of the element itself.-1 if not found, index is zero based
findKey object on dictionary with key, name value pairs returns first key whose value matches returns the key of the first element predicate returns truthy for instead of the element itself
findLast array return last element and whole element that matches the predicate Iterates over elements of collection, returning the last element predicate returns truthy for. undefined if not found
findLastIndex array return last element index that matches the predicate returns the index of the last element predicate returns truthy for instead of the element itself.-1 if not found, index is zero based
findLastKey object on dictionary with key, name value pairs returns last key whose value matches returns the key of the last element predicate returns truthy for instead of the element itself
flatMap array return a new array after applying the function on all elements on the array Creates a flattened array of values by running each element in collection thru iteratee and flattening the mapped results.
flatMapDeep array recursively apply flatMap to each array that exists in the main array
const usersArray = [[{ ‘user’: ‘pebbles’, ‘active’: true },

{ ‘user’: ‘barney’,  ‘active’: true }],

[{ ‘user’: ‘fred’,    ‘active’: false }]

];

recursively flattens the mapped results
[ [ { user: ‘pebbles’, active: true },
{ user: ‘barney’, active: true } ],
[ { user: ‘pebbles’, active: true },
{ user: ‘barney’, active: true } ],
[ { user: ‘fred’, active: false } ],
[ { user: ‘fred’, active: false } ] ]
[ { user: ‘pebbles’, active: true },
{ user: ‘barney’, active: true },
{ user: ‘pebbles’, active: true },
{ user: ‘barney’, active: true },
{ user: ‘fred’, active: false },
{ user: ‘fred’, active: false } ]
flatMapDepth array same as flatMapDeep except depth specification recursively flattens the mapped results up to depth times.
forEach array/collection perform a function on each element of array or collection Iterates over elements of collection and invokes iteratee for each element.
forEachRight array/collection perform a function on each element of array or collection from right to left iterates over elements of collection from right to left.
forIn object perform a function on each key that you inherit from object or directly defined on the object Iterates over own and inherited enumerable string keyed properties of an object and invokes iteratee for each property
forInRight object perform a function on each key that you inherit from object or directly defined on the object from Right to left Iterates over own and inherited enumerable string keyed properties of an object and invokes iteratee for each property from right to left
forOwn object perform a function on each key that are directly defined on the object Iterates over own string keyed properties of an object and invokes iteratee for each property
forOwnRight object perform a function on each key that are directly defined on the object from right to left Iterates over own string keyed properties of an object and invokes iteratee for each property from right to left
map array/collection returns a new array by applying function to each element of the array Creates an array of values by running each element in collection thru iteratee.
mapKeys object returns keys associated with the object this method creates an object with the same values as object and keys generated by running each own enumerable string keyed property of object thru iteratee.
mapValues object turns values associated with the object Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee.
partition array/collection returns true array and false array from collection Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, the second of which contains elements predicate returns falsey for
reject array/collection returns elements that returns false for predicate` this method returns the elements of collection that predicate does not return truthy for
remove array/collection removes array elements and returns remaining elements, original array is modified Removes all elements from array that predicate returns truthy for and returns an array of the elements remaining
some array/collection return true if any element in collection passes predicate Checks if predicate returns truthy for any element of collection. Iteration is stopped once predicate returns truthy
takeRightWhile
array/collection return an array from the end while predicate returns true Creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsey
takeWhile array/collection return an array from beginging while predicate returns true Creates a slice of array with elements taken from the begining. Elements are taken until predicate returns falsey
times utility return an array as a result of application of iteratee n times Invokes the iteratee n times, returning an array of the results of each invocation

 

 

Advertisements
Categories: Javascript Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: