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

rangerjs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rangerjs - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

7

package.json
{
"name": "rangerjs",
"version": "0.0.4",
"version": "0.0.5",
"description": "A lightweight JS library for defining an array of ranges.",

@@ -19,3 +19,6 @@ "main": "ranger.js",

},
"homepage": "https://github.com/nigh7sh4de/rangerjs#readme"
"homepage": "https://github.com/nigh7sh4de/rangerjs#readme",
"devDependencies": {
"mongoose": "^4.4.17"
}
}

@@ -13,2 +13,42 @@

ranger.prototype = {
removeRecuringRange: function(start, end, interval, count, finish) {
var _start = Number(start),
_end = Number(end),
_finish = Number(finish),
_interval = Number(interval),
type = start.constructor;
if (endBeforeStart(start, end))
return new Error('Start must be before end for range.');
if (interval < end - start)
return new Error('Interval must be greater than duration of each range.');
if ((count == null || count < 0) && finish == null)
return new Error('Recuring range must specify total count or limit.');
count = count < 1 || !count ? parseInt((_finish - _start) / _interval) : count;
if (count <= 0)
return new Error('Recuring interval must be greater than 0.');
for (var i=0; i < count; i++)
this.removeRange(new type(_start + i*_interval),
new type(_end + i*_interval));
},
addRecuringRange: function(start, end, interval, count, finish) {
var _start = Number(start),
_end = Number(end),
_finish = Number(finish),
_interval = Number(interval),
type = start.constructor;
if (endBeforeStart(start, end))
return new Error('Start must be before end for range.');
if (interval < end - start)
return new Error('Interval must be greater than duration of each range.');
if ((count == null || count < 0) && finish == null)
return new Error('Recuring range must specify total count or limit.');
count = count < 1 || !count ? parseInt((_finish - _start) / _interval) : count;
if (count <= 0)
return new Error('Recuring interval must be greater than 0.');
for (var i=0; i < count; i++)
this.addRange(new type(_start + i*_interval),
new type(_end + i*_interval));
},
addRange: function(start, end) {

@@ -80,3 +120,3 @@ if (endBeforeStart(start, end))

if (this.ranges[i+1] >= start) {
if (this.ranges[i] > end)
if (this.ranges[i] >= end)
return;

@@ -89,3 +129,3 @@ else if (this.ranges[i] < start &&

else if (this.ranges[i] >= start &&
this.ranges[i+1] < end) {
this.ranges[i+1] <= end) {
this.ranges.splice(i, 2);

@@ -95,3 +135,3 @@ i -= 2;

else if (this.ranges[i] < start &&
this.ranges[i+1] < end) {
this.ranges[i+1] <= end) {
this.ranges[i+1] = start;

@@ -98,0 +138,0 @@ }

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