numgen

Creates objects that generate number sequences

numgen

Creates objects that generate number sequences.

Disclaimer: this package does not have anything common with ECMAScript 6 generators nor with yield operator.

npm install numgen

Component

component install gamtiq/numgen

Jam

jam install numgen

Bower

bower install numgen

SPM

spm install numgen

Use dist/numgen.js or dist/numgen.min.js (minified version).

var NumGen = require("numgen");
require(["numgen"], function(NumGen) {
    ...
});
define(["path/to/dist/numgen.js"], function(NumGen) {
    ...
});
<!-- Use bower_components/numgen/dist/numgen.js if the library was installed by Bower -->
<script type="text/javascript" src="path/to/dist/numgen.js"></script>
<script type="text/javascript">
    // numgen is available via NumGen field of window object 
    ...
</script> 
var seq = new NumGen({
                        startValue: 3,
                        factor: 4,
                        valueChangefunction(data) {
                            return data.index > 1 ? data.current : data.value;
                        }
                    });
console.log("Geometric progression:");
for (var nI = 1; nI < 11; nI++) {
    console.log("#", nI, " - ", seq.getNext());
}

See test/numgen.js for additional examples.

See doc folder.

MIT