강현태

add crawler

Showing 1000 changed files with 4783 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

This diff is collapsed. Click to expand it.
...@@ -9,6 +9,11 @@ var index = require('./routes/index'); ...@@ -9,6 +9,11 @@ var index = require('./routes/index');
9 var users = require('./routes/users'); 9 var users = require('./routes/users');
10 10
11 var app = express(); 11 var app = express();
12 +var crawler = require('./controllers/webtoon_crawler');
13 +//크롤러
14 +var myCrawler = new crawler();
15 +myCrawler.run();
16 +
12 17
13 // view engine setup 18 // view engine setup
14 app.set('views', path.join(__dirname, 'views')); 19 app.set('views', path.join(__dirname, 'views'));
......
1 +try {
2 + var Spooky = require('spooky');
3 +} catch (e) {
4 + var Spooky = require('../lib/spooky');
5 +}
6 +
7 +function crawler() {
8 + this.webtoonList = new Array();
9 + this.run = run;
10 +}
11 +
12 +
13 +function getEpisodeList(webtoonNum) {
14 + //spooky를 만든다
15 + var spooky = new Spooky({
16 + child: {
17 + transport: 'http'
18 + },
19 + casper: {
20 + logLevel: 'debug',
21 + verbose: true
22 + }
23 + }, function (err) {
24 + if (err) {
25 + e = new Error('Failed to initialize SpookyJS');
26 + e.details = err;
27 + throw e;
28 + }
29 +
30 + spooky.start("http://comic.naver.com/webtoon/list.nhn?titleId=650305");
31 + spooky.then(function () {
32 + var content = function() {
33 + var contentsList = new Array();
34 + var titleList = new Array();
35 + var list = document.querySelectorAll('#content > table > tbody > tr');
36 + for (i = 0; i < list.length; i++) {
37 + tmp = list[i].querySelectorAll('td.title');
38 + for(j=0;j<tmp.length;j++){
39 + titleList.push(tmp[j].innerText);
40 + }
41 + //contentsList.push(list[i].querySelectorAll('td').innerText)
42 + }
43 + return titleList;
44 + }
45 + this.emit('list',this.evaluate(content));
46 + //#content > table > tbody
47 + });
48 + spooky.run();
49 + });
50 +
51 + spooky.on('title',function (title) {
52 + console.log('TITLE : ' + title);
53 + })
54 +
55 + spooky.on('list',function (titleList) {
56 + for(i=0;i<titleList.length;i++){
57 + console.log('-'+titleList[i]);
58 + }
59 + webtoonList.length=0;
60 + webtoonList=titleList;
61 + })
62 +
63 + spooky.on('console', function (line) {
64 + console.log(line);
65 + });
66 +
67 + spooky.on('error', function (e, stack) {
68 + console.error(e);
69 +
70 + if (stack) {
71 + console.log(stack);
72 + }
73 + });
74 +}
75 +
76 +function run() {
77 + //getEpisodeList();
78 + setTimeout(getEpisodeList,5000);
79 +}
80 +
81 +module.exports = crawler;
82 +
1 +../casperjs/bin/casperjs
...\ No newline at end of file ...\ No newline at end of file
1 +../extract-zip/cli.js
...\ No newline at end of file ...\ No newline at end of file
1 +../har-validator/bin/har-validator
...\ No newline at end of file ...\ No newline at end of file
1 +../mkdirp/bin/cmd.js
...\ No newline at end of file ...\ No newline at end of file
1 +../phantomjs/bin/phantomjs
...\ No newline at end of file ...\ No newline at end of file
1 +../rimraf/bin.js
...\ No newline at end of file ...\ No newline at end of file
1 +../sshpk/bin/sshpk-conv
...\ No newline at end of file ...\ No newline at end of file
1 +../sshpk/bin/sshpk-sign
...\ No newline at end of file ...\ No newline at end of file
1 +../sshpk/bin/sshpk-verify
...\ No newline at end of file ...\ No newline at end of file
1 +../node-uuid/bin/uuid
...\ No newline at end of file ...\ No newline at end of file
1 +../which/bin/which
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +module.exports = function () {
3 + return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g;
4 +};
1 +The MIT License (MIT)
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
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 +{
2 + "_args": [
3 + [
4 + {
5 + "raw": "ansi-regex@^2.0.0",
6 + "scope": null,
7 + "escapedName": "ansi-regex",
8 + "name": "ansi-regex",
9 + "rawSpec": "^2.0.0",
10 + "spec": ">=2.0.0 <3.0.0",
11 + "type": "range"
12 + },
13 + "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/has-ansi"
14 + ]
15 + ],
16 + "_from": "ansi-regex@>=2.0.0 <3.0.0",
17 + "_id": "ansi-regex@2.1.1",
18 + "_inCache": true,
19 + "_location": "/ansi-regex",
20 + "_nodeVersion": "0.10.32",
21 + "_npmOperationalInternal": {
22 + "host": "packages-18-east.internal.npmjs.com",
23 + "tmp": "tmp/ansi-regex-2.1.1.tgz_1484363378013_0.4482989883981645"
24 + },
25 + "_npmUser": {
26 + "name": "qix",
27 + "email": "i.am.qix@gmail.com"
28 + },
29 + "_npmVersion": "2.14.2",
30 + "_phantomChildren": {},
31 + "_requested": {
32 + "raw": "ansi-regex@^2.0.0",
33 + "scope": null,
34 + "escapedName": "ansi-regex",
35 + "name": "ansi-regex",
36 + "rawSpec": "^2.0.0",
37 + "spec": ">=2.0.0 <3.0.0",
38 + "type": "range"
39 + },
40 + "_requiredBy": [
41 + "/has-ansi",
42 + "/strip-ansi"
43 + ],
44 + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
45 + "_shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df",
46 + "_shrinkwrap": null,
47 + "_spec": "ansi-regex@^2.0.0",
48 + "_where": "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/has-ansi",
49 + "author": {
50 + "name": "Sindre Sorhus",
51 + "email": "sindresorhus@gmail.com",
52 + "url": "sindresorhus.com"
53 + },
54 + "bugs": {
55 + "url": "https://github.com/chalk/ansi-regex/issues"
56 + },
57 + "dependencies": {},
58 + "description": "Regular expression for matching ANSI escape codes",
59 + "devDependencies": {
60 + "ava": "0.17.0",
61 + "xo": "0.16.0"
62 + },
63 + "directories": {},
64 + "dist": {
65 + "shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df",
66 + "tarball": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz"
67 + },
68 + "engines": {
69 + "node": ">=0.10.0"
70 + },
71 + "files": [
72 + "index.js"
73 + ],
74 + "gitHead": "7c908e7b4eb6cd82bfe1295e33fdf6d166c7ed85",
75 + "homepage": "https://github.com/chalk/ansi-regex#readme",
76 + "keywords": [
77 + "ansi",
78 + "styles",
79 + "color",
80 + "colour",
81 + "colors",
82 + "terminal",
83 + "console",
84 + "cli",
85 + "string",
86 + "tty",
87 + "escape",
88 + "formatting",
89 + "rgb",
90 + "256",
91 + "shell",
92 + "xterm",
93 + "command-line",
94 + "text",
95 + "regex",
96 + "regexp",
97 + "re",
98 + "match",
99 + "test",
100 + "find",
101 + "pattern"
102 + ],
103 + "license": "MIT",
104 + "maintainers": [
105 + {
106 + "name": "qix",
107 + "email": "i.am.qix@gmail.com"
108 + },
109 + {
110 + "name": "sindresorhus",
111 + "email": "sindresorhus@gmail.com"
112 + }
113 + ],
114 + "name": "ansi-regex",
115 + "optionalDependencies": {},
116 + "readme": "ERROR: No README data found!",
117 + "repository": {
118 + "type": "git",
119 + "url": "git+https://github.com/chalk/ansi-regex.git"
120 + },
121 + "scripts": {
122 + "test": "xo && ava --verbose",
123 + "view-supported": "node fixtures/view-codes.js"
124 + },
125 + "version": "2.1.1",
126 + "xo": {
127 + "rules": {
128 + "guard-for-in": 0,
129 + "no-loop-func": 0
130 + }
131 + }
132 +}
1 +# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
2 +
3 +> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
4 +
5 +
6 +## Install
7 +
8 +```
9 +$ npm install --save ansi-regex
10 +```
11 +
12 +
13 +## Usage
14 +
15 +```js
16 +const ansiRegex = require('ansi-regex');
17 +
18 +ansiRegex().test('\u001b[4mcake\u001b[0m');
19 +//=> true
20 +
21 +ansiRegex().test('cake');
22 +//=> false
23 +
24 +'\u001b[4mcake\u001b[0m'.match(ansiRegex());
25 +//=> ['\u001b[4m', '\u001b[0m']
26 +```
27 +
28 +## FAQ
29 +
30 +### Why do you test for codes not in the ECMA 48 standard?
31 +
32 +Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, we test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
33 +
34 +On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
35 +
36 +
37 +## License
38 +
39 +MIT © [Sindre Sorhus](http://sindresorhus.com)
1 +'use strict';
2 +
3 +function assembleStyles () {
4 + var styles = {
5 + modifiers: {
6 + reset: [0, 0],
7 + bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
8 + dim: [2, 22],
9 + italic: [3, 23],
10 + underline: [4, 24],
11 + inverse: [7, 27],
12 + hidden: [8, 28],
13 + strikethrough: [9, 29]
14 + },
15 + colors: {
16 + black: [30, 39],
17 + red: [31, 39],
18 + green: [32, 39],
19 + yellow: [33, 39],
20 + blue: [34, 39],
21 + magenta: [35, 39],
22 + cyan: [36, 39],
23 + white: [37, 39],
24 + gray: [90, 39]
25 + },
26 + bgColors: {
27 + bgBlack: [40, 49],
28 + bgRed: [41, 49],
29 + bgGreen: [42, 49],
30 + bgYellow: [43, 49],
31 + bgBlue: [44, 49],
32 + bgMagenta: [45, 49],
33 + bgCyan: [46, 49],
34 + bgWhite: [47, 49]
35 + }
36 + };
37 +
38 + // fix humans
39 + styles.colors.grey = styles.colors.gray;
40 +
41 + Object.keys(styles).forEach(function (groupName) {
42 + var group = styles[groupName];
43 +
44 + Object.keys(group).forEach(function (styleName) {
45 + var style = group[styleName];
46 +
47 + styles[styleName] = group[styleName] = {
48 + open: '\u001b[' + style[0] + 'm',
49 + close: '\u001b[' + style[1] + 'm'
50 + };
51 + });
52 +
53 + Object.defineProperty(styles, groupName, {
54 + value: group,
55 + enumerable: false
56 + });
57 + });
58 +
59 + return styles;
60 +}
61 +
62 +Object.defineProperty(module, 'exports', {
63 + enumerable: true,
64 + get: assembleStyles
65 +});
1 +The MIT License (MIT)
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
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 +{
2 + "_args": [
3 + [
4 + {
5 + "raw": "ansi-styles@^2.2.1",
6 + "scope": null,
7 + "escapedName": "ansi-styles",
8 + "name": "ansi-styles",
9 + "rawSpec": "^2.2.1",
10 + "spec": ">=2.2.1 <3.0.0",
11 + "type": "range"
12 + },
13 + "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/chalk"
14 + ]
15 + ],
16 + "_from": "ansi-styles@>=2.2.1 <3.0.0",
17 + "_id": "ansi-styles@2.2.1",
18 + "_inCache": true,
19 + "_location": "/ansi-styles",
20 + "_nodeVersion": "4.3.0",
21 + "_npmOperationalInternal": {
22 + "host": "packages-12-west.internal.npmjs.com",
23 + "tmp": "tmp/ansi-styles-2.2.1.tgz_1459197317833_0.9694824463222176"
24 + },
25 + "_npmUser": {
26 + "name": "sindresorhus",
27 + "email": "sindresorhus@gmail.com"
28 + },
29 + "_npmVersion": "3.8.3",
30 + "_phantomChildren": {},
31 + "_requested": {
32 + "raw": "ansi-styles@^2.2.1",
33 + "scope": null,
34 + "escapedName": "ansi-styles",
35 + "name": "ansi-styles",
36 + "rawSpec": "^2.2.1",
37 + "spec": ">=2.2.1 <3.0.0",
38 + "type": "range"
39 + },
40 + "_requiredBy": [
41 + "/chalk"
42 + ],
43 + "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
44 + "_shasum": "b432dd3358b634cf75e1e4664368240533c1ddbe",
45 + "_shrinkwrap": null,
46 + "_spec": "ansi-styles@^2.2.1",
47 + "_where": "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/chalk",
48 + "author": {
49 + "name": "Sindre Sorhus",
50 + "email": "sindresorhus@gmail.com",
51 + "url": "sindresorhus.com"
52 + },
53 + "bugs": {
54 + "url": "https://github.com/chalk/ansi-styles/issues"
55 + },
56 + "dependencies": {},
57 + "description": "ANSI escape codes for styling strings in the terminal",
58 + "devDependencies": {
59 + "mocha": "*"
60 + },
61 + "directories": {},
62 + "dist": {
63 + "shasum": "b432dd3358b634cf75e1e4664368240533c1ddbe",
64 + "tarball": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz"
65 + },
66 + "engines": {
67 + "node": ">=0.10.0"
68 + },
69 + "files": [
70 + "index.js"
71 + ],
72 + "gitHead": "95c59b23be760108b6530ca1c89477c21b258032",
73 + "homepage": "https://github.com/chalk/ansi-styles#readme",
74 + "keywords": [
75 + "ansi",
76 + "styles",
77 + "color",
78 + "colour",
79 + "colors",
80 + "terminal",
81 + "console",
82 + "cli",
83 + "string",
84 + "tty",
85 + "escape",
86 + "formatting",
87 + "rgb",
88 + "256",
89 + "shell",
90 + "xterm",
91 + "log",
92 + "logging",
93 + "command-line",
94 + "text"
95 + ],
96 + "license": "MIT",
97 + "maintainers": [
98 + {
99 + "name": "sindresorhus",
100 + "email": "sindresorhus@gmail.com"
101 + }
102 + ],
103 + "name": "ansi-styles",
104 + "optionalDependencies": {},
105 + "readme": "ERROR: No README data found!",
106 + "repository": {
107 + "type": "git",
108 + "url": "git+https://github.com/chalk/ansi-styles.git"
109 + },
110 + "scripts": {
111 + "test": "mocha"
112 + },
113 + "version": "2.2.1"
114 +}
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](http://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 +![](screenshot.png)
8 +
9 +
10 +## Install
11 +
12 +```
13 +$ npm install --save ansi-styles
14 +```
15 +
16 +
17 +## Usage
18 +
19 +```js
20 +var ansi = require('ansi-styles');
21 +
22 +console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
23 +```
24 +
25 +
26 +## API
27 +
28 +Each style has an `open` and `close` property.
29 +
30 +
31 +## Styles
32 +
33 +### Modifiers
34 +
35 +- `reset`
36 +- `bold`
37 +- `dim`
38 +- `italic` *(not widely supported)*
39 +- `underline`
40 +- `inverse`
41 +- `hidden`
42 +- `strikethrough` *(not widely supported)*
43 +
44 +### Colors
45 +
46 +- `black`
47 +- `red`
48 +- `green`
49 +- `yellow`
50 +- `blue`
51 +- `magenta`
52 +- `cyan`
53 +- `white`
54 +- `gray`
55 +
56 +### Background colors
57 +
58 +- `bgBlack`
59 +- `bgRed`
60 +- `bgGreen`
61 +- `bgYellow`
62 +- `bgBlue`
63 +- `bgMagenta`
64 +- `bgCyan`
65 +- `bgWhite`
66 +
67 +
68 +## Advanced usage
69 +
70 +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.
71 +
72 +- `ansi.modifiers`
73 +- `ansi.colors`
74 +- `ansi.bgColors`
75 +
76 +
77 +###### Example
78 +
79 +```js
80 +console.log(ansi.colors.green.open);
81 +```
82 +
83 +
84 +## License
85 +
86 +MIT © [Sindre Sorhus](http://sindresorhus.com)
1 +node_modules
2 +*.log
1 +language: node_js
2 +node_js:
3 + - 0.8
4 + - 0.10
1 +Copyright (c) 2011 Mark Cavage, All rights reserved.
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 +node-asn1 is a library for encoding and decoding ASN.1 datatypes in pure JS.
2 +Currently BER encoding is supported; at some point I'll likely have to do DER.
3 +
4 +## Usage
5 +
6 +Mostly, if you're *actually* needing to read and write ASN.1, you probably don't
7 +need this readme to explain what and why. If you have no idea what ASN.1 is,
8 +see this: ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
9 +
10 +The source is pretty much self-explanatory, and has read/write methods for the
11 +common types out there.
12 +
13 +### Decoding
14 +
15 +The following reads an ASN.1 sequence with a boolean.
16 +
17 + var Ber = require('asn1').Ber;
18 +
19 + var reader = new Ber.Reader(new Buffer([0x30, 0x03, 0x01, 0x01, 0xff]));
20 +
21 + reader.readSequence();
22 + console.log('Sequence len: ' + reader.length);
23 + if (reader.peek() === Ber.Boolean)
24 + console.log(reader.readBoolean());
25 +
26 +### Encoding
27 +
28 +The following generates the same payload as above.
29 +
30 + var Ber = require('asn1').Ber;
31 +
32 + var writer = new Ber.Writer();
33 +
34 + writer.startSequence();
35 + writer.writeBoolean(true);
36 + writer.endSequence();
37 +
38 + console.log(writer.buffer);
39 +
40 +## Installation
41 +
42 + npm install asn1
43 +
44 +## License
45 +
46 +MIT.
47 +
48 +## Bugs
49 +
50 +See <https://github.com/mcavage/node-asn1/issues>.
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +
4 +module.exports = {
5 +
6 + newInvalidAsn1Error: function(msg) {
7 + var e = new Error();
8 + e.name = 'InvalidAsn1Error';
9 + e.message = msg || '';
10 + return e;
11 + }
12 +
13 +};
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +var errors = require('./errors');
4 +var types = require('./types');
5 +
6 +var Reader = require('./reader');
7 +var Writer = require('./writer');
8 +
9 +
10 +///--- Exports
11 +
12 +module.exports = {
13 +
14 + Reader: Reader,
15 +
16 + Writer: Writer
17 +
18 +};
19 +
20 +for (var t in types) {
21 + if (types.hasOwnProperty(t))
22 + module.exports[t] = types[t];
23 +}
24 +for (var e in errors) {
25 + if (errors.hasOwnProperty(e))
26 + module.exports[e] = errors[e];
27 +}
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +var assert = require('assert');
4 +
5 +var ASN1 = require('./types');
6 +var errors = require('./errors');
7 +
8 +
9 +///--- Globals
10 +
11 +var newInvalidAsn1Error = errors.newInvalidAsn1Error;
12 +
13 +
14 +
15 +///--- API
16 +
17 +function Reader(data) {
18 + if (!data || !Buffer.isBuffer(data))
19 + throw new TypeError('data must be a node Buffer');
20 +
21 + this._buf = data;
22 + this._size = data.length;
23 +
24 + // These hold the "current" state
25 + this._len = 0;
26 + this._offset = 0;
27 +}
28 +
29 +Object.defineProperty(Reader.prototype, 'length', {
30 + enumerable: true,
31 + get: function () { return (this._len); }
32 +});
33 +
34 +Object.defineProperty(Reader.prototype, 'offset', {
35 + enumerable: true,
36 + get: function () { return (this._offset); }
37 +});
38 +
39 +Object.defineProperty(Reader.prototype, 'remain', {
40 + get: function () { return (this._size - this._offset); }
41 +});
42 +
43 +Object.defineProperty(Reader.prototype, 'buffer', {
44 + get: function () { return (this._buf.slice(this._offset)); }
45 +});
46 +
47 +
48 +/**
49 + * Reads a single byte and advances offset; you can pass in `true` to make this
50 + * a "peek" operation (i.e., get the byte, but don't advance the offset).
51 + *
52 + * @param {Boolean} peek true means don't move offset.
53 + * @return {Number} the next byte, null if not enough data.
54 + */
55 +Reader.prototype.readByte = function(peek) {
56 + if (this._size - this._offset < 1)
57 + return null;
58 +
59 + var b = this._buf[this._offset] & 0xff;
60 +
61 + if (!peek)
62 + this._offset += 1;
63 +
64 + return b;
65 +};
66 +
67 +
68 +Reader.prototype.peek = function() {
69 + return this.readByte(true);
70 +};
71 +
72 +
73 +/**
74 + * Reads a (potentially) variable length off the BER buffer. This call is
75 + * not really meant to be called directly, as callers have to manipulate
76 + * the internal buffer afterwards.
77 + *
78 + * As a result of this call, you can call `Reader.length`, until the
79 + * next thing called that does a readLength.
80 + *
81 + * @return {Number} the amount of offset to advance the buffer.
82 + * @throws {InvalidAsn1Error} on bad ASN.1
83 + */
84 +Reader.prototype.readLength = function(offset) {
85 + if (offset === undefined)
86 + offset = this._offset;
87 +
88 + if (offset >= this._size)
89 + return null;
90 +
91 + var lenB = this._buf[offset++] & 0xff;
92 + if (lenB === null)
93 + return null;
94 +
95 + if ((lenB & 0x80) == 0x80) {
96 + lenB &= 0x7f;
97 +
98 + if (lenB == 0)
99 + throw newInvalidAsn1Error('Indefinite length not supported');
100 +
101 + if (lenB > 4)
102 + throw newInvalidAsn1Error('encoding too long');
103 +
104 + if (this._size - offset < lenB)
105 + return null;
106 +
107 + this._len = 0;
108 + for (var i = 0; i < lenB; i++)
109 + this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
110 +
111 + } else {
112 + // Wasn't a variable length
113 + this._len = lenB;
114 + }
115 +
116 + return offset;
117 +};
118 +
119 +
120 +/**
121 + * Parses the next sequence in this BER buffer.
122 + *
123 + * To get the length of the sequence, call `Reader.length`.
124 + *
125 + * @return {Number} the sequence's tag.
126 + */
127 +Reader.prototype.readSequence = function(tag) {
128 + var seq = this.peek();
129 + if (seq === null)
130 + return null;
131 + if (tag !== undefined && tag !== seq)
132 + throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
133 + ': got 0x' + seq.toString(16));
134 +
135 + var o = this.readLength(this._offset + 1); // stored in `length`
136 + if (o === null)
137 + return null;
138 +
139 + this._offset = o;
140 + return seq;
141 +};
142 +
143 +
144 +Reader.prototype.readInt = function() {
145 + return this._readTag(ASN1.Integer);
146 +};
147 +
148 +
149 +Reader.prototype.readBoolean = function() {
150 + return (this._readTag(ASN1.Boolean) === 0 ? false : true);
151 +};
152 +
153 +
154 +Reader.prototype.readEnumeration = function() {
155 + return this._readTag(ASN1.Enumeration);
156 +};
157 +
158 +
159 +Reader.prototype.readString = function(tag, retbuf) {
160 + if (!tag)
161 + tag = ASN1.OctetString;
162 +
163 + var b = this.peek();
164 + if (b === null)
165 + return null;
166 +
167 + if (b !== tag)
168 + throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
169 + ': got 0x' + b.toString(16));
170 +
171 + var o = this.readLength(this._offset + 1); // stored in `length`
172 +
173 + if (o === null)
174 + return null;
175 +
176 + if (this.length > this._size - o)
177 + return null;
178 +
179 + this._offset = o;
180 +
181 + if (this.length === 0)
182 + return retbuf ? new Buffer(0) : '';
183 +
184 + var str = this._buf.slice(this._offset, this._offset + this.length);
185 + this._offset += this.length;
186 +
187 + return retbuf ? str : str.toString('utf8');
188 +};
189 +
190 +Reader.prototype.readOID = function(tag) {
191 + if (!tag)
192 + tag = ASN1.OID;
193 +
194 + var b = this.readString(tag, true);
195 + if (b === null)
196 + return null;
197 +
198 + var values = [];
199 + var value = 0;
200 +
201 + for (var i = 0; i < b.length; i++) {
202 + var byte = b[i] & 0xff;
203 +
204 + value <<= 7;
205 + value += byte & 0x7f;
206 + if ((byte & 0x80) == 0) {
207 + values.push(value);
208 + value = 0;
209 + }
210 + }
211 +
212 + value = values.shift();
213 + values.unshift(value % 40);
214 + values.unshift((value / 40) >> 0);
215 +
216 + return values.join('.');
217 +};
218 +
219 +
220 +Reader.prototype._readTag = function(tag) {
221 + assert.ok(tag !== undefined);
222 +
223 + var b = this.peek();
224 +
225 + if (b === null)
226 + return null;
227 +
228 + if (b !== tag)
229 + throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
230 + ': got 0x' + b.toString(16));
231 +
232 + var o = this.readLength(this._offset + 1); // stored in `length`
233 + if (o === null)
234 + return null;
235 +
236 + if (this.length > 4)
237 + throw newInvalidAsn1Error('Integer too long: ' + this.length);
238 +
239 + if (this.length > this._size - o)
240 + return null;
241 + this._offset = o;
242 +
243 + var fb = this._buf[this._offset];
244 + var value = 0;
245 +
246 + for (var i = 0; i < this.length; i++) {
247 + value <<= 8;
248 + value |= (this._buf[this._offset++] & 0xff);
249 + }
250 +
251 + if ((fb & 0x80) == 0x80 && i !== 4)
252 + value -= (1 << (i * 8));
253 +
254 + return value >> 0;
255 +};
256 +
257 +
258 +
259 +///--- Exported API
260 +
261 +module.exports = Reader;
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +
4 +module.exports = {
5 + EOC: 0,
6 + Boolean: 1,
7 + Integer: 2,
8 + BitString: 3,
9 + OctetString: 4,
10 + Null: 5,
11 + OID: 6,
12 + ObjectDescriptor: 7,
13 + External: 8,
14 + Real: 9, // float
15 + Enumeration: 10,
16 + PDV: 11,
17 + Utf8String: 12,
18 + RelativeOID: 13,
19 + Sequence: 16,
20 + Set: 17,
21 + NumericString: 18,
22 + PrintableString: 19,
23 + T61String: 20,
24 + VideotexString: 21,
25 + IA5String: 22,
26 + UTCTime: 23,
27 + GeneralizedTime: 24,
28 + GraphicString: 25,
29 + VisibleString: 26,
30 + GeneralString: 28,
31 + UniversalString: 29,
32 + CharacterString: 30,
33 + BMPString: 31,
34 + Constructor: 32,
35 + Context: 128
36 +};
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +var assert = require('assert');
4 +var ASN1 = require('./types');
5 +var errors = require('./errors');
6 +
7 +
8 +///--- Globals
9 +
10 +var newInvalidAsn1Error = errors.newInvalidAsn1Error;
11 +
12 +var DEFAULT_OPTS = {
13 + size: 1024,
14 + growthFactor: 8
15 +};
16 +
17 +
18 +///--- Helpers
19 +
20 +function merge(from, to) {
21 + assert.ok(from);
22 + assert.equal(typeof(from), 'object');
23 + assert.ok(to);
24 + assert.equal(typeof(to), 'object');
25 +
26 + var keys = Object.getOwnPropertyNames(from);
27 + keys.forEach(function(key) {
28 + if (to[key])
29 + return;
30 +
31 + var value = Object.getOwnPropertyDescriptor(from, key);
32 + Object.defineProperty(to, key, value);
33 + });
34 +
35 + return to;
36 +}
37 +
38 +
39 +
40 +///--- API
41 +
42 +function Writer(options) {
43 + options = merge(DEFAULT_OPTS, options || {});
44 +
45 + this._buf = new Buffer(options.size || 1024);
46 + this._size = this._buf.length;
47 + this._offset = 0;
48 + this._options = options;
49 +
50 + // A list of offsets in the buffer where we need to insert
51 + // sequence tag/len pairs.
52 + this._seq = [];
53 +}
54 +
55 +Object.defineProperty(Writer.prototype, 'buffer', {
56 + get: function () {
57 + if (this._seq.length)
58 + throw new InvalidAsn1Error(this._seq.length + ' unended sequence(s)');
59 +
60 + return (this._buf.slice(0, this._offset));
61 + }
62 +});
63 +
64 +Writer.prototype.writeByte = function(b) {
65 + if (typeof(b) !== 'number')
66 + throw new TypeError('argument must be a Number');
67 +
68 + this._ensure(1);
69 + this._buf[this._offset++] = b;
70 +};
71 +
72 +
73 +Writer.prototype.writeInt = function(i, tag) {
74 + if (typeof(i) !== 'number')
75 + throw new TypeError('argument must be a Number');
76 + if (typeof(tag) !== 'number')
77 + tag = ASN1.Integer;
78 +
79 + var sz = 4;
80 +
81 + while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&
82 + (sz > 1)) {
83 + sz--;
84 + i <<= 8;
85 + }
86 +
87 + if (sz > 4)
88 + throw new InvalidAsn1Error('BER ints cannot be > 0xffffffff');
89 +
90 + this._ensure(2 + sz);
91 + this._buf[this._offset++] = tag;
92 + this._buf[this._offset++] = sz;
93 +
94 + while (sz-- > 0) {
95 + this._buf[this._offset++] = ((i & 0xff000000) >>> 24);
96 + i <<= 8;
97 + }
98 +
99 +};
100 +
101 +
102 +Writer.prototype.writeNull = function() {
103 + this.writeByte(ASN1.Null);
104 + this.writeByte(0x00);
105 +};
106 +
107 +
108 +Writer.prototype.writeEnumeration = function(i, tag) {
109 + if (typeof(i) !== 'number')
110 + throw new TypeError('argument must be a Number');
111 + if (typeof(tag) !== 'number')
112 + tag = ASN1.Enumeration;
113 +
114 + return this.writeInt(i, tag);
115 +};
116 +
117 +
118 +Writer.prototype.writeBoolean = function(b, tag) {
119 + if (typeof(b) !== 'boolean')
120 + throw new TypeError('argument must be a Boolean');
121 + if (typeof(tag) !== 'number')
122 + tag = ASN1.Boolean;
123 +
124 + this._ensure(3);
125 + this._buf[this._offset++] = tag;
126 + this._buf[this._offset++] = 0x01;
127 + this._buf[this._offset++] = b ? 0xff : 0x00;
128 +};
129 +
130 +
131 +Writer.prototype.writeString = function(s, tag) {
132 + if (typeof(s) !== 'string')
133 + throw new TypeError('argument must be a string (was: ' + typeof(s) + ')');
134 + if (typeof(tag) !== 'number')
135 + tag = ASN1.OctetString;
136 +
137 + var len = Buffer.byteLength(s);
138 + this.writeByte(tag);
139 + this.writeLength(len);
140 + if (len) {
141 + this._ensure(len);
142 + this._buf.write(s, this._offset);
143 + this._offset += len;
144 + }
145 +};
146 +
147 +
148 +Writer.prototype.writeBuffer = function(buf, tag) {
149 + if (typeof(tag) !== 'number')
150 + throw new TypeError('tag must be a number');
151 + if (!Buffer.isBuffer(buf))
152 + throw new TypeError('argument must be a buffer');
153 +
154 + this.writeByte(tag);
155 + this.writeLength(buf.length);
156 + this._ensure(buf.length);
157 + buf.copy(this._buf, this._offset, 0, buf.length);
158 + this._offset += buf.length;
159 +};
160 +
161 +
162 +Writer.prototype.writeStringArray = function(strings) {
163 + if ((!strings instanceof Array))
164 + throw new TypeError('argument must be an Array[String]');
165 +
166 + var self = this;
167 + strings.forEach(function(s) {
168 + self.writeString(s);
169 + });
170 +};
171 +
172 +// This is really to solve DER cases, but whatever for now
173 +Writer.prototype.writeOID = function(s, tag) {
174 + if (typeof(s) !== 'string')
175 + throw new TypeError('argument must be a string');
176 + if (typeof(tag) !== 'number')
177 + tag = ASN1.OID;
178 +
179 + if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
180 + throw new Error('argument is not a valid OID string');
181 +
182 + function encodeOctet(bytes, octet) {
183 + if (octet < 128) {
184 + bytes.push(octet);
185 + } else if (octet < 16384) {
186 + bytes.push((octet >>> 7) | 0x80);
187 + bytes.push(octet & 0x7F);
188 + } else if (octet < 2097152) {
189 + bytes.push((octet >>> 14) | 0x80);
190 + bytes.push(((octet >>> 7) | 0x80) & 0xFF);
191 + bytes.push(octet & 0x7F);
192 + } else if (octet < 268435456) {
193 + bytes.push((octet >>> 21) | 0x80);
194 + bytes.push(((octet >>> 14) | 0x80) & 0xFF);
195 + bytes.push(((octet >>> 7) | 0x80) & 0xFF);
196 + bytes.push(octet & 0x7F);
197 + } else {
198 + bytes.push(((octet >>> 28) | 0x80) & 0xFF);
199 + bytes.push(((octet >>> 21) | 0x80) & 0xFF);
200 + bytes.push(((octet >>> 14) | 0x80) & 0xFF);
201 + bytes.push(((octet >>> 7) | 0x80) & 0xFF);
202 + bytes.push(octet & 0x7F);
203 + }
204 + }
205 +
206 + var tmp = s.split('.');
207 + var bytes = [];
208 + bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
209 + tmp.slice(2).forEach(function(b) {
210 + encodeOctet(bytes, parseInt(b, 10));
211 + });
212 +
213 + var self = this;
214 + this._ensure(2 + bytes.length);
215 + this.writeByte(tag);
216 + this.writeLength(bytes.length);
217 + bytes.forEach(function(b) {
218 + self.writeByte(b);
219 + });
220 +};
221 +
222 +
223 +Writer.prototype.writeLength = function(len) {
224 + if (typeof(len) !== 'number')
225 + throw new TypeError('argument must be a Number');
226 +
227 + this._ensure(4);
228 +
229 + if (len <= 0x7f) {
230 + this._buf[this._offset++] = len;
231 + } else if (len <= 0xff) {
232 + this._buf[this._offset++] = 0x81;
233 + this._buf[this._offset++] = len;
234 + } else if (len <= 0xffff) {
235 + this._buf[this._offset++] = 0x82;
236 + this._buf[this._offset++] = len >> 8;
237 + this._buf[this._offset++] = len;
238 + } else if (len <= 0xffffff) {
239 + this._buf[this._offset++] = 0x83;
240 + this._buf[this._offset++] = len >> 16;
241 + this._buf[this._offset++] = len >> 8;
242 + this._buf[this._offset++] = len;
243 + } else {
244 + throw new InvalidAsn1ERror('Length too long (> 4 bytes)');
245 + }
246 +};
247 +
248 +Writer.prototype.startSequence = function(tag) {
249 + if (typeof(tag) !== 'number')
250 + tag = ASN1.Sequence | ASN1.Constructor;
251 +
252 + this.writeByte(tag);
253 + this._seq.push(this._offset);
254 + this._ensure(3);
255 + this._offset += 3;
256 +};
257 +
258 +
259 +Writer.prototype.endSequence = function() {
260 + var seq = this._seq.pop();
261 + var start = seq + 3;
262 + var len = this._offset - start;
263 +
264 + if (len <= 0x7f) {
265 + this._shift(start, len, -2);
266 + this._buf[seq] = len;
267 + } else if (len <= 0xff) {
268 + this._shift(start, len, -1);
269 + this._buf[seq] = 0x81;
270 + this._buf[seq + 1] = len;
271 + } else if (len <= 0xffff) {
272 + this._buf[seq] = 0x82;
273 + this._buf[seq + 1] = len >> 8;
274 + this._buf[seq + 2] = len;
275 + } else if (len <= 0xffffff) {
276 + this._shift(start, len, 1);
277 + this._buf[seq] = 0x83;
278 + this._buf[seq + 1] = len >> 16;
279 + this._buf[seq + 2] = len >> 8;
280 + this._buf[seq + 3] = len;
281 + } else {
282 + throw new InvalidAsn1Error('Sequence too long');
283 + }
284 +};
285 +
286 +
287 +Writer.prototype._shift = function(start, len, shift) {
288 + assert.ok(start !== undefined);
289 + assert.ok(len !== undefined);
290 + assert.ok(shift);
291 +
292 + this._buf.copy(this._buf, start + shift, start, start + len);
293 + this._offset += shift;
294 +};
295 +
296 +Writer.prototype._ensure = function(len) {
297 + assert.ok(len);
298 +
299 + if (this._size - this._offset < len) {
300 + var sz = this._size * this._options.growthFactor;
301 + if (sz - this._offset < len)
302 + sz += len;
303 +
304 + var buf = new Buffer(sz);
305 +
306 + this._buf.copy(buf, 0, 0, this._offset);
307 + this._buf = buf;
308 + this._size = sz;
309 + }
310 +};
311 +
312 +
313 +
314 +///--- Exported API
315 +
316 +module.exports = Writer;
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +// If you have no idea what ASN.1 or BER is, see this:
4 +// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
5 +
6 +var Ber = require('./ber/index');
7 +
8 +
9 +
10 +///--- Exported API
11 +
12 +module.exports = {
13 +
14 + Ber: Ber,
15 +
16 + BerReader: Ber.Reader,
17 +
18 + BerWriter: Ber.Writer
19 +
20 +};
1 +{
2 + "_args": [
3 + [
4 + {
5 + "raw": "asn1@~0.2.3",
6 + "scope": null,
7 + "escapedName": "asn1",
8 + "name": "asn1",
9 + "rawSpec": "~0.2.3",
10 + "spec": ">=0.2.3 <0.3.0",
11 + "type": "range"
12 + },
13 + "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/sshpk"
14 + ]
15 + ],
16 + "_from": "asn1@>=0.2.3 <0.3.0",
17 + "_id": "asn1@0.2.3",
18 + "_inCache": true,
19 + "_location": "/asn1",
20 + "_npmUser": {
21 + "name": "pfmooney",
22 + "email": "patrick.f.mooney@gmail.com"
23 + },
24 + "_npmVersion": "1.4.28",
25 + "_phantomChildren": {},
26 + "_requested": {
27 + "raw": "asn1@~0.2.3",
28 + "scope": null,
29 + "escapedName": "asn1",
30 + "name": "asn1",
31 + "rawSpec": "~0.2.3",
32 + "spec": ">=0.2.3 <0.3.0",
33 + "type": "range"
34 + },
35 + "_requiredBy": [
36 + "/sshpk"
37 + ],
38 + "_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
39 + "_shasum": "dac8787713c9966849fc8180777ebe9c1ddf3b86",
40 + "_shrinkwrap": null,
41 + "_spec": "asn1@~0.2.3",
42 + "_where": "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/sshpk",
43 + "author": {
44 + "name": "Mark Cavage",
45 + "email": "mcavage@gmail.com"
46 + },
47 + "bugs": {
48 + "url": "https://github.com/mcavage/node-asn1/issues"
49 + },
50 + "contributors": [
51 + {
52 + "name": "David Gwynne",
53 + "email": "loki@animata.net"
54 + },
55 + {
56 + "name": "Yunong Xiao",
57 + "email": "yunong@joyent.com"
58 + },
59 + {
60 + "name": "Alex Wilson",
61 + "email": "alex.wilson@joyent.com"
62 + }
63 + ],
64 + "dependencies": {},
65 + "description": "Contains parsers and serializers for ASN.1 (currently BER only)",
66 + "devDependencies": {
67 + "tap": "0.4.8"
68 + },
69 + "directories": {},
70 + "dist": {
71 + "shasum": "dac8787713c9966849fc8180777ebe9c1ddf3b86",
72 + "tarball": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz"
73 + },
74 + "homepage": "https://github.com/mcavage/node-asn1",
75 + "license": "MIT",
76 + "main": "lib/index.js",
77 + "maintainers": [
78 + {
79 + "name": "mcavage",
80 + "email": "mcavage@gmail.com"
81 + },
82 + {
83 + "name": "pfmooney",
84 + "email": "patrick.f.mooney@gmail.com"
85 + }
86 + ],
87 + "name": "asn1",
88 + "optionalDependencies": {},
89 + "readme": "ERROR: No README data found!",
90 + "repository": {
91 + "type": "git",
92 + "url": "git://github.com/mcavage/node-asn1.git"
93 + },
94 + "scripts": {
95 + "test": "tap ./tst"
96 + },
97 + "version": "0.2.3"
98 +}
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +var test = require('tap').test;
4 +
5 +
6 +
7 +///--- Globals
8 +
9 +var BerReader;
10 +
11 +
12 +
13 +///--- Tests
14 +
15 +test('load library', function(t) {
16 + BerReader = require('../../lib/index').BerReader;
17 + t.ok(BerReader);
18 + try {
19 + new BerReader();
20 + t.fail('Should have thrown');
21 + } catch (e) {
22 + t.ok(e instanceof TypeError, 'Should have been a type error');
23 + }
24 + t.end();
25 +});
26 +
27 +
28 +test('read byte', function(t) {
29 + var reader = new BerReader(new Buffer([0xde]));
30 + t.ok(reader);
31 + t.equal(reader.readByte(), 0xde, 'wrong value');
32 + t.end();
33 +});
34 +
35 +
36 +test('read 1 byte int', function(t) {
37 + var reader = new BerReader(new Buffer([0x02, 0x01, 0x03]));
38 + t.ok(reader);
39 + t.equal(reader.readInt(), 0x03, 'wrong value');
40 + t.equal(reader.length, 0x01, 'wrong length');
41 + t.end();
42 +});
43 +
44 +
45 +test('read 2 byte int', function(t) {
46 + var reader = new BerReader(new Buffer([0x02, 0x02, 0x7e, 0xde]));
47 + t.ok(reader);
48 + t.equal(reader.readInt(), 0x7ede, 'wrong value');
49 + t.equal(reader.length, 0x02, 'wrong length');
50 + t.end();
51 +});
52 +
53 +
54 +test('read 3 byte int', function(t) {
55 + var reader = new BerReader(new Buffer([0x02, 0x03, 0x7e, 0xde, 0x03]));
56 + t.ok(reader);
57 + t.equal(reader.readInt(), 0x7ede03, 'wrong value');
58 + t.equal(reader.length, 0x03, 'wrong length');
59 + t.end();
60 +});
61 +
62 +
63 +test('read 4 byte int', function(t) {
64 + var reader = new BerReader(new Buffer([0x02, 0x04, 0x7e, 0xde, 0x03, 0x01]));
65 + t.ok(reader);
66 + t.equal(reader.readInt(), 0x7ede0301, 'wrong value');
67 + t.equal(reader.length, 0x04, 'wrong length');
68 + t.end();
69 +});
70 +
71 +
72 +test('read 1 byte negative int', function(t) {
73 + var reader = new BerReader(new Buffer([0x02, 0x01, 0xdc]));
74 + t.ok(reader);
75 + t.equal(reader.readInt(), -36, 'wrong value');
76 + t.equal(reader.length, 0x01, 'wrong length');
77 + t.end();
78 +});
79 +
80 +
81 +test('read 2 byte negative int', function(t) {
82 + var reader = new BerReader(new Buffer([0x02, 0x02, 0xc0, 0x4e]));
83 + t.ok(reader);
84 + t.equal(reader.readInt(), -16306, 'wrong value');
85 + t.equal(reader.length, 0x02, 'wrong length');
86 + t.end();
87 +});
88 +
89 +
90 +test('read 3 byte negative int', function(t) {
91 + var reader = new BerReader(new Buffer([0x02, 0x03, 0xff, 0x00, 0x19]));
92 + t.ok(reader);
93 + t.equal(reader.readInt(), -65511, 'wrong value');
94 + t.equal(reader.length, 0x03, 'wrong length');
95 + t.end();
96 +});
97 +
98 +
99 +test('read 4 byte negative int', function(t) {
100 + var reader = new BerReader(new Buffer([0x02, 0x04, 0x91, 0x7c, 0x22, 0x1f]));
101 + t.ok(reader);
102 + t.equal(reader.readInt(), -1854135777, 'wrong value');
103 + t.equal(reader.length, 0x04, 'wrong length');
104 + t.end();
105 +});
106 +
107 +
108 +test('read boolean true', function(t) {
109 + var reader = new BerReader(new Buffer([0x01, 0x01, 0xff]));
110 + t.ok(reader);
111 + t.equal(reader.readBoolean(), true, 'wrong value');
112 + t.equal(reader.length, 0x01, 'wrong length');
113 + t.end();
114 +});
115 +
116 +
117 +test('read boolean false', function(t) {
118 + var reader = new BerReader(new Buffer([0x01, 0x01, 0x00]));
119 + t.ok(reader);
120 + t.equal(reader.readBoolean(), false, 'wrong value');
121 + t.equal(reader.length, 0x01, 'wrong length');
122 + t.end();
123 +});
124 +
125 +
126 +test('read enumeration', function(t) {
127 + var reader = new BerReader(new Buffer([0x0a, 0x01, 0x20]));
128 + t.ok(reader);
129 + t.equal(reader.readEnumeration(), 0x20, 'wrong value');
130 + t.equal(reader.length, 0x01, 'wrong length');
131 + t.end();
132 +});
133 +
134 +
135 +test('read string', function(t) {
136 + var dn = 'cn=foo,ou=unit,o=test';
137 + var buf = new Buffer(dn.length + 2);
138 + buf[0] = 0x04;
139 + buf[1] = Buffer.byteLength(dn);
140 + buf.write(dn, 2);
141 + var reader = new BerReader(buf);
142 + t.ok(reader);
143 + t.equal(reader.readString(), dn, 'wrong value');
144 + t.equal(reader.length, dn.length, 'wrong length');
145 + t.end();
146 +});
147 +
148 +
149 +test('read sequence', function(t) {
150 + var reader = new BerReader(new Buffer([0x30, 0x03, 0x01, 0x01, 0xff]));
151 + t.ok(reader);
152 + t.equal(reader.readSequence(), 0x30, 'wrong value');
153 + t.equal(reader.length, 0x03, 'wrong length');
154 + t.equal(reader.readBoolean(), true, 'wrong value');
155 + t.equal(reader.length, 0x01, 'wrong length');
156 + t.end();
157 +});
158 +
159 +
160 +test('anonymous LDAPv3 bind', function(t) {
161 + var BIND = new Buffer(14);
162 + BIND[0] = 0x30; // Sequence
163 + BIND[1] = 12; // len
164 + BIND[2] = 0x02; // ASN.1 Integer
165 + BIND[3] = 1; // len
166 + BIND[4] = 0x04; // msgid (make up 4)
167 + BIND[5] = 0x60; // Bind Request
168 + BIND[6] = 7; // len
169 + BIND[7] = 0x02; // ASN.1 Integer
170 + BIND[8] = 1; // len
171 + BIND[9] = 0x03; // v3
172 + BIND[10] = 0x04; // String (bind dn)
173 + BIND[11] = 0; // len
174 + BIND[12] = 0x80; // ContextSpecific (choice)
175 + BIND[13] = 0; // simple bind
176 +
177 + // Start testing ^^
178 + var ber = new BerReader(BIND);
179 + t.equal(ber.readSequence(), 48, 'Not an ASN.1 Sequence');
180 + t.equal(ber.length, 12, 'Message length should be 12');
181 + t.equal(ber.readInt(), 4, 'Message id should have been 4');
182 + t.equal(ber.readSequence(), 96, 'Bind Request should have been 96');
183 + t.equal(ber.length, 7, 'Bind length should have been 7');
184 + t.equal(ber.readInt(), 3, 'LDAP version should have been 3');
185 + t.equal(ber.readString(), '', 'Bind DN should have been empty');
186 + t.equal(ber.length, 0, 'string length should have been 0');
187 + t.equal(ber.readByte(), 0x80, 'Should have been ContextSpecific (choice)');
188 + t.equal(ber.readByte(), 0, 'Should have been simple bind');
189 + t.equal(null, ber.readByte(), 'Should be out of data');
190 + t.end();
191 +});
192 +
193 +
194 +test('long string', function(t) {
195 + var buf = new Buffer(256);
196 + var o;
197 + var s =
198 + '2;649;CN=Red Hat CS 71GA Demo,O=Red Hat CS 71GA Demo,C=US;' +
199 + 'CN=RHCS Agent - admin01,UID=admin01,O=redhat,C=US [1] This is ' +
200 + 'Teena Vradmin\'s description.';
201 + buf[0] = 0x04;
202 + buf[1] = 0x81;
203 + buf[2] = 0x94;
204 + buf.write(s, 3);
205 + var ber = new BerReader(buf.slice(0, 3 + s.length));
206 + t.equal(ber.readString(), s);
207 + t.end();
208 +});
1 +// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2 +
3 +var test = require('tap').test;
4 +var sys = require('sys');
5 +
6 +///--- Globals
7 +
8 +var BerWriter;
9 +
10 +var BerReader;
11 +
12 +
13 +///--- Tests
14 +
15 +test('load library', function(t) {
16 + BerWriter = require('../../lib/index').BerWriter;
17 + t.ok(BerWriter);
18 + t.ok(new BerWriter());
19 + t.end();
20 +});
21 +
22 +
23 +test('write byte', function(t) {
24 + var writer = new BerWriter();
25 +
26 + writer.writeByte(0xC2);
27 + var ber = writer.buffer;
28 +
29 + t.ok(ber);
30 + t.equal(ber.length, 1, 'Wrong length');
31 + t.equal(ber[0], 0xC2, 'value wrong');
32 +
33 + t.end();
34 +});
35 +
36 +
37 +test('write 1 byte int', function(t) {
38 + var writer = new BerWriter();
39 +
40 + writer.writeInt(0x7f);
41 + var ber = writer.buffer;
42 +
43 + t.ok(ber);
44 + t.equal(ber.length, 3, 'Wrong length for an int: ' + ber.length);
45 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong (2) -> ' + ber[0]);
46 + t.equal(ber[1], 0x01, 'length wrong(1) -> ' + ber[1]);
47 + t.equal(ber[2], 0x7f, 'value wrong(3) -> ' + ber[2]);
48 +
49 + t.end();
50 +});
51 +
52 +
53 +test('write 2 byte int', function(t) {
54 + var writer = new BerWriter();
55 +
56 + writer.writeInt(0x7ffe);
57 + var ber = writer.buffer;
58 +
59 + t.ok(ber);
60 + t.equal(ber.length, 4, 'Wrong length for an int');
61 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
62 + t.equal(ber[1], 0x02, 'length wrong');
63 + t.equal(ber[2], 0x7f, 'value wrong (byte 1)');
64 + t.equal(ber[3], 0xfe, 'value wrong (byte 2)');
65 +
66 + t.end();
67 +});
68 +
69 +
70 +test('write 3 byte int', function(t) {
71 + var writer = new BerWriter();
72 +
73 + writer.writeInt(0x7ffffe);
74 + var ber = writer.buffer;
75 +
76 + t.ok(ber);
77 + t.equal(ber.length, 5, 'Wrong length for an int');
78 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
79 + t.equal(ber[1], 0x03, 'length wrong');
80 + t.equal(ber[2], 0x7f, 'value wrong (byte 1)');
81 + t.equal(ber[3], 0xff, 'value wrong (byte 2)');
82 + t.equal(ber[4], 0xfe, 'value wrong (byte 3)');
83 +
84 + t.end();
85 +});
86 +
87 +
88 +test('write 4 byte int', function(t) {
89 + var writer = new BerWriter();
90 +
91 + writer.writeInt(0x7ffffffe);
92 + var ber = writer.buffer;
93 +
94 + t.ok(ber);
95 +
96 + t.equal(ber.length, 6, 'Wrong length for an int');
97 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
98 + t.equal(ber[1], 0x04, 'length wrong');
99 + t.equal(ber[2], 0x7f, 'value wrong (byte 1)');
100 + t.equal(ber[3], 0xff, 'value wrong (byte 2)');
101 + t.equal(ber[4], 0xff, 'value wrong (byte 3)');
102 + t.equal(ber[5], 0xfe, 'value wrong (byte 4)');
103 +
104 + t.end();
105 +});
106 +
107 +
108 +test('write 1 byte negative int', function(t) {
109 + var writer = new BerWriter();
110 +
111 + writer.writeInt(-128);
112 + var ber = writer.buffer;
113 +
114 + t.ok(ber);
115 +
116 + t.equal(ber.length, 3, 'Wrong length for an int');
117 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
118 + t.equal(ber[1], 0x01, 'length wrong');
119 + t.equal(ber[2], 0x80, 'value wrong (byte 1)');
120 +
121 + t.end();
122 +});
123 +
124 +
125 +test('write 2 byte negative int', function(t) {
126 + var writer = new BerWriter();
127 +
128 + writer.writeInt(-22400);
129 + var ber = writer.buffer;
130 +
131 + t.ok(ber);
132 +
133 + t.equal(ber.length, 4, 'Wrong length for an int');
134 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
135 + t.equal(ber[1], 0x02, 'length wrong');
136 + t.equal(ber[2], 0xa8, 'value wrong (byte 1)');
137 + t.equal(ber[3], 0x80, 'value wrong (byte 2)');
138 +
139 + t.end();
140 +});
141 +
142 +
143 +test('write 3 byte negative int', function(t) {
144 + var writer = new BerWriter();
145 +
146 + writer.writeInt(-481653);
147 + var ber = writer.buffer;
148 +
149 + t.ok(ber);
150 +
151 + t.equal(ber.length, 5, 'Wrong length for an int');
152 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
153 + t.equal(ber[1], 0x03, 'length wrong');
154 + t.equal(ber[2], 0xf8, 'value wrong (byte 1)');
155 + t.equal(ber[3], 0xa6, 'value wrong (byte 2)');
156 + t.equal(ber[4], 0x8b, 'value wrong (byte 3)');
157 +
158 + t.end();
159 +});
160 +
161 +
162 +test('write 4 byte negative int', function(t) {
163 + var writer = new BerWriter();
164 +
165 + writer.writeInt(-1522904131);
166 + var ber = writer.buffer;
167 +
168 + t.ok(ber);
169 +
170 + t.equal(ber.length, 6, 'Wrong length for an int');
171 + t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
172 + t.equal(ber[1], 0x04, 'length wrong');
173 + t.equal(ber[2], 0xa5, 'value wrong (byte 1)');
174 + t.equal(ber[3], 0x3a, 'value wrong (byte 2)');
175 + t.equal(ber[4], 0x53, 'value wrong (byte 3)');
176 + t.equal(ber[5], 0xbd, 'value wrong (byte 4)');
177 +
178 + t.end();
179 +});
180 +
181 +
182 +test('write boolean', function(t) {
183 + var writer = new BerWriter();
184 +
185 + writer.writeBoolean(true);
186 + writer.writeBoolean(false);
187 + var ber = writer.buffer;
188 +
189 + t.ok(ber);
190 + t.equal(ber.length, 6, 'Wrong length');
191 + t.equal(ber[0], 0x01, 'tag wrong');
192 + t.equal(ber[1], 0x01, 'length wrong');
193 + t.equal(ber[2], 0xff, 'value wrong');
194 + t.equal(ber[3], 0x01, 'tag wrong');
195 + t.equal(ber[4], 0x01, 'length wrong');
196 + t.equal(ber[5], 0x00, 'value wrong');
197 +
198 + t.end();
199 +});
200 +
201 +
202 +test('write string', function(t) {
203 + var writer = new BerWriter();
204 + writer.writeString('hello world');
205 + var ber = writer.buffer;
206 +
207 + t.ok(ber);
208 + t.equal(ber.length, 13, 'wrong length');
209 + t.equal(ber[0], 0x04, 'wrong tag');
210 + t.equal(ber[1], 11, 'wrong length');
211 + t.equal(ber.slice(2).toString('utf8'), 'hello world', 'wrong value');
212 +
213 + t.end();
214 +});
215 +
216 +test('write buffer', function(t) {
217 + var writer = new BerWriter();
218 + // write some stuff to start with
219 + writer.writeString('hello world');
220 + var ber = writer.buffer;
221 + var buf = new Buffer([0x04, 0x0b, 0x30, 0x09, 0x02, 0x01, 0x0f, 0x01, 0x01,
222 + 0xff, 0x01, 0x01, 0xff]);
223 + writer.writeBuffer(buf.slice(2, buf.length), 0x04);
224 + ber = writer.buffer;
225 +
226 + t.ok(ber);
227 + t.equal(ber.length, 26, 'wrong length');
228 + t.equal(ber[0], 0x04, 'wrong tag');
229 + t.equal(ber[1], 11, 'wrong length');
230 + t.equal(ber.slice(2, 13).toString('utf8'), 'hello world', 'wrong value');
231 + t.equal(ber[13], buf[0], 'wrong tag');
232 + t.equal(ber[14], buf[1], 'wrong length');
233 + for (var i = 13, j = 0; i < ber.length && j < buf.length; i++, j++) {
234 + t.equal(ber[i], buf[j], 'buffer contents not identical');
235 + }
236 + t.end();
237 +});
238 +
239 +test('write string array', function(t) {
240 + var writer = new BerWriter();
241 + writer.writeStringArray(['hello world', 'fubar!']);
242 + var ber = writer.buffer;
243 +
244 + t.ok(ber);
245 +
246 + t.equal(ber.length, 21, 'wrong length');
247 + t.equal(ber[0], 0x04, 'wrong tag');
248 + t.equal(ber[1], 11, 'wrong length');
249 + t.equal(ber.slice(2, 13).toString('utf8'), 'hello world', 'wrong value');
250 +
251 + t.equal(ber[13], 0x04, 'wrong tag');
252 + t.equal(ber[14], 6, 'wrong length');
253 + t.equal(ber.slice(15).toString('utf8'), 'fubar!', 'wrong value');
254 +
255 + t.end();
256 +});
257 +
258 +
259 +test('resize internal buffer', function(t) {
260 + var writer = new BerWriter({size: 2});
261 + writer.writeString('hello world');
262 + var ber = writer.buffer;
263 +
264 + t.ok(ber);
265 + t.equal(ber.length, 13, 'wrong length');
266 + t.equal(ber[0], 0x04, 'wrong tag');
267 + t.equal(ber[1], 11, 'wrong length');
268 + t.equal(ber.slice(2).toString('utf8'), 'hello world', 'wrong value');
269 +
270 + t.end();
271 +});
272 +
273 +
274 +test('sequence', function(t) {
275 + var writer = new BerWriter({size: 25});
276 + writer.startSequence();
277 + writer.writeString('hello world');
278 + writer.endSequence();
279 + var ber = writer.buffer;
280 +
281 + t.ok(ber);
282 + console.log(ber);
283 + t.equal(ber.length, 15, 'wrong length');
284 + t.equal(ber[0], 0x30, 'wrong tag');
285 + t.equal(ber[1], 13, 'wrong length');
286 + t.equal(ber[2], 0x04, 'wrong tag');
287 + t.equal(ber[3], 11, 'wrong length');
288 + t.equal(ber.slice(4).toString('utf8'), 'hello world', 'wrong value');
289 +
290 + t.end();
291 +});
292 +
293 +
294 +test('nested sequence', function(t) {
295 + var writer = new BerWriter({size: 25});
296 + writer.startSequence();
297 + writer.writeString('hello world');
298 + writer.startSequence();
299 + writer.writeString('hello world');
300 + writer.endSequence();
301 + writer.endSequence();
302 + var ber = writer.buffer;
303 +
304 + t.ok(ber);
305 + t.equal(ber.length, 30, 'wrong length');
306 + t.equal(ber[0], 0x30, 'wrong tag');
307 + t.equal(ber[1], 28, 'wrong length');
308 + t.equal(ber[2], 0x04, 'wrong tag');
309 + t.equal(ber[3], 11, 'wrong length');
310 + t.equal(ber.slice(4, 15).toString('utf8'), 'hello world', 'wrong value');
311 + t.equal(ber[15], 0x30, 'wrong tag');
312 + t.equal(ber[16], 13, 'wrong length');
313 + t.equal(ber[17], 0x04, 'wrong tag');
314 + t.equal(ber[18], 11, 'wrong length');
315 + t.equal(ber.slice(19, 30).toString('utf8'), 'hello world', 'wrong value');
316 +
317 + t.end();
318 +});
319 +
320 +
321 +test('LDAP bind message', function(t) {
322 + var dn = 'cn=foo,ou=unit,o=test';
323 + var writer = new BerWriter();
324 + writer.startSequence();
325 + writer.writeInt(3); // msgid = 3
326 + writer.startSequence(0x60); // ldap bind
327 + writer.writeInt(3); // ldap v3
328 + writer.writeString(dn);
329 + writer.writeByte(0x80);
330 + writer.writeByte(0x00);
331 + writer.endSequence();
332 + writer.endSequence();
333 + var ber = writer.buffer;
334 +
335 + t.ok(ber);
336 + t.equal(ber.length, 35, 'wrong length (buffer)');
337 + t.equal(ber[0], 0x30, 'wrong tag');
338 + t.equal(ber[1], 33, 'wrong length');
339 + t.equal(ber[2], 0x02, 'wrong tag');
340 + t.equal(ber[3], 1, 'wrong length');
341 + t.equal(ber[4], 0x03, 'wrong value');
342 + t.equal(ber[5], 0x60, 'wrong tag');
343 + t.equal(ber[6], 28, 'wrong length');
344 + t.equal(ber[7], 0x02, 'wrong tag');
345 + t.equal(ber[8], 1, 'wrong length');
346 + t.equal(ber[9], 0x03, 'wrong value');
347 + t.equal(ber[10], 0x04, 'wrong tag');
348 + t.equal(ber[11], dn.length, 'wrong length');
349 + t.equal(ber.slice(12, 33).toString('utf8'), dn, 'wrong value');
350 + t.equal(ber[33], 0x80, 'wrong tag');
351 + t.equal(ber[34], 0x00, 'wrong len');
352 +
353 + t.end();
354 +});
355 +
356 +
357 +test('Write OID', function(t) {
358 + var oid = '1.2.840.113549.1.1.1';
359 + var writer = new BerWriter();
360 + writer.writeOID(oid);
361 +
362 + var ber = writer.buffer;
363 + t.ok(ber);
364 + console.log(require('util').inspect(ber));
365 + console.log(require('util').inspect(new Buffer([0x06, 0x09, 0x2a, 0x86,
366 + 0x48, 0x86, 0xf7, 0x0d,
367 + 0x01, 0x01, 0x01])));
368 +
369 + t.end();
370 +});
1 +Dave Eddy <dave@daveeddy.com>
2 +Fred Kuo <fred.kuo@joyent.com>
3 +Lars-Magnus Skog <ralphtheninja@riseup.net>
4 +Mark Cavage <mcavage@gmail.com>
5 +Patrick Mooney <pmooney@pfmooney.com>
6 +Rob Gulewich <robert.gulewich@joyent.com>
1 +# assert-plus Changelog
2 +
3 +## 0.2.0
4 +
5 +- Fix `assert.object(null)` so it throws
6 +- Fix optional/arrayOf exports for non-type-of asserts
7 +- Add optiona/arrayOf exports for Stream/Date/Regex/uuid
8 +- Add basic unit test coverage
1 +# assert-plus
2 +
3 +This library is a super small wrapper over node's assert module that has two
4 +things: (1) the ability to disable assertions with the environment variable
5 +NODE\_NDEBUG, and (2) some API wrappers for argument testing. Like
6 +`assert.string(myArg, 'myArg')`. As a simple example, most of my code looks
7 +like this:
8 +
9 +```javascript
10 + var assert = require('assert-plus');
11 +
12 + function fooAccount(options, callback) {
13 + assert.object(options, 'options');
14 + assert.number(options.id, 'options.id');
15 + assert.bool(options.isManager, 'options.isManager');
16 + assert.string(options.name, 'options.name');
17 + assert.arrayOfString(options.email, 'options.email');
18 + assert.func(callback, 'callback');
19 +
20 + // Do stuff
21 + callback(null, {});
22 + }
23 +```
24 +
25 +# API
26 +
27 +All methods that *aren't* part of node's core assert API are simply assumed to
28 +take an argument, and then a string 'name' that's not a message; `AssertionError`
29 +will be thrown if the assertion fails with a message like:
30 +
31 + AssertionError: foo (string) is required
32 + at test (/home/mark/work/foo/foo.js:3:9)
33 + at Object.<anonymous> (/home/mark/work/foo/foo.js:15:1)
34 + at Module._compile (module.js:446:26)
35 + at Object..js (module.js:464:10)
36 + at Module.load (module.js:353:31)
37 + at Function._load (module.js:311:12)
38 + at Array.0 (module.js:484:10)
39 + at EventEmitter._tickCallback (node.js:190:38)
40 +
41 +from:
42 +
43 +```javascript
44 + function test(foo) {
45 + assert.string(foo, 'foo');
46 + }
47 +```
48 +
49 +There you go. You can check that arrays are of a homogeneous type with `Arrayof$Type`:
50 +
51 +```javascript
52 + function test(foo) {
53 + assert.arrayOfString(foo, 'foo');
54 + }
55 +```
56 +
57 +You can assert IFF an argument is not `undefined` (i.e., an optional arg):
58 +
59 +```javascript
60 + assert.optionalString(foo, 'foo');
61 +```
62 +
63 +Lastly, you can opt-out of assertion checking altogether by setting the
64 +environment variable `NODE_NDEBUG=1`. This is pseudo-useful if you have
65 +lots of assertions, and don't want to pay `typeof ()` taxes to v8 in
66 +production. Be advised: The standard functions re-exported from `assert` are
67 +also disabled in assert-plus if NDEBUG is specified. Using them directly from
68 +the `assert` module avoids this behavior.
69 +
70 +The complete list of APIs is:
71 +
72 +* assert.array
73 +* assert.bool
74 +* assert.buffer
75 +* assert.func
76 +* assert.number
77 +* assert.object
78 +* assert.string
79 +* assert.stream
80 +* assert.date
81 +* assert.regex
82 +* assert.uuid
83 +* assert.arrayOfArray
84 +* assert.arrayOfBool
85 +* assert.arrayOfBuffer
86 +* assert.arrayOfFunc
87 +* assert.arrayOfNumber
88 +* assert.arrayOfObject
89 +* assert.arrayOfString
90 +* assert.arrayOfStream
91 +* assert.arrayOfDate
92 +* assert.arrayOfUuid
93 +* assert.optionalArray
94 +* assert.optionalBool
95 +* assert.optionalBuffer
96 +* assert.optionalFunc
97 +* assert.optionalNumber
98 +* assert.optionalObject
99 +* assert.optionalString
100 +* assert.optionalStream
101 +* assert.optionalDate
102 +* assert.optionalUuid
103 +* assert.optionalArrayOfArray
104 +* assert.optionalArrayOfBool
105 +* assert.optionalArrayOfBuffer
106 +* assert.optionalArrayOfFunc
107 +* assert.optionalArrayOfNumber
108 +* assert.optionalArrayOfObject
109 +* assert.optionalArrayOfString
110 +* assert.optionalArrayOfStream
111 +* assert.optionalArrayOfDate
112 +* assert.optionalArrayOfUuid
113 +* assert.AssertionError
114 +* assert.fail
115 +* assert.ok
116 +* assert.equal
117 +* assert.notEqual
118 +* assert.deepEqual
119 +* assert.notDeepEqual
120 +* assert.strictEqual
121 +* assert.notStrictEqual
122 +* assert.throws
123 +* assert.doesNotThrow
124 +* assert.ifError
125 +
126 +# Installation
127 +
128 + npm install assert-plus
129 +
130 +## License
131 +
132 +The MIT License (MIT)
133 +Copyright (c) 2012 Mark Cavage
134 +
135 +Permission is hereby granted, free of charge, to any person obtaining a copy of
136 +this software and associated documentation files (the "Software"), to deal in
137 +the Software without restriction, including without limitation the rights to
138 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
139 +the Software, and to permit persons to whom the Software is furnished to do so,
140 +subject to the following conditions:
141 +
142 +The above copyright notice and this permission notice shall be included in all
143 +copies or substantial portions of the Software.
144 +
145 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
146 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
147 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
148 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
149 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
150 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
151 +SOFTWARE.
152 +
153 +## Bugs
154 +
155 +See <https://github.com/mcavage/node-assert-plus/issues>.
1 +// Copyright (c) 2012, Mark Cavage. All rights reserved.
2 +// Copyright 2015 Joyent, Inc.
3 +
4 +var assert = require('assert');
5 +var Stream = require('stream').Stream;
6 +var util = require('util');
7 +
8 +
9 +///--- Globals
10 +
11 +/* JSSTYLED */
12 +var UUID_REGEXP = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
13 +
14 +
15 +///--- Internal
16 +
17 +function _capitalize(str) {
18 + return (str.charAt(0).toUpperCase() + str.slice(1));
19 +}
20 +
21 +function _toss(name, expected, oper, arg, actual) {
22 + throw new assert.AssertionError({
23 + message: util.format('%s (%s) is required', name, expected),
24 + actual: (actual === undefined) ? typeof (arg) : actual(arg),
25 + expected: expected,
26 + operator: oper || '===',
27 + stackStartFunction: _toss.caller
28 + });
29 +}
30 +
31 +function _getClass(arg) {
32 + return (Object.prototype.toString.call(arg).slice(8, -1));
33 +}
34 +
35 +function noop() {
36 + // Why even bother with asserts?
37 +}
38 +
39 +
40 +///--- Exports
41 +
42 +var types = {
43 + bool: {
44 + check: function (arg) { return typeof (arg) === 'boolean'; }
45 + },
46 + func: {
47 + check: function (arg) { return typeof (arg) === 'function'; }
48 + },
49 + string: {
50 + check: function (arg) { return typeof (arg) === 'string'; }
51 + },
52 + object: {
53 + check: function (arg) {
54 + return typeof (arg) === 'object' && arg !== null;
55 + }
56 + },
57 + number: {
58 + check: function (arg) {
59 + return typeof (arg) === 'number' && !isNaN(arg) && isFinite(arg);
60 + }
61 + },
62 + buffer: {
63 + check: function (arg) { return Buffer.isBuffer(arg); },
64 + operator: 'Buffer.isBuffer'
65 + },
66 + array: {
67 + check: function (arg) { return Array.isArray(arg); },
68 + operator: 'Array.isArray'
69 + },
70 + stream: {
71 + check: function (arg) { return arg instanceof Stream; },
72 + operator: 'instanceof',
73 + actual: _getClass
74 + },
75 + date: {
76 + check: function (arg) { return arg instanceof Date; },
77 + operator: 'instanceof',
78 + actual: _getClass
79 + },
80 + regexp: {
81 + check: function (arg) { return arg instanceof RegExp; },
82 + operator: 'instanceof',
83 + actual: _getClass
84 + },
85 + uuid: {
86 + check: function (arg) {
87 + return typeof (arg) === 'string' && UUID_REGEXP.test(arg);
88 + },
89 + operator: 'isUUID'
90 + }
91 +};
92 +
93 +function _setExports(ndebug) {
94 + var keys = Object.keys(types);
95 + var out;
96 +
97 + /* re-export standard assert */
98 + if (process.env.NODE_NDEBUG) {
99 + out = noop;
100 + } else {
101 + out = function (arg, msg) {
102 + if (!arg) {
103 + _toss(msg, 'true', arg);
104 + }
105 + };
106 + }
107 +
108 + /* standard checks */
109 + keys.forEach(function (k) {
110 + if (ndebug) {
111 + out[k] = noop;
112 + return;
113 + }
114 + var type = types[k];
115 + out[k] = function (arg, msg) {
116 + if (!type.check(arg)) {
117 + _toss(msg, k, type.operator, arg, type.actual);
118 + }
119 + };
120 + });
121 +
122 + /* optional checks */
123 + keys.forEach(function (k) {
124 + var name = 'optional' + _capitalize(k);
125 + if (ndebug) {
126 + out[name] = noop;
127 + return;
128 + }
129 + var type = types[k];
130 + out[name] = function (arg, msg) {
131 + if (arg === undefined || arg === null) {
132 + return;
133 + }
134 + if (!type.check(arg)) {
135 + _toss(msg, k, type.operator, arg, type.actual);
136 + }
137 + };
138 + });
139 +
140 + /* arrayOf checks */
141 + keys.forEach(function (k) {
142 + var name = 'arrayOf' + _capitalize(k);
143 + if (ndebug) {
144 + out[name] = noop;
145 + return;
146 + }
147 + var type = types[k];
148 + var expected = '[' + k + ']';
149 + out[name] = function (arg, msg) {
150 + if (!Array.isArray(arg)) {
151 + _toss(msg, expected, type.operator, arg, type.actual);
152 + }
153 + var i;
154 + for (i = 0; i < arg.length; i++) {
155 + if (!type.check(arg[i])) {
156 + _toss(msg, expected, type.operator, arg, type.actual);
157 + }
158 + }
159 + };
160 + });
161 +
162 + /* optionalArrayOf checks */
163 + keys.forEach(function (k) {
164 + var name = 'optionalArrayOf' + _capitalize(k);
165 + if (ndebug) {
166 + out[name] = noop;
167 + return;
168 + }
169 + var type = types[k];
170 + var expected = '[' + k + ']';
171 + out[name] = function (arg, msg) {
172 + if (arg === undefined || arg === null) {
173 + return;
174 + }
175 + if (!Array.isArray(arg)) {
176 + _toss(msg, expected, type.operator, arg, type.actual);
177 + }
178 + var i;
179 + for (i = 0; i < arg.length; i++) {
180 + if (!type.check(arg[i])) {
181 + _toss(msg, expected, type.operator, arg, type.actual);
182 + }
183 + }
184 + };
185 + });
186 +
187 + /* re-export built-in assertions */
188 + Object.keys(assert).forEach(function (k) {
189 + if (k === 'AssertionError') {
190 + out[k] = assert[k];
191 + return;
192 + }
193 + if (ndebug) {
194 + out[k] = noop;
195 + return;
196 + }
197 + out[k] = assert[k];
198 + });
199 +
200 + /* export ourselves (for unit tests _only_) */
201 + out._setExports = _setExports;
202 +
203 + return out;
204 +}
205 +
206 +module.exports = _setExports(process.env.NODE_NDEBUG);
1 +{
2 + "_args": [
3 + [
4 + {
5 + "raw": "assert-plus@^0.2.0",
6 + "scope": null,
7 + "escapedName": "assert-plus",
8 + "name": "assert-plus",
9 + "rawSpec": "^0.2.0",
10 + "spec": ">=0.2.0 <0.3.0",
11 + "type": "range"
12 + },
13 + "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/http-signature"
14 + ]
15 + ],
16 + "_from": "assert-plus@>=0.2.0 <0.3.0",
17 + "_id": "assert-plus@0.2.0",
18 + "_inCache": true,
19 + "_location": "/assert-plus",
20 + "_nodeVersion": "0.10.36",
21 + "_npmUser": {
22 + "name": "pfmooney",
23 + "email": "patrick.f.mooney@gmail.com"
24 + },
25 + "_npmVersion": "3.3.8",
26 + "_phantomChildren": {},
27 + "_requested": {
28 + "raw": "assert-plus@^0.2.0",
29 + "scope": null,
30 + "escapedName": "assert-plus",
31 + "name": "assert-plus",
32 + "rawSpec": "^0.2.0",
33 + "spec": ">=0.2.0 <0.3.0",
34 + "type": "range"
35 + },
36 + "_requiredBy": [
37 + "/http-signature"
38 + ],
39 + "_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
40 + "_shasum": "d74e1b87e7affc0db8aadb7021f3fe48101ab234",
41 + "_shrinkwrap": null,
42 + "_spec": "assert-plus@^0.2.0",
43 + "_where": "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/http-signature",
44 + "author": {
45 + "name": "Mark Cavage",
46 + "email": "mcavage@gmail.com"
47 + },
48 + "bugs": {
49 + "url": "https://github.com/mcavage/node-assert-plus/issues"
50 + },
51 + "contributors": [
52 + {
53 + "name": "Dave Eddy",
54 + "email": "dave@daveeddy.com"
55 + },
56 + {
57 + "name": "Fred Kuo",
58 + "email": "fred.kuo@joyent.com"
59 + },
60 + {
61 + "name": "Lars-Magnus Skog",
62 + "email": "ralphtheninja@riseup.net"
63 + },
64 + {
65 + "name": "Mark Cavage",
66 + "email": "mcavage@gmail.com"
67 + },
68 + {
69 + "name": "Patrick Mooney",
70 + "email": "pmooney@pfmooney.com"
71 + },
72 + {
73 + "name": "Rob Gulewich",
74 + "email": "robert.gulewich@joyent.com"
75 + }
76 + ],
77 + "dependencies": {},
78 + "description": "Extra assertions on top of node's assert module",
79 + "devDependencies": {
80 + "faucet": "0.0.1",
81 + "tape": "4.2.2"
82 + },
83 + "directories": {},
84 + "dist": {
85 + "shasum": "d74e1b87e7affc0db8aadb7021f3fe48101ab234",
86 + "tarball": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz"
87 + },
88 + "engines": {
89 + "node": ">=0.8"
90 + },
91 + "homepage": "https://github.com/mcavage/node-assert-plus#readme",
92 + "license": "MIT",
93 + "main": "./assert.js",
94 + "maintainers": [
95 + {
96 + "name": "mcavage",
97 + "email": "mcavage@gmail.com"
98 + },
99 + {
100 + "name": "pfmooney",
101 + "email": "patrick.f.mooney@gmail.com"
102 + }
103 + ],
104 + "name": "assert-plus",
105 + "optionalDependencies": {},
106 + "readme": "ERROR: No README data found!",
107 + "repository": {
108 + "type": "git",
109 + "url": "git+https://github.com/mcavage/node-assert-plus.git"
110 + },
111 + "scripts": {
112 + "test": "tape tests/*.js | ./node_modules/.bin/faucet"
113 + },
114 + "version": "0.2.0"
115 +}
This diff is collapsed. Click to expand it.
1 +Copyright (c) 2010-2017 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 +[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async)
5 +[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)
6 +[![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)
7 +[![libhive - Open source examples](https://www.libhive.com/providers/npm/packages/async/examples/badge.svg)](https://www.libhive.com/providers/npm/packages/async)
8 +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/async/badge?style=rounded)](https://www.jsdelivr.com/package/npm/async)
9 +
10 +
11 +Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.
12 +
13 +For Documentation, visit <https://caolan.github.io/async/>
14 +
15 +*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
16 +
17 +
18 +```javascript
19 +// for use with Node-style callbacks...
20 +var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
21 +var configs = {};
22 +
23 +async.forEachOf(obj, (value, key, callback) => {
24 + fs.readFile(__dirname + value, "utf8", (err, data) => {
25 + if (err) return callback(err);
26 + try {
27 + configs[key] = JSON.parse(data);
28 + } catch (e) {
29 + return callback(e);
30 + }
31 + callback();
32 + });
33 +}, err => {
34 + if (err) console.error(err.message);
35 + // configs is now a map of JSON data
36 + doSomethingWith(configs);
37 +});
38 +```
39 +
40 +```javascript
41 +// ...or ES2017 async functions
42 +async.mapLimit(urls, 5, async function(url) {
43 + const response = await fetch(url)
44 + return response.body
45 +}, (err, results) => {
46 + if (err) throw err
47 + // results is now an array of the response bodies
48 + console.log(results)
49 +})
50 +```
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _doParallel = require('./internal/doParallel');
12 +
13 +var _doParallel2 = _interopRequireDefault(_doParallel);
14 +
15 +var _notId = require('./internal/notId');
16 +
17 +var _notId2 = _interopRequireDefault(_notId);
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|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 + * @example
40 + *
41 + * async.every(['file1','file2','file3'], function(filePath, callback) {
42 + * fs.access(filePath, function(err) {
43 + * callback(null, !err)
44 + * });
45 + * }, function(err, result) {
46 + * // if result is true then every file exists
47 + * });
48 + */
49 +exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
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 _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _doParallelLimit = require('./internal/doParallelLimit');
12 +
13 +var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
14 +
15 +var _notId = require('./internal/notId');
16 +
17 +var _notId2 = _interopRequireDefault(_notId);
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|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 + */
41 +exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
42 +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 _everyLimit = require('./everyLimit');
8 +
9 +var _everyLimit2 = _interopRequireDefault(_everyLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
19 + *
20 + * @name everySeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.every]{@link module:Collections.every}
25 + * @alias allSeries
26 + * @category Collection
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
29 + * in the collection in series.
30 + * The iteratee must complete with a boolean result value.
31 + * Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished. Result will be either `true` or `false`
34 + * depending on the values of the async tests. Invoked with (err, result).
35 + */
36 +exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1);
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 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _doParallel = require('./internal/doParallel');
12 +
13 +var _doParallel2 = _interopRequireDefault(_doParallel);
14 +
15 +var _identity = require('lodash/identity');
16 +
17 +var _identity2 = _interopRequireDefault(_identity);
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|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 + * @example
42 + *
43 + * async.some(['file1','file2','file3'], function(filePath, callback) {
44 + * fs.access(filePath, function(err) {
45 + * callback(null, !err)
46 + * });
47 + * }, function(err, result) {
48 + * // if result is true then at least one of the files exists
49 + * });
50 + */
51 +exports.default = (0, _doParallel2.default)((0, _createTester2.default)(Boolean, _identity2.default));
52 +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');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _doParallelLimit = require('./internal/doParallelLimit');
12 +
13 +var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
14 +
15 +var _identity = require('lodash/identity');
16 +
17 +var _identity2 = _interopRequireDefault(_identity);
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|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 + */
42 +exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(Boolean, _identity2.default));
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 _someLimit = require('./someLimit');
8 +
9 +var _someLimit2 = _interopRequireDefault(_someLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
19 + *
20 + * @name someSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.some]{@link module:Collections.some}
25 + * @alias anySeries
26 + * @category Collection
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
29 + * in the collections in series.
30 + * The iteratee should complete with a boolean `result` value.
31 + * Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called as soon as any
33 + * iteratee returns `true`, or after all the iteratee functions have finished.
34 + * Result will be either `true` or `false` depending on the values of the async
35 + * tests. Invoked with (err, result).
36 + */
37 +exports.default = (0, _doLimit2.default)(_someLimit2.default, 1);
38 +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 + var args = (0, _slice2.default)(arguments, 1);
9 + return function () /*callArgs*/{
10 + var callArgs = (0, _slice2.default)(arguments);
11 + return fn.apply(null, args.concat(callArgs));
12 + };
13 +};
14 +
15 +var _slice = require('./internal/slice');
16 +
17 +var _slice2 = _interopRequireDefault(_slice);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +;
22 +
23 +/**
24 + * Creates a continuation function with some arguments already applied.
25 + *
26 + * Useful as a shorthand when combined with other control flow functions. Any
27 + * arguments passed to the returned function are added to the arguments
28 + * originally passed to apply.
29 + *
30 + * @name apply
31 + * @static
32 + * @memberOf module:Utils
33 + * @method
34 + * @category Util
35 + * @param {Function} fn - The function you want to eventually apply all
36 + * arguments to. Invokes with (arguments...).
37 + * @param {...*} arguments... - Any number of arguments to automatically apply
38 + * when the continuation is called.
39 + * @returns {Function} the partially-applied function
40 + * @example
41 + *
42 + * // using apply
43 + * async.parallel([
44 + * async.apply(fs.writeFile, 'testfile1', 'test1'),
45 + * async.apply(fs.writeFile, 'testfile2', 'test2')
46 + * ]);
47 + *
48 + *
49 + * // the same process without using apply
50 + * async.parallel([
51 + * function(callback) {
52 + * fs.writeFile('testfile1', 'test1', callback);
53 + * },
54 + * function(callback) {
55 + * fs.writeFile('testfile2', 'test2', callback);
56 + * }
57 + * ]);
58 + *
59 + * // It's possible to pass any number of additional arguments when calling the
60 + * // continuation:
61 + *
62 + * node> var fn = async.apply(sys.puts, 'one');
63 + * node> fn('two', 'three');
64 + * one
65 + * two
66 + * three
67 + */
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 _applyEach = require('./internal/applyEach');
8 +
9 +var _applyEach2 = _interopRequireDefault(_applyEach);
10 +
11 +var _map = require('./map');
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.
23 + *
24 + * @name applyEach
25 + * @static
26 + * @memberOf module:ControlFlow
27 + * @method
28 + * @category Control Flow
29 + * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s
30 + * to all call with the same arguments
31 + * @param {...*} [args] - any number of separate arguments to pass to the
32 + * function.
33 + * @param {Function} [callback] - the final argument should be the callback,
34 + * called when all functions have completed processing.
35 + * @returns {Function} - If only the first argument, `fns`, is provided, it will
36 + * return a function which lets you pass in the arguments as if it were a single
37 + * function call. The signature is `(..args, callback)`. If invoked with any
38 + * arguments, `callback` is required.
39 + * @example
40 + *
41 + * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
42 + *
43 + * // partial application example:
44 + * async.each(
45 + * buckets,
46 + * async.applyEach([enableSearch, updateSchema]),
47 + * callback
48 + * );
49 + */
50 +exports.default = (0, _applyEach2.default)(_map2.default);
51 +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');
8 +
9 +var _applyEach2 = _interopRequireDefault(_applyEach);
10 +
11 +var _mapSeries = require('./mapSeries');
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|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 {Function} - If only the first argument is provided, it will return
33 + * a function which lets you pass in the arguments as if it were a single
34 + * function call.
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 _isObject = require('lodash/isObject');
9 +
10 +var _isObject2 = _interopRequireDefault(_isObject);
11 +
12 +var _initialParams = require('./internal/initialParams');
13 +
14 +var _initialParams2 = _interopRequireDefault(_initialParams);
15 +
16 +var _setImmediate = require('./internal/setImmediate');
17 +
18 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * Take a sync function and make it async, passing its return value to a
24 + * callback. This is useful for plugging sync functions into a waterfall,
25 + * series, or other async functions. Any arguments passed to the generated
26 + * function will be passed to the wrapped function (except for the final
27 + * callback argument). Errors thrown will be passed to the callback.
28 + *
29 + * If the function passed to `asyncify` returns a Promise, that promises's
30 + * resolved/rejected state will be used to call the callback, rather than simply
31 + * the synchronous return value.
32 + *
33 + * This also means you can asyncify ES2017 `async` functions.
34 + *
35 + * @name asyncify
36 + * @static
37 + * @memberOf module:Utils
38 + * @method
39 + * @alias wrapSync
40 + * @category Util
41 + * @param {Function} func - The synchronous function, or Promise-returning
42 + * function to convert to an {@link AsyncFunction}.
43 + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
44 + * invoked with `(args..., callback)`.
45 + * @example
46 + *
47 + * // passing a regular synchronous function
48 + * async.waterfall([
49 + * async.apply(fs.readFile, filename, "utf8"),
50 + * async.asyncify(JSON.parse),
51 + * function (data, next) {
52 + * // data is the result of parsing the text.
53 + * // If there was a parsing error, it would have been caught.
54 + * }
55 + * ], callback);
56 + *
57 + * // passing a function returning a promise
58 + * async.waterfall([
59 + * async.apply(fs.readFile, filename, "utf8"),
60 + * async.asyncify(function (contents) {
61 + * return db.model.create(contents);
62 + * }),
63 + * function (model, next) {
64 + * // `model` is the instantiated model object.
65 + * // If there was an error, this function would be skipped.
66 + * }
67 + * ], callback);
68 + *
69 + * // es2017 example, though `asyncify` is not needed if your JS environment
70 + * // supports async functions out of the box
71 + * var q = async.queue(async.asyncify(async function(file) {
72 + * var intermediateStep = await processFile(file);
73 + * return await somePromise(intermediateStep)
74 + * }));
75 + *
76 + * q.push(files);
77 + */
78 +function asyncify(func) {
79 + return (0, _initialParams2.default)(function (args, callback) {
80 + var result;
81 + try {
82 + result = func.apply(this, args);
83 + } catch (e) {
84 + return callback(e);
85 + }
86 + // if result is Promise object
87 + if ((0, _isObject2.default)(result) && typeof result.then === 'function') {
88 + result.then(function (value) {
89 + invokeCallback(callback, null, value);
90 + }, function (err) {
91 + invokeCallback(callback, err.message ? err : new Error(err));
92 + });
93 + } else {
94 + callback(null, result);
95 + }
96 + });
97 +}
98 +
99 +function invokeCallback(callback, error, value) {
100 + try {
101 + callback(error, value);
102 + } catch (e) {
103 + (0, _setImmediate2.default)(rethrow, e);
104 + }
105 +}
106 +
107 +function rethrow(error) {
108 + throw error;
109 +}
110 +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 (tasks, concurrency, callback) {
8 + if (typeof concurrency === 'function') {
9 + // concurrency is optional, shift the args.
10 + callback = concurrency;
11 + concurrency = null;
12 + }
13 + callback = (0, _once2.default)(callback || _noop2.default);
14 + var keys = (0, _keys2.default)(tasks);
15 + var numTasks = keys.length;
16 + if (!numTasks) {
17 + return callback(null);
18 + }
19 + if (!concurrency) {
20 + concurrency = numTasks;
21 + }
22 +
23 + var results = {};
24 + var runningTasks = 0;
25 + var hasError = false;
26 +
27 + var listeners = Object.create(null);
28 +
29 + var readyTasks = [];
30 +
31 + // for cycle detection:
32 + var readyToCheck = []; // tasks that have been identified as reachable
33 + // without the possibility of returning to an ancestor task
34 + var uncheckedDependencies = {};
35 +
36 + (0, _baseForOwn2.default)(tasks, function (task, key) {
37 + if (!(0, _isArray2.default)(task)) {
38 + // no dependencies
39 + enqueueTask(key, [task]);
40 + readyToCheck.push(key);
41 + return;
42 + }
43 +
44 + var dependencies = task.slice(0, task.length - 1);
45 + var remainingDependencies = dependencies.length;
46 + if (remainingDependencies === 0) {
47 + enqueueTask(key, task);
48 + readyToCheck.push(key);
49 + return;
50 + }
51 + uncheckedDependencies[key] = remainingDependencies;
52 +
53 + (0, _arrayEach2.default)(dependencies, function (dependencyName) {
54 + if (!tasks[dependencyName]) {
55 + throw new Error('async.auto task `' + key + '` has a non-existent dependency `' + dependencyName + '` in ' + dependencies.join(', '));
56 + }
57 + addListener(dependencyName, function () {
58 + remainingDependencies--;
59 + if (remainingDependencies === 0) {
60 + enqueueTask(key, task);
61 + }
62 + });
63 + });
64 + });
65 +
66 + checkForDeadlocks();
67 + processQueue();
68 +
69 + function enqueueTask(key, task) {
70 + readyTasks.push(function () {
71 + runTask(key, task);
72 + });
73 + }
74 +
75 + function processQueue() {
76 + if (readyTasks.length === 0 && runningTasks === 0) {
77 + return callback(null, results);
78 + }
79 + while (readyTasks.length && runningTasks < concurrency) {
80 + var run = readyTasks.shift();
81 + run();
82 + }
83 + }
84 +
85 + function addListener(taskName, fn) {
86 + var taskListeners = listeners[taskName];
87 + if (!taskListeners) {
88 + taskListeners = listeners[taskName] = [];
89 + }
90 +
91 + taskListeners.push(fn);
92 + }
93 +
94 + function taskComplete(taskName) {
95 + var taskListeners = listeners[taskName] || [];
96 + (0, _arrayEach2.default)(taskListeners, function (fn) {
97 + fn();
98 + });
99 + processQueue();
100 + }
101 +
102 + function runTask(key, task) {
103 + if (hasError) return;
104 +
105 + var taskCallback = (0, _onlyOnce2.default)(function (err, result) {
106 + runningTasks--;
107 + if (arguments.length > 2) {
108 + result = (0, _slice2.default)(arguments, 1);
109 + }
110 + if (err) {
111 + var safeResults = {};
112 + (0, _baseForOwn2.default)(results, function (val, rkey) {
113 + safeResults[rkey] = val;
114 + });
115 + safeResults[key] = result;
116 + hasError = true;
117 + listeners = Object.create(null);
118 +
119 + callback(err, safeResults);
120 + } else {
121 + results[key] = result;
122 + taskComplete(key);
123 + }
124 + });
125 +
126 + runningTasks++;
127 + var taskFn = (0, _wrapAsync2.default)(task[task.length - 1]);
128 + if (task.length > 1) {
129 + taskFn(results, taskCallback);
130 + } else {
131 + taskFn(taskCallback);
132 + }
133 + }
134 +
135 + function checkForDeadlocks() {
136 + // Kahn's algorithm
137 + // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
138 + // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
139 + var currentTask;
140 + var counter = 0;
141 + while (readyToCheck.length) {
142 + currentTask = readyToCheck.pop();
143 + counter++;
144 + (0, _arrayEach2.default)(getDependents(currentTask), function (dependent) {
145 + if (--uncheckedDependencies[dependent] === 0) {
146 + readyToCheck.push(dependent);
147 + }
148 + });
149 + }
150 +
151 + if (counter !== numTasks) {
152 + throw new Error('async.auto cannot execute tasks due to a recursive dependency');
153 + }
154 + }
155 +
156 + function getDependents(taskName) {
157 + var result = [];
158 + (0, _baseForOwn2.default)(tasks, function (task, key) {
159 + if ((0, _isArray2.default)(task) && (0, _baseIndexOf2.default)(task, taskName, 0) >= 0) {
160 + result.push(key);
161 + }
162 + });
163 + return result;
164 + }
165 +};
166 +
167 +var _arrayEach = require('lodash/_arrayEach');
168 +
169 +var _arrayEach2 = _interopRequireDefault(_arrayEach);
170 +
171 +var _baseForOwn = require('lodash/_baseForOwn');
172 +
173 +var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
174 +
175 +var _baseIndexOf = require('lodash/_baseIndexOf');
176 +
177 +var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
178 +
179 +var _isArray = require('lodash/isArray');
180 +
181 +var _isArray2 = _interopRequireDefault(_isArray);
182 +
183 +var _keys = require('lodash/keys');
184 +
185 +var _keys2 = _interopRequireDefault(_keys);
186 +
187 +var _noop = require('lodash/noop');
188 +
189 +var _noop2 = _interopRequireDefault(_noop);
190 +
191 +var _slice = require('./internal/slice');
192 +
193 +var _slice2 = _interopRequireDefault(_slice);
194 +
195 +var _once = require('./internal/once');
196 +
197 +var _once2 = _interopRequireDefault(_once);
198 +
199 +var _onlyOnce = require('./internal/onlyOnce');
200 +
201 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
202 +
203 +var _wrapAsync = require('./internal/wrapAsync');
204 +
205 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
206 +
207 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
208 +
209 +module.exports = exports['default'];
210 +
211 +/**
212 + * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
213 + * their requirements. Each function can optionally depend on other functions
214 + * being completed first, and each function is run as soon as its requirements
215 + * are satisfied.
216 + *
217 + * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
218 + * will stop. Further tasks will not execute (so any other functions depending
219 + * on it will not run), and the main `callback` is immediately called with the
220 + * error.
221 + *
222 + * {@link AsyncFunction}s also receive an object containing the results of functions which
223 + * have completed so far as the first argument, if they have dependencies. If a
224 + * task function has no dependencies, it will only be passed a callback.
225 + *
226 + * @name auto
227 + * @static
228 + * @memberOf module:ControlFlow
229 + * @method
230 + * @category Control Flow
231 + * @param {Object} tasks - An object. Each of its properties is either a
232 + * function or an array of requirements, with the {@link AsyncFunction} itself the last item
233 + * in the array. The object's key of a property serves as the name of the task
234 + * defined by that property, i.e. can be used when specifying requirements for
235 + * other tasks. The function receives one or two arguments:
236 + * * a `results` object, containing the results of the previously executed
237 + * functions, only passed if the task has any dependencies,
238 + * * a `callback(err, result)` function, which must be called when finished,
239 + * passing an `error` (which can be `null`) and the result of the function's
240 + * execution.
241 + * @param {number} [concurrency=Infinity] - An optional `integer` for
242 + * determining the maximum number of tasks that can be run in parallel. By
243 + * default, as many as possible.
244 + * @param {Function} [callback] - An optional callback which is called when all
245 + * the tasks have been completed. It receives the `err` argument if any `tasks`
246 + * pass an error to their callback. Results are always returned; however, if an
247 + * error occurs, no further `tasks` will be performed, and the results object
248 + * will only contain partial results. Invoked with (err, results).
249 + * @returns undefined
250 + * @example
251 + *
252 + * async.auto({
253 + * // this function will just be passed a callback
254 + * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
255 + * showData: ['readData', function(results, cb) {
256 + * // results.readData is the file's contents
257 + * // ...
258 + * }]
259 + * }, callback);
260 + *
261 + * async.auto({
262 + * get_data: function(callback) {
263 + * console.log('in get_data');
264 + * // async code to get some data
265 + * callback(null, 'data', 'converted to array');
266 + * },
267 + * make_folder: function(callback) {
268 + * console.log('in make_folder');
269 + * // async code to create a directory to store a file in
270 + * // this is run at the same time as getting the data
271 + * callback(null, 'folder');
272 + * },
273 + * write_file: ['get_data', 'make_folder', function(results, callback) {
274 + * console.log('in write_file', JSON.stringify(results));
275 + * // once there is some data and the directory exists,
276 + * // write the data to a file in the directory
277 + * callback(null, 'filename');
278 + * }],
279 + * email_link: ['write_file', function(results, callback) {
280 + * console.log('in email_link', JSON.stringify(results));
281 + * // once the file is written let's email a link to it...
282 + * // results.write_file contains the filename returned by write_file.
283 + * callback(null, {'file':results.write_file, 'email':'user@example.com'});
284 + * }]
285 + * }, function(err, results) {
286 + * console.log('err = ', err);
287 + * console.log('results = ', results);
288 + * });
289 + */
...\ 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 = autoInject;
7 +
8 +var _auto = require('./auto');
9 +
10 +var _auto2 = _interopRequireDefault(_auto);
11 +
12 +var _baseForOwn = require('lodash/_baseForOwn');
13 +
14 +var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
15 +
16 +var _arrayMap = require('lodash/_arrayMap');
17 +
18 +var _arrayMap2 = _interopRequireDefault(_arrayMap);
19 +
20 +var _isArray = require('lodash/isArray');
21 +
22 +var _isArray2 = _interopRequireDefault(_isArray);
23 +
24 +var _trim = require('lodash/trim');
25 +
26 +var _trim2 = _interopRequireDefault(_trim);
27 +
28 +var _wrapAsync = require('./internal/wrapAsync');
29 +
30 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
31 +
32 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33 +
34 +var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
35 +var FN_ARG_SPLIT = /,/;
36 +var FN_ARG = /(=.+)?(\s*)$/;
37 +var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
38 +
39 +function parseParams(func) {
40 + func = func.toString().replace(STRIP_COMMENTS, '');
41 + func = func.match(FN_ARGS)[2].replace(' ', '');
42 + func = func ? func.split(FN_ARG_SPLIT) : [];
43 + func = func.map(function (arg) {
44 + return (0, _trim2.default)(arg.replace(FN_ARG, ''));
45 + });
46 + return func;
47 +}
48 +
49 +/**
50 + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
51 + * tasks are specified as parameters to the function, after the usual callback
52 + * parameter, with the parameter names matching the names of the tasks it
53 + * depends on. This can provide even more readable task graphs which can be
54 + * easier to maintain.
55 + *
56 + * If a final callback is specified, the task results are similarly injected,
57 + * specified as named parameters after the initial error parameter.
58 + *
59 + * The autoInject function is purely syntactic sugar and its semantics are
60 + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
61 + *
62 + * @name autoInject
63 + * @static
64 + * @memberOf module:ControlFlow
65 + * @method
66 + * @see [async.auto]{@link module:ControlFlow.auto}
67 + * @category Control Flow
68 + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
69 + * the form 'func([dependencies...], callback). The object's key of a property
70 + * serves as the name of the task defined by that property, i.e. can be used
71 + * when specifying requirements for other tasks.
72 + * * The `callback` parameter is a `callback(err, result)` which must be called
73 + * when finished, passing an `error` (which can be `null`) and the result of
74 + * the function's execution. The remaining parameters name other tasks on
75 + * which the task is dependent, and the results from those tasks are the
76 + * arguments of those parameters.
77 + * @param {Function} [callback] - An optional callback which is called when all
78 + * the tasks have been completed. It receives the `err` argument if any `tasks`
79 + * pass an error to their callback, and a `results` object with any completed
80 + * task results, similar to `auto`.
81 + * @example
82 + *
83 + * // The example from `auto` can be rewritten as follows:
84 + * async.autoInject({
85 + * get_data: function(callback) {
86 + * // async code to get some data
87 + * callback(null, 'data', 'converted to array');
88 + * },
89 + * make_folder: function(callback) {
90 + * // async code to create a directory to store a file in
91 + * // this is run at the same time as getting the data
92 + * callback(null, 'folder');
93 + * },
94 + * write_file: function(get_data, make_folder, callback) {
95 + * // once there is some data and the directory exists,
96 + * // write the data to a file in the directory
97 + * callback(null, 'filename');
98 + * },
99 + * email_link: function(write_file, callback) {
100 + * // once the file is written let's email a link to it...
101 + * // write_file contains the filename returned by write_file.
102 + * callback(null, {'file':write_file, 'email':'user@example.com'});
103 + * }
104 + * }, function(err, results) {
105 + * console.log('err = ', err);
106 + * console.log('email_link = ', results.email_link);
107 + * });
108 + *
109 + * // If you are using a JS minifier that mangles parameter names, `autoInject`
110 + * // will not work with plain functions, since the parameter names will be
111 + * // collapsed to a single letter identifier. To work around this, you can
112 + * // explicitly specify the names of the parameters your task function needs
113 + * // in an array, similar to Angular.js dependency injection.
114 + *
115 + * // This still has an advantage over plain `auto`, since the results a task
116 + * // depends on are still spread into arguments.
117 + * async.autoInject({
118 + * //...
119 + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
120 + * callback(null, 'filename');
121 + * }],
122 + * email_link: ['write_file', function(write_file, callback) {
123 + * callback(null, {'file':write_file, 'email':'user@example.com'});
124 + * }]
125 + * //...
126 + * }, function(err, results) {
127 + * console.log('err = ', err);
128 + * console.log('email_link = ', results.email_link);
129 + * });
130 + */
131 +function autoInject(tasks, callback) {
132 + var newTasks = {};
133 +
134 + (0, _baseForOwn2.default)(tasks, function (taskFn, key) {
135 + var params;
136 + var fnIsAsync = (0, _wrapAsync.isAsync)(taskFn);
137 + var hasNoDeps = !fnIsAsync && taskFn.length === 1 || fnIsAsync && taskFn.length === 0;
138 +
139 + if ((0, _isArray2.default)(taskFn)) {
140 + params = taskFn.slice(0, -1);
141 + taskFn = taskFn[taskFn.length - 1];
142 +
143 + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
144 + } else if (hasNoDeps) {
145 + // no dependencies, use the function as-is
146 + newTasks[key] = taskFn;
147 + } else {
148 + params = parseParams(taskFn);
149 + if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
150 + throw new Error("autoInject task functions require explicit parameters.");
151 + }
152 +
153 + // remove callback param
154 + if (!fnIsAsync) params.pop();
155 +
156 + newTasks[key] = params.concat(newTask);
157 + }
158 +
159 + function newTask(results, taskCb) {
160 + var newArgs = (0, _arrayMap2.default)(params, function (name) {
161 + return results[name];
162 + });
163 + newArgs.push(taskCb);
164 + (0, _wrapAsync2.default)(taskFn).apply(null, newArgs);
165 + }
166 + });
167 +
168 + (0, _auto2.default)(newTasks, callback);
169 +}
170 +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 + "mocha_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');
9 +
10 +var _queue2 = _interopRequireDefault(_queue);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * A cargo of tasks for the worker function to complete. Cargo inherits all of
16 + * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
17 + * @typedef {Object} CargoObject
18 + * @memberOf module:ControlFlow
19 + * @property {Function} length - A function returning the number of items
20 + * waiting to be processed. Invoke like `cargo.length()`.
21 + * @property {number} payload - An `integer` for determining how many tasks
22 + * should be process per round. This property can be changed after a `cargo` is
23 + * created to alter the payload on-the-fly.
24 + * @property {Function} push - Adds `task` to the `queue`. The callback is
25 + * called once the `worker` has finished processing the task. Instead of a
26 + * single task, an array of `tasks` can be submitted. The respective callback is
27 + * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
28 + * @property {Function} saturated - A callback that is called when the
29 + * `queue.length()` hits the concurrency and further tasks will be queued.
30 + * @property {Function} empty - A callback that is called when the last item
31 + * from the `queue` is given to a `worker`.
32 + * @property {Function} drain - A callback that is called when the last item
33 + * from the `queue` has returned from the `worker`.
34 + * @property {Function} idle - a function returning false if there are items
35 + * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
36 + * @property {Function} pause - a function that pauses the processing of tasks
37 + * until `resume()` is called. Invoke like `cargo.pause()`.
38 + * @property {Function} resume - a function that resumes the processing of
39 + * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
40 + * @property {Function} kill - a function that removes the `drain` callback and
41 + * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
42 + */
43 +
44 +/**
45 + * Creates a `cargo` object with the specified payload. Tasks added to the
46 + * cargo will be processed altogether (up to the `payload` limit). If the
47 + * `worker` is in progress, the task is queued until it becomes available. Once
48 + * the `worker` has completed some tasks, each callback of those tasks is
49 + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
50 + * for how `cargo` and `queue` work.
51 + *
52 + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
53 + * at a time, cargo passes an array of tasks to a single worker, repeating
54 + * when the worker is finished.
55 + *
56 + * @name cargo
57 + * @static
58 + * @memberOf module:ControlFlow
59 + * @method
60 + * @see [async.queue]{@link module:ControlFlow.queue}
61 + * @category Control Flow
62 + * @param {AsyncFunction} worker - An asynchronous function for processing an array
63 + * of queued tasks. Invoked with `(tasks, callback)`.
64 + * @param {number} [payload=Infinity] - An optional `integer` for determining
65 + * how many tasks should be processed per round; if omitted, the default is
66 + * unlimited.
67 + * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
68 + * attached as certain properties to listen for specific events during the
69 + * lifecycle of the cargo and inner queue.
70 + * @example
71 + *
72 + * // create a cargo object with payload 2
73 + * var cargo = async.cargo(function(tasks, callback) {
74 + * for (var i=0; i<tasks.length; i++) {
75 + * console.log('hello ' + tasks[i].name);
76 + * }
77 + * callback();
78 + * }, 2);
79 + *
80 + * // add some items
81 + * cargo.push({name: 'foo'}, function(err) {
82 + * console.log('finished processing foo');
83 + * });
84 + * cargo.push({name: 'bar'}, function(err) {
85 + * console.log('finished processing bar');
86 + * });
87 + * cargo.push({name: 'baz'}, function(err) {
88 + * console.log('finished processing baz');
89 + * });
90 + */
91 +function cargo(worker, payload) {
92 + return (0, _queue2.default)(worker, 1, payload);
93 +}
94 +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 _seq2.default.apply(null, (0, _slice2.default)(arguments).reverse());
9 +};
10 +
11 +var _seq = require('./seq');
12 +
13 +var _seq2 = _interopRequireDefault(_seq);
14 +
15 +var _slice = require('./internal/slice');
16 +
17 +var _slice2 = _interopRequireDefault(_slice);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +;
22 +
23 +/**
24 + * Creates a function which is a composition of the passed asynchronous
25 + * functions. Each function consumes the return value of the function that
26 + * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
27 + * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
28 + *
29 + * Each function is executed with the `this` binding of the composed function.
30 + *
31 + * @name compose
32 + * @static
33 + * @memberOf module:ControlFlow
34 + * @method
35 + * @category Control Flow
36 + * @param {...AsyncFunction} functions - the asynchronous functions to compose
37 + * @returns {Function} an asynchronous function that is the composed
38 + * asynchronous `functions`
39 + * @example
40 + *
41 + * function add1(n, callback) {
42 + * setTimeout(function () {
43 + * callback(null, n + 1);
44 + * }, 10);
45 + * }
46 + *
47 + * function mul3(n, callback) {
48 + * setTimeout(function () {
49 + * callback(null, n * 3);
50 + * }, 10);
51 + * }
52 + *
53 + * var add1mul3 = async.compose(mul3, add1);
54 + * add1mul3(4, function (err, result) {
55 + * // result now equals 15
56 + * });
57 + */
58 +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 _doLimit = require('./internal/doLimit');
8 +
9 +var _doLimit2 = _interopRequireDefault(_doLimit);
10 +
11 +var _concatLimit = require('./concatLimit');
12 +
13 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
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. There is no guarantee that the
21 + * results array will be returned in the original order of `coll` passed to the
22 + * `iteratee` function.
23 + *
24 + * @name concat
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @category Collection
29 + * @param {Array|Iterable|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(err)] - 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 + * @example
37 + *
38 + * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
39 + * // files is now a list of filenames that exist in the 3 directories
40 + * });
41 + */
42 +exports.default = (0, _doLimit2.default)(_concatLimit2.default, Infinity);
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 +exports.default = function (coll, limit, iteratee, callback) {
8 + callback = callback || _noop2.default;
9 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
10 + (0, _mapLimit2.default)(coll, limit, function (val, callback) {
11 + _iteratee(val, function (err /*, ...args*/) {
12 + if (err) return callback(err);
13 + return callback(null, (0, _slice2.default)(arguments, 1));
14 + });
15 + }, function (err, mapResults) {
16 + var result = [];
17 + for (var i = 0; i < mapResults.length; i++) {
18 + if (mapResults[i]) {
19 + result = _concat.apply(result, mapResults[i]);
20 + }
21 + }
22 +
23 + return callback(err, result);
24 + });
25 +};
26 +
27 +var _noop = require('lodash/noop');
28 +
29 +var _noop2 = _interopRequireDefault(_noop);
30 +
31 +var _wrapAsync = require('./internal/wrapAsync');
32 +
33 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
34 +
35 +var _slice = require('./internal/slice');
36 +
37 +var _slice2 = _interopRequireDefault(_slice);
38 +
39 +var _mapLimit = require('./mapLimit');
40 +
41 +var _mapLimit2 = _interopRequireDefault(_mapLimit);
42 +
43 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44 +
45 +var _concat = Array.prototype.concat;
46 +
47 +/**
48 + * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
49 + *
50 + * @name concatLimit
51 + * @static
52 + * @memberOf module:Collections
53 + * @method
54 + * @see [async.concat]{@link module:Collections.concat}
55 + * @category Collection
56 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
57 + * @param {number} limit - The maximum number of async operations at a time.
58 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
59 + * which should use an array as its result. Invoked with (item, callback).
60 + * @param {Function} [callback] - A callback which is called after all the
61 + * `iteratee` functions have finished, or an error occurs. Results is an array
62 + * containing the concatenated results of the `iteratee` function. Invoked with
63 + * (err, results).
64 + */
65 +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 _doLimit = require('./internal/doLimit');
8 +
9 +var _doLimit2 = _interopRequireDefault(_doLimit);
10 +
11 +var _concatLimit = require('./concatLimit');
12 +
13 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
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 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
27 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
28 + * The iteratee should complete with an array an array of results.
29 + * Invoked with (item, callback).
30 + * @param {Function} [callback(err)] - A callback which is called after all the
31 + * `iteratee` functions have finished, or an error occurs. Results is an array
32 + * containing the concatenated results of the `iteratee` function. Invoked with
33 + * (err, results).
34 + */
35 +exports.default = (0, _doLimit2.default)(_concatLimit2.default, 1);
36 +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 () /*...values*/{
8 + var values = (0, _slice2.default)(arguments);
9 + var args = [null].concat(values);
10 + return function () /*...ignoredArgs, callback*/{
11 + var callback = arguments[arguments.length - 1];
12 + return callback.apply(this, args);
13 + };
14 +};
15 +
16 +var _slice = require('./internal/slice');
17 +
18 +var _slice2 = _interopRequireDefault(_slice);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +;
23 +
24 +/**
25 + * Returns a function that when called, calls-back with the values provided.
26 + * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
27 + * [`auto`]{@link module:ControlFlow.auto}.
28 + *
29 + * @name constant
30 + * @static
31 + * @memberOf module:Utils
32 + * @method
33 + * @category Util
34 + * @param {...*} arguments... - Any number of arguments to automatically invoke
35 + * callback with.
36 + * @returns {AsyncFunction} Returns a function that when invoked, automatically
37 + * invokes the callback with the previous given arguments.
38 + * @example
39 + *
40 + * async.waterfall([
41 + * async.constant(42),
42 + * function (value, next) {
43 + * // value === 42
44 + * },
45 + * //...
46 + * ], callback);
47 + *
48 + * async.waterfall([
49 + * async.constant(filename, "utf8"),
50 + * fs.readFile,
51 + * function (fileData, next) {
52 + * //...
53 + * }
54 + * //...
55 + * ], callback);
56 + *
57 + * async.auto({
58 + * hostname: async.constant("https://server.net/"),
59 + * port: findFreePort,
60 + * launchServer: ["hostname", "port", function (options, cb) {
61 + * startServer(options, cb);
62 + * }],
63 + * //...
64 + * }, callback);
65 + */
66 +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 _identity = require('lodash/identity');
8 +
9 +var _identity2 = _interopRequireDefault(_identity);
10 +
11 +var _createTester = require('./internal/createTester');
12 +
13 +var _createTester2 = _interopRequireDefault(_createTester);
14 +
15 +var _doParallel = require('./internal/doParallel');
16 +
17 +var _doParallel2 = _interopRequireDefault(_doParallel);
18 +
19 +var _findGetResult = require('./internal/findGetResult');
20 +
21 +var _findGetResult2 = _interopRequireDefault(_findGetResult);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Returns the first value in `coll` that passes an async truth test. The
27 + * `iteratee` is applied in parallel, meaning the first iteratee to return
28 + * `true` will fire the detect `callback` with that result. That means the
29 + * result might not be the first item in the original `coll` (in terms of order)
30 + * that passes the test.
31 +
32 + * If order within the original `coll` is important, then look at
33 + * [`detectSeries`]{@link module:Collections.detectSeries}.
34 + *
35 + * @name detect
36 + * @static
37 + * @memberOf module:Collections
38 + * @method
39 + * @alias find
40 + * @category Collections
41 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
42 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
43 + * The iteratee must complete with a boolean value as its result.
44 + * Invoked with (item, callback).
45 + * @param {Function} [callback] - A callback which is called as soon as any
46 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
47 + * Result will be the first item in the array that passes the truth test
48 + * (iteratee) or the value `undefined` if none passed. Invoked with
49 + * (err, result).
50 + * @example
51 + *
52 + * async.detect(['file1','file2','file3'], function(filePath, callback) {
53 + * fs.access(filePath, function(err) {
54 + * callback(null, !err)
55 + * });
56 + * }, function(err, result) {
57 + * // result now equals the first file in the list that exists
58 + * });
59 + */
60 +exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default));
61 +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 _identity = require('lodash/identity');
8 +
9 +var _identity2 = _interopRequireDefault(_identity);
10 +
11 +var _createTester = require('./internal/createTester');
12 +
13 +var _createTester2 = _interopRequireDefault(_createTester);
14 +
15 +var _doParallelLimit = require('./internal/doParallelLimit');
16 +
17 +var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
18 +
19 +var _findGetResult = require('./internal/findGetResult');
20 +
21 +var _findGetResult2 = _interopRequireDefault(_findGetResult);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
27 + * time.
28 + *
29 + * @name detectLimit
30 + * @static
31 + * @memberOf module:Collections
32 + * @method
33 + * @see [async.detect]{@link module:Collections.detect}
34 + * @alias findLimit
35 + * @category Collections
36 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
37 + * @param {number} limit - The maximum number of async operations at a time.
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 + */
47 +exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default));
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 _detectLimit = require('./detectLimit');
8 +
9 +var _detectLimit2 = _interopRequireDefault(_detectLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
19 + *
20 + * @name detectSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.detect]{@link module:Collections.detect}
25 + * @alias findSeries
26 + * @category Collections
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
29 + * The iteratee must complete with a boolean value as its result.
30 + * Invoked with (item, callback).
31 + * @param {Function} [callback] - A callback which is called as soon as any
32 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
33 + * Result will be the first item in the array that passes the truth test
34 + * (iteratee) or the value `undefined` if none passed. Invoked with
35 + * (err, result).
36 + */
37 +exports.default = (0, _doLimit2.default)(_detectLimit2.default, 1);
38 +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');
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 is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = doDuring;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _slice = require('./internal/slice');
13 +
14 +var _slice2 = _interopRequireDefault(_slice);
15 +
16 +var _onlyOnce = require('./internal/onlyOnce');
17 +
18 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
19 +
20 +var _wrapAsync = require('./internal/wrapAsync');
21 +
22 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
23 +
24 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25 +
26 +/**
27 + * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
28 + * the order of operations, the arguments `test` and `fn` are switched.
29 + *
30 + * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
31 + * @name doDuring
32 + * @static
33 + * @memberOf module:ControlFlow
34 + * @method
35 + * @see [async.during]{@link module:ControlFlow.during}
36 + * @category Control Flow
37 + * @param {AsyncFunction} fn - An async function which is called each time
38 + * `test` passes. Invoked with (callback).
39 + * @param {AsyncFunction} test - asynchronous truth test to perform before each
40 + * execution of `fn`. Invoked with (...args, callback), where `...args` are the
41 + * non-error args from the previous callback of `fn`.
42 + * @param {Function} [callback] - A callback which is called after the test
43 + * function has failed and repeated execution of `fn` has stopped. `callback`
44 + * will be passed an error if one occurred, otherwise `null`.
45 + */
46 +function doDuring(fn, test, callback) {
47 + callback = (0, _onlyOnce2.default)(callback || _noop2.default);
48 + var _fn = (0, _wrapAsync2.default)(fn);
49 + var _test = (0, _wrapAsync2.default)(test);
50 +
51 + function next(err /*, ...args*/) {
52 + if (err) return callback(err);
53 + var args = (0, _slice2.default)(arguments, 1);
54 + args.push(check);
55 + _test.apply(this, args);
56 + };
57 +
58 + function check(err, truth) {
59 + if (err) return callback(err);
60 + if (!truth) return callback(null);
61 + _fn(next);
62 + }
63 +
64 + check(null, true);
65 +}
66 +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');
9 +
10 +var _doWhilst2 = _interopRequireDefault(_doWhilst);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
16 + * argument ordering differs from `until`.
17 + *
18 + * @name doUntil
19 + * @static
20 + * @memberOf module:ControlFlow
21 + * @method
22 + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
23 + * @category Control Flow
24 + * @param {AsyncFunction} iteratee - An async function which is called each time
25 + * `test` fails. Invoked with (callback).
26 + * @param {Function} test - synchronous truth test to perform after each
27 + * execution of `iteratee`. Invoked with any non-error callback results of
28 + * `iteratee`.
29 + * @param {Function} [callback] - A callback which is called after the test
30 + * function has passed and repeated execution of `iteratee` has stopped. `callback`
31 + * will be passed an error and any arguments passed to the final `iteratee`'s
32 + * callback. Invoked with (err, [results]);
33 + */
34 +function doUntil(iteratee, test, callback) {
35 + (0, _doWhilst2.default)(iteratee, function () {
36 + return !test.apply(this, arguments);
37 + }, callback);
38 +}
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 +exports.default = doWhilst;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _slice = require('./internal/slice');
13 +
14 +var _slice2 = _interopRequireDefault(_slice);
15 +
16 +var _onlyOnce = require('./internal/onlyOnce');
17 +
18 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
19 +
20 +var _wrapAsync = require('./internal/wrapAsync');
21 +
22 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
23 +
24 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25 +
26 +/**
27 + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
28 + * the order of operations, the arguments `test` and `iteratee` are switched.
29 + *
30 + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
31 + *
32 + * @name doWhilst
33 + * @static
34 + * @memberOf module:ControlFlow
35 + * @method
36 + * @see [async.whilst]{@link module:ControlFlow.whilst}
37 + * @category Control Flow
38 + * @param {AsyncFunction} iteratee - A function which is called each time `test`
39 + * passes. Invoked with (callback).
40 + * @param {Function} test - synchronous truth test to perform after each
41 + * execution of `iteratee`. Invoked with any non-error callback results of
42 + * `iteratee`.
43 + * @param {Function} [callback] - A callback which is called after the test
44 + * function has failed and repeated execution of `iteratee` has stopped.
45 + * `callback` will be passed an error and any arguments passed to the final
46 + * `iteratee`'s callback. Invoked with (err, [results]);
47 + */
48 +function doWhilst(iteratee, test, callback) {
49 + callback = (0, _onlyOnce2.default)(callback || _noop2.default);
50 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
51 + var next = function (err /*, ...args*/) {
52 + if (err) return callback(err);
53 + var args = (0, _slice2.default)(arguments, 1);
54 + if (test.apply(this, args)) return _iteratee(next);
55 + callback.apply(null, [null].concat(args));
56 + };
57 + _iteratee(next);
58 +}
59 +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 = during;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _onlyOnce = require('./internal/onlyOnce');
13 +
14 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
15 +
16 +var _wrapAsync = require('./internal/wrapAsync');
17 +
18 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
24 + * is passed a callback in the form of `function (err, truth)`. If error is
25 + * passed to `test` or `fn`, the main callback is immediately called with the
26 + * value of the error.
27 + *
28 + * @name during
29 + * @static
30 + * @memberOf module:ControlFlow
31 + * @method
32 + * @see [async.whilst]{@link module:ControlFlow.whilst}
33 + * @category Control Flow
34 + * @param {AsyncFunction} test - asynchronous truth test to perform before each
35 + * execution of `fn`. Invoked with (callback).
36 + * @param {AsyncFunction} fn - An async function which is called each time
37 + * `test` passes. Invoked with (callback).
38 + * @param {Function} [callback] - A callback which is called after the test
39 + * function has failed and repeated execution of `fn` has stopped. `callback`
40 + * will be passed an error, if one occurred, otherwise `null`.
41 + * @example
42 + *
43 + * var count = 0;
44 + *
45 + * async.during(
46 + * function (callback) {
47 + * return callback(null, count < 5);
48 + * },
49 + * function (callback) {
50 + * count++;
51 + * setTimeout(callback, 1000);
52 + * },
53 + * function (err) {
54 + * // 5 seconds have passed
55 + * }
56 + * );
57 + */
58 +function during(test, fn, callback) {
59 + callback = (0, _onlyOnce2.default)(callback || _noop2.default);
60 + var _fn = (0, _wrapAsync2.default)(fn);
61 + var _test = (0, _wrapAsync2.default)(test);
62 +
63 + function next(err) {
64 + if (err) return callback(err);
65 + _test(check);
66 + }
67 +
68 + function check(err, truth) {
69 + if (err) return callback(err);
70 + if (!truth) return callback(null);
71 + _fn(next);
72 + }
73 +
74 + _test(check);
75 +}
76 +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 = eachLimit;
7 +
8 +var _eachOf = require('./eachOf');
9 +
10 +var _eachOf2 = _interopRequireDefault(_eachOf);
11 +
12 +var _withoutIndex = require('./internal/withoutIndex');
13 +
14 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
15 +
16 +var _wrapAsync = require('./internal/wrapAsync');
17 +
18 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * Applies the function `iteratee` to each item in `coll`, in parallel.
24 + * The `iteratee` is called with an item from the list, and a callback for when
25 + * it has finished. If the `iteratee` passes an error to its `callback`, the
26 + * main `callback` (for the `each` function) is immediately called with the
27 + * error.
28 + *
29 + * Note, that since this function applies `iteratee` to each item in parallel,
30 + * there is no guarantee that the iteratee functions will complete in order.
31 + *
32 + * @name each
33 + * @static
34 + * @memberOf module:Collections
35 + * @method
36 + * @alias forEach
37 + * @category Collection
38 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
39 + * @param {AsyncFunction} iteratee - An async function to apply to
40 + * each item in `coll`. Invoked with (item, callback).
41 + * The array index is not passed to the iteratee.
42 + * If you need the index, use `eachOf`.
43 + * @param {Function} [callback] - A callback which is called when all
44 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
45 + * @example
46 + *
47 + * // assuming openFiles is an array of file names and saveFile is a function
48 + * // to save the modified contents of that file:
49 + *
50 + * async.each(openFiles, saveFile, function(err){
51 + * // if any of the saves produced an error, err would equal that error
52 + * });
53 + *
54 + * // assuming openFiles is an array of file names
55 + * async.each(openFiles, function(file, callback) {
56 + *
57 + * // Perform operation on file here.
58 + * console.log('Processing file ' + file);
59 + *
60 + * if( file.length > 32 ) {
61 + * console.log('This file name is too long');
62 + * callback('File name too long');
63 + * } else {
64 + * // Do work to process file here
65 + * console.log('File processed');
66 + * callback();
67 + * }
68 + * }, function(err) {
69 + * // if any of the file processing produced an error, err would equal that error
70 + * if( err ) {
71 + * // One of the iterations produced an error.
72 + * // All processing will now stop.
73 + * console.log('A file failed to process');
74 + * } else {
75 + * console.log('All files have been processed successfully');
76 + * }
77 + * });
78 + */
79 +function eachLimit(coll, iteratee, callback) {
80 + (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
81 +}
82 +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 = eachLimit;
7 +
8 +var _eachOfLimit = require('./internal/eachOfLimit');
9 +
10 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
11 +
12 +var _withoutIndex = require('./internal/withoutIndex');
13 +
14 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
15 +
16 +var _wrapAsync = require('./internal/wrapAsync');
17 +
18 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
24 + *
25 + * @name eachLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.each]{@link module:Collections.each}
30 + * @alias forEachLimit
31 + * @category Collection
32 + * @param {Array|Iterable|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 item in
35 + * `coll`.
36 + * The array index is not passed to the iteratee.
37 + * If you need the index, use `eachOfLimit`.
38 + * Invoked with (item, callback).
39 + * @param {Function} [callback] - A callback which is called when all
40 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
41 + */
42 +function eachLimit(coll, limit, iteratee, callback) {
43 + (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
44 +}
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 +exports.default = function (coll, iteratee, callback) {
8 + var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
9 + eachOfImplementation(coll, (0, _wrapAsync2.default)(iteratee), callback);
10 +};
11 +
12 +var _isArrayLike = require('lodash/isArrayLike');
13 +
14 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
15 +
16 +var _breakLoop = require('./internal/breakLoop');
17 +
18 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
19 +
20 +var _eachOfLimit = require('./eachOfLimit');
21 +
22 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
23 +
24 +var _doLimit = require('./internal/doLimit');
25 +
26 +var _doLimit2 = _interopRequireDefault(_doLimit);
27 +
28 +var _noop = require('lodash/noop');
29 +
30 +var _noop2 = _interopRequireDefault(_noop);
31 +
32 +var _once = require('./internal/once');
33 +
34 +var _once2 = _interopRequireDefault(_once);
35 +
36 +var _onlyOnce = require('./internal/onlyOnce');
37 +
38 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
39 +
40 +var _wrapAsync = require('./internal/wrapAsync');
41 +
42 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
43 +
44 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45 +
46 +// eachOf implementation optimized for array-likes
47 +function eachOfArrayLike(coll, iteratee, callback) {
48 + callback = (0, _once2.default)(callback || _noop2.default);
49 + var index = 0,
50 + completed = 0,
51 + length = coll.length;
52 + if (length === 0) {
53 + callback(null);
54 + }
55 +
56 + function iteratorCallback(err, value) {
57 + if (err) {
58 + callback(err);
59 + } else if (++completed === length || value === _breakLoop2.default) {
60 + callback(null);
61 + }
62 + }
63 +
64 + for (; index < length; index++) {
65 + iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
66 + }
67 +}
68 +
69 +// a generic version of eachOf which can handle array, object, and iterator cases.
70 +var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity);
71 +
72 +/**
73 + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
74 + * to the iteratee.
75 + *
76 + * @name eachOf
77 + * @static
78 + * @memberOf module:Collections
79 + * @method
80 + * @alias forEachOf
81 + * @category Collection
82 + * @see [async.each]{@link module:Collections.each}
83 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
84 + * @param {AsyncFunction} iteratee - A function to apply to each
85 + * item in `coll`.
86 + * The `key` is the item's key, or index in the case of an array.
87 + * Invoked with (item, key, callback).
88 + * @param {Function} [callback] - A callback which is called when all
89 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
90 + * @example
91 + *
92 + * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
93 + * var configs = {};
94 + *
95 + * async.forEachOf(obj, function (value, key, callback) {
96 + * fs.readFile(__dirname + value, "utf8", function (err, data) {
97 + * if (err) return callback(err);
98 + * try {
99 + * configs[key] = JSON.parse(data);
100 + * } catch (e) {
101 + * return callback(e);
102 + * }
103 + * callback();
104 + * });
105 + * }, function (err) {
106 + * if (err) console.error(err.message);
107 + * // configs is now a map of JSON data
108 + * doSomethingWith(configs);
109 + * });
110 + */
111 +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 = eachOfLimit;
7 +
8 +var _eachOfLimit2 = require('./internal/eachOfLimit');
9 +
10 +var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
11 +
12 +var _wrapAsync = require('./internal/wrapAsync');
13 +
14 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
20 + * time.
21 + *
22 + * @name eachOfLimit
23 + * @static
24 + * @memberOf module:Collections
25 + * @method
26 + * @see [async.eachOf]{@link module:Collections.eachOf}
27 + * @alias forEachOfLimit
28 + * @category Collection
29 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
30 + * @param {number} limit - The maximum number of async operations at a time.
31 + * @param {AsyncFunction} iteratee - An async function to apply to each
32 + * item in `coll`. The `key` is the item's key, or index in the case of an
33 + * array.
34 + * Invoked with (item, key, callback).
35 + * @param {Function} [callback] - A callback which is called when all
36 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
37 + */
38 +function eachOfLimit(coll, limit, iteratee, callback) {
39 + (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
40 +}
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 +var _eachOfLimit = require('./eachOfLimit');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
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|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 + */
34 +exports.default = (0, _doLimit2.default)(_eachOfLimit2.default, 1);
35 +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');
8 +
9 +var _eachLimit2 = _interopRequireDefault(_eachLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
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 + * @name eachSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.each]{@link module:Collections.each}
25 + * @alias forEachSeries
26 + * @category Collection
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - An async function to apply to each
29 + * item in `coll`.
30 + * The array index is not passed to the iteratee.
31 + * If you need the index, use `eachOfSeries`.
32 + * Invoked with (item, callback).
33 + * @param {Function} [callback] - A callback which is called when all
34 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
35 + */
36 +exports.default = (0, _doLimit2.default)(_eachLimit2.default, 1);
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 = ensureAsync;
7 +
8 +var _setImmediate = require('./internal/setImmediate');
9 +
10 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
11 +
12 +var _initialParams = require('./internal/initialParams');
13 +
14 +var _initialParams2 = _interopRequireDefault(_initialParams);
15 +
16 +var _wrapAsync = require('./internal/wrapAsync');
17 +
18 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19 +
20 +/**
21 + * Wrap an async function and ensure it calls its callback on a later tick of
22 + * the event loop. If the function already calls its callback on a next tick,
23 + * no extra deferral is added. This is useful for preventing stack overflows
24 + * (`RangeError: Maximum call stack size exceeded`) and generally keeping
25 + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
26 + * contained. ES2017 `async` functions are returned as-is -- they are immune
27 + * to Zalgo's corrupting influences, as they always resolve on a later tick.
28 + *
29 + * @name ensureAsync
30 + * @static
31 + * @memberOf module:Utils
32 + * @method
33 + * @category Util
34 + * @param {AsyncFunction} fn - an async function, one that expects a node-style
35 + * callback as its last argument.
36 + * @returns {AsyncFunction} Returns a wrapped function with the exact same call
37 + * signature as the function passed in.
38 + * @example
39 + *
40 + * function sometimesAsync(arg, callback) {
41 + * if (cache[arg]) {
42 + * return callback(null, cache[arg]); // this would be synchronous!!
43 + * } else {
44 + * doSomeIO(arg, callback); // this IO would be asynchronous
45 + * }
46 + * }
47 + *
48 + * // this has a risk of stack overflows if many results are cached in a row
49 + * async.mapSeries(args, sometimesAsync, done);
50 + *
51 + * // this will defer sometimesAsync's callback if necessary,
52 + * // preventing stack overflows
53 + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
54 + */
55 +function ensureAsync(fn) {
56 + if ((0, _wrapAsync.isAsync)(fn)) return fn;
57 + return (0, _initialParams2.default)(function (args, callback) {
58 + var sync = true;
59 + args.push(function () {
60 + var innerArgs = arguments;
61 + if (sync) {
62 + (0, _setImmediate2.default)(function () {
63 + callback.apply(null, innerArgs);
64 + });
65 + } else {
66 + callback.apply(null, innerArgs);
67 + }
68 + });
69 + fn.apply(this, args);
70 + sync = false;
71 + });
72 +}
73 +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 could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
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 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.
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.