mobily / ts-belt

🔧 Fast, modern, and practical utility library for FP in TypeScript.
https://mobily.github.io/ts-belt
MIT License
1.11k stars 31 forks source link

A.range documentation error? #41

Closed mrwizard82d1 closed 2 years ago

mrwizard82d1 commented 2 years ago

Thanks for producing this library.

I'm new to TypeScript and somewhat new to functional programming, but this library seems to have what I would like to see in a functional programming library.

The documentation for A.range states "Returns a new array of numbers from start (inclusive) to finish (exclusive)." However, it actually appears to include the upper bound. Here is the text from a Node session (using ts-node):

λ ./node_modules/.bin/ts-node import { A } from '@mobily/ts-belt'; undefined A.range(0, 3); [ 0, 1, 2, 3 ] A.rangeBy(0, 3, 1); [ 0, 1, 2, 3 ]

When I look at the documentation for Belt.Array.range, it reports that the range is inclusive (on both arguments) and the following example duplicates the behavior that I am seeing:

Belt.Array.range(0, 3) == [0, 1, 2, 3]

I'm uncertain if the error is in the documentation or in the implementation.

mobily commented 2 years ago

@mrwizard82d1 thanks for posting this issue, the implementation is ok, and certainly the error was in the documentation, fixed in https://github.com/mobily/ts-belt/commit/726840a8a5bb709be1d5dc4ff5df7585d7726053!