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.2 to 0.2.3

examples/example4.js

5

examples/example.js

@@ -18,3 +18,6 @@ var RangeGen = require('../');

var h = RangeGen(1,0,0.1);
console.log("[1-0,0.1] "+h.join(",")+"\n");
console.log("[1-0,0.1] "+h.join(',')+"\n");
console.log("\n --- Floats with `map(function(x) { return x.toPrecision(2); })` ---");
console.log("[0-1,0.1] "+g.map(function(x) { return x.toPrecision(2); }).join(",")+"\n");
console.log("[1-0,0.1] "+h.map(function(x) { return x.toPrecision(2); }).join(',')+"\n");
} catch (e) {

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

2

examples/example2.js

@@ -34,3 +34,3 @@ var RangeGen = require('../');

try {
console.log("\n- Inalid range. [a-30] -");
console.log("\n- Invalid range. [a-30] -");
var iterator = RangeGen.iterator("a",30,1,true);

@@ -37,0 +37,0 @@ } catch (e) {

@@ -7,7 +7,8 @@ /*

(function(Setup){
var RangeGen = function (from, to, step, error) {
var range = [];
var invalid = RangeGen.validate(to,from);
var RangeGen = function (from, to, step, error, cb) {
var range = [],
invalid = RangeGen.validate(to,from),
cb = cb||function(x){return x};
if (invalid) {
return RangeGen.handleError(invalid,error);
return cb(RangeGen.handleError(invalid,error));
};

@@ -18,3 +19,3 @@ var calc = RangeGen.calculate(from,to,step,2);

calc["from"] += calc["incr"];
if (calc["from"] <= 0) {
if (calc["from"] < 0) {
break;

@@ -25,3 +26,3 @@ };

// This should NOT happen, but error if it does!
return (!!(range.length)?range:RangeGen.handleError(RangeGen.Errors("NotGenerated"),error));
return cb(!!(range.length)?range:RangeGen.handleError(RangeGen.Errors("NotGenerated"),error));
};

@@ -81,3 +82,3 @@ RangeGen.validate = function (to, from) {

incr: (direction?step:-step),
loops: ~~((end-start)/step+ext),
loops: Math.floor((end-start)/step+ext),
};

@@ -84,0 +85,0 @@ };

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

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

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

RangeGen (v0.2.2)
RangeGen (v0.2.3)
======

@@ -22,3 +22,3 @@

-- Array generator (See "examples.js" for usage) --
var array = RangeGen(<from>,<to>,[<step>[,<exceptions>]]);
var array = RangeGen(<from>,<to>,[<step>[,<exceptions>[,<CB/filter>]]]);

@@ -29,2 +29,3 @@ From - The letter or number to start the range at. (Number, Float, Letters)

Exceptions* - Throw error messages. Default, return an empty array. (Boolean);
CB/filter* - Use a callback or filter results. (see example4.js)
* Optional.

@@ -64,2 +65,5 @@

console.log("[1-0,0.1] "+h.join(",")+"\n");
console.log("\n --- Floats with `map(function(x) { return x.toPrecision(2); })` ---");
console.log("[0-1,0.1] "+g.map(function(x) { return x.toPrecision(2); }).join(",")+"\n");
console.log("[1-0,0.1] "+h.map(function(x) { return x.toPrecision(2); }).join(',')+"\n");
} catch (e) {

@@ -129,3 +133,3 @@ console.log(e);

try {
console.log("\n- Inalid range. [a-30] -");
console.log("\n- Invalid range. [a-30] -");
var iterator = RangeGen.iterator("a",30,1,true);

@@ -169,2 +173,5 @@ } catch (e) {

output("[1-0,0.1] "+h.join(",")+"\n");
output("<br /> --- Floats with `map(function(x) { return x.toPrecision(2); })` ---");
output("[0-1,0.1] "+g.map(function(x) { return x.toPrecision(2); }).join(",")+"\n");
output("[1-0,0.1] "+h.map(function(x) { return x.toPrecision(2); }).join(',')+"\n");
} catch (e) {

@@ -195,5 +202,14 @@ output(e);

```
```javascript
var range = require('../');
try {
console.log("--- As a callback ---");
range(1,10,3,null,function (x) { x.forEach(function (x) { console.log(x); }); });
console.log("\n--- As a filter ---");
console.log(range(1,100,3,null,function (x) { return x.filter(function(y) { return y%4===0; }); }).join(','));
} catch (e) {
console.log(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