Tooly

Tooly is a package based in Lodash for Dart that contain utilities for working with lists, maps, sets and objects.

Method list

chunk

Create an list of elements split into groups the length of initial list size.

Tooly.chunk([1, 2, 3, 4, 5], 2);
// [[1, 2], [3, 4], 5]

compact

Create a list without null, false, 0 and '' from another list.

Tooly.compact([0, 77, '', 55, false]);
// [77, 55]

concat

Create a list that contain the initial list and additional list.

Tooly.concat([1, 2, 3], [4, 5, 6]);
// [1, 2, 3, 4, 5, 6]

difference

Create a list of values that not include in the second list.

Tooly.difference([1, 2, 3], [3, 4, 5]);
// [1, 2]

drop

Create a list with n elements dropped from the beginning.

Tooly.drop([1, 2, 3], 2);
// [3]

fill

Fills elements of list with value from start up to, but not including end.

Tooly.fill([1, 2, 3, 4, 5], '*', 1, 3);
// [1, *, *, 4, 5]

findIndex

Find value index of list.

Tooly.findIndex([1, 2, 3], (e) => e == 2);
// 1

findLastIndex

Find value index of list but it iterate over elements of list from right to left.

Tooly.findLastIndex([1, 2, 3], (e) => e == 2);
// 1

flatten

Flattens list a single level deep.

Tooly.flatten([1, 2, [3, 4], ['a', 'b']]);
// [1, 2, 3, 4, a, b]

indexOf

Gets the first index of value in the list.

Tooly.indexOf([1, 2, 3, 4], 4);
// 3

listToString

Create a string from a list.

Tooly.listToString(['first', 'second', 'third']);
// first, second, third

uniq

Create a list no duplicate elements from another list.

Tooly.uniq([1, 1, 1, 5, 5, 8]);
// [1, 5, 8]

dropRight

Create a list with n elements dropped from the end.

Tooly.dropRight([1, 2, 3, 4], 1);
// [1, 2, 3]

first

Gets the first element of list.

Tooly.first([1, 2, 3]);
// 1

flattenDeep

Flattens list recursively.

Tooly.flattenDeep([1, [2, [3, [4]], 5]]);
// [1, 2, 3, 4, 5]

initial

Gets all but the last element of list.

Tooly.initial([1, 2, 3]);
// [1, 2]

join

Converts all elements in list into a string separated by separator.

Tooly.join(['a', 'b', 'c'], '~');
// a~b~c

last

Gets the last element of list.

Tooly.last([1, 2, 3]);
// 3

nth

Gets the element at index n of list. If n is negative, the nth element from the end is returned.

Tooly.nth([1, 2, 3, 4], 1);
// 2

Tooly.nth([1, 2, 3, 4], -2);
// 3

sum

Calculates the sum of a list of numbers.

Tooly.sum([1, 2, 3, 4]);
// 10

take

Creates a slice of list with n elements taken from the beginning.

Tooly.take([1, 2, 3, 4], 2);
// [1, 2]

takeRight

Creates a slice of list with n elements taken from the end.

Tooly.takeRight([1, 2, 3, 4], 2);
// [3, 4]

Much more under construction...

Libraries

tooly
utils