Skip to content

Commit

Permalink
not for dist, fails one test
Browse files Browse the repository at this point in the history
  • Loading branch information
Faris Chebib committed Oct 2, 2015
1 parent 0acdd9b commit 8db7e3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion dist/moment-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ DateRange.prototype.subtract = function(other) {
* @param {(!DateRange|String)} range Date range to be used for iteration or
* shorthand string (shorthands:
* http://momentjs.com/docs/#/manipulating/add/)
* Can also use Object Literals for different intervals.
* Eg, {minutes: 30}
* @param {!DateRange~by} hollaback Callback
* @param {!boolean} exclusive Indicate that the end of the range should not
* be included in the iter.
Expand All @@ -212,9 +214,12 @@ DateRange.prototype.by = function(range, hollaback, exclusive) {
if (typeof range === 'string') {
_byString.call(this, range, hollaback, exclusive);
}
else {
else if (range.__proto__.constructor.name === "DateRange") {
_byRange.call(this, range, hollaback, exclusive);
}
else if (typeof range === "object") {
_byObject.call(this, range, hollaback, exclusive);
}
return this;
};

Expand All @@ -239,6 +244,18 @@ function _byString(interval, hollaback, exclusive) {
}
}

/**
* @private
*/
function _byObject(interval, hollaback, exclusive) {
var current = moment(this.start);

while (this.contains(current, exclusive)) {
hollaback.call(this, current.clone());
current.add(interval);
}
}

/**
* @private
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/moment-range.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8db7e3b

Please sign in to comment.