moment-range
Advanced tools
Comparing version
@@ -43,3 +43,3 @@ // Generated by CoffeeScript 1.3.3 | ||
* for each sub-range. | ||
* @param {!DateRange} range Date range to be used for iteration. | ||
* @param {!DateRange|String} range Date range to be used for iteration or shorthand string (shorthands: http://momentjs.com/docs/#/manipulating/add/) | ||
* @param {!function(Moment)} hollaback Function to execute for each sub-range. | ||
@@ -52,4 +52,12 @@ * @return {!boolean} | ||
DateRange.prototype.by = function(range, hollaback) { | ||
var i, l, _i; | ||
var end, i, l, start, _i; | ||
if (typeof range === 'string') { | ||
start = moment(); | ||
end = moment(start).add(range, 1); | ||
range = moment().range(start, end); | ||
} | ||
l = Math.round(this / range); | ||
if (l === Infinity) { | ||
return this; | ||
} | ||
for (i = _i = 0; 0 <= l ? _i <= l : _i >= l; i = 0 <= l ? ++_i : --_i) { | ||
@@ -56,0 +64,0 @@ hollaback.call(this, moment(this.start.valueOf() + range.valueOf() * i)); |
@@ -8,3 +8,3 @@ { "name": "moment-range" | ||
, "directories": { "lib" : "./lib" } | ||
, "version": "0.1.1" | ||
, "version": "0.1.2" | ||
, "engines": | ||
@@ -11,0 +11,0 @@ { "node": "*" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
12011
8.7%89
9.88%0
-100%8
-11.11%