* fix: make Ellipsis operate on runes instead of bytes to prevent Unicode truncation
The Ellipsis function previously used byte-based length counting (len(str))
and byte-based slicing (str[:length-3]), which could split multi-byte
Unicode characters in the middle, producing garbled output.
This changes the function to use []rune conversion so the length parameter
counts Unicode code points instead of bytes. Emoji, CJK ideographs, and
other multi-byte characters are now never split in the middle.
Fixes#520
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: avoid rune slice allocation in Ellipsis
Use range-based iteration to count runes without allocating a []rune
slice, per reviewer suggestion. The early-return for length < 3 is
kept explicit for clarity.
* Simplify Ellipsis: remove early return for length < 3, reuse ellipsis const
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add Take, TakeWhile, FilterTake, Window, and Sliding functions
Add five new slice manipulation functions with tests, examples, and documentation.
* improve Take function safety and add benchmarks
* rename FilterTake to TakeFilter and add README docs
* remove Window and Sliding benchmarks
* apply gofmt and fix linter errors
* apply gofmt and fix linter errors
* feat(intersectby): form transform callback in first position and add support for vaarg
* feat(it): adding loit.IntersectBy
* doc: adding lo.IntersectBy + loit.IntersectBy
* doc: adding lo.IntersectBy + loit.IntersectBy
* style: fix linter
* doc: adding example for lo.IntersectBy
* Fix linting
* Use is.ElementsMatch
This will ignore the ordering of the final intersection. Especially
important when checking old versions of go that do not guarantee an order
when iterating through maps.
* lint: fix inconsistent callback function parameter names
* lint: rename "iteratee" to "transform" for *Map helpers
* lint: rename "project" parameters to "transform"
* lint: rename "cb" parameters to "callback"
* lint: rename "iteratee" to "callback" for ForEach helpers
---------
Co-authored-by: Franky W. <frankywahl@users.noreply.github.com>
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
* Fix linting
* Use is.ElementsMatch
This will ignore the ordering of the final intersection. Especially
important when checking old versions of go that do not guarantee an order
when iterating through maps.
* fix: rename IsSortedByKey to IsSortedBy
---------
Co-authored-by: Franky W. <frankywahl@users.noreply.github.com>
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
* Allow Union to take many lists
* Allow Intersect to take many lists
* Allow for any number of intersection arguments
* Do not use recursion
Optimize Intersect to avoid using recursion and reduce computation
* Add ExampleIntersect
Adds an example test for intersect
* Add example for Intersect in Readme
* Update docs for Intersect
* Update README.md
Fixed the error in the usage example of lo.Latest in readme.md
use []time.Time{…} (value of type []time.Time) as time.Time value in argument to lo.Latest
* Update README.md
* feature: add Mode function with tests and documentation
---------
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
* Update README.md
Fixed the error in the usage example of lo.Latest in readme.md
use []time.Time{…} (value of type []time.Time) as time.Time value in argument to lo.Latest
* Update README.md
---------
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
* feat: Add NthOr and NthOrEmpty functions
This commit introduces two new functions, `NthOr` and `NthOrEmpty`, to the `find` package. These functions provide a safer way to access elements at a specific index in a slice, handling out-of-bounds scenarios gracefully.
- `NthOr`: Returns the element at the specified index or a provided fallback value if the index is out of bounds.
- `NthOrEmpty`: Returns the element at the specified index or the zero value for the slice's element type if the index is out of bounds.
* update readme