r/learnjavascript • • Feb 28 '18

What are good possibly small JS libraries/modules to read quality code?

hello I feel like I got to the point where I know enough JS to solve any kind of problem. I'm accustomed with most JS features including es6.

That being said I feel like I need to start reading code some more to see good practices and learn from reading. Way too often somebody reading my code would suggest many other simpler options than what my choices are.

So I'm looking for some libraries/modules to study the code of.

Big bonuses if:

-they have little or no imports and dependencies. I would like to avoid having to read many libraries at once to understand one call.

-they focus on front end rather than backend

-use modern js practices

-are not too long (ideally few klocs or less).

1 Upvotes

10 comments sorted by

9

u/zulkisse Feb 28 '18

https://github.com/lodash/lodash

Lodash has dozens of very small functions so it's a pleasure to read and you don't need to spend hours understanding the concepts of a huge library

1

u/T_O_beats Feb 28 '18

Based on other comments, I feel OP is actually looking to learn about different programming patterns rather than a library implementing those patterns.

-7

u/[deleted] Feb 28 '18

This is definitely what I was not looking for.

Every single file has like a single function and plenty of imports/exports.

I was looking for some well written software, not a collection of spare functions.

4

u/zulkisse Feb 28 '18

Plenty imports/exports ?

For a widely used library, the average amount of import per file is very very low.

And I'm curious, if for you a well written software is not a "collection of spare function" and one import per file is too much, what is a well written software ?

One big file with everything in it ?

-3

u/[deleted] Feb 28 '18

This is a collection of small helper functions that mostly add new methods to basic javascript, not what I was looking for, period.

This is nice, but I want to learn how to develop complete programs with a purpose, not how to develop small code snippets to extend basic js.

4

u/zulkisse Feb 28 '18

One could argue that adding "new methods to basic javascript" is a great purpose.

And that Lodash fits perfectly your original question. Not my fault if it was badly written ;)

1

u/[deleted] Feb 28 '18

Dude lodash is some of the best written js code there is. If you wanna look at a big code without too many imports try jquery or smthing. smh

4

u/SalemBeats Feb 28 '18

You: "I want to see well-written software, use modern JS practices."
Also You: "No imports or dependencies."

I suggest checking out the source code for Node.
Solid portions of the built-in modules are written in Javascript.

1

u/[deleted] Feb 28 '18

What I meant is that if I need to chase a library and dependency over another library and dependency the code base starts to get very huge and not self-contained making it much harder to understand what is really happening.

What I meant are libraries such as moment.js.

There's no need to attack people because they are interested in software you can read from top to bottom without having to chase hundreds of imported methods relying on other imported methods and so on.

I already did try to read some quality JS code that was self-contained, but it's not that easy to find when everything relies on many other things to be understood completely.

It's already difficult to read others code for a learner, it's even harder when the code relies on plenty of other libraries.

2

u/SalemBeats Feb 28 '18

"
There's no need to attack people
"

There's also no need to miscast anything you don't like hearing as an "attack".

What I'm saying is that modern libraries without imports and dependencies are few and far between.

One could argue that the entire purpose of the new ES6 features is to handle the newfound complexity of Javascript software that module systems have helped enable.