jamesplease / moment-business

Utilities for work days in Moment. (Western workweeks only.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

integrate with moment prototype

SaharZehavi opened this issue · comments

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())

@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 👍 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 ✌️