gastonmesseri / numerable

Number formatting library for Javascript and Node.js apps
MIT License
80 stars 1 forks source link

Is there a plan to create an FP API? #3

Open yannickglt opened 3 years ago

yannickglt commented 3 years ago

By FP API, I mean an equivalent to the date-fns/fp module with curried and capped functions.

Thanks for this promising project!

gastonmesseri commented 2 years ago

Hi @yannickglt ,

Sorry for the late reply. When I say FP API, I mean not depending on classes and constructors, but simple pure functions. So, maybe it is not what you thought. In any case, given the implementation of the library, and if many users think it is useful, I think it could be not highly complex implementing the type of FP API that date-fns/fp has implemented. So, it could also be exposed as numerable/fp.

Do you have any suggestions about how the FP API could be exposed, or actual uses cases for this feature?

I hope this answers your question, and thanks for your feedback,

Gastón

yannickglt commented 2 years ago

Hi @gastonmesseri

Thanks for your answer 🙂

Pure functions is the main idea behind date-fns 2. The only thing the FP part bring, is currying.

It does not change a lot to the API except the value is always curried and permits combining operators using pipe, flow, or combine helpers.

Example:

const total = pipe(
  sum,
  format('0,0.00')
)
console.log(total([123, 456, 78.9]))

Dont know how it can be handled by the lib, maybe using a fp suffix as you suggested (numeral/fp) but thanks for your asking anyway 🙂

Moreover, let me know if I can help in any way, with PR, writing spec, doc, and so on.