Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-array-reduce

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-array-reduce - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

36

index.js

@@ -10,16 +10,40 @@ /*!

module.exports = function reduce(arr, init, fn, cb) {
module.exports = function reduce(arr, memo, iteratee, cb) {
if (!Array.isArray(arr)) {
throw new TypeError('expected an array');
}
if (typeof iteratee !== 'function') {
throw new TypeError('expected iteratee to be a function');
}
if (typeof cb !== 'function') {
throw new TypeError('a callback function is expected');
throw new TypeError('expected callback to be a function');
}
var callback = once(cb);
(function next(i, acc) {
if (i === arr.length) {
return cb(null, acc);
callback(null, acc);
return;
}
fn(acc, arr[i], function(err, val) {
if (err) return cb(err);
iteratee(acc, arr[i], function(err, val) {
if (err) {
next(err);
return;
}
next(i + 1, val);
});
})(0, init);
})(0, memo);
};
function once(fn) {
var value;
return function() {
if (!fn.called) {
fn.called = true;
value = fn.apply(this, arguments);
}
return value;
};
}

30

package.json
{
"name": "async-array-reduce",
"description": "Async reduce.",
"version": "0.1.0",
"version": "0.2.0",
"homepage": "https://github.com/jonschlinkert/async-array-reduce",

@@ -13,3 +13,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"files": [
"index.js"
"index.js",
"LICENSE"
],

@@ -24,4 +25,4 @@ "main": "index.js",

"devDependencies": {
"mocha": "*",
"should": "*"
"gulp-format-md": "^0.1.9",
"mocha": "^3.0.0"
},

@@ -36,9 +37,24 @@ "keywords": [

"list": [
"arr-reduce",
"arr-filter",
"arr-flatten",
"arr-reduce",
"array-unique"
]
}
},
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
},
"reflinks": [
"verb",
"verb-generate-readme"
]
}
}
}

@@ -1,11 +0,11 @@

# async-array-reduce [![NPM version](https://badge.fury.io/js/async-array-reduce.svg)](http://badge.fury.io/js/async-array-reduce)
# async-array-reduce [![NPM version](https://img.shields.io/npm/v/async-array-reduce.svg?style=flat)](https://www.npmjs.com/package/async-array-reduce) [![NPM downloads](https://img.shields.io/npm/dm/async-array-reduce.svg?style=flat)](https://npmjs.org/package/async-array-reduce) [![Build Status](https://img.shields.io/travis/jonschlinkert/async-array-reduce.svg?style=flat)](https://travis-ci.org/jonschlinkert/async-array-reduce)
> Async reduce.
Async reduce.
## Install
Install with [npm](https://www.npmjs.com/)
Install with [npm](https://www.npmjs.com/):
```sh
$ npm i async-array-reduce --save
$ npm install --save async-array-reduce
```

@@ -26,35 +26,47 @@

## Related projects
## About
* [arr-reduce](https://github.com/jonschlinkert/arr-reduce): Fast array reduce that also loops over sparse elements.
* [arr-filter](https://github.com/jonschlinkert/arr-filter): Faster alternative to javascript's native filter method.
* [arr-flatten](https://github.com/jonschlinkert/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
* [array-unique](https://github.com/jonschlinkert/array-unique): Return an array free of duplicate values. Fastest ES5 implementation.
### Related projects
## Running tests
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.")
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.")
* [arr-reduce](https://www.npmjs.com/package/arr-reduce): Fast array reduce that also loops over sparse elements. | [homepage](https://github.com/jonschlinkert/arr-reduce "Fast array reduce that also loops over sparse elements.")
* [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.")
Install dev dependencies:
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Building docs
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm i -d && npm test
$ npm install -g verb verb-generate-readme && verb
```
## Contributing
### Running tests
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/async-array-reduce/issues/new)
Install dev dependencies:
## Author
```sh
$ npm install -d && npm test
```
### Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
### License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/async-array-reduce/blob/master/LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 01, 2015._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.28, on August 02, 2016._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc