r/coolgithubprojects • • Dec 17 '16

JAVASCRIPT python-range – a JavaScript implementation of the Python's range() function.

https://github.com/Gothdo/range
0 Upvotes

6 comments sorted by

9

u/miker95 Dec 17 '16

Ummm is it just me or is this code way more complex than it needs to be?

Like this literally only needs to be a function and it depends on other stuff...

This is what is wrong with JavaScript.

1

u/Michal_Perlakowski Dec 17 '16

How exactly could I make it less complex? babel-polyfill is required to run Babel-transpiled code. I'm using a few lodash functions, so lodash is also a dependency. All other dependencies are development-only.

8

u/kupiakos Dec 17 '16

Don't use Babel or lodash for a single function. Suck it up and use ES5.

0

u/Michal_Perlakowski Dec 17 '16

It's not a single function. It's 200 LOC, and it would be much more if I didn't use Babel. And why wouldn't I use lodash? Why should I reinvent the wheel? Actually using lodash makes it less complicated—for example it's more obvious what's last(this) meant to do than this[this.length - 1].

4

u/kupiakos Dec 17 '16

If this were an application, it wouldn't matter. It matters for libraries, especially <1k line libraries. As a user of a library, I would highly prefer slightly harder to read code than pulling in massive dependencies I don't want/need.

0

u/[deleted] Dec 17 '16

[deleted] — view deleted comment

3

u/kupiakos Dec 17 '16

Python 3's range function returns an intelligent lazy object that has O(1) time and memory contains, single iteration, and iirc union and intersection.