npm install arrayreducearrayreduce
==========
[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
[![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]
[bd_repo_url]: https://github.com/okunishinishi/node-arrayreduce
[bd_travis_url]: http://travis-ci.org/okunishinishi/node-arrayreduce
[bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-arrayreduce.svg?style=flat
[bd_license_url]: https://github.com/okunishinishi/node-arrayreduce/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-arrayreduce
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-arrayreduce.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-arrayreduce.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-arrayreduce
[bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-arrayreduce.svg
[bd_npm_url]: http://www.npmjs.org/package/arrayreduce
[bd_npm_shield_url]: http://img.shields.io/npm/v/arrayreduce.svg?style=flat
[bd_bower_badge_url]: https://img.shields.io/bower/v/arrayreduce.svg?style=flat
Array reducing utility.
``bash`
npm install arrayreduce --save
+ Concat Array
+ Boolean And
+ Boolean Or
+ Index By Attr
arraysort.arrayConcat() create a function which reduce entries as concatenated array.
`javascript
"use strict";
const arrayreduce = require('arrayreduce');
// Define a reducing function.
let arrayConcat = arrayreduce.arrayConcat();
// Execute sorting.
let values = ['foo', ['bar', 'baz']].reduce(arrayConcat, []);
console.log(values); // -> ['foo', 'baz', 'bar']
`
arraysort.booleanAnd() create a function which reduce entries with and condition.
`javascript
"use strict";
const arrayreduce = require('arrayreduce');
// Define a reducing function.
let booleanAnd = arrayreduce.booleanAnd();
// Execute reducing.
let result = [true, false, true].reduce(booleanAnd, true);
console.log(result); // -> false
`
arraysort.booleanOr() create a function which reduce entries with and condition.
`javascript
"use strict";
const arrayreduce = require('arrayreduce');
// Define a reducing function.
let booleanOr = arrayreduce.booleanOr();
// Execute reducing.
let result = [true, false, true].reduce(booleanOr, true);
console.log(result); // -> true
`
arraysort.indexByAttr() create a function which reduce entries to index object.
`javascript
"use strict";
const arrayreduce = require('arrayreduce');
// Define a reducing function.
let indexByAttr = arrayreduce.indexByAttr();
// Execute indexing.
let index = [
{id: 1, name: 'foo'},
{id: 2, name: 'bar'}
].reduce(indexByAttr('id'), {});
console.log(index); // -> {'1': {id: 1, name: 'foo'}, '2': {id: 2, name: 'bar'}}
``
License
-------
This software is released under the MIT License.
Links
------