박규리

Change folder name

Showing 694 changed files with 4799 additions and 0 deletions
1 +var express = require('express');
2 +var bodyParser = require('body-parser');
3 +var app = express();
4 +
5 +app.use(express.static('public'));
6 +app.use(bodyParser.urlencoded({extended : true}));
7 +
8 +// app.set('views','./views');
9 +app.set('view engine','ejs'); // ejs 템플릿 엔진 연동
10 +
11 +// routing setting - 라우팅
12 +app.get('/', function(req,res){
13 + // res.send('HelloWorld!');
14 + var data = req.body;
15 + res.render('index',{name:data}); // views dir 안에 있는 index.ejs 파일
16 +});
17 +
18 +app.post('/', function(req,res){
19 + var data = req.body.name;
20 + res.render('index',{name : data});
21 +});
22 +
23 +app.listen(8080,function(){
24 + console.log('App Listening on port 8080')
25 +})
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../ejs/bin/cli.js" "$@"
10 +else
11 + exec node "$basedir/../ejs/bin/cli.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\ejs\bin\cli.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../ejs/bin/cli.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../ejs/bin/cli.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../ejs/bin/cli.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../ejs/bin/cli.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../jake/bin/cli.js" "$@"
10 +else
11 + exec node "$basedir/../jake/bin/cli.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\jake\bin\cli.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../jake/bin/cli.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../jake/bin/cli.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../jake/bin/cli.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../jake/bin/cli.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
10 +else
11 + exec node "$basedir/../mime/cli.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../mime/cli.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../mime/cli.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
This diff is collapsed. Click to expand it.
1 +1.3.8 / 2022-02-02
2 +==================
3 +
4 + * deps: mime-types@~2.1.34
5 + - deps: mime-db@~1.51.0
6 + * deps: negotiator@0.6.3
7 +
8 +1.3.7 / 2019-04-29
9 +==================
10 +
11 + * deps: negotiator@0.6.2
12 + - Fix sorting charset, encoding, and language with extra parameters
13 +
14 +1.3.6 / 2019-04-28
15 +==================
16 +
17 + * deps: mime-types@~2.1.24
18 + - deps: mime-db@~1.40.0
19 +
20 +1.3.5 / 2018-02-28
21 +==================
22 +
23 + * deps: mime-types@~2.1.18
24 + - deps: mime-db@~1.33.0
25 +
26 +1.3.4 / 2017-08-22
27 +==================
28 +
29 + * deps: mime-types@~2.1.16
30 + - deps: mime-db@~1.29.0
31 +
32 +1.3.3 / 2016-05-02
33 +==================
34 +
35 + * deps: mime-types@~2.1.11
36 + - deps: mime-db@~1.23.0
37 + * deps: negotiator@0.6.1
38 + - perf: improve `Accept` parsing speed
39 + - perf: improve `Accept-Charset` parsing speed
40 + - perf: improve `Accept-Encoding` parsing speed
41 + - perf: improve `Accept-Language` parsing speed
42 +
43 +1.3.2 / 2016-03-08
44 +==================
45 +
46 + * deps: mime-types@~2.1.10
47 + - Fix extension of `application/dash+xml`
48 + - Update primary extension for `audio/mp4`
49 + - deps: mime-db@~1.22.0
50 +
51 +1.3.1 / 2016-01-19
52 +==================
53 +
54 + * deps: mime-types@~2.1.9
55 + - deps: mime-db@~1.21.0
56 +
57 +1.3.0 / 2015-09-29
58 +==================
59 +
60 + * deps: mime-types@~2.1.7
61 + - deps: mime-db@~1.19.0
62 + * deps: negotiator@0.6.0
63 + - Fix including type extensions in parameters in `Accept` parsing
64 + - Fix parsing `Accept` parameters with quoted equals
65 + - Fix parsing `Accept` parameters with quoted semicolons
66 + - Lazy-load modules from main entry point
67 + - perf: delay type concatenation until needed
68 + - perf: enable strict mode
69 + - perf: hoist regular expressions
70 + - perf: remove closures getting spec properties
71 + - perf: remove a closure from media type parsing
72 + - perf: remove property delete from media type parsing
73 +
74 +1.2.13 / 2015-09-06
75 +===================
76 +
77 + * deps: mime-types@~2.1.6
78 + - deps: mime-db@~1.18.0
79 +
80 +1.2.12 / 2015-07-30
81 +===================
82 +
83 + * deps: mime-types@~2.1.4
84 + - deps: mime-db@~1.16.0
85 +
86 +1.2.11 / 2015-07-16
87 +===================
88 +
89 + * deps: mime-types@~2.1.3
90 + - deps: mime-db@~1.15.0
91 +
92 +1.2.10 / 2015-07-01
93 +===================
94 +
95 + * deps: mime-types@~2.1.2
96 + - deps: mime-db@~1.14.0
97 +
98 +1.2.9 / 2015-06-08
99 +==================
100 +
101 + * deps: mime-types@~2.1.1
102 + - perf: fix deopt during mapping
103 +
104 +1.2.8 / 2015-06-07
105 +==================
106 +
107 + * deps: mime-types@~2.1.0
108 + - deps: mime-db@~1.13.0
109 + * perf: avoid argument reassignment & argument slice
110 + * perf: avoid negotiator recursive construction
111 + * perf: enable strict mode
112 + * perf: remove unnecessary bitwise operator
113 +
114 +1.2.7 / 2015-05-10
115 +==================
116 +
117 + * deps: negotiator@0.5.3
118 + - Fix media type parameter matching to be case-insensitive
119 +
120 +1.2.6 / 2015-05-07
121 +==================
122 +
123 + * deps: mime-types@~2.0.11
124 + - deps: mime-db@~1.9.1
125 + * deps: negotiator@0.5.2
126 + - Fix comparing media types with quoted values
127 + - Fix splitting media types with quoted commas
128 +
129 +1.2.5 / 2015-03-13
130 +==================
131 +
132 + * deps: mime-types@~2.0.10
133 + - deps: mime-db@~1.8.0
134 +
135 +1.2.4 / 2015-02-14
136 +==================
137 +
138 + * Support Node.js 0.6
139 + * deps: mime-types@~2.0.9
140 + - deps: mime-db@~1.7.0
141 + * deps: negotiator@0.5.1
142 + - Fix preference sorting to be stable for long acceptable lists
143 +
144 +1.2.3 / 2015-01-31
145 +==================
146 +
147 + * deps: mime-types@~2.0.8
148 + - deps: mime-db@~1.6.0
149 +
150 +1.2.2 / 2014-12-30
151 +==================
152 +
153 + * deps: mime-types@~2.0.7
154 + - deps: mime-db@~1.5.0
155 +
156 +1.2.1 / 2014-12-30
157 +==================
158 +
159 + * deps: mime-types@~2.0.5
160 + - deps: mime-db@~1.3.1
161 +
162 +1.2.0 / 2014-12-19
163 +==================
164 +
165 + * deps: negotiator@0.5.0
166 + - Fix list return order when large accepted list
167 + - Fix missing identity encoding when q=0 exists
168 + - Remove dynamic building of Negotiator class
169 +
170 +1.1.4 / 2014-12-10
171 +==================
172 +
173 + * deps: mime-types@~2.0.4
174 + - deps: mime-db@~1.3.0
175 +
176 +1.1.3 / 2014-11-09
177 +==================
178 +
179 + * deps: mime-types@~2.0.3
180 + - deps: mime-db@~1.2.0
181 +
182 +1.1.2 / 2014-10-14
183 +==================
184 +
185 + * deps: negotiator@0.4.9
186 + - Fix error when media type has invalid parameter
187 +
188 +1.1.1 / 2014-09-28
189 +==================
190 +
191 + * deps: mime-types@~2.0.2
192 + - deps: mime-db@~1.1.0
193 + * deps: negotiator@0.4.8
194 + - Fix all negotiations to be case-insensitive
195 + - Stable sort preferences of same quality according to client order
196 +
197 +1.1.0 / 2014-09-02
198 +==================
199 +
200 + * update `mime-types`
201 +
202 +1.0.7 / 2014-07-04
203 +==================
204 +
205 + * Fix wrong type returned from `type` when match after unknown extension
206 +
207 +1.0.6 / 2014-06-24
208 +==================
209 +
210 + * deps: negotiator@0.4.7
211 +
212 +1.0.5 / 2014-06-20
213 +==================
214 +
215 + * fix crash when unknown extension given
216 +
217 +1.0.4 / 2014-06-19
218 +==================
219 +
220 + * use `mime-types`
221 +
222 +1.0.3 / 2014-06-11
223 +==================
224 +
225 + * deps: negotiator@0.4.6
226 + - Order by specificity when quality is the same
227 +
228 +1.0.2 / 2014-05-29
229 +==================
230 +
231 + * Fix interpretation when header not in request
232 + * deps: pin negotiator@0.4.5
233 +
234 +1.0.1 / 2014-01-18
235 +==================
236 +
237 + * Identity encoding isn't always acceptable
238 + * deps: negotiator@~0.4.0
239 +
240 +1.0.0 / 2013-12-27
241 +==================
242 +
243 + * Genesis
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# accepts
2 +
3 +[![NPM Version][npm-version-image]][npm-url]
4 +[![NPM Downloads][npm-downloads-image]][npm-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][github-actions-ci-image]][github-actions-ci-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 +Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 +
12 +In addition to negotiator, it allows:
13 +
14 +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 + as well as `('text/html', 'application/json')`.
16 +- Allows type shorthands such as `json`.
17 +- Returns `false` when no types match
18 +- Treats non-existent headers as `*`
19 +
20 +## Installation
21 +
22 +This is a [Node.js](https://nodejs.org/en/) module available through the
23 +[npm registry](https://www.npmjs.com/). Installation is done using the
24 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 +
26 +```sh
27 +$ npm install accepts
28 +```
29 +
30 +## API
31 +
32 +```js
33 +var accepts = require('accepts')
34 +```
35 +
36 +### accepts(req)
37 +
38 +Create a new `Accepts` object for the given `req`.
39 +
40 +#### .charset(charsets)
41 +
42 +Return the first accepted charset. If nothing in `charsets` is accepted,
43 +then `false` is returned.
44 +
45 +#### .charsets()
46 +
47 +Return the charsets that the request accepts, in the order of the client's
48 +preference (most preferred first).
49 +
50 +#### .encoding(encodings)
51 +
52 +Return the first accepted encoding. If nothing in `encodings` is accepted,
53 +then `false` is returned.
54 +
55 +#### .encodings()
56 +
57 +Return the encodings that the request accepts, in the order of the client's
58 +preference (most preferred first).
59 +
60 +#### .language(languages)
61 +
62 +Return the first accepted language. If nothing in `languages` is accepted,
63 +then `false` is returned.
64 +
65 +#### .languages()
66 +
67 +Return the languages that the request accepts, in the order of the client's
68 +preference (most preferred first).
69 +
70 +#### .type(types)
71 +
72 +Return the first accepted type (and it is returned as the same text as what
73 +appears in the `types` array). If nothing in `types` is accepted, then `false`
74 +is returned.
75 +
76 +The `types` array can contain full MIME types or file extensions. Any value
77 +that is not a full MIME types is passed to `require('mime-types').lookup`.
78 +
79 +#### .types()
80 +
81 +Return the types that the request accepts, in the order of the client's
82 +preference (most preferred first).
83 +
84 +## Examples
85 +
86 +### Simple type negotiation
87 +
88 +This simple example shows how to use `accepts` to return a different typed
89 +respond body based on what the client wants to accept. The server lists it's
90 +preferences in order and will get back the best match between the client and
91 +server.
92 +
93 +```js
94 +var accepts = require('accepts')
95 +var http = require('http')
96 +
97 +function app (req, res) {
98 + var accept = accepts(req)
99 +
100 + // the order of this list is significant; should be server preferred order
101 + switch (accept.type(['json', 'html'])) {
102 + case 'json':
103 + res.setHeader('Content-Type', 'application/json')
104 + res.write('{"hello":"world!"}')
105 + break
106 + case 'html':
107 + res.setHeader('Content-Type', 'text/html')
108 + res.write('<b>hello, world!</b>')
109 + break
110 + default:
111 + // the fallback is text/plain, so no need to specify it above
112 + res.setHeader('Content-Type', 'text/plain')
113 + res.write('hello, world!')
114 + break
115 + }
116 +
117 + res.end()
118 +}
119 +
120 +http.createServer(app).listen(3000)
121 +```
122 +
123 +You can test this out with the cURL program:
124 +```sh
125 +curl -I -H'Accept: text/html' http://localhost:3000/
126 +```
127 +
128 +## License
129 +
130 +[MIT](LICENSE)
131 +
132 +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
133 +[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
134 +[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
135 +[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
136 +[node-version-image]: https://badgen.net/npm/node/accepts
137 +[node-version-url]: https://nodejs.org/en/download
138 +[npm-downloads-image]: https://badgen.net/npm/dm/accepts
139 +[npm-url]: https://npmjs.org/package/accepts
140 +[npm-version-image]: https://badgen.net/npm/v/accepts
1 +/*!
2 + * accepts
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var Negotiator = require('negotiator')
16 +var mime = require('mime-types')
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = Accepts
24 +
25 +/**
26 + * Create a new Accepts object for the given req.
27 + *
28 + * @param {object} req
29 + * @public
30 + */
31 +
32 +function Accepts (req) {
33 + if (!(this instanceof Accepts)) {
34 + return new Accepts(req)
35 + }
36 +
37 + this.headers = req.headers
38 + this.negotiator = new Negotiator(req)
39 +}
40 +
41 +/**
42 + * Check if the given `type(s)` is acceptable, returning
43 + * the best match when true, otherwise `undefined`, in which
44 + * case you should respond with 406 "Not Acceptable".
45 + *
46 + * The `type` value may be a single mime type string
47 + * such as "application/json", the extension name
48 + * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 + * or array is given the _best_ match, if any is returned.
50 + *
51 + * Examples:
52 + *
53 + * // Accept: text/html
54 + * this.types('html');
55 + * // => "html"
56 + *
57 + * // Accept: text/*, application/json
58 + * this.types('html');
59 + * // => "html"
60 + * this.types('text/html');
61 + * // => "text/html"
62 + * this.types('json', 'text');
63 + * // => "json"
64 + * this.types('application/json');
65 + * // => "application/json"
66 + *
67 + * // Accept: text/*, application/json
68 + * this.types('image/png');
69 + * this.types('png');
70 + * // => undefined
71 + *
72 + * // Accept: text/*;q=.5, application/json
73 + * this.types(['html', 'json']);
74 + * this.types('html', 'json');
75 + * // => "json"
76 + *
77 + * @param {String|Array} types...
78 + * @return {String|Array|Boolean}
79 + * @public
80 + */
81 +
82 +Accepts.prototype.type =
83 +Accepts.prototype.types = function (types_) {
84 + var types = types_
85 +
86 + // support flattened arguments
87 + if (types && !Array.isArray(types)) {
88 + types = new Array(arguments.length)
89 + for (var i = 0; i < types.length; i++) {
90 + types[i] = arguments[i]
91 + }
92 + }
93 +
94 + // no types, return all requested types
95 + if (!types || types.length === 0) {
96 + return this.negotiator.mediaTypes()
97 + }
98 +
99 + // no accept header, return first given type
100 + if (!this.headers.accept) {
101 + return types[0]
102 + }
103 +
104 + var mimes = types.map(extToMime)
105 + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 + var first = accepts[0]
107 +
108 + return first
109 + ? types[mimes.indexOf(first)]
110 + : false
111 +}
112 +
113 +/**
114 + * Return accepted encodings or best fit based on `encodings`.
115 + *
116 + * Given `Accept-Encoding: gzip, deflate`
117 + * an array sorted by quality is returned:
118 + *
119 + * ['gzip', 'deflate']
120 + *
121 + * @param {String|Array} encodings...
122 + * @return {String|Array}
123 + * @public
124 + */
125 +
126 +Accepts.prototype.encoding =
127 +Accepts.prototype.encodings = function (encodings_) {
128 + var encodings = encodings_
129 +
130 + // support flattened arguments
131 + if (encodings && !Array.isArray(encodings)) {
132 + encodings = new Array(arguments.length)
133 + for (var i = 0; i < encodings.length; i++) {
134 + encodings[i] = arguments[i]
135 + }
136 + }
137 +
138 + // no encodings, return all requested encodings
139 + if (!encodings || encodings.length === 0) {
140 + return this.negotiator.encodings()
141 + }
142 +
143 + return this.negotiator.encodings(encodings)[0] || false
144 +}
145 +
146 +/**
147 + * Return accepted charsets or best fit based on `charsets`.
148 + *
149 + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 + * an array sorted by quality is returned:
151 + *
152 + * ['utf-8', 'utf-7', 'iso-8859-1']
153 + *
154 + * @param {String|Array} charsets...
155 + * @return {String|Array}
156 + * @public
157 + */
158 +
159 +Accepts.prototype.charset =
160 +Accepts.prototype.charsets = function (charsets_) {
161 + var charsets = charsets_
162 +
163 + // support flattened arguments
164 + if (charsets && !Array.isArray(charsets)) {
165 + charsets = new Array(arguments.length)
166 + for (var i = 0; i < charsets.length; i++) {
167 + charsets[i] = arguments[i]
168 + }
169 + }
170 +
171 + // no charsets, return all requested charsets
172 + if (!charsets || charsets.length === 0) {
173 + return this.negotiator.charsets()
174 + }
175 +
176 + return this.negotiator.charsets(charsets)[0] || false
177 +}
178 +
179 +/**
180 + * Return accepted languages or best fit based on `langs`.
181 + *
182 + * Given `Accept-Language: en;q=0.8, es, pt`
183 + * an array sorted by quality is returned:
184 + *
185 + * ['es', 'pt', 'en']
186 + *
187 + * @param {String|Array} langs...
188 + * @return {Array|String}
189 + * @public
190 + */
191 +
192 +Accepts.prototype.lang =
193 +Accepts.prototype.langs =
194 +Accepts.prototype.language =
195 +Accepts.prototype.languages = function (languages_) {
196 + var languages = languages_
197 +
198 + // support flattened arguments
199 + if (languages && !Array.isArray(languages)) {
200 + languages = new Array(arguments.length)
201 + for (var i = 0; i < languages.length; i++) {
202 + languages[i] = arguments[i]
203 + }
204 + }
205 +
206 + // no languages, return all requested languages
207 + if (!languages || languages.length === 0) {
208 + return this.negotiator.languages()
209 + }
210 +
211 + return this.negotiator.languages(languages)[0] || false
212 +}
213 +
214 +/**
215 + * Convert extnames to mime.
216 + *
217 + * @param {String} type
218 + * @return {String}
219 + * @private
220 + */
221 +
222 +function extToMime (type) {
223 + return type.indexOf('/') === -1
224 + ? mime.lookup(type)
225 + : type
226 +}
227 +
228 +/**
229 + * Check if mime is valid.
230 + *
231 + * @param {String} type
232 + * @return {String}
233 + * @private
234 + */
235 +
236 +function validMime (type) {
237 + return typeof type === 'string'
238 +}
1 +{
2 + "name": "accepts",
3 + "description": "Higher-level content negotiation",
4 + "version": "1.3.8",
5 + "contributors": [
6 + "Douglas Christopher Wilson <doug@somethingdoug.com>",
7 + "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
8 + ],
9 + "license": "MIT",
10 + "repository": "jshttp/accepts",
11 + "dependencies": {
12 + "mime-types": "~2.1.34",
13 + "negotiator": "0.6.3"
14 + },
15 + "devDependencies": {
16 + "deep-equal": "1.0.1",
17 + "eslint": "7.32.0",
18 + "eslint-config-standard": "14.1.1",
19 + "eslint-plugin-import": "2.25.4",
20 + "eslint-plugin-markdown": "2.2.1",
21 + "eslint-plugin-node": "11.1.0",
22 + "eslint-plugin-promise": "4.3.1",
23 + "eslint-plugin-standard": "4.1.0",
24 + "mocha": "9.2.0",
25 + "nyc": "15.1.0"
26 + },
27 + "files": [
28 + "LICENSE",
29 + "HISTORY.md",
30 + "index.js"
31 + ],
32 + "engines": {
33 + "node": ">= 0.6"
34 + },
35 + "scripts": {
36 + "lint": "eslint .",
37 + "test": "mocha --reporter spec --check-leaks --bail test/",
38 + "test-ci": "nyc --reporter=lcov --reporter=text npm test",
39 + "test-cov": "nyc --reporter=html --reporter=text npm test"
40 + },
41 + "keywords": [
42 + "content",
43 + "negotiation",
44 + "accept",
45 + "accepts"
46 + ]
47 +}
1 +declare type CSSColor =
2 + | 'aliceblue'
3 + | 'antiquewhite'
4 + | 'aqua'
5 + | 'aquamarine'
6 + | 'azure'
7 + | 'beige'
8 + | 'bisque'
9 + | 'black'
10 + | 'blanchedalmond'
11 + | 'blue'
12 + | 'blueviolet'
13 + | 'brown'
14 + | 'burlywood'
15 + | 'cadetblue'
16 + | 'chartreuse'
17 + | 'chocolate'
18 + | 'coral'
19 + | 'cornflowerblue'
20 + | 'cornsilk'
21 + | 'crimson'
22 + | 'cyan'
23 + | 'darkblue'
24 + | 'darkcyan'
25 + | 'darkgoldenrod'
26 + | 'darkgray'
27 + | 'darkgreen'
28 + | 'darkgrey'
29 + | 'darkkhaki'
30 + | 'darkmagenta'
31 + | 'darkolivegreen'
32 + | 'darkorange'
33 + | 'darkorchid'
34 + | 'darkred'
35 + | 'darksalmon'
36 + | 'darkseagreen'
37 + | 'darkslateblue'
38 + | 'darkslategray'
39 + | 'darkslategrey'
40 + | 'darkturquoise'
41 + | 'darkviolet'
42 + | 'deeppink'
43 + | 'deepskyblue'
44 + | 'dimgray'
45 + | 'dimgrey'
46 + | 'dodgerblue'
47 + | 'firebrick'
48 + | 'floralwhite'
49 + | 'forestgreen'
50 + | 'fuchsia'
51 + | 'gainsboro'
52 + | 'ghostwhite'
53 + | 'gold'
54 + | 'goldenrod'
55 + | 'gray'
56 + | 'green'
57 + | 'greenyellow'
58 + | 'grey'
59 + | 'honeydew'
60 + | 'hotpink'
61 + | 'indianred'
62 + | 'indigo'
63 + | 'ivory'
64 + | 'khaki'
65 + | 'lavender'
66 + | 'lavenderblush'
67 + | 'lawngreen'
68 + | 'lemonchiffon'
69 + | 'lightblue'
70 + | 'lightcoral'
71 + | 'lightcyan'
72 + | 'lightgoldenrodyellow'
73 + | 'lightgray'
74 + | 'lightgreen'
75 + | 'lightgrey'
76 + | 'lightpink'
77 + | 'lightsalmon'
78 + | 'lightseagreen'
79 + | 'lightskyblue'
80 + | 'lightslategray'
81 + | 'lightslategrey'
82 + | 'lightsteelblue'
83 + | 'lightyellow'
84 + | 'lime'
85 + | 'limegreen'
86 + | 'linen'
87 + | 'magenta'
88 + | 'maroon'
89 + | 'mediumaquamarine'
90 + | 'mediumblue'
91 + | 'mediumorchid'
92 + | 'mediumpurple'
93 + | 'mediumseagreen'
94 + | 'mediumslateblue'
95 + | 'mediumspringgreen'
96 + | 'mediumturquoise'
97 + | 'mediumvioletred'
98 + | 'midnightblue'
99 + | 'mintcream'
100 + | 'mistyrose'
101 + | 'moccasin'
102 + | 'navajowhite'
103 + | 'navy'
104 + | 'oldlace'
105 + | 'olive'
106 + | 'olivedrab'
107 + | 'orange'
108 + | 'orangered'
109 + | 'orchid'
110 + | 'palegoldenrod'
111 + | 'palegreen'
112 + | 'paleturquoise'
113 + | 'palevioletred'
114 + | 'papayawhip'
115 + | 'peachpuff'
116 + | 'peru'
117 + | 'pink'
118 + | 'plum'
119 + | 'powderblue'
120 + | 'purple'
121 + | 'rebeccapurple'
122 + | 'red'
123 + | 'rosybrown'
124 + | 'royalblue'
125 + | 'saddlebrown'
126 + | 'salmon'
127 + | 'sandybrown'
128 + | 'seagreen'
129 + | 'seashell'
130 + | 'sienna'
131 + | 'silver'
132 + | 'skyblue'
133 + | 'slateblue'
134 + | 'slategray'
135 + | 'slategrey'
136 + | 'snow'
137 + | 'springgreen'
138 + | 'steelblue'
139 + | 'tan'
140 + | 'teal'
141 + | 'thistle'
142 + | 'tomato'
143 + | 'turquoise'
144 + | 'violet'
145 + | 'wheat'
146 + | 'white'
147 + | 'whitesmoke'
148 + | 'yellow'
149 + | 'yellowgreen';
150 +
151 +declare namespace ansiStyles {
152 + interface ColorConvert {
153 + /**
154 + The RGB color space.
155 +
156 + @param red - (`0`-`255`)
157 + @param green - (`0`-`255`)
158 + @param blue - (`0`-`255`)
159 + */
160 + rgb(red: number, green: number, blue: number): string;
161 +
162 + /**
163 + The RGB HEX color space.
164 +
165 + @param hex - A hexadecimal string containing RGB data.
166 + */
167 + hex(hex: string): string;
168 +
169 + /**
170 + @param keyword - A CSS color name.
171 + */
172 + keyword(keyword: CSSColor): string;
173 +
174 + /**
175 + The HSL color space.
176 +
177 + @param hue - (`0`-`360`)
178 + @param saturation - (`0`-`100`)
179 + @param lightness - (`0`-`100`)
180 + */
181 + hsl(hue: number, saturation: number, lightness: number): string;
182 +
183 + /**
184 + The HSV color space.
185 +
186 + @param hue - (`0`-`360`)
187 + @param saturation - (`0`-`100`)
188 + @param value - (`0`-`100`)
189 + */
190 + hsv(hue: number, saturation: number, value: number): string;
191 +
192 + /**
193 + The HSV color space.
194 +
195 + @param hue - (`0`-`360`)
196 + @param whiteness - (`0`-`100`)
197 + @param blackness - (`0`-`100`)
198 + */
199 + hwb(hue: number, whiteness: number, blackness: number): string;
200 +
201 + /**
202 + Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
203 + */
204 + ansi(ansi: number): string;
205 +
206 + /**
207 + Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
208 + */
209 + ansi256(ansi: number): string;
210 + }
211 +
212 + interface CSPair {
213 + /**
214 + The ANSI terminal control sequence for starting this style.
215 + */
216 + readonly open: string;
217 +
218 + /**
219 + The ANSI terminal control sequence for ending this style.
220 + */
221 + readonly close: string;
222 + }
223 +
224 + interface ColorBase {
225 + readonly ansi: ColorConvert;
226 + readonly ansi256: ColorConvert;
227 + readonly ansi16m: ColorConvert;
228 +
229 + /**
230 + The ANSI terminal control sequence for ending this color.
231 + */
232 + readonly close: string;
233 + }
234 +
235 + interface Modifier {
236 + /**
237 + Resets the current color chain.
238 + */
239 + readonly reset: CSPair;
240 +
241 + /**
242 + Make text bold.
243 + */
244 + readonly bold: CSPair;
245 +
246 + /**
247 + Emitting only a small amount of light.
248 + */
249 + readonly dim: CSPair;
250 +
251 + /**
252 + Make text italic. (Not widely supported)
253 + */
254 + readonly italic: CSPair;
255 +
256 + /**
257 + Make text underline. (Not widely supported)
258 + */
259 + readonly underline: CSPair;
260 +
261 + /**
262 + Inverse background and foreground colors.
263 + */
264 + readonly inverse: CSPair;
265 +
266 + /**
267 + Prints the text, but makes it invisible.
268 + */
269 + readonly hidden: CSPair;
270 +
271 + /**
272 + Puts a horizontal line through the center of the text. (Not widely supported)
273 + */
274 + readonly strikethrough: CSPair;
275 + }
276 +
277 + interface ForegroundColor {
278 + readonly black: CSPair;
279 + readonly red: CSPair;
280 + readonly green: CSPair;
281 + readonly yellow: CSPair;
282 + readonly blue: CSPair;
283 + readonly cyan: CSPair;
284 + readonly magenta: CSPair;
285 + readonly white: CSPair;
286 +
287 + /**
288 + Alias for `blackBright`.
289 + */
290 + readonly gray: CSPair;
291 +
292 + /**
293 + Alias for `blackBright`.
294 + */
295 + readonly grey: CSPair;
296 +
297 + readonly blackBright: CSPair;
298 + readonly redBright: CSPair;
299 + readonly greenBright: CSPair;
300 + readonly yellowBright: CSPair;
301 + readonly blueBright: CSPair;
302 + readonly cyanBright: CSPair;
303 + readonly magentaBright: CSPair;
304 + readonly whiteBright: CSPair;
305 + }
306 +
307 + interface BackgroundColor {
308 + readonly bgBlack: CSPair;
309 + readonly bgRed: CSPair;
310 + readonly bgGreen: CSPair;
311 + readonly bgYellow: CSPair;
312 + readonly bgBlue: CSPair;
313 + readonly bgCyan: CSPair;
314 + readonly bgMagenta: CSPair;
315 + readonly bgWhite: CSPair;
316 +
317 + /**
318 + Alias for `bgBlackBright`.
319 + */
320 + readonly bgGray: CSPair;
321 +
322 + /**
323 + Alias for `bgBlackBright`.
324 + */
325 + readonly bgGrey: CSPair;
326 +
327 + readonly bgBlackBright: CSPair;
328 + readonly bgRedBright: CSPair;
329 + readonly bgGreenBright: CSPair;
330 + readonly bgYellowBright: CSPair;
331 + readonly bgBlueBright: CSPair;
332 + readonly bgCyanBright: CSPair;
333 + readonly bgMagentaBright: CSPair;
334 + readonly bgWhiteBright: CSPair;
335 + }
336 +}
337 +
338 +declare const ansiStyles: {
339 + readonly modifier: ansiStyles.Modifier;
340 + readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
341 + readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
342 + readonly codes: ReadonlyMap<number, number>;
343 +} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
344 +
345 +export = ansiStyles;
1 +'use strict';
2 +
3 +const wrapAnsi16 = (fn, offset) => (...args) => {
4 + const code = fn(...args);
5 + return `\u001B[${code + offset}m`;
6 +};
7 +
8 +const wrapAnsi256 = (fn, offset) => (...args) => {
9 + const code = fn(...args);
10 + return `\u001B[${38 + offset};5;${code}m`;
11 +};
12 +
13 +const wrapAnsi16m = (fn, offset) => (...args) => {
14 + const rgb = fn(...args);
15 + return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
16 +};
17 +
18 +const ansi2ansi = n => n;
19 +const rgb2rgb = (r, g, b) => [r, g, b];
20 +
21 +const setLazyProperty = (object, property, get) => {
22 + Object.defineProperty(object, property, {
23 + get: () => {
24 + const value = get();
25 +
26 + Object.defineProperty(object, property, {
27 + value,
28 + enumerable: true,
29 + configurable: true
30 + });
31 +
32 + return value;
33 + },
34 + enumerable: true,
35 + configurable: true
36 + });
37 +};
38 +
39 +/** @type {typeof import('color-convert')} */
40 +let colorConvert;
41 +const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
42 + if (colorConvert === undefined) {
43 + colorConvert = require('color-convert');
44 + }
45 +
46 + const offset = isBackground ? 10 : 0;
47 + const styles = {};
48 +
49 + for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
50 + const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
51 + if (sourceSpace === targetSpace) {
52 + styles[name] = wrap(identity, offset);
53 + } else if (typeof suite === 'object') {
54 + styles[name] = wrap(suite[targetSpace], offset);
55 + }
56 + }
57 +
58 + return styles;
59 +};
60 +
61 +function assembleStyles() {
62 + const codes = new Map();
63 + const styles = {
64 + modifier: {
65 + reset: [0, 0],
66 + // 21 isn't widely supported and 22 does the same thing
67 + bold: [1, 22],
68 + dim: [2, 22],
69 + italic: [3, 23],
70 + underline: [4, 24],
71 + inverse: [7, 27],
72 + hidden: [8, 28],
73 + strikethrough: [9, 29]
74 + },
75 + color: {
76 + black: [30, 39],
77 + red: [31, 39],
78 + green: [32, 39],
79 + yellow: [33, 39],
80 + blue: [34, 39],
81 + magenta: [35, 39],
82 + cyan: [36, 39],
83 + white: [37, 39],
84 +
85 + // Bright color
86 + blackBright: [90, 39],
87 + redBright: [91, 39],
88 + greenBright: [92, 39],
89 + yellowBright: [93, 39],
90 + blueBright: [94, 39],
91 + magentaBright: [95, 39],
92 + cyanBright: [96, 39],
93 + whiteBright: [97, 39]
94 + },
95 + bgColor: {
96 + bgBlack: [40, 49],
97 + bgRed: [41, 49],
98 + bgGreen: [42, 49],
99 + bgYellow: [43, 49],
100 + bgBlue: [44, 49],
101 + bgMagenta: [45, 49],
102 + bgCyan: [46, 49],
103 + bgWhite: [47, 49],
104 +
105 + // Bright color
106 + bgBlackBright: [100, 49],
107 + bgRedBright: [101, 49],
108 + bgGreenBright: [102, 49],
109 + bgYellowBright: [103, 49],
110 + bgBlueBright: [104, 49],
111 + bgMagentaBright: [105, 49],
112 + bgCyanBright: [106, 49],
113 + bgWhiteBright: [107, 49]
114 + }
115 + };
116 +
117 + // Alias bright black as gray (and grey)
118 + styles.color.gray = styles.color.blackBright;
119 + styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
120 + styles.color.grey = styles.color.blackBright;
121 + styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
122 +
123 + for (const [groupName, group] of Object.entries(styles)) {
124 + for (const [styleName, style] of Object.entries(group)) {
125 + styles[styleName] = {
126 + open: `\u001B[${style[0]}m`,
127 + close: `\u001B[${style[1]}m`
128 + };
129 +
130 + group[styleName] = styles[styleName];
131 +
132 + codes.set(style[0], style[1]);
133 + }
134 +
135 + Object.defineProperty(styles, groupName, {
136 + value: group,
137 + enumerable: false
138 + });
139 + }
140 +
141 + Object.defineProperty(styles, 'codes', {
142 + value: codes,
143 + enumerable: false
144 + });
145 +
146 + styles.color.close = '\u001B[39m';
147 + styles.bgColor.close = '\u001B[49m';
148 +
149 + setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
150 + setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
151 + setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
152 + setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
153 + setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
154 + setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
155 +
156 + return styles;
157 +}
158 +
159 +// Make the export immutable
160 +Object.defineProperty(module, 'exports', {
161 + enumerable: true,
162 + get: assembleStyles
163 +});
1 +MIT License
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 +
7 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 +
9 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +{
2 + "name": "ansi-styles",
3 + "version": "4.3.0",
4 + "description": "ANSI escape codes for styling strings in the terminal",
5 + "license": "MIT",
6 + "repository": "chalk/ansi-styles",
7 + "funding": "https://github.com/chalk/ansi-styles?sponsor=1",
8 + "author": {
9 + "name": "Sindre Sorhus",
10 + "email": "sindresorhus@gmail.com",
11 + "url": "sindresorhus.com"
12 + },
13 + "engines": {
14 + "node": ">=8"
15 + },
16 + "scripts": {
17 + "test": "xo && ava && tsd",
18 + "screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
19 + },
20 + "files": [
21 + "index.js",
22 + "index.d.ts"
23 + ],
24 + "keywords": [
25 + "ansi",
26 + "styles",
27 + "color",
28 + "colour",
29 + "colors",
30 + "terminal",
31 + "console",
32 + "cli",
33 + "string",
34 + "tty",
35 + "escape",
36 + "formatting",
37 + "rgb",
38 + "256",
39 + "shell",
40 + "xterm",
41 + "log",
42 + "logging",
43 + "command-line",
44 + "text"
45 + ],
46 + "dependencies": {
47 + "color-convert": "^2.0.1"
48 + },
49 + "devDependencies": {
50 + "@types/color-convert": "^1.9.0",
51 + "ava": "^2.3.0",
52 + "svg-term-cli": "^2.1.1",
53 + "tsd": "^0.11.0",
54 + "xo": "^0.25.3"
55 + }
56 +}
1 +# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
2 +
3 +> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
4 +
5 +You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
6 +
7 +<img src="screenshot.svg" width="900">
8 +
9 +## Install
10 +
11 +```
12 +$ npm install ansi-styles
13 +```
14 +
15 +## Usage
16 +
17 +```js
18 +const style = require('ansi-styles');
19 +
20 +console.log(`${style.green.open}Hello world!${style.green.close}`);
21 +
22 +
23 +// Color conversion between 16/256/truecolor
24 +// NOTE: If conversion goes to 16 colors or 256 colors, the original color
25 +// may be degraded to fit that color palette. This means terminals
26 +// that do not support 16 million colors will best-match the
27 +// original color.
28 +console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
29 +console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
30 +console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
31 +```
32 +
33 +## API
34 +
35 +Each style has an `open` and `close` property.
36 +
37 +## Styles
38 +
39 +### Modifiers
40 +
41 +- `reset`
42 +- `bold`
43 +- `dim`
44 +- `italic` *(Not widely supported)*
45 +- `underline`
46 +- `inverse`
47 +- `hidden`
48 +- `strikethrough` *(Not widely supported)*
49 +
50 +### Colors
51 +
52 +- `black`
53 +- `red`
54 +- `green`
55 +- `yellow`
56 +- `blue`
57 +- `magenta`
58 +- `cyan`
59 +- `white`
60 +- `blackBright` (alias: `gray`, `grey`)
61 +- `redBright`
62 +- `greenBright`
63 +- `yellowBright`
64 +- `blueBright`
65 +- `magentaBright`
66 +- `cyanBright`
67 +- `whiteBright`
68 +
69 +### Background colors
70 +
71 +- `bgBlack`
72 +- `bgRed`
73 +- `bgGreen`
74 +- `bgYellow`
75 +- `bgBlue`
76 +- `bgMagenta`
77 +- `bgCyan`
78 +- `bgWhite`
79 +- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
80 +- `bgRedBright`
81 +- `bgGreenBright`
82 +- `bgYellowBright`
83 +- `bgBlueBright`
84 +- `bgMagentaBright`
85 +- `bgCyanBright`
86 +- `bgWhiteBright`
87 +
88 +## Advanced usage
89 +
90 +By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
91 +
92 +- `style.modifier`
93 +- `style.color`
94 +- `style.bgColor`
95 +
96 +###### Example
97 +
98 +```js
99 +console.log(style.color.green.open);
100 +```
101 +
102 +Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
103 +
104 +###### Example
105 +
106 +```js
107 +console.log(style.codes.get(36));
108 +//=> 39
109 +```
110 +
111 +## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
112 +
113 +`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
114 +
115 +The following color spaces from `color-convert` are supported:
116 +
117 +- `rgb`
118 +- `hex`
119 +- `keyword`
120 +- `hsl`
121 +- `hsv`
122 +- `hwb`
123 +- `ansi`
124 +- `ansi256`
125 +
126 +To use these, call the associated conversion function with the intended output, for example:
127 +
128 +```js
129 +style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
130 +style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
131 +
132 +style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
133 +style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
134 +
135 +style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
136 +style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
137 +```
138 +
139 +## Related
140 +
141 +- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
142 +
143 +## Maintainers
144 +
145 +- [Sindre Sorhus](https://github.com/sindresorhus)
146 +- [Josh Junon](https://github.com/qix-)
147 +
148 +## For enterprise
149 +
150 +Available as part of the Tidelift Subscription.
151 +
152 +The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# Array Flatten
2 +
3 +[![NPM version][npm-image]][npm-url]
4 +[![NPM downloads][downloads-image]][downloads-url]
5 +[![Build status][travis-image]][travis-url]
6 +[![Test coverage][coveralls-image]][coveralls-url]
7 +
8 +> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
9 +
10 +## Installation
11 +
12 +```
13 +npm install array-flatten --save
14 +```
15 +
16 +## Usage
17 +
18 +```javascript
19 +var flatten = require('array-flatten')
20 +
21 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
22 +//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
23 +
24 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
25 +//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
26 +
27 +(function () {
28 + flatten(arguments) //=> [1, 2, 3]
29 +})(1, [2, 3])
30 +```
31 +
32 +## License
33 +
34 +MIT
35 +
36 +[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
37 +[npm-url]: https://npmjs.org/package/array-flatten
38 +[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
39 +[downloads-url]: https://npmjs.org/package/array-flatten
40 +[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
41 +[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
42 +[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
43 +[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
1 +'use strict'
2 +
3 +/**
4 + * Expose `arrayFlatten`.
5 + */
6 +module.exports = arrayFlatten
7 +
8 +/**
9 + * Recursive flatten function with depth.
10 + *
11 + * @param {Array} array
12 + * @param {Array} result
13 + * @param {Number} depth
14 + * @return {Array}
15 + */
16 +function flattenWithDepth (array, result, depth) {
17 + for (var i = 0; i < array.length; i++) {
18 + var value = array[i]
19 +
20 + if (depth > 0 && Array.isArray(value)) {
21 + flattenWithDepth(value, result, depth - 1)
22 + } else {
23 + result.push(value)
24 + }
25 + }
26 +
27 + return result
28 +}
29 +
30 +/**
31 + * Recursive flatten function. Omitting depth is slightly faster.
32 + *
33 + * @param {Array} array
34 + * @param {Array} result
35 + * @return {Array}
36 + */
37 +function flattenForever (array, result) {
38 + for (var i = 0; i < array.length; i++) {
39 + var value = array[i]
40 +
41 + if (Array.isArray(value)) {
42 + flattenForever(value, result)
43 + } else {
44 + result.push(value)
45 + }
46 + }
47 +
48 + return result
49 +}
50 +
51 +/**
52 + * Flatten an array, with the ability to define a depth.
53 + *
54 + * @param {Array} array
55 + * @param {Number} depth
56 + * @return {Array}
57 + */
58 +function arrayFlatten (array, depth) {
59 + if (depth == null) {
60 + return flattenForever(array, [])
61 + }
62 +
63 + return flattenWithDepth(array, [], depth)
64 +}
1 +{
2 + "name": "array-flatten",
3 + "version": "1.1.1",
4 + "description": "Flatten an array of nested arrays into a single flat array",
5 + "main": "array-flatten.js",
6 + "files": [
7 + "array-flatten.js",
8 + "LICENSE"
9 + ],
10 + "scripts": {
11 + "test": "istanbul cover _mocha -- -R spec"
12 + },
13 + "repository": {
14 + "type": "git",
15 + "url": "git://github.com/blakeembrey/array-flatten.git"
16 + },
17 + "keywords": [
18 + "array",
19 + "flatten",
20 + "arguments",
21 + "depth"
22 + ],
23 + "author": {
24 + "name": "Blake Embrey",
25 + "email": "hello@blakeembrey.com",
26 + "url": "http://blakeembrey.me"
27 + },
28 + "license": "MIT",
29 + "bugs": {
30 + "url": "https://github.com/blakeembrey/array-flatten/issues"
31 + },
32 + "homepage": "https://github.com/blakeembrey/array-flatten",
33 + "devDependencies": {
34 + "istanbul": "^0.3.13",
35 + "mocha": "^2.2.4",
36 + "pre-commit": "^1.0.7",
37 + "standard": "^3.7.3"
38 + }
39 +}
This diff is collapsed. Click to expand it.
1 +Copyright (c) 2010-2018 Caolan McMahon
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to deal
5 +in the Software without restriction, including without limitation the rights
6 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 +copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 +THE SOFTWARE.
1 +![Async Logo](https://raw.githubusercontent.com/caolan/async/master/logo/async-logo_readme.jpg)
2 +
3 +[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async)
4 +[![Build Status via Azure Pipelines](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master)
5 +[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async)
6 +[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)
7 +[![Join the chat at https://gitter.im/caolan/async](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8 +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/async/badge?style=rounded)](https://www.jsdelivr.com/package/npm/async)
9 +
10 +<!--
11 +|Linux|Windows|MacOS|
12 +|-|-|-|
13 +|[![Linux Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=Linux&configuration=Linux%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [![Windows Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=Windows&configuration=Windows%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [![MacOS Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=OSX&configuration=OSX%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master)| -->
14 +
15 +Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/v3/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm i async`, it can also be used directly in the browser. A ESM/MJS version is included in the main `async` package that should automatically be used with compatible bundlers such as Webpack and Rollup.
16 +
17 +A pure ESM version of Async is available as [`async-es`](https://www.npmjs.com/package/async-es).
18 +
19 +For Documentation, visit <https://caolan.github.io/async/>
20 +
21 +*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
22 +
23 +
24 +```javascript
25 +// for use with Node-style callbacks...
26 +var async = require("async");
27 +
28 +var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
29 +var configs = {};
30 +
31 +async.forEachOf(obj, (value, key, callback) => {
32 + fs.readFile(__dirname + value, "utf8", (err, data) => {
33 + if (err) return callback(err);
34 + try {
35 + configs[key] = JSON.parse(data);
36 + } catch (e) {
37 + return callback(e);
38 + }
39 + callback();
40 + });
41 +}, err => {
42 + if (err) console.error(err.message);
43 + // configs is now a map of JSON data
44 + doSomethingWith(configs);
45 +});
46 +```
47 +
48 +```javascript
49 +var async = require("async");
50 +
51 +// ...or ES2017 async functions
52 +async.mapLimit(urls, 5, async function(url) {
53 + const response = await fetch(url)
54 + return response.body
55 +}, (err, results) => {
56 + if (err) throw err
57 + // results is now an array of the response bodies
58 + console.log(results)
59 +})
60 +```
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf.js');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns `true` if every element in `coll` satisfies an async test. If any
23 + * iteratee call returns `false`, the main `callback` is immediately called.
24 + *
25 + * @name every
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @alias all
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in parallel.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + * @example
41 + *
42 + * // dir1 is a directory that contains file1.txt, file2.txt
43 + * // dir2 is a directory that contains file3.txt, file4.txt
44 + * // dir3 is a directory that contains file5.txt
45 + * // dir4 does not exist
46 + *
47 + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt'];
48 + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
49 + *
50 + * // asynchronous function that checks if a file exists
51 + * function fileExists(file, callback) {
52 + * fs.access(file, fs.constants.F_OK, (err) => {
53 + * callback(null, !err);
54 + * });
55 + * }
56 + *
57 + * // Using callbacks
58 + * async.every(fileList, fileExists, function(err, result) {
59 + * console.log(result);
60 + * // true
61 + * // result is true since every file exists
62 + * });
63 + *
64 + * async.every(withMissingFileList, fileExists, function(err, result) {
65 + * console.log(result);
66 + * // false
67 + * // result is false since NOT every file exists
68 + * });
69 + *
70 + * // Using Promises
71 + * async.every(fileList, fileExists)
72 + * .then( result => {
73 + * console.log(result);
74 + * // true
75 + * // result is true since every file exists
76 + * }).catch( err => {
77 + * console.log(err);
78 + * });
79 + *
80 + * async.every(withMissingFileList, fileExists)
81 + * .then( result => {
82 + * console.log(result);
83 + * // false
84 + * // result is false since NOT every file exists
85 + * }).catch( err => {
86 + * console.log(err);
87 + * });
88 + *
89 + * // Using async/await
90 + * async () => {
91 + * try {
92 + * let result = await async.every(fileList, fileExists);
93 + * console.log(result);
94 + * // true
95 + * // result is true since every file exists
96 + * }
97 + * catch (err) {
98 + * console.log(err);
99 + * }
100 + * }
101 + *
102 + * async () => {
103 + * try {
104 + * let result = await async.every(withMissingFileList, fileExists);
105 + * console.log(result);
106 + * // false
107 + * // result is false since NOT every file exists
108 + * }
109 + * catch (err) {
110 + * console.log(err);
111 + * }
112 + * }
113 + *
114 + */
115 +function every(coll, iteratee, callback) {
116 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOf2.default, coll, iteratee, callback);
117 +}
118 +exports.default = (0, _awaitify2.default)(every, 3);
119 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit.js');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name everyLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allLimit
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collection in parallel.
35 + * The iteratee must complete with a boolean result value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called after all the
38 + * `iteratee` functions have finished. Result will be either `true` or `false`
39 + * depending on the values of the async tests. Invoked with (err, result).
40 + * @returns {Promise} a promise, if no callback provided
41 + */
42 +function everyLimit(coll, limit, iteratee, callback) {
43 + return (0, _createTester2.default)(bool => !bool, res => !res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
44 +}
45 +exports.default = (0, _awaitify2.default)(everyLimit, 4);
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfSeries = require('./eachOfSeries.js');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
23 + *
24 + * @name everySeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allSeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in series.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + */
41 +function everySeries(coll, iteratee, callback) {
42 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOfSeries2.default, coll, iteratee, callback);
43 +}
44 +exports.default = (0, _awaitify2.default)(everySeries, 3);
45 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf.js');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns `true` if at least one element in the `coll` satisfies an async test.
23 + * If any iteratee call returns `true`, the main `callback` is immediately
24 + * called.
25 + *
26 + * @name some
27 + * @static
28 + * @memberOf module:Collections
29 + * @method
30 + * @alias any
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collections in parallel.
35 + * The iteratee should complete with a boolean `result` value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the iteratee functions have finished.
39 + * Result will be either `true` or `false` depending on the values of the async
40 + * tests. Invoked with (err, result).
41 + * @returns {Promise} a promise, if no callback provided
42 + * @example
43 + *
44 + * // dir1 is a directory that contains file1.txt, file2.txt
45 + * // dir2 is a directory that contains file3.txt, file4.txt
46 + * // dir3 is a directory that contains file5.txt
47 + * // dir4 does not exist
48 + *
49 + * // asynchronous function that checks if a file exists
50 + * function fileExists(file, callback) {
51 + * fs.access(file, fs.constants.F_OK, (err) => {
52 + * callback(null, !err);
53 + * });
54 + * }
55 + *
56 + * // Using callbacks
57 + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists,
58 + * function(err, result) {
59 + * console.log(result);
60 + * // true
61 + * // result is true since some file in the list exists
62 + * }
63 + *);
64 + *
65 + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists,
66 + * function(err, result) {
67 + * console.log(result);
68 + * // false
69 + * // result is false since none of the files exists
70 + * }
71 + *);
72 + *
73 + * // Using Promises
74 + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists)
75 + * .then( result => {
76 + * console.log(result);
77 + * // true
78 + * // result is true since some file in the list exists
79 + * }).catch( err => {
80 + * console.log(err);
81 + * });
82 + *
83 + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists)
84 + * .then( result => {
85 + * console.log(result);
86 + * // false
87 + * // result is false since none of the files exists
88 + * }).catch( err => {
89 + * console.log(err);
90 + * });
91 + *
92 + * // Using async/await
93 + * async () => {
94 + * try {
95 + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists);
96 + * console.log(result);
97 + * // true
98 + * // result is true since some file in the list exists
99 + * }
100 + * catch (err) {
101 + * console.log(err);
102 + * }
103 + * }
104 + *
105 + * async () => {
106 + * try {
107 + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists);
108 + * console.log(result);
109 + * // false
110 + * // result is false since none of the files exists
111 + * }
112 + * catch (err) {
113 + * console.log(err);
114 + * }
115 + * }
116 + *
117 + */
118 +function some(coll, iteratee, callback) {
119 + return (0, _createTester2.default)(Boolean, res => res)(_eachOf2.default, coll, iteratee, callback);
120 +}
121 +exports.default = (0, _awaitify2.default)(some, 3);
122 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit.js');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name someLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.some]{@link module:Collections.some}
29 + * @alias anyLimit
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collections in parallel.
35 + * The iteratee should complete with a boolean `result` value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the iteratee functions have finished.
39 + * Result will be either `true` or `false` depending on the values of the async
40 + * tests. Invoked with (err, result).
41 + * @returns {Promise} a promise, if no callback provided
42 + */
43 +function someLimit(coll, limit, iteratee, callback) {
44 + return (0, _createTester2.default)(Boolean, res => res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
45 +}
46 +exports.default = (0, _awaitify2.default)(someLimit, 4);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfSeries = require('./eachOfSeries.js');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
23 + *
24 + * @name someSeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.some]{@link module:Collections.some}
29 + * @alias anySeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collections in series.
34 + * The iteratee should complete with a boolean `result` value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called as soon as any
37 + * iteratee returns `true`, or after all the iteratee functions have finished.
38 + * Result will be either `true` or `false` depending on the values of the async
39 + * tests. Invoked with (err, result).
40 + * @returns {Promise} a promise, if no callback provided
41 + */
42 +function someSeries(coll, iteratee, callback) {
43 + return (0, _createTester2.default)(Boolean, res => res)(_eachOfSeries2.default, coll, iteratee, callback);
44 +}
45 +exports.default = (0, _awaitify2.default)(someSeries, 3);
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (fn, ...args) {
8 + return (...callArgs) => fn(...args, ...callArgs);
9 +};
10 +
11 +module.exports = exports["default"]; /**
12 + * Creates a continuation function with some arguments already applied.
13 + *
14 + * Useful as a shorthand when combined with other control flow functions. Any
15 + * arguments passed to the returned function are added to the arguments
16 + * originally passed to apply.
17 + *
18 + * @name apply
19 + * @static
20 + * @memberOf module:Utils
21 + * @method
22 + * @category Util
23 + * @param {Function} fn - The function you want to eventually apply all
24 + * arguments to. Invokes with (arguments...).
25 + * @param {...*} arguments... - Any number of arguments to automatically apply
26 + * when the continuation is called.
27 + * @returns {Function} the partially-applied function
28 + * @example
29 + *
30 + * // using apply
31 + * async.parallel([
32 + * async.apply(fs.writeFile, 'testfile1', 'test1'),
33 + * async.apply(fs.writeFile, 'testfile2', 'test2')
34 + * ]);
35 + *
36 + *
37 + * // the same process without using apply
38 + * async.parallel([
39 + * function(callback) {
40 + * fs.writeFile('testfile1', 'test1', callback);
41 + * },
42 + * function(callback) {
43 + * fs.writeFile('testfile2', 'test2', callback);
44 + * }
45 + * ]);
46 + *
47 + * // It's possible to pass any number of additional arguments when calling the
48 + * // continuation:
49 + *
50 + * node> var fn = async.apply(sys.puts, 'one');
51 + * node> fn('two', 'three');
52 + * one
53 + * two
54 + * three
55 + */
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _applyEach = require('./internal/applyEach.js');
8 +
9 +var _applyEach2 = _interopRequireDefault(_applyEach);
10 +
11 +var _map = require('./map.js');
12 +
13 +var _map2 = _interopRequireDefault(_map);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Applies the provided arguments to each function in the array, calling
19 + * `callback` after all functions have completed. If you only provide the first
20 + * argument, `fns`, then it will return a function which lets you pass in the
21 + * arguments as if it were a single function call. If more arguments are
22 + * provided, `callback` is required while `args` is still optional. The results
23 + * for each of the applied async functions are passed to the final callback
24 + * as an array.
25 + *
26 + * @name applyEach
27 + * @static
28 + * @memberOf module:ControlFlow
29 + * @method
30 + * @category Control Flow
31 + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s
32 + * to all call with the same arguments
33 + * @param {...*} [args] - any number of separate arguments to pass to the
34 + * function.
35 + * @param {Function} [callback] - the final argument should be the callback,
36 + * called when all functions have completed processing.
37 + * @returns {AsyncFunction} - Returns a function that takes no args other than
38 + * an optional callback, that is the result of applying the `args` to each
39 + * of the functions.
40 + * @example
41 + *
42 + * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket')
43 + *
44 + * appliedFn((err, results) => {
45 + * // results[0] is the results for `enableSearch`
46 + * // results[1] is the results for `updateSchema`
47 + * });
48 + *
49 + * // partial application example:
50 + * async.each(
51 + * buckets,
52 + * async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(),
53 + * callback
54 + * );
55 + */
56 +exports.default = (0, _applyEach2.default)(_map2.default);
57 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _applyEach = require('./internal/applyEach.js');
8 +
9 +var _applyEach2 = _interopRequireDefault(_applyEach);
10 +
11 +var _mapSeries = require('./mapSeries.js');
12 +
13 +var _mapSeries2 = _interopRequireDefault(_mapSeries);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
19 + *
20 + * @name applyEachSeries
21 + * @static
22 + * @memberOf module:ControlFlow
23 + * @method
24 + * @see [async.applyEach]{@link module:ControlFlow.applyEach}
25 + * @category Control Flow
26 + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s to all
27 + * call with the same arguments
28 + * @param {...*} [args] - any number of separate arguments to pass to the
29 + * function.
30 + * @param {Function} [callback] - the final argument should be the callback,
31 + * called when all functions have completed processing.
32 + * @returns {AsyncFunction} - A function, that when called, is the result of
33 + * appling the `args` to the list of functions. It takes no args, other than
34 + * a callback.
35 + */
36 +exports.default = (0, _applyEach2.default)(_mapSeries2.default);
37 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = asyncify;
7 +
8 +var _initialParams = require('./internal/initialParams.js');
9 +
10 +var _initialParams2 = _interopRequireDefault(_initialParams);
11 +
12 +var _setImmediate = require('./internal/setImmediate.js');
13 +
14 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
15 +
16 +var _wrapAsync = require('./internal/wrapAsync.js');
17 +
18 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19 +
20 +/**
21 + * Take a sync function and make it async, passing its return value to a
22 + * callback. This is useful for plugging sync functions into a waterfall,
23 + * series, or other async functions. Any arguments passed to the generated
24 + * function will be passed to the wrapped function (except for the final
25 + * callback argument). Errors thrown will be passed to the callback.
26 + *
27 + * If the function passed to `asyncify` returns a Promise, that promises's
28 + * resolved/rejected state will be used to call the callback, rather than simply
29 + * the synchronous return value.
30 + *
31 + * This also means you can asyncify ES2017 `async` functions.
32 + *
33 + * @name asyncify
34 + * @static
35 + * @memberOf module:Utils
36 + * @method
37 + * @alias wrapSync
38 + * @category Util
39 + * @param {Function} func - The synchronous function, or Promise-returning
40 + * function to convert to an {@link AsyncFunction}.
41 + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
42 + * invoked with `(args..., callback)`.
43 + * @example
44 + *
45 + * // passing a regular synchronous function
46 + * async.waterfall([
47 + * async.apply(fs.readFile, filename, "utf8"),
48 + * async.asyncify(JSON.parse),
49 + * function (data, next) {
50 + * // data is the result of parsing the text.
51 + * // If there was a parsing error, it would have been caught.
52 + * }
53 + * ], callback);
54 + *
55 + * // passing a function returning a promise
56 + * async.waterfall([
57 + * async.apply(fs.readFile, filename, "utf8"),
58 + * async.asyncify(function (contents) {
59 + * return db.model.create(contents);
60 + * }),
61 + * function (model, next) {
62 + * // `model` is the instantiated model object.
63 + * // If there was an error, this function would be skipped.
64 + * }
65 + * ], callback);
66 + *
67 + * // es2017 example, though `asyncify` is not needed if your JS environment
68 + * // supports async functions out of the box
69 + * var q = async.queue(async.asyncify(async function(file) {
70 + * var intermediateStep = await processFile(file);
71 + * return await somePromise(intermediateStep)
72 + * }));
73 + *
74 + * q.push(files);
75 + */
76 +function asyncify(func) {
77 + if ((0, _wrapAsync.isAsync)(func)) {
78 + return function (...args /*, callback*/) {
79 + const callback = args.pop();
80 + const promise = func.apply(this, args);
81 + return handlePromise(promise, callback);
82 + };
83 + }
84 +
85 + return (0, _initialParams2.default)(function (args, callback) {
86 + var result;
87 + try {
88 + result = func.apply(this, args);
89 + } catch (e) {
90 + return callback(e);
91 + }
92 + // if result is Promise object
93 + if (result && typeof result.then === 'function') {
94 + return handlePromise(result, callback);
95 + } else {
96 + callback(null, result);
97 + }
98 + });
99 +}
100 +
101 +function handlePromise(promise, callback) {
102 + return promise.then(value => {
103 + invokeCallback(callback, null, value);
104 + }, err => {
105 + invokeCallback(callback, err && err.message ? err : new Error(err));
106 + });
107 +}
108 +
109 +function invokeCallback(callback, error, value) {
110 + try {
111 + callback(error, value);
112 + } catch (err) {
113 + (0, _setImmediate2.default)(e => {
114 + throw e;
115 + }, err);
116 + }
117 +}
118 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = autoInject;
7 +
8 +var _auto = require('./auto.js');
9 +
10 +var _auto2 = _interopRequireDefault(_auto);
11 +
12 +var _wrapAsync = require('./internal/wrapAsync.js');
13 +
14 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +var FN_ARGS = /^(?:async\s+)?(?:function)?\s*\w*\s*\(\s*([^)]+)\s*\)(?:\s*{)/;
19 +var ARROW_FN_ARGS = /^(?:async\s+)?\(?\s*([^)=]+)\s*\)?(?:\s*=>)/;
20 +var FN_ARG_SPLIT = /,/;
21 +var FN_ARG = /(=.+)?(\s*)$/;
22 +
23 +function stripComments(string) {
24 + let stripped = '';
25 + let index = 0;
26 + let endBlockComment = string.indexOf('*/');
27 + while (index < string.length) {
28 + if (string[index] === '/' && string[index + 1] === '/') {
29 + // inline comment
30 + let endIndex = string.indexOf('\n', index);
31 + index = endIndex === -1 ? string.length : endIndex;
32 + } else if (endBlockComment !== -1 && string[index] === '/' && string[index + 1] === '*') {
33 + // block comment
34 + let endIndex = string.indexOf('*/', index);
35 + if (endIndex !== -1) {
36 + index = endIndex + 2;
37 + endBlockComment = string.indexOf('*/', index);
38 + } else {
39 + stripped += string[index];
40 + index++;
41 + }
42 + } else {
43 + stripped += string[index];
44 + index++;
45 + }
46 + }
47 + return stripped;
48 +}
49 +
50 +function parseParams(func) {
51 + const src = stripComments(func.toString());
52 + let match = src.match(FN_ARGS);
53 + if (!match) {
54 + match = src.match(ARROW_FN_ARGS);
55 + }
56 + if (!match) throw new Error('could not parse args in autoInject\nSource:\n' + src);
57 + let [, args] = match;
58 + return args.replace(/\s/g, '').split(FN_ARG_SPLIT).map(arg => arg.replace(FN_ARG, '').trim());
59 +}
60 +
61 +/**
62 + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
63 + * tasks are specified as parameters to the function, after the usual callback
64 + * parameter, with the parameter names matching the names of the tasks it
65 + * depends on. This can provide even more readable task graphs which can be
66 + * easier to maintain.
67 + *
68 + * If a final callback is specified, the task results are similarly injected,
69 + * specified as named parameters after the initial error parameter.
70 + *
71 + * The autoInject function is purely syntactic sugar and its semantics are
72 + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
73 + *
74 + * @name autoInject
75 + * @static
76 + * @memberOf module:ControlFlow
77 + * @method
78 + * @see [async.auto]{@link module:ControlFlow.auto}
79 + * @category Control Flow
80 + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
81 + * the form 'func([dependencies...], callback). The object's key of a property
82 + * serves as the name of the task defined by that property, i.e. can be used
83 + * when specifying requirements for other tasks.
84 + * * The `callback` parameter is a `callback(err, result)` which must be called
85 + * when finished, passing an `error` (which can be `null`) and the result of
86 + * the function's execution. The remaining parameters name other tasks on
87 + * which the task is dependent, and the results from those tasks are the
88 + * arguments of those parameters.
89 + * @param {Function} [callback] - An optional callback which is called when all
90 + * the tasks have been completed. It receives the `err` argument if any `tasks`
91 + * pass an error to their callback, and a `results` object with any completed
92 + * task results, similar to `auto`.
93 + * @returns {Promise} a promise, if no callback is passed
94 + * @example
95 + *
96 + * // The example from `auto` can be rewritten as follows:
97 + * async.autoInject({
98 + * get_data: function(callback) {
99 + * // async code to get some data
100 + * callback(null, 'data', 'converted to array');
101 + * },
102 + * make_folder: function(callback) {
103 + * // async code to create a directory to store a file in
104 + * // this is run at the same time as getting the data
105 + * callback(null, 'folder');
106 + * },
107 + * write_file: function(get_data, make_folder, callback) {
108 + * // once there is some data and the directory exists,
109 + * // write the data to a file in the directory
110 + * callback(null, 'filename');
111 + * },
112 + * email_link: function(write_file, callback) {
113 + * // once the file is written let's email a link to it...
114 + * // write_file contains the filename returned by write_file.
115 + * callback(null, {'file':write_file, 'email':'user@example.com'});
116 + * }
117 + * }, function(err, results) {
118 + * console.log('err = ', err);
119 + * console.log('email_link = ', results.email_link);
120 + * });
121 + *
122 + * // If you are using a JS minifier that mangles parameter names, `autoInject`
123 + * // will not work with plain functions, since the parameter names will be
124 + * // collapsed to a single letter identifier. To work around this, you can
125 + * // explicitly specify the names of the parameters your task function needs
126 + * // in an array, similar to Angular.js dependency injection.
127 + *
128 + * // This still has an advantage over plain `auto`, since the results a task
129 + * // depends on are still spread into arguments.
130 + * async.autoInject({
131 + * //...
132 + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
133 + * callback(null, 'filename');
134 + * }],
135 + * email_link: ['write_file', function(write_file, callback) {
136 + * callback(null, {'file':write_file, 'email':'user@example.com'});
137 + * }]
138 + * //...
139 + * }, function(err, results) {
140 + * console.log('err = ', err);
141 + * console.log('email_link = ', results.email_link);
142 + * });
143 + */
144 +function autoInject(tasks, callback) {
145 + var newTasks = {};
146 +
147 + Object.keys(tasks).forEach(key => {
148 + var taskFn = tasks[key];
149 + var params;
150 + var fnIsAsync = (0, _wrapAsync.isAsync)(taskFn);
151 + var hasNoDeps = !fnIsAsync && taskFn.length === 1 || fnIsAsync && taskFn.length === 0;
152 +
153 + if (Array.isArray(taskFn)) {
154 + params = [...taskFn];
155 + taskFn = params.pop();
156 +
157 + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
158 + } else if (hasNoDeps) {
159 + // no dependencies, use the function as-is
160 + newTasks[key] = taskFn;
161 + } else {
162 + params = parseParams(taskFn);
163 + if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
164 + throw new Error("autoInject task functions require explicit parameters.");
165 + }
166 +
167 + // remove callback param
168 + if (!fnIsAsync) params.pop();
169 +
170 + newTasks[key] = params.concat(newTask);
171 + }
172 +
173 + function newTask(results, taskCb) {
174 + var newArgs = params.map(name => results[name]);
175 + newArgs.push(taskCb);
176 + (0, _wrapAsync2.default)(taskFn)(...newArgs);
177 + }
178 + });
179 +
180 + return (0, _auto2.default)(newTasks, callback);
181 +}
182 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "async",
3 + "main": "dist/async.js",
4 + "ignore": [
5 + "bower_components",
6 + "lib",
7 + "test",
8 + "node_modules",
9 + "perf",
10 + "support",
11 + "**/.*",
12 + "*.config.js",
13 + "*.json",
14 + "index.js",
15 + "Makefile"
16 + ]
17 +}
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = cargo;
7 +
8 +var _queue = require('./internal/queue.js');
9 +
10 +var _queue2 = _interopRequireDefault(_queue);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Creates a `cargo` object with the specified payload. Tasks added to the
16 + * cargo will be processed altogether (up to the `payload` limit). If the
17 + * `worker` is in progress, the task is queued until it becomes available. Once
18 + * the `worker` has completed some tasks, each callback of those tasks is
19 + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
20 + * for how `cargo` and `queue` work.
21 + *
22 + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
23 + * at a time, cargo passes an array of tasks to a single worker, repeating
24 + * when the worker is finished.
25 + *
26 + * @name cargo
27 + * @static
28 + * @memberOf module:ControlFlow
29 + * @method
30 + * @see [async.queue]{@link module:ControlFlow.queue}
31 + * @category Control Flow
32 + * @param {AsyncFunction} worker - An asynchronous function for processing an array
33 + * of queued tasks. Invoked with `(tasks, callback)`.
34 + * @param {number} [payload=Infinity] - An optional `integer` for determining
35 + * how many tasks should be processed per round; if omitted, the default is
36 + * unlimited.
37 + * @returns {module:ControlFlow.QueueObject} A cargo object to manage the tasks. Callbacks can
38 + * attached as certain properties to listen for specific events during the
39 + * lifecycle of the cargo and inner queue.
40 + * @example
41 + *
42 + * // create a cargo object with payload 2
43 + * var cargo = async.cargo(function(tasks, callback) {
44 + * for (var i=0; i<tasks.length; i++) {
45 + * console.log('hello ' + tasks[i].name);
46 + * }
47 + * callback();
48 + * }, 2);
49 + *
50 + * // add some items
51 + * cargo.push({name: 'foo'}, function(err) {
52 + * console.log('finished processing foo');
53 + * });
54 + * cargo.push({name: 'bar'}, function(err) {
55 + * console.log('finished processing bar');
56 + * });
57 + * await cargo.push({name: 'baz'});
58 + * console.log('finished processing baz');
59 + */
60 +function cargo(worker, payload) {
61 + return (0, _queue2.default)(worker, 1, payload);
62 +}
63 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = cargo;
7 +
8 +var _queue = require('./internal/queue.js');
9 +
10 +var _queue2 = _interopRequireDefault(_queue);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Creates a `cargoQueue` object with the specified payload. Tasks added to the
16 + * cargoQueue will be processed together (up to the `payload` limit) in `concurrency` parallel workers.
17 + * If the all `workers` are in progress, the task is queued until one becomes available. Once
18 + * a `worker` has completed some tasks, each callback of those tasks is
19 + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
20 + * for how `cargo` and `queue` work.
21 + *
22 + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
23 + * at a time, and [`cargo`]{@link module:ControlFlow.cargo} passes an array of tasks to a single worker,
24 + * the cargoQueue passes an array of tasks to multiple parallel workers.
25 + *
26 + * @name cargoQueue
27 + * @static
28 + * @memberOf module:ControlFlow
29 + * @method
30 + * @see [async.queue]{@link module:ControlFlow.queue}
31 + * @see [async.cargo]{@link module:ControlFLow.cargo}
32 + * @category Control Flow
33 + * @param {AsyncFunction} worker - An asynchronous function for processing an array
34 + * of queued tasks. Invoked with `(tasks, callback)`.
35 + * @param {number} [concurrency=1] - An `integer` for determining how many
36 + * `worker` functions should be run in parallel. If omitted, the concurrency
37 + * defaults to `1`. If the concurrency is `0`, an error is thrown.
38 + * @param {number} [payload=Infinity] - An optional `integer` for determining
39 + * how many tasks should be processed per round; if omitted, the default is
40 + * unlimited.
41 + * @returns {module:ControlFlow.QueueObject} A cargoQueue object to manage the tasks. Callbacks can
42 + * attached as certain properties to listen for specific events during the
43 + * lifecycle of the cargoQueue and inner queue.
44 + * @example
45 + *
46 + * // create a cargoQueue object with payload 2 and concurrency 2
47 + * var cargoQueue = async.cargoQueue(function(tasks, callback) {
48 + * for (var i=0; i<tasks.length; i++) {
49 + * console.log('hello ' + tasks[i].name);
50 + * }
51 + * callback();
52 + * }, 2, 2);
53 + *
54 + * // add some items
55 + * cargoQueue.push({name: 'foo'}, function(err) {
56 + * console.log('finished processing foo');
57 + * });
58 + * cargoQueue.push({name: 'bar'}, function(err) {
59 + * console.log('finished processing bar');
60 + * });
61 + * cargoQueue.push({name: 'baz'}, function(err) {
62 + * console.log('finished processing baz');
63 + * });
64 + * cargoQueue.push({name: 'boo'}, function(err) {
65 + * console.log('finished processing boo');
66 + * });
67 + */
68 +function cargo(worker, concurrency, payload) {
69 + return (0, _queue2.default)(worker, concurrency, payload);
70 +}
71 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = compose;
7 +
8 +var _seq = require('./seq.js');
9 +
10 +var _seq2 = _interopRequireDefault(_seq);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Creates a function which is a composition of the passed asynchronous
16 + * functions. Each function consumes the return value of the function that
17 + * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
18 + * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
19 + *
20 + * If the last argument to the composed function is not a function, a promise
21 + * is returned when you call it.
22 + *
23 + * Each function is executed with the `this` binding of the composed function.
24 + *
25 + * @name compose
26 + * @static
27 + * @memberOf module:ControlFlow
28 + * @method
29 + * @category Control Flow
30 + * @param {...AsyncFunction} functions - the asynchronous functions to compose
31 + * @returns {Function} an asynchronous function that is the composed
32 + * asynchronous `functions`
33 + * @example
34 + *
35 + * function add1(n, callback) {
36 + * setTimeout(function () {
37 + * callback(null, n + 1);
38 + * }, 10);
39 + * }
40 + *
41 + * function mul3(n, callback) {
42 + * setTimeout(function () {
43 + * callback(null, n * 3);
44 + * }, 10);
45 + * }
46 + *
47 + * var add1mul3 = async.compose(mul3, add1);
48 + * add1mul3(4, function (err, result) {
49 + * // result now equals 15
50 + * });
51 + */
52 +function compose(...args) {
53 + return (0, _seq2.default)(...args.reverse());
54 +}
55 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _concatLimit = require('./concatLimit.js');
8 +
9 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
10 +
11 +var _awaitify = require('./internal/awaitify.js');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
19 + * the concatenated list. The `iteratee`s are called in parallel, and the
20 + * results are concatenated as they return. The results array will be returned in
21 + * the original order of `coll` passed to the `iteratee` function.
22 + *
23 + * @name concat
24 + * @static
25 + * @memberOf module:Collections
26 + * @method
27 + * @category Collection
28 + * @alias flatMap
29 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
30 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
31 + * which should use an array as its result. Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished, or an error occurs. Results is an array
34 + * containing the concatenated results of the `iteratee` function. Invoked with
35 + * (err, results).
36 + * @returns A Promise, if no callback is passed
37 + * @example
38 + *
39 + * // dir1 is a directory that contains file1.txt, file2.txt
40 + * // dir2 is a directory that contains file3.txt, file4.txt
41 + * // dir3 is a directory that contains file5.txt
42 + * // dir4 does not exist
43 + *
44 + * let directoryList = ['dir1','dir2','dir3'];
45 + * let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4'];
46 + *
47 + * // Using callbacks
48 + * async.concat(directoryList, fs.readdir, function(err, results) {
49 + * if (err) {
50 + * console.log(err);
51 + * } else {
52 + * console.log(results);
53 + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
54 + * }
55 + * });
56 + *
57 + * // Error Handling
58 + * async.concat(withMissingDirectoryList, fs.readdir, function(err, results) {
59 + * if (err) {
60 + * console.log(err);
61 + * // [ Error: ENOENT: no such file or directory ]
62 + * // since dir4 does not exist
63 + * } else {
64 + * console.log(results);
65 + * }
66 + * });
67 + *
68 + * // Using Promises
69 + * async.concat(directoryList, fs.readdir)
70 + * .then(results => {
71 + * console.log(results);
72 + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
73 + * }).catch(err => {
74 + * console.log(err);
75 + * });
76 + *
77 + * // Error Handling
78 + * async.concat(withMissingDirectoryList, fs.readdir)
79 + * .then(results => {
80 + * console.log(results);
81 + * }).catch(err => {
82 + * console.log(err);
83 + * // [ Error: ENOENT: no such file or directory ]
84 + * // since dir4 does not exist
85 + * });
86 + *
87 + * // Using async/await
88 + * async () => {
89 + * try {
90 + * let results = await async.concat(directoryList, fs.readdir);
91 + * console.log(results);
92 + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
93 + * } catch (err) {
94 + * console.log(err);
95 + * }
96 + * }
97 + *
98 + * // Error Handling
99 + * async () => {
100 + * try {
101 + * let results = await async.concat(withMissingDirectoryList, fs.readdir);
102 + * console.log(results);
103 + * } catch (err) {
104 + * console.log(err);
105 + * // [ Error: ENOENT: no such file or directory ]
106 + * // since dir4 does not exist
107 + * }
108 + * }
109 + *
110 + */
111 +function concat(coll, iteratee, callback) {
112 + return (0, _concatLimit2.default)(coll, Infinity, iteratee, callback);
113 +}
114 +exports.default = (0, _awaitify2.default)(concat, 3);
115 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _wrapAsync = require('./internal/wrapAsync.js');
8 +
9 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
10 +
11 +var _mapLimit = require('./mapLimit.js');
12 +
13 +var _mapLimit2 = _interopRequireDefault(_mapLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name concatLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.concat]{@link module:Collections.concat}
29 + * @category Collection
30 + * @alias flatMapLimit
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
34 + * which should use an array as its result. Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called after all the
36 + * `iteratee` functions have finished, or an error occurs. Results is an array
37 + * containing the concatenated results of the `iteratee` function. Invoked with
38 + * (err, results).
39 + * @returns A Promise, if no callback is passed
40 + */
41 +function concatLimit(coll, limit, iteratee, callback) {
42 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
43 + return (0, _mapLimit2.default)(coll, limit, (val, iterCb) => {
44 + _iteratee(val, (err, ...args) => {
45 + if (err) return iterCb(err);
46 + return iterCb(err, args);
47 + });
48 + }, (err, mapResults) => {
49 + var result = [];
50 + for (var i = 0; i < mapResults.length; i++) {
51 + if (mapResults[i]) {
52 + result = result.concat(...mapResults[i]);
53 + }
54 + }
55 +
56 + return callback(err, result);
57 + });
58 +}
59 +exports.default = (0, _awaitify2.default)(concatLimit, 4);
60 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _concatLimit = require('./concatLimit.js');
8 +
9 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
10 +
11 +var _awaitify = require('./internal/awaitify.js');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
19 + *
20 + * @name concatSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.concat]{@link module:Collections.concat}
25 + * @category Collection
26 + * @alias flatMapSeries
27 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
29 + * The iteratee should complete with an array an array of results.
30 + * Invoked with (item, callback).
31 + * @param {Function} [callback] - A callback which is called after all the
32 + * `iteratee` functions have finished, or an error occurs. Results is an array
33 + * containing the concatenated results of the `iteratee` function. Invoked with
34 + * (err, results).
35 + * @returns A Promise, if no callback is passed
36 + */
37 +function concatSeries(coll, iteratee, callback) {
38 + return (0, _concatLimit2.default)(coll, 1, iteratee, callback);
39 +}
40 +exports.default = (0, _awaitify2.default)(concatSeries, 3);
41 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (...args) {
8 + return function (...ignoredArgs /*, callback*/) {
9 + var callback = ignoredArgs.pop();
10 + return callback(null, ...args);
11 + };
12 +};
13 +
14 +module.exports = exports["default"]; /**
15 + * Returns a function that when called, calls-back with the values provided.
16 + * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
17 + * [`auto`]{@link module:ControlFlow.auto}.
18 + *
19 + * @name constant
20 + * @static
21 + * @memberOf module:Utils
22 + * @method
23 + * @category Util
24 + * @param {...*} arguments... - Any number of arguments to automatically invoke
25 + * callback with.
26 + * @returns {AsyncFunction} Returns a function that when invoked, automatically
27 + * invokes the callback with the previous given arguments.
28 + * @example
29 + *
30 + * async.waterfall([
31 + * async.constant(42),
32 + * function (value, next) {
33 + * // value === 42
34 + * },
35 + * //...
36 + * ], callback);
37 + *
38 + * async.waterfall([
39 + * async.constant(filename, "utf8"),
40 + * fs.readFile,
41 + * function (fileData, next) {
42 + * //...
43 + * }
44 + * //...
45 + * ], callback);
46 + *
47 + * async.auto({
48 + * hostname: async.constant("https://server.net/"),
49 + * port: findFreePort,
50 + * launchServer: ["hostname", "port", function (options, cb) {
51 + * startServer(options, cb);
52 + * }],
53 + * //...
54 + * }, callback);
55 + */
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf.js');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns the first value in `coll` that passes an async truth test. The
23 + * `iteratee` is applied in parallel, meaning the first iteratee to return
24 + * `true` will fire the detect `callback` with that result. That means the
25 + * result might not be the first item in the original `coll` (in terms of order)
26 + * that passes the test.
27 +
28 + * If order within the original `coll` is important, then look at
29 + * [`detectSeries`]{@link module:Collections.detectSeries}.
30 + *
31 + * @name detect
32 + * @static
33 + * @memberOf module:Collections
34 + * @method
35 + * @alias find
36 + * @category Collections
37 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
38 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
39 + * The iteratee must complete with a boolean value as its result.
40 + * Invoked with (item, callback).
41 + * @param {Function} [callback] - A callback which is called as soon as any
42 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
43 + * Result will be the first item in the array that passes the truth test
44 + * (iteratee) or the value `undefined` if none passed. Invoked with
45 + * (err, result).
46 + * @returns A Promise, if no callback is passed
47 + * @example
48 + *
49 + * // dir1 is a directory that contains file1.txt, file2.txt
50 + * // dir2 is a directory that contains file3.txt, file4.txt
51 + * // dir3 is a directory that contains file5.txt
52 + *
53 + * // asynchronous function that checks if a file exists
54 + * function fileExists(file, callback) {
55 + * fs.access(file, fs.constants.F_OK, (err) => {
56 + * callback(null, !err);
57 + * });
58 + * }
59 + *
60 + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists,
61 + * function(err, result) {
62 + * console.log(result);
63 + * // dir1/file1.txt
64 + * // result now equals the first file in the list that exists
65 + * }
66 + *);
67 + *
68 + * // Using Promises
69 + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists)
70 + * .then(result => {
71 + * console.log(result);
72 + * // dir1/file1.txt
73 + * // result now equals the first file in the list that exists
74 + * }).catch(err => {
75 + * console.log(err);
76 + * });
77 + *
78 + * // Using async/await
79 + * async () => {
80 + * try {
81 + * let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists);
82 + * console.log(result);
83 + * // dir1/file1.txt
84 + * // result now equals the file in the list that exists
85 + * }
86 + * catch (err) {
87 + * console.log(err);
88 + * }
89 + * }
90 + *
91 + */
92 +function detect(coll, iteratee, callback) {
93 + return (0, _createTester2.default)(bool => bool, (res, item) => item)(_eachOf2.default, coll, iteratee, callback);
94 +}
95 +exports.default = (0, _awaitify2.default)(detect, 3);
96 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit.js');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name detectLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.detect]{@link module:Collections.detect}
30 + * @alias findLimit
31 + * @category Collections
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
35 + * The iteratee must complete with a boolean value as its result.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
39 + * Result will be the first item in the array that passes the truth test
40 + * (iteratee) or the value `undefined` if none passed. Invoked with
41 + * (err, result).
42 + * @returns a Promise if no callback is passed
43 + */
44 +function detectLimit(coll, limit, iteratee, callback) {
45 + return (0, _createTester2.default)(bool => bool, (res, item) => item)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
46 +}
47 +exports.default = (0, _awaitify2.default)(detectLimit, 4);
48 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit.js');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
23 + *
24 + * @name detectSeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.detect]{@link module:Collections.detect}
29 + * @alias findSeries
30 + * @category Collections
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
33 + * The iteratee must complete with a boolean value as its result.
34 + * Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called as soon as any
36 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
37 + * Result will be the first item in the array that passes the truth test
38 + * (iteratee) or the value `undefined` if none passed. Invoked with
39 + * (err, result).
40 + * @returns a Promise if no callback is passed
41 + */
42 +function detectSeries(coll, iteratee, callback) {
43 + return (0, _createTester2.default)(bool => bool, (res, item) => item)((0, _eachOfLimit2.default)(1), coll, iteratee, callback);
44 +}
45 +
46 +exports.default = (0, _awaitify2.default)(detectSeries, 3);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _consoleFunc = require('./internal/consoleFunc.js');
8 +
9 +var _consoleFunc2 = _interopRequireDefault(_consoleFunc);
10 +
11 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12 +
13 +/**
14 + * Logs the result of an [`async` function]{@link AsyncFunction} to the
15 + * `console` using `console.dir` to display the properties of the resulting object.
16 + * Only works in Node.js or in browsers that support `console.dir` and
17 + * `console.error` (such as FF and Chrome).
18 + * If multiple arguments are returned from the async function,
19 + * `console.dir` is called on each argument in order.
20 + *
21 + * @name dir
22 + * @static
23 + * @memberOf module:Utils
24 + * @method
25 + * @category Util
26 + * @param {AsyncFunction} function - The function you want to eventually apply
27 + * all arguments to.
28 + * @param {...*} arguments... - Any number of arguments to apply to the function.
29 + * @example
30 + *
31 + * // in a module
32 + * var hello = function(name, callback) {
33 + * setTimeout(function() {
34 + * callback(null, {hello: name});
35 + * }, 1000);
36 + * };
37 + *
38 + * // in the node repl
39 + * node> async.dir(hello, 'world');
40 + * {hello: 'world'}
41 + */
42 +exports.default = (0, _consoleFunc2.default)('dir');
43 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _onlyOnce = require('./internal/onlyOnce.js');
8 +
9 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync.js');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
23 + * the order of operations, the arguments `test` and `iteratee` are switched.
24 + *
25 + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
26 + *
27 + * @name doWhilst
28 + * @static
29 + * @memberOf module:ControlFlow
30 + * @method
31 + * @see [async.whilst]{@link module:ControlFlow.whilst}
32 + * @category Control Flow
33 + * @param {AsyncFunction} iteratee - A function which is called each time `test`
34 + * passes. Invoked with (callback).
35 + * @param {AsyncFunction} test - asynchronous truth test to perform after each
36 + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
37 + * non-error args from the previous callback of `iteratee`.
38 + * @param {Function} [callback] - A callback which is called after the test
39 + * function has failed and repeated execution of `iteratee` has stopped.
40 + * `callback` will be passed an error and any arguments passed to the final
41 + * `iteratee`'s callback. Invoked with (err, [results]);
42 + * @returns {Promise} a promise, if no callback is passed
43 + */
44 +function doWhilst(iteratee, test, callback) {
45 + callback = (0, _onlyOnce2.default)(callback);
46 + var _fn = (0, _wrapAsync2.default)(iteratee);
47 + var _test = (0, _wrapAsync2.default)(test);
48 + var results;
49 +
50 + function next(err, ...args) {
51 + if (err) return callback(err);
52 + if (err === false) return;
53 + results = args;
54 + _test(...args, check);
55 + }
56 +
57 + function check(err, truth) {
58 + if (err) return callback(err);
59 + if (err === false) return;
60 + if (!truth) return callback(null, ...results);
61 + _fn(next);
62 + }
63 +
64 + return check(null, true);
65 +}
66 +
67 +exports.default = (0, _awaitify2.default)(doWhilst, 3);
68 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = doUntil;
7 +
8 +var _doWhilst = require('./doWhilst.js');
9 +
10 +var _doWhilst2 = _interopRequireDefault(_doWhilst);
11 +
12 +var _wrapAsync = require('./internal/wrapAsync.js');
13 +
14 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
20 + * argument ordering differs from `until`.
21 + *
22 + * @name doUntil
23 + * @static
24 + * @memberOf module:ControlFlow
25 + * @method
26 + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
27 + * @category Control Flow
28 + * @param {AsyncFunction} iteratee - An async function which is called each time
29 + * `test` fails. Invoked with (callback).
30 + * @param {AsyncFunction} test - asynchronous truth test to perform after each
31 + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
32 + * non-error args from the previous callback of `iteratee`
33 + * @param {Function} [callback] - A callback which is called after the test
34 + * function has passed and repeated execution of `iteratee` has stopped. `callback`
35 + * will be passed an error and any arguments passed to the final `iteratee`'s
36 + * callback. Invoked with (err, [results]);
37 + * @returns {Promise} a promise, if no callback is passed
38 + */
39 +function doUntil(iteratee, test, callback) {
40 + const _test = (0, _wrapAsync2.default)(test);
41 + return (0, _doWhilst2.default)(iteratee, (...args) => {
42 + const cb = args.pop();
43 + _test(...args, (err, truth) => cb(err, !truth));
44 + }, callback);
45 +}
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _onlyOnce = require('./internal/onlyOnce.js');
8 +
9 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync.js');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
23 + * the order of operations, the arguments `test` and `iteratee` are switched.
24 + *
25 + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
26 + *
27 + * @name doWhilst
28 + * @static
29 + * @memberOf module:ControlFlow
30 + * @method
31 + * @see [async.whilst]{@link module:ControlFlow.whilst}
32 + * @category Control Flow
33 + * @param {AsyncFunction} iteratee - A function which is called each time `test`
34 + * passes. Invoked with (callback).
35 + * @param {AsyncFunction} test - asynchronous truth test to perform after each
36 + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
37 + * non-error args from the previous callback of `iteratee`.
38 + * @param {Function} [callback] - A callback which is called after the test
39 + * function has failed and repeated execution of `iteratee` has stopped.
40 + * `callback` will be passed an error and any arguments passed to the final
41 + * `iteratee`'s callback. Invoked with (err, [results]);
42 + * @returns {Promise} a promise, if no callback is passed
43 + */
44 +function doWhilst(iteratee, test, callback) {
45 + callback = (0, _onlyOnce2.default)(callback);
46 + var _fn = (0, _wrapAsync2.default)(iteratee);
47 + var _test = (0, _wrapAsync2.default)(test);
48 + var results;
49 +
50 + function next(err, ...args) {
51 + if (err) return callback(err);
52 + if (err === false) return;
53 + results = args;
54 + _test(...args, check);
55 + }
56 +
57 + function check(err, truth) {
58 + if (err) return callback(err);
59 + if (err === false) return;
60 + if (!truth) return callback(null, ...results);
61 + _fn(next);
62 + }
63 +
64 + return check(null, true);
65 +}
66 +
67 +exports.default = (0, _awaitify2.default)(doWhilst, 3);
68 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _onlyOnce = require('./internal/onlyOnce.js');
8 +
9 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync.js');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
23 + * stopped, or an error occurs.
24 + *
25 + * @name whilst
26 + * @static
27 + * @memberOf module:ControlFlow
28 + * @method
29 + * @category Control Flow
30 + * @param {AsyncFunction} test - asynchronous truth test to perform before each
31 + * execution of `iteratee`. Invoked with ().
32 + * @param {AsyncFunction} iteratee - An async function which is called each time
33 + * `test` passes. Invoked with (callback).
34 + * @param {Function} [callback] - A callback which is called after the test
35 + * function has failed and repeated execution of `iteratee` has stopped. `callback`
36 + * will be passed an error and any arguments passed to the final `iteratee`'s
37 + * callback. Invoked with (err, [results]);
38 + * @returns {Promise} a promise, if no callback is passed
39 + * @example
40 + *
41 + * var count = 0;
42 + * async.whilst(
43 + * function test(cb) { cb(null, count < 5); },
44 + * function iter(callback) {
45 + * count++;
46 + * setTimeout(function() {
47 + * callback(null, count);
48 + * }, 1000);
49 + * },
50 + * function (err, n) {
51 + * // 5 seconds have passed, n = 5
52 + * }
53 + * );
54 + */
55 +function whilst(test, iteratee, callback) {
56 + callback = (0, _onlyOnce2.default)(callback);
57 + var _fn = (0, _wrapAsync2.default)(iteratee);
58 + var _test = (0, _wrapAsync2.default)(test);
59 + var results = [];
60 +
61 + function next(err, ...rest) {
62 + if (err) return callback(err);
63 + results = rest;
64 + if (err === false) return;
65 + _test(check);
66 + }
67 +
68 + function check(err, truth) {
69 + if (err) return callback(err);
70 + if (err === false) return;
71 + if (!truth) return callback(null, ...results);
72 + _fn(next);
73 + }
74 +
75 + return _test(check);
76 +}
77 +exports.default = (0, _awaitify2.default)(whilst, 3);
78 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOf = require('./eachOf.js');
8 +
9 +var _eachOf2 = _interopRequireDefault(_eachOf);
10 +
11 +var _withoutIndex = require('./internal/withoutIndex.js');
12 +
13 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync.js');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify.js');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Applies the function `iteratee` to each item in `coll`, in parallel.
27 + * The `iteratee` is called with an item from the list, and a callback for when
28 + * it has finished. If the `iteratee` passes an error to its `callback`, the
29 + * main `callback` (for the `each` function) is immediately called with the
30 + * error.
31 + *
32 + * Note, that since this function applies `iteratee` to each item in parallel,
33 + * there is no guarantee that the iteratee functions will complete in order.
34 + *
35 + * @name each
36 + * @static
37 + * @memberOf module:Collections
38 + * @method
39 + * @alias forEach
40 + * @category Collection
41 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
42 + * @param {AsyncFunction} iteratee - An async function to apply to
43 + * each item in `coll`. Invoked with (item, callback).
44 + * The array index is not passed to the iteratee.
45 + * If you need the index, use `eachOf`.
46 + * @param {Function} [callback] - A callback which is called when all
47 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
48 + * @returns {Promise} a promise, if a callback is omitted
49 + * @example
50 + *
51 + * // dir1 is a directory that contains file1.txt, file2.txt
52 + * // dir2 is a directory that contains file3.txt, file4.txt
53 + * // dir3 is a directory that contains file5.txt
54 + * // dir4 does not exist
55 + *
56 + * const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt'];
57 + * const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt'];
58 + *
59 + * // asynchronous function that deletes a file
60 + * const deleteFile = function(file, callback) {
61 + * fs.unlink(file, callback);
62 + * };
63 + *
64 + * // Using callbacks
65 + * async.each(fileList, deleteFile, function(err) {
66 + * if( err ) {
67 + * console.log(err);
68 + * } else {
69 + * console.log('All files have been deleted successfully');
70 + * }
71 + * });
72 + *
73 + * // Error Handling
74 + * async.each(withMissingFileList, deleteFile, function(err){
75 + * console.log(err);
76 + * // [ Error: ENOENT: no such file or directory ]
77 + * // since dir4/file2.txt does not exist
78 + * // dir1/file1.txt could have been deleted
79 + * });
80 + *
81 + * // Using Promises
82 + * async.each(fileList, deleteFile)
83 + * .then( () => {
84 + * console.log('All files have been deleted successfully');
85 + * }).catch( err => {
86 + * console.log(err);
87 + * });
88 + *
89 + * // Error Handling
90 + * async.each(fileList, deleteFile)
91 + * .then( () => {
92 + * console.log('All files have been deleted successfully');
93 + * }).catch( err => {
94 + * console.log(err);
95 + * // [ Error: ENOENT: no such file or directory ]
96 + * // since dir4/file2.txt does not exist
97 + * // dir1/file1.txt could have been deleted
98 + * });
99 + *
100 + * // Using async/await
101 + * async () => {
102 + * try {
103 + * await async.each(files, deleteFile);
104 + * }
105 + * catch (err) {
106 + * console.log(err);
107 + * }
108 + * }
109 + *
110 + * // Error Handling
111 + * async () => {
112 + * try {
113 + * await async.each(withMissingFileList, deleteFile);
114 + * }
115 + * catch (err) {
116 + * console.log(err);
117 + * // [ Error: ENOENT: no such file or directory ]
118 + * // since dir4/file2.txt does not exist
119 + * // dir1/file1.txt could have been deleted
120 + * }
121 + * }
122 + *
123 + */
124 +function eachLimit(coll, iteratee, callback) {
125 + return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
126 +}
127 +
128 +exports.default = (0, _awaitify2.default)(eachLimit, 3);
129 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit = require('./internal/eachOfLimit.js');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _withoutIndex = require('./internal/withoutIndex.js');
12 +
13 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync.js');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify.js');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
27 + *
28 + * @name eachLimit
29 + * @static
30 + * @memberOf module:Collections
31 + * @method
32 + * @see [async.each]{@link module:Collections.each}
33 + * @alias forEachLimit
34 + * @category Collection
35 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
36 + * @param {number} limit - The maximum number of async operations at a time.
37 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
38 + * `coll`.
39 + * The array index is not passed to the iteratee.
40 + * If you need the index, use `eachOfLimit`.
41 + * Invoked with (item, callback).
42 + * @param {Function} [callback] - A callback which is called when all
43 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
44 + * @returns {Promise} a promise, if a callback is omitted
45 + */
46 +function eachLimit(coll, limit, iteratee, callback) {
47 + return (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
48 +}
49 +exports.default = (0, _awaitify2.default)(eachLimit, 4);
50 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _isArrayLike = require('./internal/isArrayLike.js');
8 +
9 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
10 +
11 +var _breakLoop = require('./internal/breakLoop.js');
12 +
13 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
14 +
15 +var _eachOfLimit = require('./eachOfLimit.js');
16 +
17 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
18 +
19 +var _once = require('./internal/once.js');
20 +
21 +var _once2 = _interopRequireDefault(_once);
22 +
23 +var _onlyOnce = require('./internal/onlyOnce.js');
24 +
25 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
26 +
27 +var _wrapAsync = require('./internal/wrapAsync.js');
28 +
29 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
30 +
31 +var _awaitify = require('./internal/awaitify.js');
32 +
33 +var _awaitify2 = _interopRequireDefault(_awaitify);
34 +
35 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36 +
37 +// eachOf implementation optimized for array-likes
38 +function eachOfArrayLike(coll, iteratee, callback) {
39 + callback = (0, _once2.default)(callback);
40 + var index = 0,
41 + completed = 0,
42 + { length } = coll,
43 + canceled = false;
44 + if (length === 0) {
45 + callback(null);
46 + }
47 +
48 + function iteratorCallback(err, value) {
49 + if (err === false) {
50 + canceled = true;
51 + }
52 + if (canceled === true) return;
53 + if (err) {
54 + callback(err);
55 + } else if (++completed === length || value === _breakLoop2.default) {
56 + callback(null);
57 + }
58 + }
59 +
60 + for (; index < length; index++) {
61 + iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
62 + }
63 +}
64 +
65 +// a generic version of eachOf which can handle array, object, and iterator cases.
66 +function eachOfGeneric(coll, iteratee, callback) {
67 + return (0, _eachOfLimit2.default)(coll, Infinity, iteratee, callback);
68 +}
69 +
70 +/**
71 + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
72 + * to the iteratee.
73 + *
74 + * @name eachOf
75 + * @static
76 + * @memberOf module:Collections
77 + * @method
78 + * @alias forEachOf
79 + * @category Collection
80 + * @see [async.each]{@link module:Collections.each}
81 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
82 + * @param {AsyncFunction} iteratee - A function to apply to each
83 + * item in `coll`.
84 + * The `key` is the item's key, or index in the case of an array.
85 + * Invoked with (item, key, callback).
86 + * @param {Function} [callback] - A callback which is called when all
87 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
88 + * @returns {Promise} a promise, if a callback is omitted
89 + * @example
90 + *
91 + * // dev.json is a file containing a valid json object config for dev environment
92 + * // dev.json is a file containing a valid json object config for test environment
93 + * // prod.json is a file containing a valid json object config for prod environment
94 + * // invalid.json is a file with a malformed json object
95 + *
96 + * let configs = {}; //global variable
97 + * let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'};
98 + * let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'};
99 + *
100 + * // asynchronous function that reads a json file and parses the contents as json object
101 + * function parseFile(file, key, callback) {
102 + * fs.readFile(file, "utf8", function(err, data) {
103 + * if (err) return calback(err);
104 + * try {
105 + * configs[key] = JSON.parse(data);
106 + * } catch (e) {
107 + * return callback(e);
108 + * }
109 + * callback();
110 + * });
111 + * }
112 + *
113 + * // Using callbacks
114 + * async.forEachOf(validConfigFileMap, parseFile, function (err) {
115 + * if (err) {
116 + * console.error(err);
117 + * } else {
118 + * console.log(configs);
119 + * // configs is now a map of JSON data, e.g.
120 + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
121 + * }
122 + * });
123 + *
124 + * //Error handing
125 + * async.forEachOf(invalidConfigFileMap, parseFile, function (err) {
126 + * if (err) {
127 + * console.error(err);
128 + * // JSON parse error exception
129 + * } else {
130 + * console.log(configs);
131 + * }
132 + * });
133 + *
134 + * // Using Promises
135 + * async.forEachOf(validConfigFileMap, parseFile)
136 + * .then( () => {
137 + * console.log(configs);
138 + * // configs is now a map of JSON data, e.g.
139 + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
140 + * }).catch( err => {
141 + * console.error(err);
142 + * });
143 + *
144 + * //Error handing
145 + * async.forEachOf(invalidConfigFileMap, parseFile)
146 + * .then( () => {
147 + * console.log(configs);
148 + * }).catch( err => {
149 + * console.error(err);
150 + * // JSON parse error exception
151 + * });
152 + *
153 + * // Using async/await
154 + * async () => {
155 + * try {
156 + * let result = await async.forEachOf(validConfigFileMap, parseFile);
157 + * console.log(configs);
158 + * // configs is now a map of JSON data, e.g.
159 + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
160 + * }
161 + * catch (err) {
162 + * console.log(err);
163 + * }
164 + * }
165 + *
166 + * //Error handing
167 + * async () => {
168 + * try {
169 + * let result = await async.forEachOf(invalidConfigFileMap, parseFile);
170 + * console.log(configs);
171 + * }
172 + * catch (err) {
173 + * console.log(err);
174 + * // JSON parse error exception
175 + * }
176 + * }
177 + *
178 + */
179 +function eachOf(coll, iteratee, callback) {
180 + var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
181 + return eachOfImplementation(coll, (0, _wrapAsync2.default)(iteratee), callback);
182 +}
183 +
184 +exports.default = (0, _awaitify2.default)(eachOf, 3);
185 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit2 = require('./internal/eachOfLimit.js');
8 +
9 +var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync.js');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name eachOfLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.eachOf]{@link module:Collections.eachOf}
30 + * @alias forEachOfLimit
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {AsyncFunction} iteratee - An async function to apply to each
35 + * item in `coll`. The `key` is the item's key, or index in the case of an
36 + * array.
37 + * Invoked with (item, key, callback).
38 + * @param {Function} [callback] - A callback which is called when all
39 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
40 + * @returns {Promise} a promise, if a callback is omitted
41 + */
42 +function eachOfLimit(coll, limit, iteratee, callback) {
43 + return (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
44 +}
45 +
46 +exports.default = (0, _awaitify2.default)(eachOfLimit, 4);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit = require('./eachOfLimit.js');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _awaitify = require('./internal/awaitify.js');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
19 + *
20 + * @name eachOfSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.eachOf]{@link module:Collections.eachOf}
25 + * @alias forEachOfSeries
26 + * @category Collection
27 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
29 + * `coll`.
30 + * Invoked with (item, key, callback).
31 + * @param {Function} [callback] - A callback which is called when all `iteratee`
32 + * functions have finished, or an error occurs. Invoked with (err).
33 + * @returns {Promise} a promise, if a callback is omitted
34 + */
35 +function eachOfSeries(coll, iteratee, callback) {
36 + return (0, _eachOfLimit2.default)(coll, 1, iteratee, callback);
37 +}
38 +exports.default = (0, _awaitify2.default)(eachOfSeries, 3);
39 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachLimit = require('./eachLimit.js');
8 +
9 +var _eachLimit2 = _interopRequireDefault(_eachLimit);
10 +
11 +var _awaitify = require('./internal/awaitify.js');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
19 + *
20 + * Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item
21 + * in series and therefore the iteratee functions will complete in order.
22 +
23 + * @name eachSeries
24 + * @static
25 + * @memberOf module:Collections
26 + * @method
27 + * @see [async.each]{@link module:Collections.each}
28 + * @alias forEachSeries
29 + * @category Collection
30 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
31 + * @param {AsyncFunction} iteratee - An async function to apply to each
32 + * item in `coll`.
33 + * The array index is not passed to the iteratee.
34 + * If you need the index, use `eachOfSeries`.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called when all
37 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
38 + * @returns {Promise} a promise, if a callback is omitted
39 + */
40 +function eachSeries(coll, iteratee, callback) {
41 + return (0, _eachLimit2.default)(coll, 1, iteratee, callback);
42 +}
43 +exports.default = (0, _awaitify2.default)(eachSeries, 3);
44 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = ensureAsync;
7 +
8 +var _setImmediate = require('./internal/setImmediate.js');
9 +
10 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
11 +
12 +var _wrapAsync = require('./internal/wrapAsync.js');
13 +
14 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15 +
16 +/**
17 + * Wrap an async function and ensure it calls its callback on a later tick of
18 + * the event loop. If the function already calls its callback on a next tick,
19 + * no extra deferral is added. This is useful for preventing stack overflows
20 + * (`RangeError: Maximum call stack size exceeded`) and generally keeping
21 + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
22 + * contained. ES2017 `async` functions are returned as-is -- they are immune
23 + * to Zalgo's corrupting influences, as they always resolve on a later tick.
24 + *
25 + * @name ensureAsync
26 + * @static
27 + * @memberOf module:Utils
28 + * @method
29 + * @category Util
30 + * @param {AsyncFunction} fn - an async function, one that expects a node-style
31 + * callback as its last argument.
32 + * @returns {AsyncFunction} Returns a wrapped function with the exact same call
33 + * signature as the function passed in.
34 + * @example
35 + *
36 + * function sometimesAsync(arg, callback) {
37 + * if (cache[arg]) {
38 + * return callback(null, cache[arg]); // this would be synchronous!!
39 + * } else {
40 + * doSomeIO(arg, callback); // this IO would be asynchronous
41 + * }
42 + * }
43 + *
44 + * // this has a risk of stack overflows if many results are cached in a row
45 + * async.mapSeries(args, sometimesAsync, done);
46 + *
47 + * // this will defer sometimesAsync's callback if necessary,
48 + * // preventing stack overflows
49 + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
50 + */
51 +function ensureAsync(fn) {
52 + if ((0, _wrapAsync.isAsync)(fn)) return fn;
53 + return function (...args /*, callback*/) {
54 + var callback = args.pop();
55 + var sync = true;
56 + args.push((...innerArgs) => {
57 + if (sync) {
58 + (0, _setImmediate2.default)(() => callback(...innerArgs));
59 + } else {
60 + callback(...innerArgs);
61 + }
62 + });
63 + fn.apply(this, args);
64 + sync = false;
65 + };
66 +}
67 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf.js');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns `true` if every element in `coll` satisfies an async test. If any
23 + * iteratee call returns `false`, the main `callback` is immediately called.
24 + *
25 + * @name every
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @alias all
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in parallel.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + * @example
41 + *
42 + * // dir1 is a directory that contains file1.txt, file2.txt
43 + * // dir2 is a directory that contains file3.txt, file4.txt
44 + * // dir3 is a directory that contains file5.txt
45 + * // dir4 does not exist
46 + *
47 + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt'];
48 + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
49 + *
50 + * // asynchronous function that checks if a file exists
51 + * function fileExists(file, callback) {
52 + * fs.access(file, fs.constants.F_OK, (err) => {
53 + * callback(null, !err);
54 + * });
55 + * }
56 + *
57 + * // Using callbacks
58 + * async.every(fileList, fileExists, function(err, result) {
59 + * console.log(result);
60 + * // true
61 + * // result is true since every file exists
62 + * });
63 + *
64 + * async.every(withMissingFileList, fileExists, function(err, result) {
65 + * console.log(result);
66 + * // false
67 + * // result is false since NOT every file exists
68 + * });
69 + *
70 + * // Using Promises
71 + * async.every(fileList, fileExists)
72 + * .then( result => {
73 + * console.log(result);
74 + * // true
75 + * // result is true since every file exists
76 + * }).catch( err => {
77 + * console.log(err);
78 + * });
79 + *
80 + * async.every(withMissingFileList, fileExists)
81 + * .then( result => {
82 + * console.log(result);
83 + * // false
84 + * // result is false since NOT every file exists
85 + * }).catch( err => {
86 + * console.log(err);
87 + * });
88 + *
89 + * // Using async/await
90 + * async () => {
91 + * try {
92 + * let result = await async.every(fileList, fileExists);
93 + * console.log(result);
94 + * // true
95 + * // result is true since every file exists
96 + * }
97 + * catch (err) {
98 + * console.log(err);
99 + * }
100 + * }
101 + *
102 + * async () => {
103 + * try {
104 + * let result = await async.every(withMissingFileList, fileExists);
105 + * console.log(result);
106 + * // false
107 + * // result is false since NOT every file exists
108 + * }
109 + * catch (err) {
110 + * console.log(err);
111 + * }
112 + * }
113 + *
114 + */
115 +function every(coll, iteratee, callback) {
116 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOf2.default, coll, iteratee, callback);
117 +}
118 +exports.default = (0, _awaitify2.default)(every, 3);
119 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit.js');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name everyLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allLimit
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collection in parallel.
35 + * The iteratee must complete with a boolean result value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called after all the
38 + * `iteratee` functions have finished. Result will be either `true` or `false`
39 + * depending on the values of the async tests. Invoked with (err, result).
40 + * @returns {Promise} a promise, if no callback provided
41 + */
42 +function everyLimit(coll, limit, iteratee, callback) {
43 + return (0, _createTester2.default)(bool => !bool, res => !res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
44 +}
45 +exports.default = (0, _awaitify2.default)(everyLimit, 4);
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfSeries = require('./eachOfSeries.js');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
23 + *
24 + * @name everySeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allSeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in series.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + */
41 +function everySeries(coll, iteratee, callback) {
42 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOfSeries2.default, coll, iteratee, callback);
43 +}
44 +exports.default = (0, _awaitify2.default)(everySeries, 3);
45 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _filter2 = require('./internal/filter.js');
8 +
9 +var _filter3 = _interopRequireDefault(_filter2);
10 +
11 +var _eachOf = require('./eachOf.js');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns a new array of all the values in `coll` which pass an async truth
23 + * test. This operation is performed in parallel, but the results array will be
24 + * in the same order as the original.
25 + *
26 + * @name filter
27 + * @static
28 + * @memberOf module:Collections
29 + * @method
30 + * @alias select
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
34 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
35 + * with a boolean argument once it has completed. Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Invoked with (err, results).
38 + * @returns {Promise} a promise, if no callback provided
39 + * @example
40 + *
41 + * // dir1 is a directory that contains file1.txt, file2.txt
42 + * // dir2 is a directory that contains file3.txt, file4.txt
43 + * // dir3 is a directory that contains file5.txt
44 + *
45 + * const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
46 + *
47 + * // asynchronous function that checks if a file exists
48 + * function fileExists(file, callback) {
49 + * fs.access(file, fs.constants.F_OK, (err) => {
50 + * callback(null, !err);
51 + * });
52 + * }
53 + *
54 + * // Using callbacks
55 + * async.filter(files, fileExists, function(err, results) {
56 + * if(err) {
57 + * console.log(err);
58 + * } else {
59 + * console.log(results);
60 + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
61 + * // results is now an array of the existing files
62 + * }
63 + * });
64 + *
65 + * // Using Promises
66 + * async.filter(files, fileExists)
67 + * .then(results => {
68 + * console.log(results);
69 + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
70 + * // results is now an array of the existing files
71 + * }).catch(err => {
72 + * console.log(err);
73 + * });
74 + *
75 + * // Using async/await
76 + * async () => {
77 + * try {
78 + * let results = await async.filter(files, fileExists);
79 + * console.log(results);
80 + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
81 + * // results is now an array of the existing files
82 + * }
83 + * catch (err) {
84 + * console.log(err);
85 + * }
86 + * }
87 + *
88 + */
89 +function filter(coll, iteratee, callback) {
90 + return (0, _filter3.default)(_eachOf2.default, coll, iteratee, callback);
91 +}
92 +exports.default = (0, _awaitify2.default)(filter, 3);
93 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _filter2 = require('./internal/filter.js');
8 +
9 +var _filter3 = _interopRequireDefault(_filter2);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit.js');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name filterLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.filter]{@link module:Collections.filter}
30 + * @alias selectLimit
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
35 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
36 + * with a boolean argument once it has completed. Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called after all the
38 + * `iteratee` functions have finished. Invoked with (err, results).
39 + * @returns {Promise} a promise, if no callback provided
40 + */
41 +function filterLimit(coll, limit, iteratee, callback) {
42 + return (0, _filter3.default)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
43 +}
44 +exports.default = (0, _awaitify2.default)(filterLimit, 4);
45 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _filter2 = require('./internal/filter.js');
8 +
9 +var _filter3 = _interopRequireDefault(_filter2);
10 +
11 +var _eachOfSeries = require('./eachOfSeries.js');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
23 + *
24 + * @name filterSeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.filter]{@link module:Collections.filter}
29 + * @alias selectSeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
33 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
34 + * with a boolean argument once it has completed. Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called after all the
36 + * `iteratee` functions have finished. Invoked with (err, results)
37 + * @returns {Promise} a promise, if no callback provided
38 + */
39 +function filterSeries(coll, iteratee, callback) {
40 + return (0, _filter3.default)(_eachOfSeries2.default, coll, iteratee, callback);
41 +}
42 +exports.default = (0, _awaitify2.default)(filterSeries, 3);
43 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf.js');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns the first value in `coll` that passes an async truth test. The
23 + * `iteratee` is applied in parallel, meaning the first iteratee to return
24 + * `true` will fire the detect `callback` with that result. That means the
25 + * result might not be the first item in the original `coll` (in terms of order)
26 + * that passes the test.
27 +
28 + * If order within the original `coll` is important, then look at
29 + * [`detectSeries`]{@link module:Collections.detectSeries}.
30 + *
31 + * @name detect
32 + * @static
33 + * @memberOf module:Collections
34 + * @method
35 + * @alias find
36 + * @category Collections
37 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
38 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
39 + * The iteratee must complete with a boolean value as its result.
40 + * Invoked with (item, callback).
41 + * @param {Function} [callback] - A callback which is called as soon as any
42 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
43 + * Result will be the first item in the array that passes the truth test
44 + * (iteratee) or the value `undefined` if none passed. Invoked with
45 + * (err, result).
46 + * @returns A Promise, if no callback is passed
47 + * @example
48 + *
49 + * // dir1 is a directory that contains file1.txt, file2.txt
50 + * // dir2 is a directory that contains file3.txt, file4.txt
51 + * // dir3 is a directory that contains file5.txt
52 + *
53 + * // asynchronous function that checks if a file exists
54 + * function fileExists(file, callback) {
55 + * fs.access(file, fs.constants.F_OK, (err) => {
56 + * callback(null, !err);
57 + * });
58 + * }
59 + *
60 + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists,
61 + * function(err, result) {
62 + * console.log(result);
63 + * // dir1/file1.txt
64 + * // result now equals the first file in the list that exists
65 + * }
66 + *);
67 + *
68 + * // Using Promises
69 + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists)
70 + * .then(result => {
71 + * console.log(result);
72 + * // dir1/file1.txt
73 + * // result now equals the first file in the list that exists
74 + * }).catch(err => {
75 + * console.log(err);
76 + * });
77 + *
78 + * // Using async/await
79 + * async () => {
80 + * try {
81 + * let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists);
82 + * console.log(result);
83 + * // dir1/file1.txt
84 + * // result now equals the file in the list that exists
85 + * }
86 + * catch (err) {
87 + * console.log(err);
88 + * }
89 + * }
90 + *
91 + */
92 +function detect(coll, iteratee, callback) {
93 + return (0, _createTester2.default)(bool => bool, (res, item) => item)(_eachOf2.default, coll, iteratee, callback);
94 +}
95 +exports.default = (0, _awaitify2.default)(detect, 3);
96 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester.js');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit.js');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify.js');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name detectLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.detect]{@link module:Collections.detect}
30 + * @alias findLimit
31 + * @category Collections
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
35 + * The iteratee must complete with a boolean value as its result.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
39 + * Result will be the first item in the array that passes the truth test
40 + * (iteratee) or the value `undefined` if none passed. Invoked with
41 + * (err, result).
42 + * @returns a Promise if no callback is passed
43 + */
44 +function detectLimit(coll, limit, iteratee, callback) {
45 + return (0, _createTester2.default)(bool => bool, (res, item) => item)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
46 +}
47 +exports.default = (0, _awaitify2.default)(detectLimit, 4);
48 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.