forked from Dobby85/hearthjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct bugs; Update doc;
- Loading branch information
Maxime Magné
committed
Jan 15, 2020
1 parent
ab87071
commit 7973c95
Showing
34 changed files
with
827 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
node_modules | ||
package-lock.json | ||
package-lock.json.* | ||
.* | ||
#*# | ||
_docpress | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
## Helpers | ||
|
||
### Generic queue | ||
|
||
You know calling a callback in a loop is not a good idea and you have to create recursive function to loop on your array. This time is done. Now you can use a `genericQueue`! | ||
|
||
#### How it works? | ||
|
||
It's simple, hearthjs will create an object which will call one of your callback for each item. | ||
|
||
Here is the genericQueue prototype | ||
|
||
```js | ||
hearthjs.helpers.genericQueue(items, itemHandler, errorHandler, callback) | ||
``` | ||
|
||
An example will be clearer than text: | ||
|
||
```js | ||
const hearthjs = require('hearthjs') | ||
|
||
let myArray = ['value1', 'value2', 'value3'] | ||
|
||
let genericQueue = hearthjs.helpers.genericQueue(myArray, (item, next) => { | ||
// You will receive one by one each item of your array (value1, value2, value3) | ||
// You must call next when you finish processing your item | ||
// You can pass an error to next callback | ||
}, (error) => { | ||
// Handle errors here | ||
}, () => { | ||
// This callback is called when we stop looping on the array | ||
}) | ||
``` | ||
|
||
**WARNING: The genericQueue shift element of the array one by one. Take care of cloning your array before sending it to the genericQueue if you want to reuse it after.** | ||
|
||
```js | ||
// Clone an array | ||
let clonedArray = JSON.parse(JSON.stringify(arrayToClone)) | ||
``` | ||
|
||
```js | ||
const hearthjs = require('hearthjs') | ||
|
||
let myArray = ['value1', 'value2', 'value3'] | ||
let concatenateValues = '' | ||
|
||
let genericQueue = hearthjs.helpers.genericQueue(myArray, (item, next) => { | ||
concatenateValues += item + ' ' | ||
}, (error) => { | ||
// Handle errors here | ||
}, () => { | ||
console.log(concatenateValues) // display: value1 value2 value3 | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
* [Getting started](/#hearthjs) | ||
* [Server](/server/#server) | ||
* [Api](/api/#api) | ||
* [Converter](/converter/#converter) | ||
* [Data validation](/validation/#data-validation) | ||
* [Templating](/templating/#templating) | ||
* [Addons](/addons/#addons) | ||
* [Extern API](/extern-api/#extern-api) | ||
* [Translations](/translations/#translations) | ||
* [Cron](/cron/#cron) | ||
* [Logger](/logger/#logger) | ||
* [Helpers](/helpers/#helpers) | ||
* [Cli](/cli/#cli) | ||
* [Database](/database/#database) | ||
* [Tests](/tests/#tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.