From 1dce25e5ee93c823824a3d237cfd128614b7c4c1 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Wed, 4 Oct 2023 14:34:46 +0100 Subject: [PATCH] add list_tuple_to_unique_keys/1 usage example to README.md #59 --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cf8de3..1e9631b 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Install by adding `useful` to your list of dependencies in `mix.exs`: ```elixir def deps do [ - {:useful, "~> 1.13.1"} + {:useful, "~> 1.14.0"} ] end ``` @@ -148,6 +148,20 @@ person_id = conn.assigns.person.id || 0 But `Elixir` "_Me no likey_" ... So this is what we have. +### `list_tuple_to_unique_keys/1` + +Turns a list of tuples with the _same_ key +into a list of tuples with _unique_ keys. +Useful when dealing with "multipart" forms +that upload multiple files. e.g: + +```elixir +parts = [{"file", "pic1.png"}, {"file", "pic2.png"}] +Useful.list_tuples_to_unique_keys(parts) +[{"file-1", "pic1.png"}, {"file-2", "pic2.png"}] +``` + + ### `remove_item_from_list/2`