All notable changes to this project will be documented in this file.
For more information about changelogs, check Keep a Changelog and Vandamme.
- [ENHANCEMENT]
filter/3andtake_by_key/3accept anempties:option.:prune(default) keeps the existing behavior of dropping branches with no surviving content;:keeppreserves the container skeleton, leaving any container that filters down to empty as%{}/[]while still pruning unmatched scalar and struct leaves. - [ENHANCEMENT]
compact/2accepts the sameempties: :keep | :pruneoption as the canonical spelling for its empty-container handling. - [DEPRECATION]
compact/2's booleanprune_emptyis now a deprecated alias forempties:(prune_empty: false==empties: :keep;prune_empty: true==empties: :prune) and will be removed in 3.0. Passing both:emptiesand:prune_emptyraisesArgumentError. Existingprune_emptycalls are otherwise unchanged.
- [ENHANCEMENT] Add
compact/2to removenilmap values recursively. Empty containers are pruned by default withprune_empty: true, andstrip_list_nils: trueoptionally removesnillist elements. - [ENHANCEMENT] Add
redact/3to replace values selected by a keys list or predicate.replacement:customizes the redaction value, andrecurse_into_matched: truesearches matched containers for deeper matches instead of replacing those containers wholesale.
- [BREAKING CHANGE]
take_by_key/3is now structure-preserving. In 1.x it flattened all matches into a single-level map, silently losing data when the same key appeared in more than one branch. Matches now stay at the path where they were found. - [BREAKING CHANGE] Remove the public-but-undocumented
drop_by/2andtake_by/2. Usereject/3andfilter/3instead. - [BREAKING CHANGE] Require Elixir ~> 1.15.
- [ENHANCEMENT] New engine functions:
reject/3recursively removes entries matching a predicate;filter/3recursively keeps matching entries (kept whole) and prunes branches without a match.drop_by_value/3,drop_by_key/3, andtake_by_key/3are now sugar over the engines and each accept anoptsargument. - [ENHANCEMENT] New
structs:option on every function::leaf(default) passes structs through as opaque values,:convertrecurses into them viaMap.from_struct/1,:errorraisesArgumentErroron any struct. - [ENHANCEMENT] StreamData property suite; 100% test coverage.
| If you used | In 2.0 |
|---|---|
take_by_key(map, keys) |
Same call, new semantics: results keep their original nesting instead of being flattened (no more data loss on duplicate keys). Audit call sites that relied on a flat result. |
drop_by/2 |
reject(map, predicate) — e.g. NestedFilter.reject(map, fn _k, v -> is_nil(v) end) |
take_by/2 |
filter(map, predicate) — e.g. NestedFilter.filter(map, fn k, _v -> k in [:id] end) |
| Structs converted by hand before 1.x calls | Pass structs: :convert (or keep the default :leaf to treat structs as opaque values) |
| Elixir < 1.15 | Stay on nested_filter ~> 1.2 or upgrade Elixir; 2.0 requires ~> 1.15 |
- [WARNING FIX] Remove warning from unused parameter (thanks @rsilvestre)
- Update credo, excoveralls, ex_doc, inch_ex dependencies
- [ENHANCEMENT] Add a take_by_key function which returns a map based on user specified keys. A duplicate key's values are overwritten (or merged if the value is a map).
- [ENHANCEMENT] Filter out lists of maps
- [BUGFIX] Filter out values even if DateTime values exist in a nested map
- [BREAKING CHANGE] - Drop support for Elixir 1.2.0. This is done in order to be able to easily pattern match on DateTime structs.
- [ENHANCEMENT] Update to use more idiomatic Elixir code. Thank you scohen.
- [ENHANCEMENT] Update to allow compatibility with Elixir >= 1.2.0
- [ENHANCEMENT] Change method names to drop_by_value and drop_by_key for more clarity
- [ENHANCEMENT] Add a NestedFilter#reject_values_by_key to allow the user to specify the automatic removal of values with specific keys
- [ENHANCEMENT] Remove a "remove_empty" option to NestedFilter#reject_keys_by_values to allow the user to specify the automatic removal of keys that end up with empty values
- [ENHANCEMENT] Add a "remove_empty" option to NestedFilter#reject_keys_by_values to allow the user to specify the automatic removal of keys that end up with empty values
- Initial release to let a user filter out a nested map's keys via user specified values