tsevdos / elUtils

A library of convenient, easy-to-use, and lightweight utility functions that solve common problems encountered while building Greek (and not only) applications.
https://www.npmjs.com/package/@tsevdos/el-utils
MIT License
51 stars 15 forks source link

Add formatWeight to formatUtils module #67

Closed raptisj closed 6 months ago

raptisj commented 6 months ago

Description

This pull request introduces a new util, formatWeight, to the newly created formatUtils module. This util helps users format the wording of weight values, like appending the SI symbol, handling plural/single values, and having the weight name in short(p) or full(pound) format.

Changes Made

Usage

A simple example

formatWeight(1, { type: "pound" }) // 1 λίβρα
formatWeight(2, { type: "pound" }) // 1 λίβρες
formatWeight(3, { type: "pound", format: "short" }) // 3 lb
formatWeight(4, { type: "pound", withInternational: true }) // 4 λίβρες (lb)

This change can be the start of introducing a wide range of format utils such as speed, time, energy etc.

changeset-bot[bot] commented 6 months ago

🦋 Changeset detected

Latest commit: ac131ac3449e2a37a731eaf09d14fbb1e3b8d43e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------- | ----- | | @tsevdos/el-utils | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

tsevdos commented 6 months ago

Nice! I'll review it later today and merge it!

@raptisj r u interested on another format utility I have in mind?...

raptisj commented 6 months ago

Nice! I'll review it later today and merge it!

@raptisj r u interested on another format utility I have in mind?...

@tsevdos Regarding the SonarCloud, what is up with the strictness? I removed "nearly" all tests and it still fails. Am I doing something wrong?

I was thinking about doing a times util(e.g. 1 χρόνο πριν, 2 χρόνια πριν, 13 μήνες πριν) or something like that but sure. If you want just open a discussion with your idea.

sonarcloud[bot] commented 6 months ago

Quality Gate Failed Quality Gate failed

Failed conditions
16.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

tsevdos commented 6 months ago

Nice! I'll review it later today and merge it! @raptisj r u interested on another format utility I have in mind?...

@tsevdos Regarding the SonarCloud, what is up with the strictness? I removed "nearly" all tests and it still fails. Am I doing something wrong?

I was thinking about doing a times util(e.g. 1 χρόνο πριν, 2 χρόνια πριν, 13 μήνες πριν) or something like that but sure. If you want just open a discussion with your idea.

I know, I notice that too, but don't bother... I had the same issue with my tests, but I thought I fixed it... Let's review and merge it.