https://github.com/gamtiq/numgen
Creates objects that generate number sequences
https://github.com/gamtiq/numgen
create fibonacci generate generator number progression seq sequence
Last synced: 11 months ago
JSON representation
Creates objects that generate number sequences
- Host: GitHub
- URL: https://github.com/gamtiq/numgen
- Owner: gamtiq
- License: mit
- Created: 2013-11-24T16:32:42.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-05-29T20:56:23.000Z (almost 11 years ago)
- Last Synced: 2025-04-09T01:43:24.753Z (12 months ago)
- Topics: create, fibonacci, generate, generator, number, progression, seq, sequence
- Language: JavaScript
- Size: 592 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# numgen
[](http://badge.fury.io/js/numgen)
[](https://travis-ci.org/gamtiq/numgen)
Creates objects that generate number sequences.
Objects are iterable according to ECMAScript 6 (for example, they can be used in `for-of` loop).
**Disclaimer:** this package does not have anything common with ECMAScript 6 generators nor with `yield` operator.
## Installation
### Node
npm install numgen
### [Component](https://github.com/componentjs/component)
component install gamtiq/numgen
### [Jam](http://jamjs.org)
jam install numgen
### [Bower](http://bower.io)
bower install numgen
### [JSPM](http://jspm.io)
jspm install numgen
### [SPM](http://spmjs.io)
spm install numgen
### AMD, <script>
Use `dist/numgen.js` or `dist/numgen.min.js` (minified version).
## Usage
### Node, Component, JSPM, SPM
```js
var NumGen = require("numgen");
```
### [Duo](http://duojs.org)
```js
var NumGen = require("gamtiq/numgen");
...
```
### Jam
```js
require(["numgen"], function(NumGen) {
...
});
```
### JSPM
```js
System.import("numgen").then(function(NumGen) {
...
});
```
### AMD
```js
define(["path/to/dist/numgen.js"], function(NumGen) {
...
});
```
### Bower, <script>
```html
// numgen is available via NumGen field of window object
...
```
### Example
```js
var seq = new NumGen({
startValue: 3,
factor: 4,
valueChange: function(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());
}
console.log("Next: ");
for (var num of seq) {
nI = seq.getIndex();
console.log("#", nI, " - ", num);
if (nI > 19) {
break;
}
}
```
See `test/numgen.js` for additional examples.
## API
See `doc` folder.
## License
MIT