Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unicode number forms #12

Closed
derhuerst opened this issue Apr 25, 2016 · 11 comments
Closed

add unicode number forms #12

derhuerst opened this issue Apr 25, 2016 · 11 comments

Comments

@derhuerst
Copy link
Contributor

Number Forms like ¼ would really make sense, since they are non-ASCII and have a really nice fallback (1/4).

@sindresorhus
Copy link
Owner

Can you show an example of how it would look like using it from figures?

@derhuerst
Copy link
Contributor Author

Something like figures.1by4 or figures.oneByFour with yields in ¼.

@sindresorhus
Copy link
Owner

Probably not figures.1by4 as it's invalid JS, but yeah, sounds useful. PR welcome :)

@sindresorhus
Copy link
Owner

While I have you here. I've been thinking about adding a method to replace unicode with the fallbacks. So you could do figures('¼ yezz') and it would return '¼ yezz' on OS X / Linux and '1/4 yezz' on Windows. What do you think?

@derhuerst
Copy link
Contributor Author

derhuerst commented Apr 25, 2016

Probably not figures.1by4 as it's invalid JS, but yeah, sounds useful. PR welcome :)

You're right. One could use figures[1by4] or figures['1by4']. Will do a PR with oneByFour.

So you could do figures('¼ yezz') and it would return '¼ yezz' on OS X / Linux and '1/4 yezz' on Windows. What do you think?

Isnt that essentially template strings? So this function would "just" be sugar on top?

`${figures.tick} yezz`

@sindresorhus
Copy link
Owner

Isnt that essentially template strings?

Not really. It could be a tagged template literal [0]. The point is to let you use the original unicode character in the string and have it replaced with fallbacks when not supported. In your example you have to use the verbose descriptive property access.

[0]:

figures`¼ yezz`

@SamVerschueren
Copy link
Contributor

That would be a nice addition. Not sure if it should be implemented in figures or in a separate figures-replace module.

@sindresorhus
Copy link
Owner

@SamVerschueren I think it should be here. Could be the main export actually.

const figures = require('figures');

console.log(figures.tick);

console.log(figures`¼ yezz`);

@SamVerschueren
Copy link
Contributor

I'm ok with that. Just wanted to make sure you considered a separate module ;).

@sindresorhus
Copy link
Owner

My unrelated idea continues here: #14

@sindresorhus
Copy link
Owner

Fixed by #13.

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

No branches or pull requests

3 participants