Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are Number utilities expecting numbers of type string? #9

Closed
millsp opened this issue Jun 27, 2019 · 1 comment
Closed

Why are Number utilities expecting numbers of type string? #9

millsp opened this issue Jun 27, 2019 · 1 comment
Labels
question More info is requested wiki It's nice to learn stuff

Comments

@millsp
Copy link
Owner

millsp commented Jun 27, 2019

馃 Question

Describe your question

The Number utilities all expect receiving a number that is a string. That does not make sense.

Search tags, topics

#number #string #input

@millsp millsp changed the title Why are numbers of type string? Why are Number utilities expecting numbers of type string? Jun 27, 2019
@millsp
Copy link
Owner Author

millsp commented Jun 27, 2019

This has been designed to fight performance issues. A number for the ts-toolbelt is just an index on a map. Indexes are strings and this is the answer.

It would have been extremely heavy (but possible) to take a number as input. It would force us to search for the key of that number (basically transforming back to string every time).

This way, you can combine number operations together (at high performance) and at the end of your operations transform it to a normal number with Format!

If you want to dig more into it, have a look in Iteration/IterationOf.ts. You will find a generated map that powers all these amazing computations. From this was born Prev & Next that enabled all sorts of computations (type iteration, numbers...).

@millsp millsp added question More info is requested wiki It's nice to learn stuff labels Jun 27, 2019
@millsp millsp closed this as completed Jun 27, 2019
Repository owner locked and limited conversation to collaborators Feb 2, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question More info is requested wiki It's nice to learn stuff
Projects
None yet
Development

No branches or pull requests

1 participant