Skip to content

Commit

Permalink
updated readme and index.js with mapEach
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaugh42 committed Jun 19, 2016
1 parent 2d2af66 commit f2dec2c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# palinode
NodeJS callback-based flow control utility library
NodeJS callback-based flow control utility library. Palinode focuses on a pure, dependency free, no-frills, native javascript implementation. Palinode is intentionally not compatible with browsers; it is intended for NodeJS only.

[![Build Status](https://travis-ci.org/GannettDigital/palinode.svg?branch=master)](https://travis-ci.org/GannettDigital/palinode) [![Coverage Status](https://coveralls.io/repos/github/GannettDigital/palinode/badge.svg?branch=master)](https://coveralls.io/github/GannettDigital/palinode?branch=master)

palinode (noun): a poem in which the poet retracts a view or sentiment expressed in a former poem. - source: Google.
## Installation
```Shell
npm install palinode
Expand All @@ -19,19 +21,21 @@ npm run cover-html
```

## Setup

Just require `palinode`
```Javascript
var theFunctionToUse = require(`palinode`).theFunctionYouWant
```

## Supported methods

### Series
Runs a series of functions. Each function calls back to the next. Any parameters passed to a callback are spread into the subsequent function call.
Runs a series of functions. Each function calls back to the next. Any parameters passed to a callback are spread into the subsequent function call.
The provided array of functions is not mutated.
All functions in a series should accept a callback in the form:
```
```Javascript
function(error, param1[, param2, param3...]) {}
```
Example usage
```
```Javascript
var series = require('palinode').series;

var numToAddEachTime = 5;
Expand All @@ -54,4 +58,21 @@ series(functions, function(error, result) {
//outputs: 15
}
```
### Map Each
Runs a single function against each member of an array, invoking a callback when complete of if an error occurs during execution. If successful for each item in the input array, the result provided to the callback will be a new array containing the mapped values.
The input array is not mutated.
Example usage
```Javascript
var mapEach = require('palinode').mapEach;
var inputArray = [1,2,3,4,5,6,7,8,9,10];

functon square(input, callback) {
return callback(null, input * input);
}

mapEach(inputArray, square, function(error, result) {
console.log(result);
//outputs: [1,4,9,16,25,36,49,64,81,100]
});

```
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

module.exports = {
series: require('./lib/series.js').series
series: require('./lib/series.js').series,
mapEach: require('./lib/map-each.js').mapEach
};

0 comments on commit f2dec2c

Please sign in to comment.