-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(utils): formatValueWithSymbol 자연스러운 역할 이해를 위해 네이밍 변경
- Loading branch information
Showing
13 changed files
with
240 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@modern-kit/utils': patch | ||
--- | ||
|
||
fix(utils): formatValueWithSymbol 자연스러운 역할 이해를 위해 네이밍 변경 - @ssi02014 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# formatValueWithSymbol | ||
|
||
주어진 `숫자` 또는 `문자열`에 주어진 `기호`를 추가하는 함수입니다. | ||
|
||
- 기호는 `prefix` 또는 `suffix` 위치에 추가할 수 있습니다. | ||
- `음수` 값의 경우 기호 앞에 `-`가 추가됩니다. | ||
- 기호와 값 사이에 `공백`을 추가할 수 있습니다. | ||
|
||
<br /> | ||
|
||
## Code | ||
[🔗 실제 구현 코드 확인](https://github.com/modern-agile-team/modern-kit/blob/main/packages/utils/src/formatter/formatValueWithSymbol/index.ts) | ||
|
||
## Interface | ||
```ts title="typescript" | ||
interface FormatValueWithSymbolOptions { | ||
symbol?: string; | ||
position?: 'prefix' | 'suffix'; | ||
space?: boolean; | ||
} | ||
``` | ||
```ts title="typescript" | ||
function formatValueWithSymbol( | ||
value: number | string, | ||
options?: FormatValueWithSymbolOptions | ||
): string; | ||
``` | ||
|
||
## Usage | ||
```ts title="typescript" | ||
import { formatValueWithSymbol } from '@modern-kit/utils'; | ||
|
||
// 통화 기호 추가 (기본 값: '') | ||
formatValueWithSymbol(1000) // '1000' | ||
formatValueWithSymbol(1000, { symbol: '원' }) // '1000원' | ||
|
||
// 통호 기호 위치 변경 (기본값: 'suffix') | ||
formatValueWithSymbol(1000, { symbol: '$', position: 'prefix' }) // '$1000' | ||
formatValueWithSymbol(1000, { symbol: '원', position: 'suffix' }) // '1000원' | ||
|
||
// 공백 추가 (기본값: false) | ||
formatValueWithSymbol(1000, { symbol: '$', position: 'prefix', space: false }) // '$1000' | ||
formatValueWithSymbol(1000, { symbol: '$', position: 'prefix', space: true }) // '$ 1000' | ||
``` | ||
|
||
<br /> | ||
|
||
### 응용 | ||
```ts title="typescript" | ||
import { | ||
formatValueWithSymbol, | ||
formatNumberWithCommas, | ||
formatNumberWithUnits | ||
} from '@modern-kit/utils'; | ||
|
||
const KRW_UNITS = [ | ||
{ unit: '조', value: 1_000_000_000_000 }, | ||
{ unit: '억', value: 100_000_000 }, | ||
{ unit: '만', value: 10_000 }, | ||
] as const; | ||
|
||
const numberWithCommas = formatNumberWithCommas(1234567); // 1,234,567 | ||
const numberWithKRWUnits = formatNumberWithUnits(1230000, { units: KRW_UNITS }); // 123만 | ||
|
||
formatValueWithSymbol(numberWithKRWUnits, { symbol: '원' }) // '123만원' | ||
formatValueWithSymbol(numberWithCommas, { symbol: '원' }) // '1,234,567원' | ||
``` |
25 changes: 0 additions & 25 deletions
25
packages/utils/src/formatter/formatNumberWithCurrency/formatNumberWithCurrency.constants.ts
This file was deleted.
Oops, something went wrong.
134 changes: 0 additions & 134 deletions
134
packages/utils/src/formatter/formatNumberWithCurrency/formatNumberWithCurrency.spec.ts
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/utils/src/formatter/formatNumberWithCurrency/formatNumberWithCurrency.types.ts
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
packages/utils/src/formatter/formatNumberWithCurrency/formatNumberWithCurrency.utils.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.