Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moment-range

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-range - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

Gruntfile.js

2

bower.json
{
"name": "moment-range",
"version": "1.1.1",
"version": "1.1.2",
"main": "./dist/moment-range.js",

@@ -5,0 +5,0 @@ "ignore": [

@@ -1,2 +0,17 @@

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define(["moment"], function (a0) {
return (root['DateRange'] = factory(a0));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("moment"));
} else {
root['DateRange'] = factory(moment);
}
}(this, function (moment) {
//-----------------------------------------------------------------------------

@@ -6,4 +21,4 @@ // Contstants

var moment = require('moment');
var INTERVALS = {

@@ -27,13 +42,47 @@ year: true,

*
* @class DateRange
* @param {(Moment|Date)} start Start of interval
* @param {(Moment|Date)} end End of interval
*/
/**
* DateRange class to store ranges and query dates.
*
* @constructor
* @class DateRange^1
* @param {!Array} range Array containing start and end dates.
*/
/**
* DateRange class to store ranges and query dates.
*
* @class DateRange^2
* @param {!String} range String formatted as an IS0 8601 time interval
*/
function DateRange(start, end) {
this.start = moment(start);
this.end = moment(end);
var parts;
var s = start;
var e = end;
if (arguments.length === 1 || end === undefined) {
if (start.length === 2) { // Infer array
s = start[0];
e = start[1];
}
else {
parts = start.split('/');
s = parts[0];
e = parts[1];
}
}
this.start = moment(s);
this.end = moment(e);
}
/**
* Constructor for prototype.
*
* @return {Function}
*/
DateRange.prototype.constructor = DateRange;
/**
* Deep clone range.

@@ -157,3 +206,3 @@ *

* @param {!boolean} exclusive Indicate that the end of the range should not
* be included in the iter.
* be included in the iter.
*

@@ -202,2 +251,12 @@ * @return {DateRange} `this`

/**
* Date range formatted as an [ISO8601 Time
* Interval](http://en.wikipedia.org/wiki/ISO_8601#Time_intervals).
*
* @return {!String}
*/
DateRange.prototype.toString = function() {
return this.start.format() + '/' + this.end.format();
};
/**
* Date range in milliseconds. Allows basic coercion math of date ranges.

@@ -308,4 +367,6 @@ *

module.exports = DateRange;
},{"moment":undefined}]},{},[1]);
return DateRange;
}));

@@ -1,1 +0,1 @@

!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b){this.start=g(a),this.end=g(b)}function e(a,b,c){for(var d=g(this.start);this.contains(d,c);)b.call(this,d.clone()),d.add(1,a)}function f(a,b,c){var d=this/a,e=Math.floor(d);if(e!==1/0){e===d&&c&&e--;for(var f=0;e>=f;f++)b.call(this,g(this.start.valueOf()+a.valueOf()*f))}}var g=a("moment"),h={year:!0,month:!0,week:!0,day:!0,hour:!0,minute:!0,second:!0};d.prototype.clone=function(){return g().range(this.start,this.end)},d.prototype.contains=function(a,b){var c=this.start,e=this.end;return a instanceof d?c<=a.start&&(e>a.end||e.isSame(a.end)&&!b):a>=c&&(e>a||e.isSame(a)&&!b)},d.prototype.overlaps=function(a){return null!==this.intersect(a)},d.prototype.intersect=function(a){var b=this.start,c=this.end;return b<=a.start&&a.start<c&&c<a.end?new d(a.start,c):a.start<b&&b<a.end&&a.end<=c?new d(b,a.end):a.start<b&&c>=b&&c<a.end?this:b<=a.start&&a.start<=a.end&&a.end<=c?a:null},d.prototype.add=function(a){return this.overlaps(a)?new d(g.min(this.start,a.start),g.max(this.end,a.end)):null},d.prototype.subtract=function(a){var b=this.start,c=this.end;return null===this.intersect(a)?[this]:a.start<=b&&c>b&&c<=a.end?[]:a.start<=b&&b<a.end&&a.end<c?[new d(a.end,c)]:b<a.start&&a.start<c&&c<=a.end?[new d(b,a.start)]:b<a.start&&a.start<a.end&&a.end<c?[new d(b,a.start),new d(a.end,c)]:void 0},d.prototype.by=function(a,b,c){return"string"==typeof a?e.call(this,a,b,c):f.call(this,a,b,c),this},d.prototype.valueOf=function(){return this.end-this.start},d.prototype.center=function(){var a=this.start+this.diff()/2;return g(a)},d.prototype.toDate=function(){return[this.start.toDate(),this.end.toDate()]},d.prototype.isSame=function(a){return this.start.isSame(a.start)&&this.end.isSame(a.end)},d.prototype.diff=function(a){return this.end.diff(this.start,a)},g.range=function(a,b){return a in h?new d(g(this).startOf(a),g(this).endOf(a)):new d(a,b)},g.range.constructor=d,g.fn.range=g.range,g.fn.within=function(a){return a.contains(this._d)},b.exports=d},{moment:void 0}]},{},[1]);
!function(a,b){"function"==typeof define&&define.amd?define(["moment"],function(c){return a.DateRange=b(c)}):"object"==typeof exports?module.exports=b(require("moment")):a.DateRange=b(moment)}(this,function(a){function b(b,c){var d,e=b,f=c;(1===arguments.length||void 0===c)&&(2===b.length?(e=b[0],f=b[1]):(d=b.split("/"),e=d[0],f=d[1])),this.start=a(e),this.end=a(f)}function c(b,c,d){for(var e=a(this.start);this.contains(e,d);)c.call(this,e.clone()),e.add(1,b)}function d(b,c,d){var e=this/b,f=Math.floor(e);if(f!==1/0){f===e&&d&&f--;for(var g=0;f>=g;g++)c.call(this,a(this.start.valueOf()+b.valueOf()*g))}}var e={year:!0,month:!0,week:!0,day:!0,hour:!0,minute:!0,second:!0};return b.prototype.constructor=b,b.prototype.clone=function(){return a().range(this.start,this.end)},b.prototype.contains=function(a,c){var d=this.start,e=this.end;return a instanceof b?d<=a.start&&(e>a.end||e.isSame(a.end)&&!c):a>=d&&(e>a||e.isSame(a)&&!c)},b.prototype.overlaps=function(a){return null!==this.intersect(a)},b.prototype.intersect=function(a){var c=this.start,d=this.end;return c<=a.start&&a.start<d&&d<a.end?new b(a.start,d):a.start<c&&c<a.end&&a.end<=d?new b(c,a.end):a.start<c&&d>=c&&d<a.end?this:c<=a.start&&a.start<=a.end&&a.end<=d?a:null},b.prototype.add=function(c){return this.overlaps(c)?new b(a.min(this.start,c.start),a.max(this.end,c.end)):null},b.prototype.subtract=function(a){var c=this.start,d=this.end;return null===this.intersect(a)?[this]:a.start<=c&&d>c&&d<=a.end?[]:a.start<=c&&c<a.end&&a.end<d?[new b(a.end,d)]:c<a.start&&a.start<d&&d<=a.end?[new b(c,a.start)]:c<a.start&&a.start<a.end&&a.end<d?[new b(c,a.start),new b(a.end,d)]:void 0},b.prototype.by=function(a,b,e){return"string"==typeof a?c.call(this,a,b,e):d.call(this,a,b,e),this},b.prototype.toString=function(){return this.start.format()+"/"+this.end.format()},b.prototype.valueOf=function(){return this.end-this.start},b.prototype.center=function(){var b=this.start+this.diff()/2;return a(b)},b.prototype.toDate=function(){return[this.start.toDate(),this.end.toDate()]},b.prototype.isSame=function(a){return this.start.isSame(a.start)&&this.end.isSame(a.end)},b.prototype.diff=function(a){return this.end.diff(this.start,a)},a.range=function(c,d){return c in e?new b(a(this).startOf(c),a(this).endOf(c)):new b(c,d)},a.range.constructor=b,a.fn.range=a.range,a.fn.within=function(a){return a.contains(this._d)},b});

@@ -63,2 +63,9 @@ //-----------------------------------------------------------------------------

/**
* Constructor for prototype.
*
* @return {Function}
*/
DateRange.prototype.constructor = DateRange;
/**
* Deep clone range.

@@ -65,0 +72,0 @@ *

@@ -24,3 +24,3 @@ {

},
"version": "1.1.1",
"version": "1.1.2",
"engines": {

@@ -30,3 +30,3 @@ "node": "*"

"scripts": {
"build": "grunt es6transpiler browserify uglify",
"build": "grunt es6transpiler replace umd uglify",
"test": "grunt mochaTest"

@@ -36,3 +36,2 @@ },

"grunt": "~0.4.1",
"grunt-browserify": "^3.8.0",
"grunt-cli": "^0.1.13",

@@ -42,2 +41,4 @@ "grunt-contrib-uglify": "^0.6.0",

"grunt-mocha-test": "~0.7.0",
"grunt-text-replace": "^0.4.0",
"grunt-umd": "^2.3.3",
"mocha": "^2.1.0",

@@ -44,0 +45,0 @@ "should": "^5.0.1"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc