Package: pylodash
Python Lodashpylodash is collection utilities allow you working witharrays,maths,numberandstringInstallationYou can install the Pylodash fromPyPI:pip install pylodashPylodash is supported on Python 3.4 and above.How to use methodsYou can call the Pylodash in your own Python code, by importing thepylodashpackage:>>> import pylodash as _
>>> _.chunk(['a', 'b' , 'c', 'd'], 2)
// => [['a', 'b'], ['c', 'd']]Pylodash MethodsArrayschunk()Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.compact()Creates an array with all falsey values removed. The values False, None, 0 and "" are falsey.difference()Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.drop()Creates a slice of array with n elements dropped from the beginning.drop_right()Creates a slice of array with n elements dropped from the end.fill()Fills elements of array with value from start up to, but not including, end.index_of()Gets the index at which the first occurrence of value is found in array using SameValueZero for equality comparisons. If fromIndex is negative, it's used as the offset from the end of array.initial()Gets all but the last element of array.pull()Removes all given values from array using SameValueZero for equality comparisons.Mathsadd()Adds two numbers.ceil()Computesnumberrounded up toprecision.divide()Divide two numbers.floor()Computesnumberrounded down toprecision.max()Computes the maximum value ofarray. If array is empty or falsey, [] is returned.mean()Computes the mean of the values inarray.min()Computes the minimum value ofarray. Ifarrayis empty or falsey, [] is returned.multiply()Multiply two numbers.substract()Subtract two numbers.sum()Computes the sum of the values in array.Numberclamp()Clamps number within the inclusive lower and upper bounds.in_range()Checks ifnis betweenstartand up to, but not including,end. Ifendis not specified, it's set tostartwithstartthen set to0. Ifstartis greater thanendthe params are swapped to support negative ranges.random()Produces a random number between the inclusive lower and upper bounds. If only one argument is provided a number between 0 and the given number is returned. If floating is true, or either lower or upper are floats, a floating-point number is returned instead of an integer.Stringcamel_case()Converts string to camel case.capitalize()Converts the first character of string to upper case and the remaining to lower case.ends_with()Checks if string ends with the given target string.escape()Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.lower_case()Converts string, as space separated words, to lower case.lower_first()Converts the first character of string to lower case.pad()Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.pad_end()Pads string on the right side if it's shorter than length. Padding characters are truncated if they exceed length.pad_start()Pads string on the left side if it's shorter than length. Padding characters are truncated if they exceed length.repeat()Repeats the given string n times.replace()Replaces matches for pattern in string with replacement.starts_with()Checks if string starts with the given target string.List methods in packages"Arrays" Methods_.chunk(array, [size=1])Example_.chunk(['a', 'b', 'c', 'd'], 2)
// => [['a', 'b'], ['c', 'd']]
 
_.chunk(['a', 'b', 'c', 'd'], 3)
// => [['a', 'b', 'c'], ['d']]_.compact(array)Example_.compact([0, 1, False, 2, '', 3])
// => [1, 2, 3]_.difference(array, [values])Example_.difference([2, 1], [2, 3])
// => [1]_.drop(array, [n=1])Example_.drop([1, 2, 3])
// => [2, 3]
 
_.drop([1, 2, 3], 2)
// => [3]
 
_.drop([1, 2, 3], 5)
// => []
 
_.drop([1, 2, 3], 0)
// => [1, 2, 3]_.drop_right(array, [n=1])Example_.drop_right([1, 2, 3])
// => [1, 2]
 
_.drop_right([1, 2, 3], 2)
// => [1]
 
_.drop_right([1, 2, 3], 5)
// => []
 
_.drop_right([1, 2, 3], 0)
// => [1, 2, 3]_.fill(array, value, [start=0])Examplearray = [1, 2, 3]
 
_.fill(array, 'a')
// => ['a', 'a', 'a']
 
_.fill(Array(3), 2)
// => [2, 2, 2]
 
_.fill([4, 6, 8, 10], '*', 1, 3)
// => [4, '*', '*', 10]_.index_of(array, value, [fromIndex=0])Example_.index_of([1, 2, 1, 2], 2)
// => 1
 
// Search from the `fromIndex`.
_.index_of([1, 2, 1, 2], 2, 2)
// => 3_.initial(array)Example_.initial([1, 2, 3])
// => [1, 2]_.pull(array, [values])Examplearray = ['a', 'b', 'c', 'a', 'b', 'c']
 
_.pull(array, 'a', 'c')
// => ['b', 'b']"Maths" Methods_.add(augend, addend)Example_.add(6, 4)
// => 10_.ceil(number, [precision=0])Example_.ceil(4.006)
// => 5
 
_.ceil(6.004, 2)
// => 6.01
 
_.ceil(6040, -2)
// => 6100_.divide(dividend, divisor)Example_.divide(6, 4)
// => 1.5_.floor(number, [precision=0])Example_.floor(4.006)
// => 4
 
_.floor(0.046, 2)
// => 0.04
 
_.floor(4060, -2)
// => 4000_.max(array)Example_.max([4, 2, 8, 6])
// => 8
 
_.max([]);
// => undefined_.mean(array)Example_.mean([4, 2, 8, 6]);
// => 5_.min(array)Example_.min([4, 2, 8, 6]);
// => 2
 
_.min([]);
// => undefined_.multiply(multiplier, multiplicand)Example_.multiply(6, 4)
// => 24_.round(number, [precision=0])Example_.round(4.006)
// => 4
 
_.round(4.006, 2)
// => 4.01
 
_.round(4060, -2)
// => 4100_.subtract(minuend, subtrahend)Example_.subtract(6, 4)
// => 2_.sum(array)Example_.sum([4, 2, 8, 6])
// => 20"Number" Methods_.clamp(number, [lower], upper)Example_.clamp(-10, -5, 5)
// => -5
 
_.clamp(10, -5, 5)
// => 5_.in_range(number, [start=0], end)Example_.in_range(3, 2, 4)
// => True
 
_.in_range(4, 8)
// => True
 
_.in_range(4, 2)
// => False
 
_.in_range(2, 2)
// => False
 
_.in_range(1.2, 2)
// => True
 
_.in_range(5.2, 4)
// => False
 
_.in_range(-3, -2, -6)
// => True_.random([lower=0], [upper=1], [floating])Example_.random(0, 5);
// => an integer between 0 and 5
 
_.random(5);
// => also an integer between 0 and 5
 
_.random(5, true);
// => a floating-point number between 0 and 5
 
_.random(1.2, 5.2);
// => a floating-point number between 1.2 and 5.2"String" Methods_.camel_case([string=''])Example_.camel_case('Foo Bar')
// => 'fooBar'
 
_.camel_case('--foo-bar--')
// => 'fooBar'
 
_.camel_case('__FOO_BAR__')
// => 'fooBar'_.capitalize([string=''])Example_.capitalize('FRED')
// => 'Fred'_.ends_with([string=''], [target], [position=string.length])Example_.ends_with('abc', 'c')
// => True
 
_.ends_with('abc', 'b')
// => False
 
_.ends_with('abc', 'b', 2)
// => True_.escape([string=''])Example_.escape('fred, barney, & pebbles')
// => 'fred, barney, &amp; pebbles'_.lower_case([string=''])Example_.lower_case('--Foo-Bar--')
// => 'foo bar'
 
_.lower_case('fooBar')
// => 'foo bar'
 
_.lower_case('__FOO_BAR__')
// => 'foo bar'_.lower_first([string=''])Example_.lower_first('Fred')
// => 'fred'
 
_.lower_first('FRED')
// => 'fRED'_.pad([string=''], [length=0], [chars=' '])Example_.pad('abc', 8)
// => '  abc   '
 
_.pad('abc', 8, '_-')
// => '_-abc_-_'
 
_.pad('abc', 3)
// => 'abc'_.pad_end([string=''], [length=0], [chars=' '])Example_.pad_end('abc', 6)
// => 'abc   '
 
_.pad_end('abc', 6, '_-')
// => 'abc_-_'
 
_.pad_end('abc', 3)
// => 'abc'_.pad_start([string=''], [length=0], [chars=' '])Example_.pad_start('abc', 6)
// => '   abc'
 
_.pad_start('abc', 6, '_-')
// => '_-_abc'
 
_.pad_start('abc', 3)
// => 'abc'_.repeat([string=''], [n=1])Example_.repeat('*', 3)
// => '***'
 
_.repeat('abc', 2)
// => 'abcabc'
 
_.repeat('abc', 0)
// => ''_.replace([string=''], pattern, replacement)Example_.replace('Hi Fred', 'Fred', 'Barney')
// => 'Hi Barney'_.starts_with([string=''], [target], [position=0])Example_.starts_with('abc', 'a')
// => True
 
_.starts_with('abc', 'b')
// => False
 
_.starts_with('abc', 'b', 1)
// => TrueDevelopment ModeBuilding Your PackageIn development mode, pylodash need install packages below to build package:- setuptools >= 38.6.0
- wheel >= 0.31.0
- twine >= 1.11.0Run command to build package:$ python3 setup.py sdist bdist_wheelTesting Your PackageTo check that your package description will render properly on PyPI, you can run twine check on the files created in dist:$ twine check dist/*Uploading Your PackagesTo install package to develop environment, we can use command:$ python3 setup.py developTo upload package to testing environment before upload to PyPI, follow step (make sure you have an account registered):$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*To publish your own package to PyPI, this final step is short:$ twine upload dist/*pipinstall Your PackageWith your package uploaded to PyPI, you can install it with pip as well:$ pip install pylodashTo run all test cases in package, you can run command below in folder package:$ python setup.py testLicenseCopyright © 2019 All rights reserved.