From 049ae83ad52083c84d29a424f0be224cdbf45349 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 9 Jan 2025 19:09:32 +0100 Subject: [PATCH] Fix `uniq` description and example (#517) * Fix `uniq` description and example The article now mentions that only adjacent values are deduplicated. The output was added to the example. * Fix formatting Co-authored-by: chirp <72366111+chirpxiv@users.noreply.github.com> --------- Co-authored-by: chirp <72366111+chirpxiv@users.noreply.github.com> --- docs/scripting/scripts.lib/uniq.mdx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/scripting/scripts.lib/uniq.mdx b/docs/scripting/scripts.lib/uniq.mdx index c6df31b4..be7c0e69 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,8 @@ 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); + return l.uniq(my_array); // => ["apples", "bananas", "oranges", "apples", "limes"] } ```