New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change lib name? #3

Closed
timrwood opened this Issue May 7, 2012 · 2 comments

Comments

2 participants
@timrwood
Copy link

timrwood commented May 7, 2012

Just a heads up, there is already a pretty popular javascript date library named Date.js so you may want to change the name of your library.

People will probably confuse the two, and Date.js tends to have a bad reputation for not being actively maintained for the past 4 years or so.

I'm not sure if you know this, but whether or not you should modify the native JS objects is a pretty hot button issue. People seem to be pretty split on the idea, thats why I wrote moment.js to not modify the native Date object. I see the dangers of modifying the Date object (say the standards people add a format function to the date object that takes LMDL or strftime parsing tokens) but I can also understand that people may prefer this methodology to adding wrapper objects around native objects.

All in all, your library looks pretty well written. I haven't looked at your unit tests, but its a really good sign that you have them. If I run across people who prefer the native prototype method, I'll definitely recommend your lib to them.

Also, I'll definitely need to look through some of your other repos. You've got a bunch of original stuff that looks pretty cool! Keep up the good work!

@neocotic

This comment has been minimized.

Copy link
Owner

neocotic commented May 8, 2012

It wasn't until after I released v1.0.0 that I realised that Date.js existed. I'm not that bothered as this is just a small project I wanted to work on to provide format support to help with some of my other project. That said; it has sightly evolved from there so I might look at how I can make my repo more unique at first glance.

I have recently thought of a naming convention that would suit libraries that extend existing objects in JavaScript; *.ext.js (e.g. date.ext.js). The repo name could become date-ext, which would also be changed on npm to replace date-js. An alternative to the file naming convention would be *-ext.js, which may appear neater for minified files (e.g. date-ext.min.js).

There are pros and cons to everything, and modifying existing objects in JavaScript is no exception. For the purpose of this library it only made sense to extend Date with the additional methods. However, you have reminded me of a step I may have missed in order to prevent overriding future implementations. For this reason I'll add a quick fix to wrap each declaration in check to determine whether or not that function already exists. Although I'm not sure if/how the unit tests should handle this.

if ('function' !== typeof Date.prototype.format) {
  Date.prototype.format = function(formatStr) {
    // ...
  };
}

I'll try make these changes (name and existence checks) as soon as possible, so please let me know what you think on my ideas and I'll begin making them.

@timrwood

This comment has been minimized.

Copy link

timrwood commented May 8, 2012

Yeah, naming libraries is really hard. I think there is also an ExtJS library, but that is more of a MVC than modifying date libraries, so there probably wont be too much confusion with date-ext. With my lib, I originally named it underscore.date because it was an underscore mixin, but then changed it to moment after spending like two weeks looking at thesauruses.

As far as extending the date prototype goes, you could probably write a function that does that check so you wouldn't have to repeat yourself.

function extendDate(name, func) {
    if (typeof Date.prototype[name] !== 'function') {
        Date.prototype[name] = func;
    }
};

extendDate('format', function(formatStr) {
    //...
});
extendDate('add', function(args) {
    //...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment