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.2.0 to 2.0.2

.jsdoc

2

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

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

@@ -5,3 +5,3 @@ (function (root, factory) {

define(["moment"], function (a0) {
return (root['moment'] = factory(a0));
return (root['DateRange'] = factory(a0));
});

@@ -14,3 +14,3 @@ } else if (typeof exports === 'object') {

} else {
root['moment'] = factory(moment);
root['DateRange'] = factory(moment);
}

@@ -65,7 +65,7 @@ }(this, function (moment) {

if (arguments.length === 1 || end === undefined) {
if (start.length === 2) { // Infer array
if (typeof start === 'object' && start.length === 2) {
s = start[0];
e = start[1];
}
else {
else if (typeof start === 'string') {
parts = start.split('/');

@@ -368,4 +368,4 @@ s = parts[0];

return moment;
return DateRange;
}));

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

!function(a,b){"function"==typeof define&&define.amd?define(["moment"],function(c){return a.moment=b(c)}):"object"==typeof exports?module.exports=b(require("moment")):a.moment=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)},a});
!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)&&("object"==typeof b&&2===b.length?(e=b[0],f=b[1]):"string"==typeof b&&(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});

@@ -43,3 +43,3 @@ module.exports = function(grunt) {

{
from: 'module.exports = moment;',
from: 'module.exports = DateRange;',
to: ''

@@ -62,4 +62,4 @@ }]

dest: 'dist/moment-range.js',
globalAlias: 'moment',
objectToExport: 'moment',
globalAlias: 'DateRange',
objectToExport: 'DateRange',
deps: {

@@ -66,0 +66,0 @@ default: ['moment']

@@ -25,16 +25,14 @@ //-----------------------------------------------------------------------------

*
* @class DateRange
* @constructor
* @param {(Moment|Date)} start Start of interval
* @param {(Moment|Date)} end End of interval
*/
/**
*//**
* DateRange class to store ranges and query dates.
*
* @class DateRange^1
* @constructor
* @param {!Array} range Array containing start and end dates.
*/
/**
*//**
* DateRange class to store ranges and query dates.
*
* @class DateRange^2
* @constructor
* @param {!String} range String formatted as an IS0 8601 time interval

@@ -48,7 +46,7 @@ */

if (arguments.length === 1 || end === undefined) {
if (start.length === 2) { // Infer array
if (typeof start === 'object' && start.length === 2) {
s = start[0];
e = start[1];
}
else {
else if (typeof start === 'string') {
parts = start.split('/');

@@ -67,3 +65,3 @@ s = parts[0];

*
* @return {Function}
* @type {DateRange}
*/

@@ -189,3 +187,3 @@ DateRange.prototype.constructor = DateRange;

* http://momentjs.com/docs/#/manipulating/add/)
* @param {!function(Moment)} hollaback Function to execute for each sub-range
* @param {!DateRange~by} hollaback Callback
* @param {!boolean} exclusive Indicate that the end of the range should not

@@ -206,3 +204,12 @@ * be included in the iter.

/**
* Callback executed for each sub-range.
*
* @callback DateRange~by
*
* @param {!Moment} current Current moment object for iteration
*/
/**
* @private

@@ -352,2 +359,2 @@ */

module.exports = moment;
module.exports = DateRange;

@@ -20,7 +20,7 @@ {

"bugs": "https://github.com/gf3/moment-range/issues",
"main": "./lib/moment-range",
"main": "./dist/moment-range",
"directories": {
"lib": "./lib"
},
"version": "1.2.0",
"version": "2.0.2",
"engines": {

@@ -31,2 +31,3 @@ "node": "*"

"build": "grunt es6transpiler replace umd uglify",
"jsdoc": "jsdoc -c .jsdoc",
"test": "grunt mochaTest"

@@ -42,6 +43,7 @@ },

"grunt-umd": "^2.3.3",
"jsdoc": "^3.3.0",
"mocha": "^2.1.0",
"should": "^5.0.1"
},
"dependencies": {
"peerDependencies": {
"moment": ">= 1"

@@ -48,0 +50,0 @@ },

@@ -288,33 +288,29 @@ # moment-range

### Browser
### Node / NPM
Simply include moment-range after moment.js:
``` html
<script src="/javascripts/moment-range.js"></script>
```
Thanks to the fine people at [cdnjs][cdnjs], you can link to moment-range from
the [cdnjs servers][cdnjs-moment-range].
### NPM
Install via npm:
``` sh
npm install moment-range
npm install moment-range --save-dev
```
Or put it in your `package.json`:
And then `require` it:
``` json
{ "moment-range": "~1" }
``` javascript
var moment = require('moment');
require('moment-range');
```
And then simply `require` it:
### Browser
``` javascript
var moment = require('moment-range');
Simply include moment-range after moment.js:
``` html
<script src="moment.js"></script>
<script src="moment-range.js"></script>
```
Thanks to the fine people at [cdnjs][cdnjs], you can link to moment-range from
the [cdnjs servers][cdnjs-moment-range].
### Bower

@@ -326,3 +322,5 @@

**Note:** Include `moment-range` _after_ `moment`.
## Running Tests

@@ -345,4 +343,5 @@

``` bash
npm build
npm test
npm run-script build
npm run-script test
npm run-script jsdoc
```

@@ -349,0 +348,0 @@

/* jshint node: true, maxlen: 200, -W030 */
/* global describe, it */
var should = require('should');
var moment = require('../lib/moment-range');
var should = require('should');
var moment = require('moment');
require('../lib/moment-range');

@@ -15,3 +16,3 @@ describe('Moment', function() {

describe('#range()', function() {
it('should a DateRange with start & end properties', function() {
it('should return a DateRange with start & end properties', function() {
dr = moment.range(m1, m2);

@@ -91,2 +92,16 @@ moment.isMoment(dr.start).should.be.true;

});
it('should allow initialization without any arguments', function() {
var dr = moment.range();
moment.isMoment(dr.start).should.be.true;
moment.isMoment(dr.end).should.be.true;
});
it('should allow initialization with undefined arguments', function() {
var dr = moment.range(undefined, undefined);
moment.isMoment(dr.start).should.be.true;
moment.isMoment(dr.end).should.be.true;
});
});

@@ -93,0 +108,0 @@

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