This class provides some similar utility methods to that of lodash.
TODO: Add installation guide
Takes a given list and breaks it into several list based on a given size
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd' };
lo.chunk(myList, 2);
// [['a', 'b'], ['c', 'd']]
lo.chunk(myList, 3);
// [['a', 'b', 'c'], ['d']]
lo.chunk(myList, 10);
// [['a', 'b', 'c', 'd']]
Drops a given number of elements off the "left hand side" of a list
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd' };
lo.drop(myList);
// ['b', 'c', 'd']
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd' };
lo.drop(myList, 2);
// ['c', 'd']
Drops a given number of elements off the "right hand side" of a list
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd' };
lo.dropRight(myList);
// ['a', 'b', 'c']
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd' };
lo.dropRight(myList, 2);
// ['a', 'b']
Fills a list with the given object a given number of times
lo.fill('foo', 3);
// ['foo', 'foo', 'foo']
Gets all but the last element of a list
List<String> myList = new List<String>{ 'a', 'b', 'c'};
lo.initial(myList);
// ['a','b']
Gets the last item from a list
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd' };
lo.last(myList);
// 'd'
Used to pluck a list of fields out of a list of objects
Account account = ...;
Object lo.pluck(account, 'name');
List<Account> accountList = ...;
List<Object> lo.pluck(accountList, 'name');
List<Case> caseList = ...;
List<Object> lo.pluck(caseList, 'contact.account.name');
Gets all but the first element of a list
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd' };
lo.rest(myList);
// ['b', 'c', 'd']
Gets part of a list
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd', 'e' };
lo.slice(myList, 2);
// ['c', 'd', 'e']
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd', 'e' };
lo.slice(myList, 2, 4);
// ['c', 'd']
Takes a given number of entries off the "left hand side" of a list
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd', 'e' };
lo.take(myList, 2);
// ['a', 'b']
Takes a given number of entries off the "right hand side" of a list
List<String> myList = new List<String>{ 'a', 'b', 'c', 'd', 'e' };
lo.takeRight(myList, 2);
// ['d', 'e']
Takes a list of Objects and typecasts them to strings
List<Account> accountList = ...;
List<String> lo.toString(lo.pluck(accountList, 'name'));
Combines a list of lists of objects and combines them into a single list
List<List<String>> myList = new List<List<String>>{
List<String>{'a', 'b'},
List<String>{'c', 'd'},
List<String>(),
List<String>{'e'}
};
lo.union(myList);
// ['a', 'b', 'c', 'd', 'e']