Skip to content

Latest commit

 

History

History
280 lines (213 loc) · 10.3 KB

upgrading.rst

File metadata and controls

280 lines (213 loc) · 10.3 KB

Upgrading

From v3.x.x to v4.0.0

Start by reading the full list of changes in v4.0.0 at the Changelog <changelog-v4.0.0>. There are a significant amount of backwards-incompatibilities that will likely need to be addressed:

  • All function aliases have been removed in favor of having a single named function for everything. This was done to make things less confusing by having only a single named function that performs an action vs. potentially using two different names for the same function.
  • A few functions have been removed whose functionality was duplicated by another function.
  • Some functions have been renamed for consistency and to align with Lodash.
  • Many functions have had their callback argument moved to another function to align with Lodash.
  • The generic callback argument has been renamed to either iteratee, predicate, or comparator. This was done to make it clearer what the callback is doing and to align more with Lodash's naming conventions.

Once the shock of those backwards-incompatibilities has worn off, discover 72 new functions:

  • 19 new array methods

    • pydash.arrays.difference_by
    • pydash.arrays.difference_with
    • pydash.arrays.from_pairs
    • pydash.arrays.intersection_by
    • pydash.arrays.intersection_with
    • pydash.arrays.nth
    • pydash.arrays.pull_all
    • pydash.arrays.sorted_index_by
    • pydash.arrays.sorted_index_of
    • pydash.arrays.sorted_last_index_by
    • pydash.arrays.sorted_last_index_of
    • pydash.arrays.sorted_uniq
    • pydash.arrays.union_by
    • pydash.arrays.union_with
    • pydash.arrays.uniq_by
    • pydash.arrays.uniq_with
    • pydash.arrays.xor_by
    • pydash.arrays.xor_with
    • pydash.arrays.zip_object_deep
  • 6 new collection methods

    • pydash.collections.flat_map
    • pydash.collections.flat_map_deep
    • pydash.collections.flat_depth
    • pydash.collections.flatten_depth
    • pydash.collections.invoke_map
    • pydash.collections.sample_size
  • 2 new function methods

    • pydash.functions.flip
    • pydash.functions.unary
  • 12 new object methods

    • pydash.objects.assign_with
    • pydash.objects.clone_deep_with
    • pydash.objects.clone_with
    • pydash.objects.invert_by
    • pydash.objects.merge_with
    • pydash.objects.omit_by
    • pydash.objects.pick_by
    • pydash.objects.set_with
    • pydash.objects.to_integer
    • pydash.objects.unset
    • pydash.objects.update
    • pydash.objects.udpate_with
  • 8 new numerical methods

    • pydash.numerical.clamp
    • pydash.numerical.divide
    • pydash.numerical.max_by
    • pydash.numerical.mean_by
    • pydash.numerical.min_by
    • pydash.numerical.multiply
    • pydash.numerical.subtract
    • pydash.numerical.sum_by
  • 4 new predicate methods

    • pydash.predicates.eq
    • pydash.predicates.is_equal_with
    • pydash.predicates.is_match_with
    • pydash.predicates.is_set
  • 6 new string methods

    • pydash.strings.lower_case
    • pydash.strings.lower_first
    • pydash.strings.to_lower
    • pydash.strings.to_upper
    • pydash.strings.upper_case
    • pydash.strings.upper_first
  • 15 new utility methods

    • pydash.utilities.cond
    • pydash.utilities.conforms
    • pydash.utilities.conforms_to
    • pydash.utilities.default_to
    • pydash.utilities.nth_arg
    • pydash.utilities.over
    • pydash.utilities.over_every
    • pydash.utilities.over_some
    • pydash.utilities.range_right
    • pydash.utilities.stub_list
    • pydash.utilities.stub_dict
    • pydash.utilities.stub_false
    • pydash.utilities.stub_string
    • pydash.utilities.stub_true
    • pydash.utilities.to_path

From v2.x.x to v3.0.0

There were several breaking changes in v3.0.0:

  • Make to_string convert None to empty string. (breaking change)
  • Make the following functions work with empty strings and None: (breaking change)
    • camel_case
    • capitalize
    • chars
    • chop
    • chop_right
    • class_case
    • clean
    • count_substr
    • decapitalize
    • ends_with
    • join
    • js_replace
    • kebab_case
    • lines
    • quote
    • re_replace
    • replace
    • series_phrase
    • series_phrase_serial
    • starts_with
    • surround
  • Reorder function arguments for after from (n, func) to (func, n). (breaking change)
  • Reorder function arguments for before from (n, func) to (func, n). (breaking change)
  • Reorder function arguments for times from (n, callback) to (callback, n). (breaking change)
  • Reorder function arguments for js_match from (reg_exp, text) to (text, reg_exp). (breaking change)
  • Reorder function arguments for js_replace from (reg_exp, text, repl) to (text, reg_exp, repl). (breaking change)

And some potential breaking changes:

  • Move arrays.join to strings.join (possible breaking change).
  • Rename join/implode's second parameter from delimiter to separator. (possible breaking change)
  • Rename split/explode's second parameter from delimiter to separator. (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

    • pydash.arrays.duplicates
  • 2 new function methods

    • pydash.functions.ary
    • pydash.functions.rearg
  • 1 new collection method:

    • pydash.collections.sort_by_all
  • 4 new object methods

    • pydash.objects.to_boolean
    • pydash.objects.to_dict
    • pydash.objects.to_number
    • pydash.objects.to_plain_object
  • 4 new predicate methods

    • pydash.predicates.is_blank
    • pydash.predicates.is_builtin and alias pydash.predicates.is_native
    • pydash.predicates.is_match
    • pydash.predicates.is_tuple
  • 1 new utility method

    • pydash.utilities.prop_of and alias pydash.utilities.property_of
  • 6 new aliases:

    • pydash.predicates.is_bool for pydash.predicates.is_boolean
    • pydash.predicates.is_dict for pydash.predicates.is_plain_object
    • pydash.predicates.is_int for pydash.predicates.is_integer
    • pydash.predicates.is_num for pydash.predicates.is_number
    • pydash.strings.truncate for pydash.strings.trunc
    • pydash.strings.underscore_case for pydash.strings.snake_case
  • Chaining can now accept the root value argument 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]

- For more details on method chaining, check out Method Chaining <method-chaining>. - For a full listing of changes in v3.0.0, check out the Changelog <changelog-v3.0.0>.

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 either flatten(..., is_deep=True) or flatten_deep(...).
  • pydash.predicates.is_number now returns False for boolean True and False. Previously, it returned True.
  • Internally, the files located in pydash.api were moved to pydash. If you imported from pydash.api.<module>, then it's recommended to change your imports to pull from pydash.
  • The function functions() was renamed to callables() to avoid ambiguities with the module functions.py.

Some notable new features:

  • Callback functions no longer require the full call signature definition.
  • A new "_" instance was added which supports both method chaining and module method calling. See api-dash-instance for more details.

For a full listing of changes in v2.0.0, check out the Changelog <changelog-v2.0.0>.