Back

The making of a modern javascript library

Mon, Jun 21 20213 min read
Nathaniel
Every 60 seconds passed in Africa, a new javascript library is created. There are a plethora of js libraries out there, and today I made another one.

What

Recently, I need to build some function revolving around syncing contacts and calendar events. They were mostly based on an old protocol named WEBDAV. It's so old that it uses convoluted xml structure to represent data. It would be hard for me to handle data since JSON is the first class citizen in javascript while xml is not.

Why

I took a look at all the existing solutions. They either are no longer maintained or lack core functions. Therefore, I've decided create a brand new library in order to fulfil these goals:
  1. Allow using json data. In order to handle data with ease.
  2. Support a wide range of protocols. Not just one of the three DAV families, but all three of them.
  3. Well tested, have little to no bugs.
  4. First class typescript support, well defined type with minimum amount of any
  5. Have an easy to read, searchable documentation.

How

First thing you need to do is understand the problem, it can be done by doing any of the following:
  • Reading previous project's code, understand the pros and cons of the previous library.
  • If your target have documented standards (in my case IETF RFC 4918, 4791, 6352), read them throughly, understand the reason behind the standards and the problem it aims to solve.
  • Write small sandboxed code samples. By starting small, you'll solve the problem piece by piece, eventually allowing the solution to the entire problem.
After making sure that you understand the problem, you can then proceed to start writing code. It's recommended to write unit tests alone the way so that you can have good code quality and be confident about every part of the project as you move.
When you finished writing code, you can setup CI pipeline which allows every commit and pull request is tested and meet the standard of code quality. It can also help automating things like deploying the documentation. I'm not going to explain the details here since they are outside the scope of this post.
Doing all of the above will only make your a decent project. To make your project great (again?), you need to do most, if not all of the following:
  • Design a cool logo for it, best paired with a slick slogan.
  • Added badges by using shields.io badges.
  • Provide a clean, easy to understand README on how to use the project.
  • Add tags that helps others to discover the great work you've done.

Takeaway

Making a good library is quite an undertaking. It take months and sometimes even years of hardworking for a good library to be made. After making this library, I'm now much more incline to give other devs projects stars. The project itself might not be useful to you, but by the act of starring the project, you appreciate the hard work of maintainers and allows the library to gain more visibility.

Comments(0)

Continue with
to comment