Introducing “party-time”: An npm package for converting Indian political party names
One thing I’ve had to do more than once in my work at the Hindustan Times is convert party acronyms to full party names, or vice versa. Imagine you have a page showing the results of the Goa state assembly elections. On mobile devices, you want to only show the party acronyms (in this case, “INC” and “BJP”), but on wider screens you want to show the full party names (“Indian National Congress” and “Bharatiya Janata Party”). To do this, you need a function that will output either the acronym or the full name, after detecting the screen size.
This problem is easy to solve, but I’ve had to write the code to do it more than once, which is time consuming. I also keep creating different libraries of party acronyms and their associated full names, and I always end up looking for them over and over again.
To solve these problems, I created an npm package called party-time.
party-time has just three functions: getType(), getInfo(), and convert(). The convert() function uses the first two, but those can also be called by themselves.
Right now, the library of parties is almost certainly not comprehensive. But as I (and, perhaps, you) use the library, the gaps will be filled in. To give it a test, you can install it with npm:
npm i party-time -S
Or you can use it in the browser by including the CDN: