# funccon

> A function concurrency strategy

Latest version **6.0.4** (published 2020-08-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install funccon
pnpm add funccon
yarn add funccon
bun add funccon
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.4 |
| Published | 2020-08-28 |
| First published | 2017-04-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | ameola01 |

## Links

- npm: https://www.npmjs.com/package/funccon
- Repository: https://github.com/adammeola01/funccon
- Homepage: https://github.com/adammeola01/funccon#readme
- Issues: https://github.com/adammeola01/funccon/issues
- npm.io page: https://npm.io/package/funccon

## Recent versions

- 6.0.4 (latest) — 2020-08-28
- 6.0.3 — 2020-08-28
- 6.0.2 — 2020-08-28
- 6.0.1 — 2020-08-28
- 6.0.0 — 2020-08-19
- 5.1.3 — 2019-07-02
- 5.1.2 — 2019-05-06
- 5.0.2 — 2019-01-05
- 5.0.1 — 2018-09-15
- 5.0.0 — 2018-05-01
- 3.0.2 — 2017-06-06
- 3.0.1 — 2017-06-06
- 3.0.0 — 2017-06-01
- 2.0.1 — 2017-05-20
- 2.0.0 — 2017-05-04
- … 4 more at https://npm.io/package/funccon/versions

## README

# FuncCon
## (function concurrence)
<hr/>
An old strategy for executing a function after a serious of asynchronous functions run to completion.

...which can also be used to make things run in sequnce, by setting the size aregument to 1

The "size" argument sets how many functions are allowed to run simultaniously
<hr/><br/>



<blockquote>
    <br/>release notes:
    <br/><br/>
    <blockquote>
        <br/>
        6.0.0:
		<br/>
		<br/>
        <blockquote>
            <br/>
            
- promise interface added<br/><br/>
    - ```done: () = >{}``` is still supported, but now optional<br/><br/>
    - 
        ```javascript
        con({
            size: numberOfFunctionsAllowedToRunAtOnce,
            funcs: arrayOfYourFunctions
        }).then(()=>{
            // next step here
        });
        ```
    - OR<br/><br/>
    - 
        ```javascript
        con({
            size: numberOfFunctionsAllowedToRunAtOnce,
            funcs: arrayOfYourFunctions
            done: ()=>{
                // next step here
            }
        });
        ```
        <br/>
        </blockquote>
        <br/>
        <br/>
    </blockquote>
    <br/>
    <br/>

```javascript
var con = require(funccon);
con({
	size: 100, // number of function allowed to run simulataniously
	funcs: [ // your functions
		(complete) => {
			var counter = 0;
			var a = setInterval(function() {
				counter++;
				console.log('func 1 counter: ' + counter);
				if (counter >= 4) {
					clearInterval(a);
					complete(1); // the complete function tells funccon to move on
								 //	Whatever you pass it will be given to the done function as an argument
				}
			}, 500);
        },
		(complete) => {
			var counter = 0;
			var a = setInterval(function() {
				counter++;
				console.log('func 2 counter: ' + counter);
				if (counter >= 4) {
					clearInterval(a);
					complete('foo');
				}
			}, 500);
        },
		(complete) => {
			var counter = 0;
			var a = setInterval(function() {
				counter++;
				console.log('func 3 counter: ' + counter);
				if (counter >= 4) {
					clearInterval(a);
					complete({
						shit: 'real'
					}, 'asfdas');
				}
			}, 500);
        },
		(complete) => {
			var counter = 0;
			var a = setInterval(function() {
				counter++;
				console.log('func 4 counter: ' + counter);
				if (counter >= 4) {
					clearInterval(a);
					complete('boom?');
				}
			}, 500);
        }
    ],
	done: function() { // this fires when all the above functions are complete
		console.log('completeFunction called, done');
		console.log();
		con({
			size: 1, // number of function allowed to run simulataniously
			funcs: [ // your functions
				(complete) => {
					var counter = 0;
					var a = setInterval(function() {
						counter++;
						console.log('func 1 counter: ' + counter);
						if (counter >= 4) {
							clearInterval(a);
							complete(1); // the complete function tells funccon to move on
										 //	Whatever you pass it will be given to the done function as an argument
						}
					}, 500);
		        },
				(complete) => {
					var counter = 0;
					var a = setInterval(function() {
						counter++;
						console.log('func 2 counter: ' + counter);
						if (counter >= 4) {
							clearInterval(a);
							complete('foo');
						}
					}, 500);
		        },
				(complete) => {
					var counter = 0;
					var a = setInterval(function() {
						counter++;
						console.log('func 3 counter: ' + counter);
						if (counter >= 4) {
							clearInterval(a);
							complete({
								shit: 'real'
							}, 'asfdas');
						}
					}, 500);
		        },
				(complete) => {
					var counter = 0;
					var a = setInterval(function() {
						counter++;
						console.log('func 4 counter: ' + counter);
						if (counter >= 4) {
							clearInterval(a);
							complete('boom?');
						}
					}, 500);
		        }
		    ],
			done: function() { // this fires when all the above functions are complete
				console.log('completeFunction called, done');
			}
		});

	}
});

```
</blockquote><br/>
Inline versions available is es5 and es6 at:  <a href="https://www.adammeola.com/wk/index.php/Js/funccon">https://www.adammeola.com/wk/index.php/Js/funccon</a>

---
_Source: https://npm.io/package/funccon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
