Skip to content

Commit

Permalink
Fix uniq description and example (#517)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: chirp <[email protected]>
  • Loading branch information
SarahIsWeird and chirpxiv authored Jan 9, 2025
1 parent b2e569f commit 049ae83
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/scripting/scripts.lib/uniq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"]
}
```

0 comments on commit 049ae83

Please sign in to comment.