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

rangegen

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rangegen - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

4

examples/example.js

@@ -15,2 +15,6 @@ var RangeGen = require('../');

console.log("[100-0,10] "+f.join(",")+"\n");
var g = RangeGen(0,1,0.1);
console.log("[0-1,0.1] "+g.join(",")+"\n");
var h = RangeGen(1,0,0.1);
console.log("[1-0,0.1] "+h.join(",")+"\n");
} catch (e) {

@@ -17,0 +21,0 @@ console.log(e);

@@ -10,2 +10,9 @@ var RangeGen = require('../');

console.log(range.join(','));
var iterator = RangeGen.iter(0,1,0.1,true);
console.log("Iterations: "+iterator.length);
var range = [];
while (iterator.hasNext()) {
range.push(iterator.next());
};
console.log(range.join(','));
} catch (e) {

@@ -12,0 +19,0 @@ console.log(e);

20

index.js

@@ -13,6 +13,9 @@ /*

};
var calc = RangeGen.calculate(from,to,RangeGen.getStep(step),2);
var calc = RangeGen.calculate(from,to,step,2);
while (--calc["loops"]) {
range.push(RangeGen.enc(calc["from"],calc["lcase"]));
calc["from"] += calc["incr"];
if (calc["from"] <= 0) {
break;
};
};

@@ -24,3 +27,3 @@ // Return an error if no range is made.

RangeGen.validate = function (to, from) {
if ((/^([a-z]+|-?[0-9]+)$/i.test(from) && /^([a-z]+|-?[0-9]+)$/i.test(to))) {
if ((/^([a-z]+|[-.0-9]+)$/i.test(from) && /^([a-z]+|[-.0-9]+)$/i.test(to))) {
if (isNaN(from) || isNaN(to)) {

@@ -63,3 +66,3 @@ if (!isNaN(from)) {

RangeGen.getStep = function (step) {
return ~~(isNaN(step)||1>step?1:step);
return (isNaN(step)||0>=step?1:step);
};

@@ -72,3 +75,4 @@ RangeGen.calculate = function (from, to, step, ext) {

start = (direction?from:to),
end = (direction?to:from);
end = (direction?to:from),
step = RangeGen.getStep(step);
return {

@@ -93,7 +97,7 @@ lcase: lcase,

});
this.length = this.loops;
this.length = this.left = this.loops;
return this;
},
hasNext: function () {
return !!(this.loops>0);
return !!(this.left>0);
},

@@ -104,3 +108,3 @@ next: function () {

this.from += this.incr;
--this.loops;
--this.left;
return str;

@@ -114,3 +118,3 @@ } else {

return Object.create(proto);
})().__init(from, to, RangeGen.getStep(step));
})().__init(from,to,step);
}

@@ -117,0 +121,0 @@ RangeGen.iter = RangeGen.iterator;

{
"name": "rangegen",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://louist.github.io/RangeGen/",

@@ -5,0 +5,0 @@ "author": {

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

RangeGen (v0.2.1)
RangeGen (v0.2.2)
======

@@ -24,7 +24,7 @@

From - The letter or number to start the range at. (numbers/letters)
To - The letter or number to end on/near. (numbers/letters)
Step* - The amount to increment or decrement by. Default, 1. (true/false, number)
exceptions* - Throw error messages. Default, return an empty array. (true/false);
* Optional.
From - The letter or number to start the range at. (Number, Float, Letters)
To - The letter or number to end on/near. (Number, Float, Letters)
Step* - The amount to increment or decrement by. Default, 1. (Boolean, Number, Float)
Exceptions* - Throw error messages. Default, return an empty array. (Boolean);
* Optional.

@@ -39,2 +39,3 @@ -- Iterators (See "examples2.js" for usage) --

length - The total number of iterations.
left - The number of iterations left.

@@ -59,2 +60,6 @@

console.log("[100-0,10] "+f.join(",")+"\n");
var g = RangeGen(0,1,0.1);
console.log("[0-1,0.1] "+g.join(",")+"\n");
var h = RangeGen(1,0,0.1);
console.log("[1-0,0.1] "+h.join(",")+"\n");
} catch (e) {

@@ -100,2 +105,9 @@ console.log(e);

console.log(range.join(','));
var iterator = RangeGen.iter(0,1,0.1,true);
console.log("Iterations: "+iterator.length);
var range = [];
while (iterator.hasNext()) {
range.push(iterator.next());
};
console.log(range.join(','));
} catch (e) {

@@ -153,2 +165,6 @@ console.log(e);

output("[100-0,10] "+f.join(",")+"\n");
var g = RangeGen(0,1,0.1);
output("[0-1,0.1] "+g.join(",")+"\n");
var h = RangeGen(1,0,0.1);
output("[1-0,0.1] "+h.join(",")+"\n");
} catch (e) {

@@ -179,1 +195,5 @@ output(e);

```
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/LouisT/rangegen/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

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