Skip to content

Add absoluteValue#21

Merged
saket merged 1 commit into
saket:trunkfrom
Goooler:abs
Mar 16, 2026
Merged

Add absoluteValue#21
saket merged 1 commit into
saket:trunkfrom
Goooler:abs

Conversation

@Goooler

@Goooler Goooler commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

@JakeWharton

Copy link
Copy Markdown
Contributor

For what it's worth, I think the utility of this is pretty niche and would be okay having to write it downstream.

@saket saket left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, why not

@saket saket merged commit f60939e into saket:trunk Mar 16, 2026
2 checks passed
@Goooler Goooler deleted the abs branch March 16, 2026 05:40
@JakeWharton

Copy link
Copy Markdown
Contributor

I actually don't think this function should be in the library anymore. The need to perform such an operation makes very little sense in the context of a byte size. I only do it for sorting by the largest delta.

@Goooler

Goooler commented Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

I added the absoluteValue here, as this library supports negative values. This behavior differs from that of byteunits.

From my understanding, there should be an easy way to derive the absolute value from a negative value.

@JakeWharton

Copy link
Copy Markdown
Contributor

Yeah I get that, but it's a weird operation to perform on a byte size in general. I don't really mind it being there, of course, since I will use it, but I also think it's perfectly reasonable to force something like this on user code.

@saket

saket commented Mar 26, 2026

Copy link
Copy Markdown
Owner

Released as part of https://github.com/saket/byte-size/releases/tag/2.2.0. Thanks again!

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.

3 participants