From 104681a46e40c49a0cfec34716497a829946b0a6 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 9 Jan 2025 17:47:48 +0100 Subject: [PATCH 1/2] Fix `uniq` description and example The article now mentions that only adjacent values are deduplicated. The output was added to the example. --- docs/scripting/scripts.lib/uniq.mdx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/scripting/scripts.lib/uniq.mdx b/docs/scripting/scripts.lib/uniq.mdx index c6df31b4..d199647a 100644 --- a/docs/scripting/scripts.lib/uniq.mdx +++ b/docs/scripting/scripts.lib/uniq.mdx @@ -2,7 +2,9 @@ title: .uniq() --- -A function that deduplicates elements from an array, while preserving the order of the remaining elements. +A function that deduplicates adjacent elements from an array, while preserving the order of the remaining elements. + +Similar to the *nix `uniq` command, duplicate values that are not adjacent are *not* removed. ## Syntax @@ -25,8 +27,9 @@ Returns an array. ```js function(context, args) { const l = #fs.scripts.lib(); - const my_array = ["apples", "bananas", "oranges", "apples", "limes", "oranges"]; + const my_array = ["apples", "apples", "bananas", "oranges", "apples", "limes"]; - return l.uniq(my_array); + const uniq_array = l.uniq(my_array); // => ["apples", "bananas", "oranges", "apples", "limes"] + return uniq_array; } ``` From 2befbb3a0292203c1cf2a2186cd46e1b950d09ec Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 9 Jan 2025 19:05:26 +0100 Subject: [PATCH 2/2] Fix formatting Co-authored-by: chirp <72366111+chirpxiv@users.noreply.github.com> --- docs/scripting/scripts.lib/uniq.mdx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/scripting/scripts.lib/uniq.mdx b/docs/scripting/scripts.lib/uniq.mdx index d199647a..be7c0e69 100644 --- a/docs/scripting/scripts.lib/uniq.mdx +++ b/docs/scripting/scripts.lib/uniq.mdx @@ -4,7 +4,7 @@ title: .uniq() A function that deduplicates adjacent elements from an array, while preserving the order of the remaining elements. -Similar to the *nix `uniq` command, duplicate values that are not adjacent are *not* removed. +Similar to the \*nix `uniq` command, duplicate values that are not adjacent are _not_ removed. ## Syntax @@ -29,7 +29,6 @@ function(context, args) { const l = #fs.scripts.lib(); const my_array = ["apples", "apples", "bananas", "oranges", "apples", "limes"]; - const uniq_array = l.uniq(my_array); // => ["apples", "bananas", "oranges", "apples", "limes"] - return uniq_array; + return l.uniq(my_array); // => ["apples", "bananas", "oranges", "apples", "limes"] } ```