A slimmed-down version of the helpful functions in lo-dash (and maybe a few extra)--written in Bash. Bash scripters rejoice!
Because lo-dash is a javascript library, the syntax of the functions in this lib will often behave a bit differently. Bash only returns integers, but it can export variables and capture output. Here are some things to keep in mind:
- You will often see in the documentation for a function that one or more variables get exported after execution completes. All exported variables start with an underscore and are snake_case (e.g.
$_im_exported). - Most non-mutative array functions in this lib will require at least 2 array names to be passed. One of them is the array on which to operate, the other is a name for the new array that will be created. This means you need to first define an array before passing its name to these functions.
- Using the magic of
eval, Bash can actually emulate callback functions. The trick is that the implementor will need to define the function ahead of time, and then pass that function name as the callback. - Functions in
functions/_/are mainly used internally by the rest of this lib, but implementors may feel free to use them for their purposes as well.
- awk
- date
- egrep
- expr
- grep
- sed
- tr
- type
- wc
- _
- array
- cuz
- date
- lang
- math
- number
- string
- utility
---==: lb_array ....
---==: lb_arrayCopy ......
---==: lb_awkCompare
---==: lb_math ......
---==: lb_slash S
---==: _difference ..................
---==: _forEach ...
---==: _indexOf ....
---==: _join ..
---==: _last ..
---==: _map .
---==: _pull ...
---==: _remove ...
---==: _reverse .....
---==: _now .
---==: _eq .....
---==: _gt ........
---==: _gte ...........
---==: _isArray ....
---==: _isEqual .....
---==: _isFunction ...
---==: _isNumber ..........
---==: _isStdin ..
---==: _lt ........
---==: _lte ...........
---==: _add ..
---==: _max .
---==: _min .
---==: _sum ...
---==: _inRange ....
---==: _random .....
---==: _endsWith ..
---==: _length ..
---==: _pad ....
---==: _padEnd ...
---==: _padStart ...
---==: _parseInt ......
---==: _repeat ...
---==: _replace .....
---==: _split ............
---==: _startsWith ..
---==: _toLower ...
---==: _toUpper ...
---==: _trim ....
---==: _trimLeft ...
---==: _trimRight ...
---==: _truncate ...
---==: _inArgs ..................
---==: _stripStyles ..........
---==: _times ...
real 0m2.044s
user 0m0.994s
sys 0m1.058s