<commit_before>fibonacci
=========

Module for [Node.js](http://nodejs.org/) to calculate fibonacci numbers for one or endless iterations.

Using the [bignum](https://github.com/justmoon/node-bignum) module, it can return numbers of any size! Instead of being limited by the hardcoded JavaScript *Number.MAX_LIMIT*.


Installation
------------

[![Build Status](https://travis-ci.org/fvdm/nodejs-fibonacci.svg?branch=1.3.0)](https://travis-ci.org/fvdm/nodejs-fibonacci)

### Build essentials

The 'bignum' dependency requires build essentials such as *gcc* and *make*. When you install this module with [NPM](http://npmjs.org/) it might fail, but at least it will tell you which build tools you are missing. Refer to your OS community to figure out how to get them, on Debian/Ubuntu systems simply run this command:

```
sudo apt-get install build-essential
```

On Mac OSX you need to install the xCode Command Line Tools.


### Module

To install the module with NPM:

```
sudo npm -g install fibonacci
```


Usage
-----

### Just one

Find one fibonacci number at 3000 iterations:

```js
var fibonacci = require('fibonacci');
var bigNumber = fibonacci.iterate( 3000 );
console.log( bigNumber )
```

Result:

```js
{ number: '410615886307971260333568378719267105220125108637369252408885430926905584274113403731330491660850044560830036835706942274588569362145476502674373045446852160486606292497360503469773453733196887405847255290082049086907512622059054542195889758031109222670849274793859539133318371244795543147611073276240066737934085191731810993201706776838934766764778739502174470268627820918553842225858306408301661862900358266857238210235802504351951472997919676524004784236376453347268364152648346245840573214241419937917242918602639810097866942392015404620153818671425739835074851396421139982713640679581178458198658692285968043243656709796000',
length: 627,
iterations: '3000',
ms: 208 }
```


### Many numbers

Get all numbers up to 4 seconds.

**WARNING: it is very important that you run the *iterate()* function AFTER the *.on('result') event*, otherwise the iteration will continue forever without emitting the events!**

```js
fibonacci.on( 'result', function( num ) {
	console.log( num.iterations +' / '+ num.number +'\n' );
	if( num.ms > 4000 ) {
		console.log( 'Done!' );
		fibonacci.kill();
	}
});

// run this AFTER everything
fibonacci.iterate();
```

Here you see I use the **[result](#result--resultobject-)** event to catch each result, the num.**ms** property to figure out how many milliseconds have passed and finally **[kill()](#kill)** to stop the iteration.


Functions
---------

### iterate( [max_iterations] )

Run the iteration

**max_iterations** (optional) - limit the amount of iterations. Without this argument it will continue untill **[kill()](#kill)** is called or the process terminated.

**Returns:** the last result as object, with these elements:

* number - the number as string
* length - the number of digits
* iterations - how many iterations it took
* ms - duration in milliseconds

### kill()

Stop the iteration loop.

**Returns:** nothing<commit_msg>Readme: minor edits and tweaks<commit_after>fibonacci
=========

Module for [node.js](http://nodejs.org/) to calculate fibonacci numbers for one or endless iterations.

Using the [bignum](https://github.com/justmoon/node-bignum) module it can return numbers of any size, instead of being limited by the hardcoded javascript `Number.MAX_LIMIT`.


Usage
-----

### Just one

Find one fibonacci number at 3000 iterations:

```js
var fibonacci = require ('fibonacci');
var bigNumber = fibonacci.iterate (3000);
console.log (bigNumber);
```

Result:

```js
{ number: '410615886307971260333568378719267105220125108637369252408885430926905584274113403731330491660850044560830036835706942274588569362145476502674373045446852160486606292497360503469773453733196887405847255290082049086907512622059054542195889758031109222670849274793859539133318371244795543147611073276240066737934085191731810993201706776838934766764778739502174470268627820918553842225858306408301661862900358266857238210235802504351951472997919676524004784236376453347268364152648346245840573214241419937917242918602639810097866942392015404620153818671425739835074851396421139982713640679581178458198658692285968043243656709796000',
length: 627,
iterations: '3000',
ms: 208 }
```


### Many numbers

Get all numbers up to 4 seconds.

**WARNING: it is very important that you run the *iterate()* function AFTER the *.on('result') event*, otherwise the iteration will continue forever without emitting the events!**

```js
fibonacci.on ('result', function (num) {
  console.log (num.iterations +' / '+ num.number +'\n');
  if (num.ms > 4000) {
    console.log ('Done!');
    fibonacci.kill ();
  }
});

// run this AFTER everything
fibonacci.iterate ();
```

Here you see I use the **[result](#result--resultobject-)** event to catch each result, the num.**ms** property to figure out how many milliseconds have passed and finally **[kill()](#kill)** to stop the iteration.


Installation
------------

[![Build Status](https://travis-ci.org/fvdm/nodejs-fibonacci.svg?branch=master)](https://travis-ci.org/fvdm/nodejs-fibonacci)

### Build essentials

The 'bignum' dependency requires build essentials such as *gcc* and *make*. When you install this module with [npm](https://www.npmjs.com/) it might fail, but at least it will tell you which build tools you are missing. Refer to your OS community to figure out how to get them.

* Debian/Ubuntu systems: `sudo apt-get install build-essential`
* Mac OSX: install xCode Command Line Tools

### Module

Stable: `npm install fibonacci`


Functions
---------

### iterate ( [max_iterations] )

Run the iteration

**max_iterations** (optional) - limit the amount of iterations. Without this argument it will continue untill **[kill()](#kill)** is called or the process terminated.

**Returns:** the last result as object, with these elements:

* number - the number as string
* length - the number of digits
* iterations - how many iterations it took
* ms - duration in milliseconds

### kill()

Stop the iteration loop.

**Returns:** nothing
{'fraction_non_alphanumeric': 0.1106777181862506, 'fraction_numerical': 0.21176661790996262, 'mean_word_length': 5.477894736842106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 7, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '272770', 'n_tokens_mistral': 2824, 'n_tokens_neox': 1950, 'n_words': 579}