Last active
January 15, 2018 01:57
-
-
Save mkamakura/85276a2d3035bbb256c67652096cba81 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// @flow | |
export function formatPriceYen(price: number): string { | |
return `¥${formatPrice(price)}` | |
} | |
export function formatPriceYenMonth(price: number): string { | |
return `${formatPriceYen(price)}/月` | |
} | |
export function formatPrice(price: number): string { | |
return String(price).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,') | |
} | |
export function formatRange(range: { min?: number, max?: number }): string { | |
const { min, max } = range | |
if (!min && !max) return '' | |
return `${min ? formatPriceYenMonth(min) : ''}〜${max ? formatPriceYenMonth(max) : ''}` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment