Skip to content

Add Unique() filter method - #248

Open
HakeemTheEmperor wants to merge 1 commit into
bitfield:masterfrom
HakeemTheEmperor:feature/unique-filter
Open

Add Unique() filter method#248
HakeemTheEmperor wants to merge 1 commit into
bitfield:masterfrom
HakeemTheEmperor:feature/unique-filter

Conversation

@HakeemTheEmperor

Copy link
Copy Markdown

Resolves #247

Changes Introduced

Adds a Unique() method to Pipe (using FilterScan) that collapses consecutive duplicate lines while maintaining chronological order and real-time streaming capability.

Testing

  • Added TestUnique in filters_test.go covering consecutive duplicates, non-consecutive duplicates, unchanged unique streams, and empty pipes.
  • Verified test coverage is 100%.

Example

script.Echo("a\na\nb\na\n").Unique().Stdout()
// Output:
// a
// b
// a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Add Uniq() filter method

1 participant