Skip to content

Commit 8c79059

Browse files
committed
1 parent 86054c1 commit 8c79059

File tree

7 files changed

+137
-83
lines changed

7 files changed

+137
-83
lines changed

.babelrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,29 @@ await reduce(
6868

6969
Returns **any** final `accumulator` value
7070

71+
### map
72+
73+
Invoke an async transform function on each item in the given Array **in parallel**,
74+
returning the resulting Array of mapped/transformed items.
75+
76+
> This is an asynchronous, parallelized version of `Array.prototype.map()`.
77+
78+
**Parameters**
79+
80+
- `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The Array to map over
81+
- `mapper` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function, gets passed `(value, index, array)`, returns the new value.
82+
83+
**Examples**
84+
85+
```javascript
86+
await map(
87+
['foo', 'baz'],
88+
async v => await fetch(v)
89+
)
90+
```
91+
92+
Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** resulting mapped/transformed values.
93+
7194
### filter
7295

7396
Invoke an async filter function on each item in the given Array **in parallel**,
@@ -195,3 +218,7 @@ await series([
195218
```
196219

197220
Returns **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** same structure as `list` input, but with values now resolved.
221+
222+
## License
223+
224+
[MIT](https://oss.ninja/mit/developit)

docs/index.html

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset='utf-8' />
5-
<title>asyncro 2.0.1 | Documentation</title>
5+
<title> | Documentation</title>
66
<meta name='viewport' content='width=device-width,initial-scale=1'>
77
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
88
<link href='assets/style.css' type='text/css' rel='stylesheet' />
@@ -13,8 +13,8 @@
1313
<div class='clearfix md-mxn2'>
1414
<div class='fixed xs-hide fix-3 overflow-auto max-height-100'>
1515
<div class='py1 px2'>
16-
<h3 class='mb0 no-anchor'>asyncro</h3>
17-
<div class='mb1'><code>2.0.1</code></div>
16+
<h3 class='mb0 no-anchor'></h3>
17+
<div class='mb1'><code></code></div>
1818
<input
1919
placeholder='Filter'
2020
id='filter-input'
@@ -34,6 +34,16 @@ <h3 class='mb0 no-anchor'>asyncro</h3>
3434
</li>
3535

3636

37+
<li><a
38+
href='#map'
39+
class="">
40+
map
41+
42+
</a>
43+
44+
</li>
45+
46+
3747
<li><a
3848
href='#filter'
3949
class="">
@@ -202,6 +212,94 @@ <h3 class='fl m0' id='reduce'>
202212

203213

204214

215+
</section>
216+
217+
218+
219+
220+
<section class='p2 mb2 clearfix bg-white minishadow'>
221+
222+
223+
<div class='clearfix'>
224+
<h3 class='fl m0' id='map'>
225+
map
226+
</h3>
227+
228+
</div>
229+
230+
231+
<p>Invoke an async transform function on each item in the given Array <strong>in parallel</strong>,
232+
returning the resulting Array of mapped/transformed items.</p>
233+
<blockquote>
234+
<p>This is an asynchronous, parallelized version of <code>Array.prototype.map()</code>.</p>
235+
</blockquote>
236+
237+
238+
<div class='pre p1 fill-light mt0'>map(array: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>, mapper: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function">Function</a>): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></div>
239+
240+
241+
242+
243+
244+
245+
246+
247+
248+
249+
<div class='py1 quiet mt1 prose-big'>Parameters</div>
250+
<div class='prose'>
251+
252+
<div class='space-bottom0'>
253+
<div>
254+
<span class='code bold'>array</span> <code class='quiet'>(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>)</code> The Array to map over
255+
256+
</div>
257+
258+
</div>
259+
260+
<div class='space-bottom0'>
261+
<div>
262+
<span class='code bold'>mapper</span> <code class='quiet'>(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function">Function</a>)</code> Async function, gets passed
263+
<code>(value, index, array)</code>
264+
, returns the new value.
265+
266+
</div>
267+
268+
</div>
269+
270+
</div>
271+
272+
273+
274+
275+
276+
277+
<div class='py1 quiet mt1 prose-big'>Returns</div>
278+
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></code>:
279+
resulting mapped/transformed values.
280+
281+
282+
283+
284+
285+
286+
287+
288+
<div class='py1 quiet mt1 prose-big'>Example</div>
289+
290+
291+
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">await</span> map(
292+
[<span class="hljs-string">'foo'</span>, <span class="hljs-string">'baz'</span>],
293+
<span class="hljs-keyword">async</span> v =&gt; <span class="hljs-keyword">await</span> fetch(v)
294+
)</pre>
295+
296+
297+
298+
299+
300+
301+
302+
205303
</section>
206304

207305

package.json

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@
33
"version": "2.0.1",
44
"description": "Asynchronous Array Utilities (for await)",
55
"main": "dist/asyncro.js",
6-
"jsnext:main": "src/index.js",
7-
"minified:main": "dist/asyncro.min.js",
6+
"module": "dist/asyncro.m.js",
7+
"source": "src/index.js",
88
"scripts": {
9-
"clean": "rimraf dist/",
10-
"build": "npm-run-all --silent clean transpile minify docs size",
11-
"prepublish": "npm-run-all build test",
9+
"build": "microbundle && npm run -s docs",
10+
"prepublish": "npm run -s build && npm t",
1211
"transpile": "rollup -c rollup.config.js -m ${npm_package_main}.map -f umd -n $npm_package_name $npm_package_jsnext_main -o $npm_package_main",
13-
"minify": "uglifyjs $npm_package_main -cm -o $npm_package_minified_main -p relative --in-source-map ${npm_package_main}.map --source-map ${npm_package_minified_main}.map",
14-
"size": "size=$(gzip-size $npm_package_minified_main) && echo \"gzip size: $size / $(pretty-bytes $size)\"",
15-
"docs": "documentation readme --section API -q && documentation build -f html -o docs -q",
16-
"test": "ava --verbose",
17-
"lint": "eslint {src,test}",
12+
"docs": "documentation readme src/*.js -q -s API && documentation build src/*.js -f html -o docs",
13+
"test": "eslint src test && npm run -s build && ava --verbose",
1814
"release": "npm run -s build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
1915
},
2016
"eslintConfig": {
@@ -38,20 +34,10 @@
3834
"homepage": "https://github.com/developit/asyncro",
3935
"devDependencies": {
4036
"ava": "^0.16.0",
41-
"babel-cli": "^6.14.0",
42-
"babel-plugin-async-to-promises": "^1.0.5",
43-
"babel-preset-es2015": "^6.14.0",
4437
"documentation": "^4.0.0-beta11",
4538
"eslint": "^3.19.0",
4639
"eslint-config-developit": "^1.1.1",
47-
"gzip-size-cli": "^1.0.0",
48-
"npm-run-all": "^3.1.1",
49-
"pretty-bytes-cli": "^2.0.0",
50-
"rollup": "^0.36.3",
51-
"rollup-plugin-babel": "^2.6.1",
52-
"rollup-plugin-es3": "^1.0.3",
53-
"rollup-plugin-memory": "^2.0.0",
54-
"sinon": "^1.17.6",
55-
"uglify-js": "^2.7.3"
40+
"microbundle": "^0.3.1",
41+
"sinon": "^1.17.6"
5642
}
5743
}

rollup.config.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22
import { spy } from 'sinon';
3-
import { series, parallel, map, filter, find, every, some } from '..';
3+
import { series, parallel, map, filter, find, every, some } from '../dist/asyncro.js';
44

55
const get = v => Promise.resolve(v);
66

0 commit comments

Comments
 (0)