DEV Community

Discussion on: PolyFull - enhance js capabilities

 
giovannicardamone profile image
Giovanni Cardamone

at this point is bit annoying, but let's give a fair reply:

Polyfilling native object is a common pratice (i don't think i have explain to you, you seems smart enought, but i will do for everyone else reading this post), due to lack of functionality missing in previous version of javascript, an example can be core-js.

The aim of core-js is to provide compatibility function where are missing.

the aim of polyfull is a bit different, and should be handled carefully.

first of all, none of ECMAScript specification should be replaced. (and i am doing this at current version ES2021)

second, i have to provide a way to make some version of polyfull incompatible if a new release of EcmaScript have name collision with polyfull. (and this can be done with flags in package.json)

of course you are creating a bit of incompatibility if you are using previous version of polyfull with new version of ecmascript if an incompatibility occurs, or if you have to make porting from an older version to a new one (i am perfectly aware of this).

but i think you can agree with me that some stuff is missing in nodejs, and it's fucking annoying.

If you need functionality to manipulate array and this stuff you can simply install lodash. but my library isn't targeting this advantages.

programmer are lazy, and i am bored of searching over and over to remove an element from array or generate a random number.

This library is just a shortaround to have some basic functionality that aren't builded in js language in two decades.

Also jsDoc annotations like @deprecated can be useful to spot where naming collisions occurs.

You are free to not use this library, the name and the warning are pretty much representing what this library do and where it can be used. And where should NOT be used.

i gonna use it in some project where i am just to lazy to do something like this:

import ArrayEnhancedOrWhatever from 'polyfull'

const myArray = [1, 2, 3]

ArrayEnhancedOrWhatever.remove(myArray, 2)
Enter fullscreen mode Exit fullscreen mode

instead of

const myArray = [1, 2, 3]
myArray.remove(2)
Enter fullscreen mode Exit fullscreen mode

furthermore, thanks for any tips and advice! And thanks for the time you spent here :D

Thread Thread
 
miketalbot profile image
Mike Talbot ⭐ • Edited

I'd just point out that Sugar has been doing this kind of thing for a long while. They've now made the extension functions "opt-in" so it can be used in a library or in a final application. In final applications I have used it in both ways.

Modifying the prototypes of objects is a contentious subject, I have a huge amount of respect for the stuff @lukeshiru writes and creates, but probably in this case fall more on the side of "it's fine if you aren't building a library". The Sugar comments on modes and other content on the site will express the opinions here far better than I can though :)