Skip to content

ottojimb/deep_clean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepClean

Provide functionality to exclude elements in nested maps or list.

Installation

If available in Hex, the package can be installed by adding deep_clean to your list of dependencies in mix.exs:

def deps do
  [{:deep_clean, "~> 0.1.1"}]
end

Documentation can be generated with ExDoc and published on HexDocs. The docs can be found at https://hexdocs.pm/deep_clean.

Usage

Simply call the DeepClean.exclude_in/2 function sending the following params:

  1. deep_elem: a map or list with nested elements
  2. clean_list: a list with the keys to be exclude from the deep_elem separated by dots by each nested level

Example

iex> DeepClean.exclude_in(%{a: %{aa: 1, ab: 2}, b: %{ba: 3, bb: 4}}, ["a.ab", "b.bb"])
.. > %{a: %{aa: 1}, b: %{ba: 3}}

iex> DeepClean.exclude_in(%{a: [%{aa: 1, ab: 2}, %{aa: 11, ab: 22},], b: [%{ba: 3, bb: 4}, %{ba: 33, bb: 44}]}, ["a.ab", "b.bb"])
.. > %{a: [%{aa: 1}, %{aa: 11}], b: [%{ba: 3}, %{ba: 33}]}

About

Exclude elements from deep nested maps/list

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages