Upgrading¶
From v2.x.x to v3.0.0¶
There were several breaking changes in v3.0.0:
- Make
to_stringconvertNoneto empty string. (breaking change) - Make the following functions work with empty strings and
None: (breaking change)camel_casecapitalizecharschopchop_rightclass_casecleancount_substrdecapitalizeends_withjoinjs_replacekebab_caselinesquotere_replacereplaceseries_phraseseries_phrase_serialstarts_withsurround
- Reorder function arguments for
afterfrom(n, func)to(func, n). (breaking change) - Reorder function arguments for
beforefrom(n, func)to(func, n). (breaking change) - Reorder function arguments for
timesfrom(n, callback)to(callback, n). (breaking change) - Reorder function arguments for
js_matchfrom(reg_exp, text)to(text, reg_exp). (breaking change) - Reorder function arguments for
js_replacefrom(reg_exp, text, repl)to(text, reg_exp, repl). (breaking change)
And some potential breaking changes:
- Move
arrays.jointostrings.join(possible breaking change). - Rename
join/implode‘s second parameter fromdelimitertoseparator. (possible breaking change) - Rename
split/explode‘s second parameter fromdelimitertoseparator. (possible breaking change)
Some notable new features/functions:
31 new string methods
pydash.strings.chars()pydash.strings.chop()pydash.strings.chop_right()pydash.strings.class_case()pydash.strings.clean()pydash.strings.count_substr()pydash.strings.decapitalize()pydash.strings.has_substr()pydash.strings.human_case()pydash.strings.insert_substr()pydash.strings.lines()pydash.strings.number_format()pydash.strings.pascal_case()pydash.strings.predecessor()pydash.strings.prune()pydash.strings.re_replace()pydash.strings.replace()pydash.strings.separator_case()pydash.strings.series_phrase()pydash.strings.series_phrase_serial()pydash.strings.slugify()pydash.strings.split()pydash.strings.strip_tags()pydash.strings.substr_left()pydash.strings.substr_left_end()pydash.strings.substr_right()pydash.strings.substr_right_end()pydash.strings.successor()pydash.strings.swap_case()pydash.strings.title_case()pydash.strings.unquote()
1 new array method
2 new function methods
1 new collection method:
4 new object methods
4 new predicate methods
1 new utility method
6 new aliases:
pydash.predicates.is_bool()forpydash.predicates.is_boolean()pydash.predicates.is_dict()forpydash.predicates.is_plain_object()pydash.predicates.is_int()forpydash.predicates.is_integer()pydash.predicates.is_num()forpydash.predicates.is_number()pydash.strings.truncate()forpydash.strings.trunc()pydash.strings.underscore_case()forpydash.strings.snake_case()
Chaining can now accept the root
valueargument late.Chains can be re-used with differnt initial values via
chain().plant.New chains can be created using the chain’s computed value as the new chain’s initial value via
chain().commit.Support iteration over class instance properties for non-list, non-dict, and non-iterable objects.
Late Value Chaining¶
The passing of the root value argument for chaining can now be done “late” meaning that you can build chains without providing a value at the beginning. This allows you to build a chain and re-use it with different root values:
>>> from pydash import py_
>>> square_sum = py_().power(2).sum()
>>> [square_sum([1, 2, 3]), square_sum([4, 5, 6]), square_sum([7, 8, 9])]
[14, 77, 194]
See also
- For more details on method chaining, check out Method Chaining.
- For a full listing of changes in
v3.0.0, check out the Changelog.
From v1.x.x to v2.0.0¶
There were several breaking and potentially breaking changes in v2.0.0:
pydash.arrays.flatten()is now shallow by default. Previously, it was deep by default. For deep flattening, use eitherflatten(..., is_deep=True)orflatten_deep(...).pydash.predicates.is_number()now returnsFalsefor booleanTrueandFalse. Previously, it returnedTrue.- Internally, the files located in
pydash.apiwere moved topydash. If you imported frompydash.api.<module>, then it’s recommended to change your imports to pull frompydash. - The function
functions()was renamed tocallables()to avoid ambiguities with the modulefunctions.py.
Some notable new features:
- Callback functions no longer require the full call signature definition. See Callbacks for more details.
- A new “_” instance was added which supports both method chaining and module method calling. See py_ Instance for more details.
See also
For a full listing of changes in v2.0.0, check out the Changelog.