jamesplease / moment-business

Utilities for work days in Moment. (Western workweeks only.)
MIT License
100 stars 27 forks source link

integrate with moment prototype #54

Closed SaharZehavi closed 7 years ago

SaharZehavi commented 7 years ago

would be a lot easier (and cleaner) if you would implement the method through the prototype.

moment().isWeekend() is much nicer then bussiness.isWeekend(moment())

jamesplease commented 7 years ago

@SaharZehavi , thanks for the issue! It used to work that way, but we intentionally moved away from it.

I understand why you might prefer the other API over the current one. One issue with attaching it on the prototype is that code is less expressive. If someone new to the project is trying to look up the documentation for isWeekend, they may not be able to find it if you’re using moment().isWeekend(). On the other hand. business.isWeekend() is more explicit when combined with an import statement.

Although I don’t intend to make this the default behavior, I predicted that people would want to use the prototype, and opened up an issue with an API that I would use for “installing” it on the Moment prototype, #49 .

I’m going to close this as a dupe of that issue. If you’re interested in adding this feature, go ahead and read through #49 . If you’re :+1: to that API, and are interested in adding it to this lib, then I’ll definitely merge it in and cut a release!

Thanks again @SaharZehavi :v: