{ "info": { "author": "Tuan Luu", "author_email": "tuan.luu@asnet.com.vn", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Topic :: Text Processing :: Linguistic" ], "description": "# Python Lodash\n\npylodash is collection utilities allow you working with `arrays`, `maths`, `number` and `string`\n\n## Installation\n\nYou can install the Pylodash from [PyPI](https://pypi.org/project/pylodash/):\n\n```\npip install pylodash\n```\n\nPylodash is supported on Python 3.4 and above.\n\n## How to use methods\n\nYou can call the Pylodash in your own Python code, by importing the `pylodash` package:\n\n```\n>>> import pylodash as _\n>>> _.chunk(['a', 'b' , 'c', 'd'], 2)\n// => [['a', 'b'], ['c', 'd']]\n```\n\n## Pylodash Methods\n\n1. [Arrays](#arrays)\n - [chunk()](#chunk)\n - 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.\n\n - [compact()](#compact)\n - Creates an array with all falsey values removed. The values False, None, 0 and \"\" are falsey.\n\n - [difference()](#difference)\n - 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.\n\n - [drop()](#drop)\n - Creates a slice of array with n elements dropped from the beginning.\n\n - [drop_right()](#drop_right)\n - Creates a slice of array with n elements dropped from the end.\n\n - [fill()](#fill)\n - Fills elements of array with value from start up to, but not including, end.\n\n - [index_of()](#index_of)\n - 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.\n\n - [initial()](#initial)\n - Gets all but the last element of array.\n\n - [pull()](#pull)\n - Removes all given values from array using SameValueZero for equality comparisons.\n\n2. [Maths](#maths)\n - [add()](#add)\n - Adds two numbers.\n\n - [ceil()](#ceil)\n - Computes *number* rounded up to *precision*.\n\n - [divide()](#divide)\n - Divide two numbers.\n\n - [floor()](#floor)\n - Computes *number* rounded down to *precision*.\n\n - [max()](#max)\n - Computes the maximum value of *array*. If array is empty or falsey, [] is returned.\n\n - [mean()](#mean)\n - Computes the mean of the values in *array*.\n\n - [min()](#min)\n - Computes the minimum value of *array*. If *array* is empty or falsey, [] is returned.\n\n - [multiply()](#multiply)\n - Multiply two numbers.\n\n - [substract()](#substract)\n - Subtract two numbers.\n\n - [sum()](#sum)\n - Computes the sum of the values in array.\n\n\n3. [Number](#number)\n - [clamp()](#clamp)\n - Clamps number within the inclusive lower and upper bounds.\n\n - [in_range()](#in_range)\n - Checks if *n* is between *start* and up to, but not including, *end*. If *end* is not specified, it's set to *start* with *start* then set to *0*. If *start* is greater than *end* the params are swapped to support negative ranges.\n\n - [random()](#random)\n - 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.\n\n4. [String](#string)\n - [camel_case()](#camelcase)\n - Converts string to camel case.\n\n - [capitalize()](#capitalize)\n - Converts the first character of string to upper case and the remaining to lower case.\n\n - [ends_with()](#ends_with)\n - Checks if string ends with the given target string.\n\n - [escape()](#escape)\n - Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in string to their corresponding HTML entities.\n\n - [lower_case()](#lower_case)\n - Converts string, as space separated words, to lower case.\n\n - [lower_first()](#lower_first)\n - Converts the first character of string to lower case.\n\n - [pad()](#pad)\n - 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.\n\n - [pad_end()](#pad_end)\n - Pads string on the right side if it's shorter than length. Padding characters are truncated if they exceed length.\n\n - [pad_start()](#pad_start)\n - Pads string on the left side if it's shorter than length. Padding characters are truncated if they exceed length.\n\n - [repeat()](#repeat)\n - Repeats the given string n times.\n\n - [replace()](#replace)\n - Replaces matches for pattern in string with replacement.\n\n - [starts_with()](#starts_with)\n - Checks if string starts with the given target string.\n\n## List methods in packages\n\n### \"Arrays\" Methods\n\n\n```\n_.chunk(array, [size=1])\n```\n\n**Example**\n\n```\n_.chunk(['a', 'b', 'c', 'd'], 2)\n// => [['a', 'b'], ['c', 'd']]\n \n_.chunk(['a', 'b', 'c', 'd'], 3)\n// => [['a', 'b', 'c'], ['d']]\n```\n---\n\n\n```\n_.compact(array)\n```\n\n**Example**\n\n```\n_.compact([0, 1, False, 2, '', 3])\n// => [1, 2, 3]\n```\n\n---\n\n```\n_.difference(array, [values])\n```\n\n**Example**\n\n```\n_.difference([2, 1], [2, 3])\n// => [1]\n```\n\n---\n\n```\n_.drop(array, [n=1])\n```\n\n**Example**\n\n```\n_.drop([1, 2, 3])\n// => [2, 3]\n \n_.drop([1, 2, 3], 2)\n// => [3]\n \n_.drop([1, 2, 3], 5)\n// => []\n \n_.drop([1, 2, 3], 0)\n// => [1, 2, 3]\n```\n\n---\n\n```\n_.drop_right(array, [n=1])\n```\n\n**Example**\n\n```\n_.drop_right([1, 2, 3])\n// => [1, 2]\n \n_.drop_right([1, 2, 3], 2)\n// => [1]\n \n_.drop_right([1, 2, 3], 5)\n// => []\n \n_.drop_right([1, 2, 3], 0)\n// => [1, 2, 3]\n```\n\n---\n\n```\n_.fill(array, value, [start=0])\n```\n\n**Example**\n\n```\narray = [1, 2, 3]\n \n_.fill(array, 'a')\n// => ['a', 'a', 'a']\n \n_.fill(Array(3), 2)\n// => [2, 2, 2]\n \n_.fill([4, 6, 8, 10], '*', 1, 3)\n// => [4, '*', '*', 10]\n```\n\n---\n\n```\n_.index_of(array, value, [fromIndex=0])\n```\n\n**Example**\n\n```\n_.index_of([1, 2, 1, 2], 2)\n// => 1\n \n// Search from the `fromIndex`.\n_.index_of([1, 2, 1, 2], 2, 2)\n// => 3\n```\n\n---\n\n```\n_.initial(array)\n```\n\n**Example**\n\n```\n_.initial([1, 2, 3])\n// => [1, 2]\n```\n\n---\n\n```\n_.pull(array, [values])\n```\n\n**Example**\n\n```\narray = ['a', 'b', 'c', 'a', 'b', 'c']\n \n_.pull(array, 'a', 'c')\n// => ['b', 'b']\n```\n\n---\n### \"Maths\" Methods\n\n\n```\n_.add(augend, addend)\n```\n\n**Example**\n\n```\n_.add(6, 4)\n// => 10\n```\n\n---\n\n```\n_.ceil(number, [precision=0])\n```\n\n**Example**\n\n```\n_.ceil(4.006)\n// => 5\n \n_.ceil(6.004, 2)\n// => 6.01\n \n_.ceil(6040, -2)\n// => 6100\n```\n\n---\n\n```\n_.divide(dividend, divisor)\n```\n\n**Example**\n\n```\n_.divide(6, 4)\n// => 1.5\n```\n\n---\n\n```\n_.floor(number, [precision=0])\n```\n\n**Example**\n\n```\n_.floor(4.006)\n// => 4\n \n_.floor(0.046, 2)\n// => 0.04\n \n_.floor(4060, -2)\n// => 4000\n```\n\n---\n\n```\n_.max(array)\n```\n\n**Example**\n\n```\n_.max([4, 2, 8, 6])\n// => 8\n \n_.max([]);\n// => undefined\n```\n\n---\n\n```\n_.mean(array)\n```\n\n**Example**\n\n```\n_.mean([4, 2, 8, 6]);\n// => 5\n```\n\n---\n\n```\n_.min(array)\n```\n\n**Example**\n\n```\n_.min([4, 2, 8, 6]);\n// => 2\n \n_.min([]);\n// => undefined\n```\n\n---\n\n```\n_.multiply(multiplier, multiplicand)\n```\n\n**Example**\n\n```\n_.multiply(6, 4)\n// => 24\n```\n\n---\n\n```\n_.round(number, [precision=0])\n```\n\n**Example**\n\n```\n_.round(4.006)\n// => 4\n \n_.round(4.006, 2)\n// => 4.01\n \n_.round(4060, -2)\n// => 4100\n```\n\n---\n\n```\n_.subtract(minuend, subtrahend)\n```\n\n**Example**\n\n```\n_.subtract(6, 4)\n// => 2\n```\n\n---\n\n```\n_.sum(array)\n```\n\n**Example**\n\n```\n_.sum([4, 2, 8, 6])\n// => 20\n```\n\n---\n### \"Number\" Methods\n\n\n```\n_.clamp(number, [lower], upper)\n```\n\n**Example**\n\n```\n_.clamp(-10, -5, 5)\n// => -5\n \n_.clamp(10, -5, 5)\n// => 5\n```\n\n---\n\n```\n_.in_range(number, [start=0], end)\n```\n\n**Example**\n\n```\n_.in_range(3, 2, 4)\n// => True\n \n_.in_range(4, 8)\n// => True\n \n_.in_range(4, 2)\n// => False\n \n_.in_range(2, 2)\n// => False\n \n_.in_range(1.2, 2)\n// => True\n \n_.in_range(5.2, 4)\n// => False\n \n_.in_range(-3, -2, -6)\n// => True\n```\n\n---\n\n```\n_.random([lower=0], [upper=1], [floating])\n```\n\n**Example**\n\n```\n_.random(0, 5);\n// => an integer between 0 and 5\n \n_.random(5);\n// => also an integer between 0 and 5\n \n_.random(5, true);\n// => a floating-point number between 0 and 5\n \n_.random(1.2, 5.2);\n// => a floating-point number between 1.2 and 5.2\n```\n\n---\n### \"String\" Methods\n\n\n```\n_.camel_case([string=''])\n```\n\n**Example**\n\n```\n_.camel_case('Foo Bar')\n// => 'fooBar'\n \n_.camel_case('--foo-bar--')\n// => 'fooBar'\n \n_.camel_case('__FOO_BAR__')\n// => 'fooBar'\n```\n\n---\n\n```\n_.capitalize([string=''])\n```\n\n**Example**\n\n```\n_.capitalize('FRED')\n// => 'Fred'\n```\n\n---\n\n```\n_.ends_with([string=''], [target], [position=string.length])\n```\n\n**Example**\n\n```\n_.ends_with('abc', 'c')\n// => True\n \n_.ends_with('abc', 'b')\n// => False\n \n_.ends_with('abc', 'b', 2)\n// => True\n```\n\n---\n\n```\n_.escape([string=''])\n```\n\n**Example**\n\n```\n_.escape('fred, barney, & pebbles')\n// => 'fred, barney, & pebbles'\n```\n\n---\n\n```\n_.lower_case([string=''])\n```\n\n**Example**\n\n```\n_.lower_case('--Foo-Bar--')\n// => 'foo bar'\n \n_.lower_case('fooBar')\n// => 'foo bar'\n \n_.lower_case('__FOO_BAR__')\n// => 'foo bar'\n```\n\n---\n\n```\n_.lower_first([string=''])\n```\n\n**Example**\n\n```\n_.lower_first('Fred')\n// => 'fred'\n \n_.lower_first('FRED')\n// => 'fRED'\n```\n\n---\n\n```\n_.pad([string=''], [length=0], [chars=' '])\n```\n\n**Example**\n\n```\n_.pad('abc', 8)\n// => ' abc '\n \n_.pad('abc', 8, '_-')\n// => '_-abc_-_'\n \n_.pad('abc', 3)\n// => 'abc'\n```\n\n---\n\n```\n_.pad_end([string=''], [length=0], [chars=' '])\n```\n\n**Example**\n\n```\n_.pad_end('abc', 6)\n// => 'abc '\n \n_.pad_end('abc', 6, '_-')\n// => 'abc_-_'\n \n_.pad_end('abc', 3)\n// => 'abc'\n```\n\n---\n\n```\n_.pad_start([string=''], [length=0], [chars=' '])\n```\n\n**Example**\n\n```\n_.pad_start('abc', 6)\n// => ' abc'\n \n_.pad_start('abc', 6, '_-')\n// => '_-_abc'\n \n_.pad_start('abc', 3)\n// => 'abc'\n```\n\n---\n\n```\n_.repeat([string=''], [n=1])\n```\n\n**Example**\n\n```\n_.repeat('*', 3)\n// => '***'\n \n_.repeat('abc', 2)\n// => 'abcabc'\n \n_.repeat('abc', 0)\n// => ''\n```\n\n---\n\n```\n_.replace([string=''], pattern, replacement)\n```\n\n**Example**\n\n```\n_.replace('Hi Fred', 'Fred', 'Barney')\n// => 'Hi Barney'\n```\n\n---\n\n```\n_.starts_with([string=''], [target], [position=0])\n```\n\n**Example**\n\n```\n_.starts_with('abc', 'a')\n// => True\n \n_.starts_with('abc', 'b')\n// => False\n \n_.starts_with('abc', 'b', 1)\n// => True\n```\n\n## Development Mode\n\n### Building Your Package\n\nIn development mode, pylodash need install packages below to build package:\n\n```\n- setuptools >= 38.6.0\n- wheel >= 0.31.0\n- twine >= 1.11.0\n```\n\n\nRun command to build package:\n\n```\n$ python3 setup.py sdist bdist_wheel\n```\n\n### Testing Your Package\n\nTo check that your package description will render properly on PyPI, you can run twine check on the files created in dist:\n\n```\n$ twine check dist/*\n```\n\n### Uploading Your Packages\n\nTo install package to develop environment, we can use command:\n\n```\n$ python3 setup.py develop\n```\n\nTo upload package to testing environment before upload to PyPI, follow step (make sure you have an account registered):\n\n```\n$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*\n```\n\nTo publish your own package to PyPI, this final step is short:\n\n```\n$ twine upload dist/*\n```\n\n### *pip* install Your Package\n\nWith your package uploaded to PyPI, you can install it with pip as well:\n\n```\n$ pip install pylodash\n```\n\nTo run all test cases in package, you can run command below in folder package:\n\n```\n$ python setup.py test\n```\n\n## License\n\nCopyright \u00a9 2019 All rights reserved.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.asoft-python.com/g-tuanluu/python-training", "keywords": "python lodash utilities pylodash", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pylodash", "package_url": "https://pypi.org/project/pylodash/", "platform": "", "project_url": "https://pypi.org/project/pylodash/", "project_urls": { "Homepage": "https://gitlab.asoft-python.com/g-tuanluu/python-training" }, "release_url": "https://pypi.org/project/pylodash/0.4.4/", "requires_dist": null, "requires_python": "", "summary": "A modern Python utility library delivering modularity, performance & extras.", "version": "0.4.4" }, "last_serial": 4909560, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7b9bc21ad89f3fd086c7970dbf28e4da", "sha256": "ea7baa2ce51d7900435d97cb715071f81eac7bbb199c4122f96b6dbc90a32b10" }, "downloads": -1, "filename": "pylodash-0.1.tar.gz", "has_sig": false, "md5_digest": "7b9bc21ad89f3fd086c7970dbf28e4da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 980, "upload_time": "2019-03-01T06:59:16", "url": "https://files.pythonhosted.org/packages/af/9e/1e8ff3c9a4164860aaf8706ed4c936ac272eaf6f5759fdeb906af191ad21/pylodash-0.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "a0b9130f104aebf083f423067cc398e1", "sha256": "98fe84b0d5b38f764463958788356a3a10fc7700de9d4d29da3de7a4ed58d00f" }, "downloads": -1, "filename": "pylodash-0.3.0.tar.gz", "has_sig": false, "md5_digest": "a0b9130f104aebf083f423067cc398e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2537, "upload_time": "2019-03-04T10:40:07", "url": "https://files.pythonhosted.org/packages/aa/48/1cfe8550298b9b390aab01b4eb9ee90faa40bdb262623b24f72bdcba5532/pylodash-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "0edd9d79c3a7cc151639c3f0d6bd326c", "sha256": "cf1687824bea94cc0d3a39b0f54224b018f949af2e1cba8db08e9e9618342ca0" }, "downloads": -1, "filename": "pylodash-0.4.0.tar.gz", "has_sig": false, "md5_digest": "0edd9d79c3a7cc151639c3f0d6bd326c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3608, "upload_time": "2019-03-05T11:08:02", "url": "https://files.pythonhosted.org/packages/42/a2/4333c32f809047b5bd68d80a372a08a32149ca4d09cfa9b90850c931ede8/pylodash-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "e2bc136670042a58c1627cdfd6cf54b7", "sha256": "eece18c4fc9cd8a3b26a989f60750d4001f6942c5b5ae0c680712660bb47be4f" }, "downloads": -1, "filename": "pylodash-0.4.1.tar.gz", "has_sig": false, "md5_digest": "e2bc136670042a58c1627cdfd6cf54b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6481, "upload_time": "2019-03-06T08:18:21", "url": "https://files.pythonhosted.org/packages/cd/e2/be12bd8381f19e1b8b1ea5d25c1d6212cb99e64edbaf3e997fc7626afea6/pylodash-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "a0133c1ecdbd12afbb426236f9031acf", "sha256": "ae2e6abb0564421b744bf892afd8f19c19025dc5d4a3a7d7f18fd59528d004c9" }, "downloads": -1, "filename": "pylodash-0.4.2.tar.gz", "has_sig": false, "md5_digest": "a0133c1ecdbd12afbb426236f9031acf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8658, "upload_time": "2019-03-06T10:46:49", "url": "https://files.pythonhosted.org/packages/36/65/b5bac7b9fd85fbab036c8419a7550a93ef17603c2289575478b7f19d6b09/pylodash-0.4.2.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "b58afb88747c595f2723fa0077e47188", "sha256": "65a508fccde9ce125d2acea824f13ae88403e33eb3d1ec0d24b19d4441bfad62" }, "downloads": -1, "filename": "pylodash-0.4.4.tar.gz", "has_sig": false, "md5_digest": "b58afb88747c595f2723fa0077e47188", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10594, "upload_time": "2019-03-07T10:47:56", "url": "https://files.pythonhosted.org/packages/39/0c/072e38e2d56455bd3c0c04ccf097c7b0c9d12abbecf068688098e87ba560/pylodash-0.4.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b58afb88747c595f2723fa0077e47188", "sha256": "65a508fccde9ce125d2acea824f13ae88403e33eb3d1ec0d24b19d4441bfad62" }, "downloads": -1, "filename": "pylodash-0.4.4.tar.gz", "has_sig": false, "md5_digest": "b58afb88747c595f2723fa0077e47188", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10594, "upload_time": "2019-03-07T10:47:56", "url": "https://files.pythonhosted.org/packages/39/0c/072e38e2d56455bd3c0c04ccf097c7b0c9d12abbecf068688098e87ba560/pylodash-0.4.4.tar.gz" } ] }