hyunjong

기존 Kakao login에서 Naver login, Google login 추가

Showing 1000 changed files with 4705 additions and 1 deletions

Too many changes to show.

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

...@@ -77,7 +77,7 @@ app.use(express.static(path.join(__dirname, 'public'))); ...@@ -77,7 +77,7 @@ app.use(express.static(path.join(__dirname, 'public')));
77 connection = mysql.createConnection({ 77 connection = mysql.createConnection({
78 host : 'localhost', 78 host : 'localhost',
79 user : 'root', 79 user : 'root',
80 - password : 'password', 80 + password : 'asd123',
81 port : 3306, 81 port : 3306,
82 database : 'ytmt' 82 database : 'ytmt'
83 }); 83 });
......
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../acorn/bin/acorn" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../acorn/bin/acorn" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\acorn\bin\acorn" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\acorn\bin\acorn" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../escodegen/bin/escodegen.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../escodegen/bin/escodegen.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\escodegen\bin\escodegen.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\escodegen\bin\escodegen.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../escodegen/bin/esgenerate.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../escodegen/bin/esgenerate.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\escodegen\bin\esgenerate.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\escodegen\bin\esgenerate.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../esprima/bin/esparse.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../esprima/bin/esparse.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\esprima\bin\esparse.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\esprima\bin\esparse.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../esprima/bin/esvalidate.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../esprima/bin/esvalidate.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\esprima\bin\esvalidate.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\esprima\bin\esvalidate.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../handlebars/bin/handlebars" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../handlebars/bin/handlebars" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\handlebars\bin\handlebars" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\handlebars\bin\handlebars" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../js-yaml/bin/js-yaml.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../js-yaml/bin/js-yaml.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\js-yaml\bin\js-yaml.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\js-yaml\bin\js-yaml.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../uglify-js/bin/uglifyjs" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../uglify-js/bin/uglifyjs" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\uglify-js\bin\uglifyjs" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\uglify-js\bin\uglifyjs" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +## 1.0.4
2 +
3 +- Added license file
4 +
5 +## 1.0.3
6 +
7 +- Replaced `let` with `var` in `lib/btoa.js`
8 + - Follow up from `1.0.2`
9 + - Resolves https://github.com/jsdom/abab/issues/18
10 +
11 +## 1.0.2
12 +
13 +- Replaced `const` with `var` in `index.js`
14 + - Allows use of `abab` in the browser without a transpilation step
15 + - Resolves https://github.com/jsdom/abab/issues/15
1 +Both the original source code and new contributions in this repository are released under the [W3C 3-clause BSD license](https://github.com/w3c/web-platform-tests/blob/master/LICENSE.md#w3c-3-clause-bsd-license).
2 +
3 +# W3C 3-clause BSD License
4 +
5 +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 +
7 +* Redistributions of works must retain the original copyright notice, this list of conditions and the following disclaimer.
8 +* Redistributions in binary form must reproduce the original copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 +* Neither the name of the W3C nor the names of its contributors may be used to endorse or promote products derived from this work without specific prior written permission.
10 +
11 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 +# abab
2 +
3 +[![npm version](https://badge.fury.io/js/abab.svg)](https://www.npmjs.com/package/abab) [![Build Status](https://travis-ci.org/jsdom/abab.svg?branch=master)](https://travis-ci.org/jsdom/abab)
4 +
5 +A module that implements `window.atob` and `window.btoa` according to the [WHATWG spec](https://html.spec.whatwg.org/multipage/webappapis.html#atob). The code is originally from [w3c/web-platform-tests](https://github.com/w3c/web-platform-tests/blob/master/html/webappapis/atob/base64.html).
6 +
7 +Compatibility: Node.js version 3+ and all major browsers (using browserify or webpack)
8 +
9 +Install with `npm`:
10 +
11 +```sh
12 +npm install abab
13 +```
14 +
15 +## API
16 +
17 +### `btoa` (base64 encode)
18 +
19 +```js
20 +const btoa = require('abab').btoa;
21 +btoa('Hello, world!'); // 'SGVsbG8sIHdvcmxkIQ=='
22 +```
23 +
24 +### `atob` (base64 decode)
25 +
26 +```js
27 +const atob = require('abab').atob;
28 +atob('SGVsbG8sIHdvcmxkIQ=='); // 'Hello, world!'
29 +```
30 +
31 +#### Valid characters
32 +
33 +[Per the spec](https://html.spec.whatwg.org/multipage/webappapis.html#atob:dom-windowbase64-btoa-3), `btoa` will accept strings "containing only characters in the range `U+0000` to `U+00FF`." If passed a string with characters above `U+00FF`, `btoa` will return `null`. If `atob` is passed a string that is not base64-valid, it will also return `null`. In both cases when `null` is returned, the spec calls for throwing a `DOMException` of type `InvalidCharacterError`.
34 +
35 +## Browsers
36 +
37 +If you want to include just one of the methods to save bytes in your client-side code, you can `require` the desired module directly.
38 +
39 +```js
40 +var atob = require('abab/lib/atob');
41 +var btoa = require('abab/lib/btoa');
42 +```
43 +
44 +-----
45 +
46 +### Checklists
47 +
48 +If you're **submitting a PR** or **deploying to npm**, please use the [checklists in CONTRIBUTING.md](https://github.com/jsdom/abab/blob/master/CONTRIBUTING.md#checklists)
49 +
50 +### Remembering `atob` vs. `btoa`
51 +
52 +Here's a mnemonic that might be useful: if you have a plain string and want to base64 encode it, then decode it, `btoa` is what you run before (**b**efore - **b**toa), and `atob` is what you run after (**a**fter - **a**tob).
1 +'use strict';
2 +
3 +var atob = require('./lib/atob');
4 +var btoa = require('./lib/btoa');
5 +
6 +module.exports = {
7 + atob: atob,
8 + btoa: btoa
9 +};
1 +'use strict';
2 +
3 +/**
4 + * Implementation of atob() according to the HTML spec, except that instead of
5 + * throwing INVALID_CHARACTER_ERR we return null.
6 + */
7 +function atob(input) {
8 + // WebIDL requires DOMStrings to just be converted using ECMAScript
9 + // ToString, which in our case amounts to calling String().
10 + input = String(input);
11 + // "Remove all space characters from input."
12 + input = input.replace(/[ \t\n\f\r]/g, '');
13 + // "If the length of input divides by 4 leaving no remainder, then: if
14 + // input ends with one or two U+003D EQUALS SIGN (=) characters, remove
15 + // them from input."
16 + if (input.length % 4 == 0 && /==?$/.test(input)) {
17 + input = input.replace(/==?$/, '');
18 + }
19 + // "If the length of input divides by 4 leaving a remainder of 1, throw an
20 + // INVALID_CHARACTER_ERR exception and abort these steps."
21 + //
22 + // "If input contains a character that is not in the following list of
23 + // characters and character ranges, throw an INVALID_CHARACTER_ERR
24 + // exception and abort these steps:
25 + //
26 + // U+002B PLUS SIGN (+)
27 + // U+002F SOLIDUS (/)
28 + // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9)
29 + // U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z
30 + // U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z"
31 + if (input.length % 4 == 1 || !/^[+/0-9A-Za-z]*$/.test(input)) {
32 + return null;
33 + }
34 + // "Let output be a string, initially empty."
35 + var output = '';
36 + // "Let buffer be a buffer that can have bits appended to it, initially
37 + // empty."
38 + //
39 + // We append bits via left-shift and or. accumulatedBits is used to track
40 + // when we've gotten to 24 bits.
41 + var buffer = 0;
42 + var accumulatedBits = 0;
43 + // "While position does not point past the end of input, run these
44 + // substeps:"
45 + for (var i = 0; i < input.length; i++) {
46 + // "Find the character pointed to by position in the first column of
47 + // the following table. Let n be the number given in the second cell of
48 + // the same row."
49 + //
50 + // "Append to buffer the six bits corresponding to number, most
51 + // significant bit first."
52 + //
53 + // atobLookup() implements the table from the spec.
54 + buffer <<= 6;
55 + buffer |= atobLookup(input[i]);
56 + // "If buffer has accumulated 24 bits, interpret them as three 8-bit
57 + // big-endian numbers. Append the three characters with code points
58 + // equal to those numbers to output, in the same order, and then empty
59 + // buffer."
60 + accumulatedBits += 6;
61 + if (accumulatedBits == 24) {
62 + output += String.fromCharCode((buffer & 0xff0000) >> 16);
63 + output += String.fromCharCode((buffer & 0xff00) >> 8);
64 + output += String.fromCharCode(buffer & 0xff);
65 + buffer = accumulatedBits = 0;
66 + }
67 + // "Advance position by one character."
68 + }
69 + // "If buffer is not empty, it contains either 12 or 18 bits. If it
70 + // contains 12 bits, discard the last four and interpret the remaining
71 + // eight as an 8-bit big-endian number. If it contains 18 bits, discard the
72 + // last two and interpret the remaining 16 as two 8-bit big-endian numbers.
73 + // Append the one or two characters with code points equal to those one or
74 + // two numbers to output, in the same order."
75 + if (accumulatedBits == 12) {
76 + buffer >>= 4;
77 + output += String.fromCharCode(buffer);
78 + } else if (accumulatedBits == 18) {
79 + buffer >>= 2;
80 + output += String.fromCharCode((buffer & 0xff00) >> 8);
81 + output += String.fromCharCode(buffer & 0xff);
82 + }
83 + // "Return output."
84 + return output;
85 +}
86 +/**
87 + * A lookup table for atob(), which converts an ASCII character to the
88 + * corresponding six-bit number.
89 + */
90 +function atobLookup(chr) {
91 + if (/[A-Z]/.test(chr)) {
92 + return chr.charCodeAt(0) - 'A'.charCodeAt(0);
93 + }
94 + if (/[a-z]/.test(chr)) {
95 + return chr.charCodeAt(0) - 'a'.charCodeAt(0) + 26;
96 + }
97 + if (/[0-9]/.test(chr)) {
98 + return chr.charCodeAt(0) - '0'.charCodeAt(0) + 52;
99 + }
100 + if (chr == '+') {
101 + return 62;
102 + }
103 + if (chr == '/') {
104 + return 63;
105 + }
106 + // Throw exception; should not be hit in tests
107 +}
108 +
109 +module.exports = atob;
1 +'use strict';
2 +
3 +/**
4 + * btoa() as defined by the HTML5 spec, which mostly just references RFC4648.
5 + */
6 +function btoa(s) {
7 + var i;
8 + // String conversion as required by WebIDL.
9 + s = String(s);
10 + // "The btoa() method must throw an INVALID_CHARACTER_ERR exception if the
11 + // method's first argument contains any character whose code point is
12 + // greater than U+00FF."
13 + for (i = 0; i < s.length; i++) {
14 + if (s.charCodeAt(i) > 255) {
15 + return null;
16 + }
17 + }
18 + var out = '';
19 + for (i = 0; i < s.length; i += 3) {
20 + var groupsOfSix = [undefined, undefined, undefined, undefined];
21 + groupsOfSix[0] = s.charCodeAt(i) >> 2;
22 + groupsOfSix[1] = (s.charCodeAt(i) & 0x03) << 4;
23 + if (s.length > i + 1) {
24 + groupsOfSix[1] |= s.charCodeAt(i + 1) >> 4;
25 + groupsOfSix[2] = (s.charCodeAt(i + 1) & 0x0f) << 2;
26 + }
27 + if (s.length > i + 2) {
28 + groupsOfSix[2] |= s.charCodeAt(i + 2) >> 6;
29 + groupsOfSix[3] = s.charCodeAt(i + 2) & 0x3f;
30 + }
31 + for (var j = 0; j < groupsOfSix.length; j++) {
32 + if (typeof groupsOfSix[j] == 'undefined') {
33 + out += '=';
34 + } else {
35 + out += btoaLookup(groupsOfSix[j]);
36 + }
37 + }
38 + }
39 + return out;
40 +}
41 +
42 +/**
43 + * Lookup table for btoa(), which converts a six-bit number into the
44 + * corresponding ASCII character.
45 + */
46 +function btoaLookup(idx) {
47 + if (idx < 26) {
48 + return String.fromCharCode(idx + 'A'.charCodeAt(0));
49 + }
50 + if (idx < 52) {
51 + return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0));
52 + }
53 + if (idx < 62) {
54 + return String.fromCharCode(idx - 52 + '0'.charCodeAt(0));
55 + }
56 + if (idx == 62) {
57 + return '+';
58 + }
59 + if (idx == 63) {
60 + return '/';
61 + }
62 + // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the tests.
63 +}
64 +
65 +module.exports = btoa;
1 +{
2 + "_args": [
3 + [
4 + "abab@1.0.4",
5 + "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT"
6 + ]
7 + ],
8 + "_from": "abab@1.0.4",
9 + "_id": "abab@1.0.4",
10 + "_inBundle": false,
11 + "_integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4=",
12 + "_location": "/abab",
13 + "_optional": true,
14 + "_phantomChildren": {},
15 + "_requested": {
16 + "type": "version",
17 + "registry": true,
18 + "raw": "abab@1.0.4",
19 + "name": "abab",
20 + "escapedName": "abab",
21 + "rawSpec": "1.0.4",
22 + "saveSpec": null,
23 + "fetchSpec": "1.0.4"
24 + },
25 + "_requiredBy": [
26 + "/jsdom"
27 + ],
28 + "_resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz",
29 + "_spec": "1.0.4",
30 + "_where": "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT",
31 + "author": {
32 + "name": "Jeff Carpenter",
33 + "email": "gcarpenterv@gmail.com"
34 + },
35 + "bugs": {
36 + "url": "https://github.com/jsdom/abab/issues"
37 + },
38 + "description": "WHATWG spec-compliant implementations of window.atob and window.btoa.",
39 + "devDependencies": {
40 + "babel-core": "^6.1.4",
41 + "babel-loader": "^6.1.0",
42 + "babel-preset-es2015": "^6.1.4",
43 + "eslint": "^1.3.1",
44 + "jscs": "^2.1.1",
45 + "karma": "^0.13.10",
46 + "karma-cli": "^0.1.1",
47 + "karma-firefox-launcher": "^0.1.6",
48 + "karma-mocha": "^0.2.0",
49 + "karma-sauce-launcher": "^0.2.14",
50 + "karma-webpack": "^1.7.0",
51 + "mocha": "^2.2.5",
52 + "webpack": "^1.12.2"
53 + },
54 + "files": [
55 + "index.js",
56 + "lib/"
57 + ],
58 + "homepage": "https://github.com/jsdom/abab#readme",
59 + "keywords": [
60 + "atob",
61 + "btoa",
62 + "browser"
63 + ],
64 + "license": "ISC",
65 + "main": "index.js",
66 + "name": "abab",
67 + "repository": {
68 + "type": "git",
69 + "url": "git+https://github.com/jsdom/abab.git"
70 + },
71 + "scripts": {
72 + "karma": "karma start",
73 + "lint": "jscs . && eslint .",
74 + "mocha": "mocha test/node",
75 + "test": "npm run lint && npm run mocha && npm run karma"
76 + },
77 + "version": "1.0.4"
78 +}
1 +Copyright (c) 2014 Forbes Lindesay
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.
...\ No newline at end of file ...\ No newline at end of file
1 +# acorn-globals
2 +
3 +Detect global variables in JavaScript using acorn
4 +
5 +[![Build Status](https://img.shields.io/travis/ForbesLindesay/acorn-globals/master.svg)](https://travis-ci.org/ForbesLindesay/acorn-globals)
6 +[![Dependency Status](https://img.shields.io/david/ForbesLindesay/acorn-globals.svg)](https://david-dm.org/ForbesLindesay/acorn-globals)
7 +[![NPM version](https://img.shields.io/npm/v/acorn-globals.svg)](https://www.npmjs.org/package/acorn-globals)
8 +
9 +## Installation
10 +
11 + npm install acorn-globals
12 +
13 +## Usage
14 +
15 +detect.js
16 +
17 +```js
18 +var fs = require('fs');
19 +var detect = require('acorn-globals');
20 +
21 +var src = fs.readFileSync(__dirname + '/input.js', 'utf8');
22 +
23 +var scope = detect(src);
24 +console.dir(scope);
25 +```
26 +
27 +input.js
28 +
29 +```js
30 +var x = 5;
31 +var y = 3, z = 2;
32 +
33 +w.foo();
34 +w = 2;
35 +
36 +RAWR=444;
37 +RAWR.foo();
38 +
39 +BLARG=3;
40 +
41 +foo(function () {
42 + var BAR = 3;
43 + process.nextTick(function (ZZZZZZZZZZZZ) {
44 + console.log('beep boop');
45 + var xyz = 4;
46 + x += 10;
47 + x.zzzzzz;
48 + ZZZ=6;
49 + });
50 + function doom () {
51 + }
52 + ZZZ.foo();
53 +
54 +});
55 +
56 +console.log(xyz);
57 +```
58 +
59 +output:
60 +
61 +```
62 +$ node example/detect.js
63 +[ { name: 'BLARG', nodes: [ [Object] ] },
64 + { name: 'RAWR', nodes: [ [Object], [Object] ] },
65 + { name: 'ZZZ', nodes: [ [Object], [Object] ] },
66 + { name: 'console', nodes: [ [Object], [Object] ] },
67 + { name: 'foo', nodes: [ [Object] ] },
68 + { name: 'process', nodes: [ [Object] ] },
69 + { name: 'w', nodes: [ [Object], [Object] ] },
70 + { name: 'xyz', nodes: [ [Object] ] } ]
71 +```
72 +
73 +
74 +## License
75 +
76 + MIT
1 +'use strict';
2 +
3 +var acorn = require('acorn');
4 +var walk = require('acorn/dist/walk');
5 +
6 +function isScope(node) {
7 + return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'ArrowFunctionExpression' || node.type === 'Program';
8 +}
9 +function isBlockScope(node) {
10 + return node.type === 'BlockStatement' || isScope(node);
11 +}
12 +
13 +function declaresArguments(node) {
14 + return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration';
15 +}
16 +
17 +function declaresThis(node) {
18 + return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration';
19 +}
20 +
21 +function reallyParse(source) {
22 + try {
23 + return acorn.parse(source, {
24 + ecmaVersion: 6,
25 + allowReturnOutsideFunction: true,
26 + allowImportExportEverywhere: true,
27 + allowHashBang: true
28 + });
29 + } catch (ex) {
30 + return acorn.parse(source, {
31 + ecmaVersion: 5,
32 + allowReturnOutsideFunction: true,
33 + allowImportExportEverywhere: true,
34 + allowHashBang: true
35 + });
36 + }
37 +}
38 +module.exports = findGlobals;
39 +module.exports.parse = reallyParse;
40 +function findGlobals(source) {
41 + var globals = [];
42 + var ast;
43 + // istanbul ignore else
44 + if (typeof source === 'string') {
45 + ast = reallyParse(source);
46 + } else {
47 + ast = source;
48 + }
49 + // istanbul ignore if
50 + if (!(ast && typeof ast === 'object' && ast.type === 'Program')) {
51 + throw new TypeError('Source must be either a string of JavaScript or an acorn AST');
52 + }
53 + var declareFunction = function (node) {
54 + var fn = node;
55 + fn.locals = fn.locals || {};
56 + node.params.forEach(function (node) {
57 + declarePattern(node, fn);
58 + });
59 + if (node.id) {
60 + fn.locals[node.id.name] = true;
61 + }
62 + }
63 + var declarePattern = function (node, parent) {
64 + switch (node.type) {
65 + case 'Identifier':
66 + parent.locals[node.name] = true;
67 + break;
68 + case 'ObjectPattern':
69 + node.properties.forEach(function (node) {
70 + declarePattern(node.value, parent);
71 + });
72 + break;
73 + case 'ArrayPattern':
74 + node.elements.forEach(function (node) {
75 + if (node) declarePattern(node, parent);
76 + });
77 + break;
78 + case 'RestElement':
79 + declarePattern(node.argument, parent);
80 + break;
81 + case 'AssignmentPattern':
82 + declarePattern(node.left, parent);
83 + break;
84 + // istanbul ignore next
85 + default:
86 + throw new Error('Unrecognized pattern type: ' + node.type);
87 + }
88 + }
89 + var declareModuleSpecifier = function (node, parents) {
90 + ast.locals = ast.locals || {};
91 + ast.locals[node.local.name] = true;
92 + }
93 + walk.ancestor(ast, {
94 + 'VariableDeclaration': function (node, parents) {
95 + var parent = null;
96 + for (var i = parents.length - 1; i >= 0 && parent === null; i--) {
97 + if (node.kind === 'var' ? isScope(parents[i]) : isBlockScope(parents[i])) {
98 + parent = parents[i];
99 + }
100 + }
101 + parent.locals = parent.locals || {};
102 + node.declarations.forEach(function (declaration) {
103 + declarePattern(declaration.id, parent);
104 + });
105 + },
106 + 'FunctionDeclaration': function (node, parents) {
107 + var parent = null;
108 + for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
109 + if (isScope(parents[i])) {
110 + parent = parents[i];
111 + }
112 + }
113 + parent.locals = parent.locals || {};
114 + parent.locals[node.id.name] = true;
115 + declareFunction(node);
116 + },
117 + 'Function': declareFunction,
118 + 'ClassDeclaration': function (node, parents) {
119 + var parent = null;
120 + for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
121 + if (isScope(parents[i])) {
122 + parent = parents[i];
123 + }
124 + }
125 + parent.locals = parent.locals || {};
126 + parent.locals[node.id.name] = true;
127 + },
128 + 'TryStatement': function (node) {
129 + if (node.handler === null) return;
130 + node.handler.body.locals = node.handler.body.locals || {};
131 + node.handler.body.locals[node.handler.param.name] = true;
132 + },
133 + 'ImportDefaultSpecifier': declareModuleSpecifier,
134 + 'ImportSpecifier': declareModuleSpecifier,
135 + 'ImportNamespaceSpecifier': declareModuleSpecifier
136 + });
137 + function identifier(node, parents) {
138 + var name = node.name;
139 + if (name === 'undefined') return;
140 + for (var i = 0; i < parents.length; i++) {
141 + if (name === 'arguments' && declaresArguments(parents[i])) {
142 + return;
143 + }
144 + if (parents[i].locals && name in parents[i].locals) {
145 + return;
146 + }
147 + }
148 + if (
149 + parents[parents.length - 2] &&
150 + parents[parents.length - 2].type === 'TryStatement' &&
151 + parents[parents.length - 2].handler &&
152 + node === parents[parents.length - 2].handler.param
153 + ) {
154 + return;
155 + }
156 + node.parents = parents;
157 + globals.push(node);
158 + }
159 + walk.ancestor(ast, {
160 + 'VariablePattern': identifier,
161 + 'Identifier': identifier,
162 + 'ThisExpression': function (node, parents) {
163 + for (var i = 0; i < parents.length; i++) {
164 + if (declaresThis(parents[i])) {
165 + return;
166 + }
167 + }
168 + node.parents = parents;
169 + globals.push(node);
170 + }
171 + });
172 + var groupedGlobals = {};
173 + globals.forEach(function (node) {
174 + groupedGlobals[node.name] = (groupedGlobals[node.name] || []);
175 + groupedGlobals[node.name].push(node);
176 + });
177 + return Object.keys(groupedGlobals).sort().map(function (name) {
178 + return {name: name, nodes: groupedGlobals[name]};
179 + });
180 +}
1 +{
2 + "_args": [
3 + [
4 + "acorn-globals@1.0.9",
5 + "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT"
6 + ]
7 + ],
8 + "_from": "acorn-globals@1.0.9",
9 + "_id": "acorn-globals@1.0.9",
10 + "_inBundle": false,
11 + "_integrity": "sha1-VbtemGkVB7dFedBRNBMhfDgMVM8=",
12 + "_location": "/acorn-globals",
13 + "_optional": true,
14 + "_phantomChildren": {},
15 + "_requested": {
16 + "type": "version",
17 + "registry": true,
18 + "raw": "acorn-globals@1.0.9",
19 + "name": "acorn-globals",
20 + "escapedName": "acorn-globals",
21 + "rawSpec": "1.0.9",
22 + "saveSpec": null,
23 + "fetchSpec": "1.0.9"
24 + },
25 + "_requiredBy": [
26 + "/jsdom"
27 + ],
28 + "_resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-1.0.9.tgz",
29 + "_spec": "1.0.9",
30 + "_where": "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT",
31 + "author": {
32 + "name": "ForbesLindesay"
33 + },
34 + "bugs": {
35 + "url": "https://github.com/ForbesLindesay/acorn-globals/issues"
36 + },
37 + "dependencies": {
38 + "acorn": "^2.1.0"
39 + },
40 + "description": "Detect global variables in JavaScript using acorn",
41 + "devDependencies": {
42 + "testit": "^2.0.2"
43 + },
44 + "files": [
45 + "index.js",
46 + "LICENSE"
47 + ],
48 + "homepage": "https://github.com/ForbesLindesay/acorn-globals#readme",
49 + "keywords": [
50 + "ast",
51 + "variable",
52 + "name",
53 + "lexical",
54 + "scope",
55 + "local",
56 + "global",
57 + "implicit"
58 + ],
59 + "license": "MIT",
60 + "name": "acorn-globals",
61 + "repository": {
62 + "type": "git",
63 + "url": "git+https://github.com/ForbesLindesay/acorn-globals.git"
64 + },
65 + "scripts": {
66 + "test": "node test"
67 + },
68 + "version": "1.0.9"
69 +}
1 +root = true
2 +
3 +[*]
4 +indent_style = space
5 +indent_size = 2
6 +end_of_line = lf
7 +insert_final_newline = true
1 +/.tern-port
2 +/test
3 +/local
1 +{
2 + "plugins": {
3 + "node": true,
4 + "es_modules": true
5 + }
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +language: node_js
2 +sudo: false
3 +node_js:
4 + - '0.10'
5 + - '0.12'
6 + - '4'
1 +List of Acorn contributors. Updated before every release.
2 +
3 +Adrian Rakovsky
4 +Alistair Braidwood
5 +Andres Suarez
6 +Aparajita Fishman
7 +Arian Stolwijk
8 +Artem Govorov
9 +Brandon Mills
10 +Charles Hughes
11 +Conrad Irwin
12 +David Bonnet
13 +ForbesLindesay
14 +Forbes Lindesay
15 +Gilad Peleg
16 +impinball
17 +Ingvar Stepanyan
18 +Jesse McCarthy
19 +Jiaxing Wang
20 +Joel Kemp
21 +Johannes Herr
22 +Jürg Lehni
23 +keeyipchan
24 +Kevin Kwok
25 +krator
26 +Marijn Haverbeke
27 +Martin Carlberg
28 +Mathias Bynens
29 +Mathieu 'p01' Henri
30 +Max Schaefer
31 +Max Zerzouri
32 +Mihai Bazon
33 +Mike Rennie
34 +Nick Fitzgerald
35 +Oskar Schöldström
36 +Paul Harper
37 +Peter Rust
38 +PlNG
39 +r-e-d
40 +Rich Harris
41 +Sebastian McKenzie
42 +Timothy Gu
43 +zsjforcn
1 +Copyright (C) 2012-2014 by various contributors (see AUTHORS)
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.
This diff is collapsed. Click to expand it.
1 +#!/usr/bin/env node
2 +"use strict";
3 +
4 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
5 +
6 +var _path = require("path");
7 +
8 +var _fs = require("fs");
9 +
10 +var _distAcornJs = require("../dist/acorn.js");
11 +
12 +var acorn = _interopRequireWildcard(_distAcornJs);
13 +
14 +var infile = undefined,
15 + forceFile = undefined,
16 + silent = false,
17 + compact = false,
18 + tokenize = false;
19 +var options = {};
20 +
21 +function help(status) {
22 + var print = status == 0 ? console.log : console.error;
23 + print("usage: " + (0, _path.basename)(process.argv[1]) + " [--ecma3|--ecma5|--ecma6]");
24 + print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]");
25 + process.exit(status);
26 +}
27 +
28 +for (var i = 2; i < process.argv.length; ++i) {
29 + var arg = process.argv[i];
30 + if ((arg == "-" || arg[0] != "-") && !infile) infile = arg;else if (arg == "--" && !infile && i + 2 == process.argv.length) forceFile = infile = process.argv[++i];else if (arg == "--ecma3") options.ecmaVersion = 3;else if (arg == "--ecma5") options.ecmaVersion = 5;else if (arg == "--ecma6") options.ecmaVersion = 6;else if (arg == "--locations") options.locations = true;else if (arg == "--allow-hash-bang") options.allowHashBang = true;else if (arg == "--silent") silent = true;else if (arg == "--compact") compact = true;else if (arg == "--help") help(0);else if (arg == "--tokenize") tokenize = true;else if (arg == "--module") options.sourceType = 'module';else help(1);
31 +}
32 +
33 +function run(code) {
34 + var result = undefined;
35 + if (!tokenize) {
36 + try {
37 + result = acorn.parse(code, options);
38 + } catch (e) {
39 + console.error(e.message);process.exit(1);
40 + }
41 + } else {
42 + result = [];
43 + var tokenizer = acorn.tokenizer(code, options),
44 + token = undefined;
45 + while (true) {
46 + try {
47 + token = tokenizer.getToken();
48 + } catch (e) {
49 + console.error(e.message);process.exit(1);
50 + }
51 + result.push(token);
52 + if (token.type == acorn.tokTypes.eof) break;
53 + }
54 + }
55 + if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2));
56 +}
57 +
58 +if (forceFile || infile && infile != "-") {
59 + run((0, _fs.readFileSync)(infile, "utf8"));
60 +} else {
61 + (function () {
62 + var code = "";
63 + process.stdin.resume();
64 + process.stdin.on("data", function (chunk) {
65 + return code += chunk;
66 + });
67 + process.stdin.on("end", function () {
68 + return run(code);
69 + });
70 + })();
71 +}
...\ No newline at end of file ...\ No newline at end of file
1 +var fs = require("fs"), path = require("path")
2 +var stream = require("stream")
3 +
4 +var browserify = require("browserify")
5 +var babel = require('babel-core')
6 +var babelify = require("babelify").configure({loose: "all"})
7 +
8 +process.chdir(path.resolve(__dirname, ".."))
9 +
10 +browserify({standalone: "acorn"})
11 + .plugin(require('browserify-derequire'))
12 + .transform(babelify)
13 + .require("./src/index.js", {entry: true})
14 + .bundle()
15 + .on("error", function (err) { console.log("Error: " + err.message) })
16 + .pipe(fs.createWriteStream("dist/acorn.js"))
17 +
18 +var ACORN_PLACEHOLDER = "this_function_call_should_be_replaced_with_a_call_to_load_acorn()";
19 +function acornShimPrepare(file) {
20 + var tr = new stream.Transform
21 + if (file == path.resolve(__dirname, "../src/index.js")) {
22 + var sent = false
23 + tr._transform = function(chunk, _, callback) {
24 + if (!sent) {
25 + sent = true
26 + callback(null, ACORN_PLACEHOLDER);
27 + } else {
28 + callback()
29 + }
30 + }
31 + } else {
32 + tr._transform = function(chunk, _, callback) { callback(null, chunk) }
33 + }
34 + return tr
35 +}
36 +function acornShimComplete() {
37 + var tr = new stream.Transform
38 + var buffer = "";
39 + tr._transform = function(chunk, _, callback) {
40 + buffer += chunk.toString("utf8");
41 + callback();
42 + };
43 + tr._flush = function (callback) {
44 + tr.push(buffer.replace(ACORN_PLACEHOLDER, "module.exports = typeof acorn != 'undefined' ? acorn : require(\"./acorn\")"));
45 + callback(null);
46 + };
47 + return tr;
48 +}
49 +
50 +browserify({standalone: "acorn.loose"})
51 + .plugin(require('browserify-derequire'))
52 + .transform(acornShimPrepare)
53 + .transform(babelify)
54 + .require("./src/loose/index.js", {entry: true})
55 + .bundle()
56 + .on("error", function (err) { console.log("Error: " + err.message) })
57 + .pipe(acornShimComplete())
58 + .pipe(fs.createWriteStream("dist/acorn_loose.js"))
59 +
60 +browserify({standalone: "acorn.walk"})
61 + .plugin(require('browserify-derequire'))
62 + .transform(acornShimPrepare)
63 + .transform(babelify)
64 + .require("./src/walk/index.js", {entry: true})
65 + .bundle()
66 + .on("error", function (err) { console.log("Error: " + err.message) })
67 + .pipe(acornShimComplete())
68 + .pipe(fs.createWriteStream("dist/walk.js"))
69 +
70 +babel.transformFile("./src/bin/acorn.js", function (err, result) {
71 + if (err) return console.log("Error: " + err.message)
72 + fs.writeFile("bin/acorn", result.code, function (err) {
73 + if (err) return console.log("Error: " + err.message)
74 +
75 + // Make bin/acorn executable
76 + if (process.platform === 'win32')
77 + return
78 + var stat = fs.statSync("bin/acorn")
79 + var newPerm = stat.mode | parseInt('111', 8)
80 + fs.chmodSync("bin/acorn", newPerm)
81 + })
82 +})
1 +// Note: run `npm install unicode-7.0.0` first.
2 +
3 +// Which Unicode version should be used?
4 +var version = '7.0.0';
5 +
6 +var start = require('unicode-' + version + '/properties/ID_Start/code-points')
7 + .filter(function(ch) { return ch > 127; });
8 +var cont = [0x200c, 0x200d].concat(require('unicode-' + version + '/properties/ID_Continue/code-points')
9 + .filter(function(ch) { return ch > 127 && start.indexOf(ch) == -1; }));
10 +
11 +function pad(str, width) {
12 + while (str.length < width) str = "0" + str;
13 + return str;
14 +}
15 +
16 +function esc(code) {
17 + var hex = code.toString(16);
18 + if (hex.length <= 2) return "\\x" + pad(hex, 2);
19 + else return "\\u" + pad(hex, 4);
20 +}
21 +
22 +function generate(chars) {
23 + var astral = [], re = "";
24 + for (var i = 0, at = 0x10000; i < chars.length; i++) {
25 + var from = chars[i], to = from;
26 + while (i < chars.length - 1 && chars[i + 1] == to + 1) {
27 + i++;
28 + to++;
29 + }
30 + if (to <= 0xffff) {
31 + if (from == to) re += esc(from);
32 + else if (from + 1 == to) re += esc(from) + esc(to);
33 + else re += esc(from) + "-" + esc(to);
34 + } else {
35 + astral.push(from - at, to - from);
36 + at = to;
37 + }
38 + }
39 + return {nonASCII: re, astral: astral};
40 +}
41 +
42 +var startData = generate(start), contData = generate(cont);
43 +
44 +console.log(" var nonASCIIidentifierStartChars = \"" + startData.nonASCII + "\";");
45 +console.log(" var nonASCIIidentifierChars = \"" + contData.nonASCII + "\";");
46 +console.log(" var astralIdentifierStartCodes = " + JSON.stringify(startData.astral) + ";");
47 +console.log(" var astralIdentifierCodes = " + JSON.stringify(contData.astral) + ";");
1 +# Combine existing list of authors with everyone known in git, sort, add header.
2 +tail --lines=+3 AUTHORS > AUTHORS.tmp
3 +git log --format='%aN' | grep -v abraidwood >> AUTHORS.tmp
4 +echo -e "List of Acorn contributors. Updated before every release.\n" > AUTHORS
5 +sort -u AUTHORS.tmp >> AUTHORS
6 +rm -f AUTHORS.tmp
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 +{
2 + "_args": [
3 + [
4 + "acorn@2.7.0",
5 + "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT"
6 + ]
7 + ],
8 + "_from": "acorn@2.7.0",
9 + "_id": "acorn@2.7.0",
10 + "_inBundle": false,
11 + "_integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=",
12 + "_location": "/acorn",
13 + "_phantomChildren": {},
14 + "_requested": {
15 + "type": "version",
16 + "registry": true,
17 + "raw": "acorn@2.7.0",
18 + "name": "acorn",
19 + "escapedName": "acorn",
20 + "rawSpec": "2.7.0",
21 + "saveSpec": null,
22 + "fetchSpec": "2.7.0"
23 + },
24 + "_requiredBy": [
25 + "/acorn-globals",
26 + "/jsdom"
27 + ],
28 + "_resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz",
29 + "_spec": "2.7.0",
30 + "_where": "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT",
31 + "bin": {
32 + "acorn": "./bin/acorn"
33 + },
34 + "bugs": {
35 + "url": "https://github.com/ternjs/acorn/issues"
36 + },
37 + "contributors": [
38 + {
39 + "name": "List of Acorn contributors. Updated before every release."
40 + },
41 + {
42 + "name": "Adrian Rakovsky"
43 + },
44 + {
45 + "name": "Alistair Braidwood"
46 + },
47 + {
48 + "name": "Andres Suarez"
49 + },
50 + {
51 + "name": "Aparajita Fishman"
52 + },
53 + {
54 + "name": "Arian Stolwijk"
55 + },
56 + {
57 + "name": "Artem Govorov"
58 + },
59 + {
60 + "name": "Brandon Mills"
61 + },
62 + {
63 + "name": "Charles Hughes"
64 + },
65 + {
66 + "name": "Conrad Irwin"
67 + },
68 + {
69 + "name": "David Bonnet"
70 + },
71 + {
72 + "name": "ForbesLindesay"
73 + },
74 + {
75 + "name": "Forbes Lindesay"
76 + },
77 + {
78 + "name": "Gilad Peleg"
79 + },
80 + {
81 + "name": "impinball"
82 + },
83 + {
84 + "name": "Ingvar Stepanyan"
85 + },
86 + {
87 + "name": "Jesse McCarthy"
88 + },
89 + {
90 + "name": "Jiaxing Wang"
91 + },
92 + {
93 + "name": "Joel Kemp"
94 + },
95 + {
96 + "name": "Johannes Herr"
97 + },
98 + {
99 + "name": "Jürg Lehni"
100 + },
101 + {
102 + "name": "keeyipchan"
103 + },
104 + {
105 + "name": "Kevin Kwok"
106 + },
107 + {
108 + "name": "krator"
109 + },
110 + {
111 + "name": "Marijn Haverbeke"
112 + },
113 + {
114 + "name": "Martin Carlberg"
115 + },
116 + {
117 + "name": "Mathias Bynens"
118 + },
119 + {
120 + "name": "Mathieu 'p01' Henri"
121 + },
122 + {
123 + "name": "Max Schaefer"
124 + },
125 + {
126 + "name": "Max Zerzouri"
127 + },
128 + {
129 + "name": "Mihai Bazon"
130 + },
131 + {
132 + "name": "Mike Rennie"
133 + },
134 + {
135 + "name": "Nick Fitzgerald"
136 + },
137 + {
138 + "name": "Oskar Schöldström"
139 + },
140 + {
141 + "name": "Paul Harper"
142 + },
143 + {
144 + "name": "Peter Rust"
145 + },
146 + {
147 + "name": "PlNG"
148 + },
149 + {
150 + "name": "r-e-d"
151 + },
152 + {
153 + "name": "Rich Harris"
154 + },
155 + {
156 + "name": "Sebastian McKenzie"
157 + },
158 + {
159 + "name": "Timothy Gu"
160 + },
161 + {
162 + "name": "zsjforcn"
163 + }
164 + ],
165 + "description": "ECMAScript parser",
166 + "devDependencies": {
167 + "babel-core": "^5.6.15",
168 + "babelify": "^6.1.2",
169 + "browserify": "^10.2.4",
170 + "browserify-derequire": "^0.9.4",
171 + "unicode-7.0.0": "~0.1.5"
172 + },
173 + "engines": {
174 + "node": ">=0.4.0"
175 + },
176 + "homepage": "https://github.com/ternjs/acorn",
177 + "license": "MIT",
178 + "main": "dist/acorn.js",
179 + "maintainers": [
180 + {
181 + "name": "Marijn Haverbeke",
182 + "email": "marijnh@gmail.com",
183 + "url": "http://marijnhaverbeke.nl"
184 + },
185 + {
186 + "name": "Ingvar Stepanyan",
187 + "email": "me@rreverser.com",
188 + "url": "http://rreverser.com/"
189 + }
190 + ],
191 + "name": "acorn",
192 + "repository": {
193 + "type": "git",
194 + "url": "git+https://github.com/ternjs/acorn.git"
195 + },
196 + "scripts": {
197 + "prepublish": "node bin/build-acorn.js",
198 + "test": "node test/run.js"
199 + },
200 + "version": "2.7.0"
201 +}
1 +#!/usr/bin/env node
2 +
3 +import {basename} from "path"
4 +import {readFileSync as readFile} from "fs"
5 +import * as acorn from "../dist/acorn.js"
6 +
7 +let infile, forceFile, silent = false, compact = false, tokenize = false
8 +const options = {}
9 +
10 +function help(status) {
11 + const print = (status == 0) ? console.log : console.error
12 + print("usage: " + basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6]")
13 + print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]")
14 + process.exit(status)
15 +}
16 +
17 +for (let i = 2; i < process.argv.length; ++i) {
18 + const arg = process.argv[i]
19 + if ((arg == "-" || arg[0] != "-") && !infile) infile = arg
20 + else if (arg == "--" && !infile && i + 2 == process.argv.length) forceFile = infile = process.argv[++i]
21 + else if (arg == "--ecma3") options.ecmaVersion = 3
22 + else if (arg == "--ecma5") options.ecmaVersion = 5
23 + else if (arg == "--ecma6") options.ecmaVersion = 6
24 + else if (arg == "--locations") options.locations = true
25 + else if (arg == "--allow-hash-bang") options.allowHashBang = true
26 + else if (arg == "--silent") silent = true
27 + else if (arg == "--compact") compact = true
28 + else if (arg == "--help") help(0)
29 + else if (arg == "--tokenize") tokenize = true
30 + else if (arg == "--module") options.sourceType = 'module'
31 + else help(1)
32 +}
33 +
34 +function run(code) {
35 + let result
36 + if (!tokenize) {
37 + try { result = acorn.parse(code, options) }
38 + catch(e) { console.error(e.message); process.exit(1) }
39 + } else {
40 + result = []
41 + let tokenizer = acorn.tokenizer(code, options), token
42 + while (true) {
43 + try { token = tokenizer.getToken() }
44 + catch(e) { console.error(e.message); process.exit(1) }
45 + result.push(token)
46 + if (token.type == acorn.tokTypes.eof) break
47 + }
48 + }
49 + if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2))
50 +}
51 +
52 +if (forceFile || infile && infile != "-") {
53 + run(readFile(infile, "utf8"))
54 +} else {
55 + let code = ""
56 + process.stdin.resume()
57 + process.stdin.on("data", chunk => code += chunk)
58 + process.stdin.on("end", () => run(code))
59 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +// Acorn is a tiny, fast JavaScript parser written in JavaScript.
2 +//
3 +// Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
4 +// various contributors and released under an MIT license.
5 +//
6 +// Git repositories for Acorn are available at
7 +//
8 +// http://marijnhaverbeke.nl/git/acorn
9 +// https://github.com/ternjs/acorn.git
10 +//
11 +// Please use the [github bug tracker][ghbt] to report issues.
12 +//
13 +// [ghbt]: https://github.com/ternjs/acorn/issues
14 +//
15 +// This file defines the main parser interface. The library also comes
16 +// with a [error-tolerant parser][dammit] and an
17 +// [abstract syntax tree walker][walk], defined in other files.
18 +//
19 +// [dammit]: acorn_loose.js
20 +// [walk]: util/walk.js
21 +
22 +import {Parser} from "./state"
23 +import "./parseutil"
24 +import "./statement"
25 +import "./lval"
26 +import "./expression"
27 +import "./location"
28 +
29 +export {Parser, plugins} from "./state"
30 +export {defaultOptions} from "./options"
31 +export {Position, SourceLocation, getLineInfo} from "./locutil"
32 +export {Node} from "./node"
33 +export {TokenType, types as tokTypes} from "./tokentype"
34 +export {TokContext, types as tokContexts} from "./tokencontext"
35 +export {isIdentifierChar, isIdentifierStart} from "./identifier"
36 +export {Token} from "./tokenize"
37 +export {isNewLine, lineBreak, lineBreakG} from "./whitespace"
38 +
39 +export const version = "2.7.0"
40 +
41 +// The main exported interface (under `self.acorn` when in the
42 +// browser) is a `parse` function that takes a code string and
43 +// returns an abstract syntax tree as specified by [Mozilla parser
44 +// API][api].
45 +//
46 +// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
47 +
48 +export function parse(input, options) {
49 + return new Parser(options, input).parse()
50 +}
51 +
52 +// This function tries to parse a single expression at a given
53 +// offset in a string. Useful for parsing mixed-language formats
54 +// that embed JavaScript expressions.
55 +
56 +export function parseExpressionAt(input, pos, options) {
57 + let p = new Parser(options, input, pos)
58 + p.nextToken()
59 + return p.parseExpression()
60 +}
61 +
62 +// Acorn is organized as a tokenizer and a recursive-descent parser.
63 +// The `tokenizer` export provides an interface to the tokenizer.
64 +
65 +export function tokenizer(input, options) {
66 + return new Parser(options, input)
67 +}
1 +import {Parser} from "./state"
2 +import {Position, getLineInfo} from "./locutil"
3 +
4 +const pp = Parser.prototype
5 +
6 +// This function is used to raise exceptions on parse errors. It
7 +// takes an offset integer (into the current `input`) to indicate
8 +// the location of the error, attaches the position to the end
9 +// of the error message, and then raises a `SyntaxError` with that
10 +// message.
11 +
12 +pp.raise = function(pos, message) {
13 + let loc = getLineInfo(this.input, pos)
14 + message += " (" + loc.line + ":" + loc.column + ")"
15 + let err = new SyntaxError(message)
16 + err.pos = pos; err.loc = loc; err.raisedAt = this.pos
17 + throw err
18 +}
19 +
20 +pp.curPosition = function() {
21 + if (this.options.locations) {
22 + return new Position(this.curLine, this.pos - this.lineStart)
23 + }
24 +}
1 +import {lineBreakG} from "./whitespace"
2 +
3 +// These are used when `options.locations` is on, for the
4 +// `startLoc` and `endLoc` properties.
5 +
6 +export class Position {
7 + constructor(line, col) {
8 + this.line = line
9 + this.column = col
10 + }
11 +
12 + offset(n) {
13 + return new Position(this.line, this.column + n)
14 + }
15 +}
16 +
17 +export class SourceLocation {
18 + constructor(p, start, end) {
19 + this.start = start
20 + this.end = end
21 + if (p.sourceFile !== null) this.source = p.sourceFile
22 + }
23 +}
24 +
25 +// The `getLineInfo` function is mostly useful when the
26 +// `locations` option is off (for performance reasons) and you
27 +// want to find the line/column position for a given character
28 +// offset. `input` should be the code string that the offset refers
29 +// into.
30 +
31 +export function getLineInfo(input, offset) {
32 + for (let line = 1, cur = 0;;) {
33 + lineBreakG.lastIndex = cur
34 + let match = lineBreakG.exec(input)
35 + if (match && match.index < offset) {
36 + ++line
37 + cur = match.index + match[0].length
38 + } else {
39 + return new Position(line, offset - cur)
40 + }
41 + }
42 +}
This diff is collapsed. Click to expand it.
1 +// Acorn: Loose parser
2 +//
3 +// This module provides an alternative parser (`parse_dammit`) that
4 +// exposes that same interface as `parse`, but will try to parse
5 +// anything as JavaScript, repairing syntax error the best it can.
6 +// There are circumstances in which it will raise an error and give
7 +// up, but they are very rare. The resulting AST will be a mostly
8 +// valid JavaScript AST (as per the [Mozilla parser API][api], except
9 +// that:
10 +//
11 +// - Return outside functions is allowed
12 +//
13 +// - Label consistency (no conflicts, break only to existing labels)
14 +// is not enforced.
15 +//
16 +// - Bogus Identifier nodes with a name of `"✖"` are inserted whenever
17 +// the parser got too confused to return anything meaningful.
18 +//
19 +// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
20 +//
21 +// The expected use for this is to *first* try `acorn.parse`, and only
22 +// if that fails switch to `parse_dammit`. The loose parser might
23 +// parse badly indented code incorrectly, so **don't** use it as
24 +// your default parser.
25 +//
26 +// Quite a lot of acorn.js is duplicated here. The alternative was to
27 +// add a *lot* of extra cruft to that file, making it less readable
28 +// and slower. Copying and editing the code allowed me to make
29 +// invasive changes and simplifications without creating a complicated
30 +// tangle.
31 +
32 +import * as acorn from ".."
33 +import {LooseParser, pluginsLoose} from "./state"
34 +import "./tokenize"
35 +import "./statement"
36 +import "./expression"
37 +
38 +export {LooseParser, pluginsLoose} from "./state"
39 +
40 +acorn.defaultOptions.tabSize = 4
41 +
42 +export function parse_dammit(input, options) {
43 + let p = new LooseParser(input, options)
44 + p.next()
45 + return p.parseTopLevel()
46 +}
47 +
48 +acorn.parse_dammit = parse_dammit
49 +acorn.LooseParser = LooseParser
50 +acorn.pluginsLoose = pluginsLoose
1 +export function isDummy(node) { return node.name == "✖" }
...\ No newline at end of file ...\ No newline at end of file
1 +import {tokenizer, SourceLocation, tokTypes as tt, Node, lineBreak, isNewLine} from ".."
2 +
3 +// Registered plugins
4 +export const pluginsLoose = {}
5 +
6 +export class LooseParser {
7 + constructor(input, options) {
8 + this.toks = tokenizer(input, options)
9 + this.options = this.toks.options
10 + this.input = this.toks.input
11 + this.tok = this.last = {type: tt.eof, start: 0, end: 0}
12 + if (this.options.locations) {
13 + let here = this.toks.curPosition()
14 + this.tok.loc = new SourceLocation(this.toks, here, here)
15 + }
16 + this.ahead = []; // Tokens ahead
17 + this.context = []; // Indentation contexted
18 + this.curIndent = 0
19 + this.curLineStart = 0
20 + this.nextLineStart = this.lineEnd(this.curLineStart) + 1
21 + // Load plugins
22 + this.options.pluginsLoose = options.pluginsLoose || {}
23 + this.loadPlugins(this.options.pluginsLoose)
24 + }
25 +
26 + startNode() {
27 + return new Node(this.toks, this.tok.start, this.options.locations ? this.tok.loc.start : null)
28 + }
29 +
30 + storeCurrentPos() {
31 + return this.options.locations ? [this.tok.start, this.tok.loc.start] : this.tok.start
32 + }
33 +
34 + startNodeAt(pos) {
35 + if (this.options.locations) {
36 + return new Node(this.toks, pos[0], pos[1])
37 + } else {
38 + return new Node(this.toks, pos)
39 + }
40 + }
41 +
42 + finishNode(node, type) {
43 + node.type = type
44 + node.end = this.last.end
45 + if (this.options.locations)
46 + node.loc.end = this.last.loc.end
47 + if (this.options.ranges)
48 + node.range[1] = this.last.end
49 + return node
50 + }
51 +
52 + dummyNode(type) {
53 + let dummy = this.startNode()
54 + dummy.type = type
55 + dummy.end = dummy.start
56 + if (this.options.locations)
57 + dummy.loc.end = dummy.loc.start
58 + if (this.options.ranges)
59 + dummy.range[1] = dummy.start
60 + this.last = {type: tt.name, start: dummy.start, end: dummy.start, loc: dummy.loc}
61 + return dummy
62 + }
63 +
64 + dummyIdent() {
65 + let dummy = this.dummyNode("Identifier")
66 + dummy.name = "✖"
67 + return dummy
68 + }
69 +
70 + dummyString() {
71 + let dummy = this.dummyNode("Literal")
72 + dummy.value = dummy.raw = "✖"
73 + return dummy
74 + }
75 +
76 + eat(type) {
77 + if (this.tok.type === type) {
78 + this.next()
79 + return true
80 + } else {
81 + return false
82 + }
83 + }
84 +
85 + isContextual(name) {
86 + return this.tok.type === tt.name && this.tok.value === name
87 + }
88 +
89 + eatContextual(name) {
90 + return this.tok.value === name && this.eat(tt.name)
91 + }
92 +
93 + canInsertSemicolon() {
94 + return this.tok.type === tt.eof || this.tok.type === tt.braceR ||
95 + lineBreak.test(this.input.slice(this.last.end, this.tok.start))
96 + }
97 +
98 + semicolon() {
99 + return this.eat(tt.semi)
100 + }
101 +
102 + expect(type) {
103 + if (this.eat(type)) return true
104 + for (let i = 1; i <= 2; i++) {
105 + if (this.lookAhead(i).type == type) {
106 + for (let j = 0; j < i; j++) this.next()
107 + return true
108 + }
109 + }
110 + }
111 +
112 + pushCx() {
113 + this.context.push(this.curIndent)
114 + }
115 +
116 + popCx() {
117 + this.curIndent = this.context.pop()
118 + }
119 +
120 + lineEnd(pos) {
121 + while (pos < this.input.length && !isNewLine(this.input.charCodeAt(pos))) ++pos
122 + return pos
123 + }
124 +
125 + indentationAfter(pos) {
126 + for (let count = 0;; ++pos) {
127 + let ch = this.input.charCodeAt(pos)
128 + if (ch === 32) ++count
129 + else if (ch === 9) count += this.options.tabSize
130 + else return count
131 + }
132 + }
133 +
134 + closes(closeTok, indent, line, blockHeuristic) {
135 + if (this.tok.type === closeTok || this.tok.type === tt.eof) return true
136 + return line != this.curLineStart && this.curIndent < indent && this.tokenStartsLine() &&
137 + (!blockHeuristic || this.nextLineStart >= this.input.length ||
138 + this.indentationAfter(this.nextLineStart) < indent)
139 + }
140 +
141 + tokenStartsLine() {
142 + for (let p = this.tok.start - 1; p >= this.curLineStart; --p) {
143 + let ch = this.input.charCodeAt(p)
144 + if (ch !== 9 && ch !== 32) return false
145 + }
146 + return true
147 + }
148 +
149 + extend(name, f) {
150 + this[name] = f(this[name])
151 + }
152 +
153 + loadPlugins(pluginConfigs) {
154 + for (let name in pluginConfigs) {
155 + let plugin = pluginsLoose[name]
156 + if (!plugin) throw new Error("Plugin '" + name + "' not found")
157 + plugin(this, pluginConfigs[name])
158 + }
159 + }
160 +}
This diff is collapsed. Click to expand it.
1 +import {tokTypes as tt, Token, isNewLine, SourceLocation, getLineInfo, lineBreakG} from ".."
2 +import {LooseParser} from "./state"
3 +
4 +const lp = LooseParser.prototype
5 +
6 +function isSpace(ch) {
7 + return (ch < 14 && ch > 8) || ch === 32 || ch === 160 || isNewLine(ch)
8 +}
9 +
10 +lp.next = function() {
11 + this.last = this.tok
12 + if (this.ahead.length)
13 + this.tok = this.ahead.shift()
14 + else
15 + this.tok = this.readToken()
16 +
17 + if (this.tok.start >= this.nextLineStart) {
18 + while (this.tok.start >= this.nextLineStart) {
19 + this.curLineStart = this.nextLineStart
20 + this.nextLineStart = this.lineEnd(this.curLineStart) + 1
21 + }
22 + this.curIndent = this.indentationAfter(this.curLineStart)
23 + }
24 +}
25 +
26 +lp.readToken = function() {
27 + for (;;) {
28 + try {
29 + this.toks.next()
30 + if (this.toks.type === tt.dot &&
31 + this.input.substr(this.toks.end, 1) === "." &&
32 + this.options.ecmaVersion >= 6) {
33 + this.toks.end++
34 + this.toks.type = tt.ellipsis
35 + }
36 + return new Token(this.toks)
37 + } catch(e) {
38 + if (!(e instanceof SyntaxError)) throw e
39 +
40 + // Try to skip some text, based on the error message, and then continue
41 + let msg = e.message, pos = e.raisedAt, replace = true
42 + if (/unterminated/i.test(msg)) {
43 + pos = this.lineEnd(e.pos + 1)
44 + if (/string/.test(msg)) {
45 + replace = {start: e.pos, end: pos, type: tt.string, value: this.input.slice(e.pos + 1, pos)}
46 + } else if (/regular expr/i.test(msg)) {
47 + let re = this.input.slice(e.pos, pos)
48 + try { re = new RegExp(re) } catch(e) {}
49 + replace = {start: e.pos, end: pos, type: tt.regexp, value: re}
50 + } else if (/template/.test(msg)) {
51 + replace = {start: e.pos, end: pos,
52 + type: tt.template,
53 + value: this.input.slice(e.pos, pos)}
54 + } else {
55 + replace = false
56 + }
57 + } else if (/invalid (unicode|regexp|number)|expecting unicode|octal literal|is reserved|directly after number|expected number in radix/i.test(msg)) {
58 + while (pos < this.input.length && !isSpace(this.input.charCodeAt(pos))) ++pos
59 + } else if (/character escape|expected hexadecimal/i.test(msg)) {
60 + while (pos < this.input.length) {
61 + let ch = this.input.charCodeAt(pos++)
62 + if (ch === 34 || ch === 39 || isNewLine(ch)) break
63 + }
64 + } else if (/unexpected character/i.test(msg)) {
65 + pos++
66 + replace = false
67 + } else if (/regular expression/i.test(msg)) {
68 + replace = true
69 + } else {
70 + throw e
71 + }
72 + this.resetTo(pos)
73 + if (replace === true) replace = {start: pos, end: pos, type: tt.name, value: "✖"}
74 + if (replace) {
75 + if (this.options.locations)
76 + replace.loc = new SourceLocation(
77 + this.toks,
78 + getLineInfo(this.input, replace.start),
79 + getLineInfo(this.input, replace.end))
80 + return replace
81 + }
82 + }
83 + }
84 +}
85 +
86 +lp.resetTo = function(pos) {
87 + this.toks.pos = pos
88 + let ch = this.input.charAt(pos - 1)
89 + this.toks.exprAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) ||
90 + /[enwfd]/.test(ch) &&
91 + /\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(this.input.slice(pos - 10, pos))
92 +
93 + if (this.options.locations) {
94 + this.toks.curLine = 1
95 + this.toks.lineStart = lineBreakG.lastIndex = 0
96 + let match
97 + while ((match = lineBreakG.exec(this.input)) && match.index < pos) {
98 + ++this.toks.curLine
99 + this.toks.lineStart = match.index + match[0].length
100 + }
101 + }
102 +}
103 +
104 +lp.lookAhead = function(n) {
105 + while (n > this.ahead.length)
106 + this.ahead.push(this.readToken())
107 + return this.ahead[n - 1]
108 +}
1 +import {types as tt} from "./tokentype"
2 +import {Parser} from "./state"
3 +import {has} from "./util"
4 +
5 +const pp = Parser.prototype
6 +
7 +// Convert existing expression atom to assignable pattern
8 +// if possible.
9 +
10 +pp.toAssignable = function(node, isBinding) {
11 + if (this.options.ecmaVersion >= 6 && node) {
12 + switch (node.type) {
13 + case "Identifier":
14 + case "ObjectPattern":
15 + case "ArrayPattern":
16 + break
17 +
18 + case "ObjectExpression":
19 + node.type = "ObjectPattern"
20 + for (let i = 0; i < node.properties.length; i++) {
21 + let prop = node.properties[i]
22 + if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter")
23 + this.toAssignable(prop.value, isBinding)
24 + }
25 + break
26 +
27 + case "ArrayExpression":
28 + node.type = "ArrayPattern"
29 + this.toAssignableList(node.elements, isBinding)
30 + break
31 +
32 + case "AssignmentExpression":
33 + if (node.operator === "=") {
34 + node.type = "AssignmentPattern"
35 + delete node.operator
36 + // falls through to AssignmentPattern
37 + } else {
38 + this.raise(node.left.end, "Only '=' operator can be used for specifying default value.")
39 + break;
40 + }
41 +
42 + case "AssignmentPattern":
43 + if (node.right.type === "YieldExpression")
44 + this.raise(node.right.start, "Yield expression cannot be a default value")
45 + break;
46 +
47 + case "ParenthesizedExpression":
48 + node.expression = this.toAssignable(node.expression, isBinding)
49 + break
50 +
51 + case "MemberExpression":
52 + if (!isBinding) break
53 +
54 + default:
55 + this.raise(node.start, "Assigning to rvalue")
56 + }
57 + }
58 + return node
59 +}
60 +
61 +// Convert list of expression atoms to binding list.
62 +
63 +pp.toAssignableList = function(exprList, isBinding) {
64 + let end = exprList.length
65 + if (end) {
66 + let last = exprList[end - 1]
67 + if (last && last.type == "RestElement") {
68 + --end
69 + } else if (last && last.type == "SpreadElement") {
70 + last.type = "RestElement"
71 + let arg = last.argument
72 + this.toAssignable(arg, isBinding)
73 + if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern")
74 + this.unexpected(arg.start)
75 + --end
76 + }
77 +
78 + if (isBinding && last.type === "RestElement" && last.argument.type !== "Identifier")
79 + this.unexpected(last.argument.start);
80 + }
81 + for (let i = 0; i < end; i++) {
82 + let elt = exprList[i]
83 + if (elt) this.toAssignable(elt, isBinding)
84 + }
85 + return exprList
86 +}
87 +
88 +// Parses spread element.
89 +
90 +pp.parseSpread = function(refDestructuringErrors) {
91 + let node = this.startNode()
92 + this.next()
93 + node.argument = this.parseMaybeAssign(refDestructuringErrors)
94 + return this.finishNode(node, "SpreadElement")
95 +}
96 +
97 +pp.parseRest = function(allowNonIdent) {
98 + let node = this.startNode()
99 + this.next()
100 +
101 + // RestElement inside of a function parameter must be an identifier
102 + if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected()
103 + else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected()
104 +
105 + return this.finishNode(node, "RestElement")
106 +}
107 +
108 +// Parses lvalue (assignable) atom.
109 +
110 +pp.parseBindingAtom = function() {
111 + if (this.options.ecmaVersion < 6) return this.parseIdent()
112 + switch (this.type) {
113 + case tt.name:
114 + return this.parseIdent()
115 +
116 + case tt.bracketL:
117 + let node = this.startNode()
118 + this.next()
119 + node.elements = this.parseBindingList(tt.bracketR, true, true)
120 + return this.finishNode(node, "ArrayPattern")
121 +
122 + case tt.braceL:
123 + return this.parseObj(true)
124 +
125 + default:
126 + this.unexpected()
127 + }
128 +}
129 +
130 +pp.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) {
131 + let elts = [], first = true
132 + while (!this.eat(close)) {
133 + if (first) first = false
134 + else this.expect(tt.comma)
135 + if (allowEmpty && this.type === tt.comma) {
136 + elts.push(null)
137 + } else if (allowTrailingComma && this.afterTrailingComma(close)) {
138 + break
139 + } else if (this.type === tt.ellipsis) {
140 + let rest = this.parseRest(allowNonIdent)
141 + this.parseBindingListItem(rest)
142 + elts.push(rest)
143 + this.expect(close)
144 + break
145 + } else {
146 + let elem = this.parseMaybeDefault(this.start, this.startLoc)
147 + this.parseBindingListItem(elem)
148 + elts.push(elem)
149 + }
150 + }
151 + return elts
152 +}
153 +
154 +pp.parseBindingListItem = function(param) {
155 + return param
156 +}
157 +
158 +// Parses assignment pattern around given atom if possible.
159 +
160 +pp.parseMaybeDefault = function(startPos, startLoc, left) {
161 + left = left || this.parseBindingAtom()
162 + if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left
163 + let node = this.startNodeAt(startPos, startLoc)
164 + node.left = left
165 + node.right = this.parseMaybeAssign()
166 + return this.finishNode(node, "AssignmentPattern")
167 +}
168 +
169 +// Verify that a node is an lval — something that can be assigned
170 +// to.
171 +
172 +pp.checkLVal = function(expr, isBinding, checkClashes) {
173 + switch (expr.type) {
174 + case "Identifier":
175 + if (this.strict && this.reservedWordsStrictBind.test(expr.name))
176 + this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode")
177 + if (checkClashes) {
178 + if (has(checkClashes, expr.name))
179 + this.raise(expr.start, "Argument name clash")
180 + checkClashes[expr.name] = true
181 + }
182 + break
183 +
184 + case "MemberExpression":
185 + if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression")
186 + break
187 +
188 + case "ObjectPattern":
189 + for (let i = 0; i < expr.properties.length; i++)
190 + this.checkLVal(expr.properties[i].value, isBinding, checkClashes)
191 + break
192 +
193 + case "ArrayPattern":
194 + for (let i = 0; i < expr.elements.length; i++) {
195 + let elem = expr.elements[i]
196 + if (elem) this.checkLVal(elem, isBinding, checkClashes)
197 + }
198 + break
199 +
200 + case "AssignmentPattern":
201 + this.checkLVal(expr.left, isBinding, checkClashes)
202 + break
203 +
204 + case "RestElement":
205 + this.checkLVal(expr.argument, isBinding, checkClashes)
206 + break
207 +
208 + case "ParenthesizedExpression":
209 + this.checkLVal(expr.expression, isBinding, checkClashes)
210 + break
211 +
212 + default:
213 + this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue")
214 + }
215 +}
1 +import {Parser} from "./state"
2 +import {SourceLocation} from "./locutil"
3 +
4 +export class Node {
5 + constructor(parser, pos, loc) {
6 + this.type = ""
7 + this.start = pos
8 + this.end = 0
9 + if (parser.options.locations)
10 + this.loc = new SourceLocation(parser, loc)
11 + if (parser.options.directSourceFile)
12 + this.sourceFile = parser.options.directSourceFile
13 + if (parser.options.ranges)
14 + this.range = [pos, 0]
15 + }
16 +}
17 +
18 +// Start an AST node, attaching a start offset.
19 +
20 +const pp = Parser.prototype
21 +
22 +pp.startNode = function() {
23 + return new Node(this, this.start, this.startLoc)
24 +}
25 +
26 +pp.startNodeAt = function(pos, loc) {
27 + return new Node(this, pos, loc)
28 +}
29 +
30 +// Finish an AST node, adding `type` and `end` properties.
31 +
32 +function finishNodeAt(node, type, pos, loc) {
33 + node.type = type
34 + node.end = pos
35 + if (this.options.locations)
36 + node.loc.end = loc
37 + if (this.options.ranges)
38 + node.range[1] = pos
39 + return node
40 +}
41 +
42 +pp.finishNode = function(node, type) {
43 + return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
44 +}
45 +
46 +// Finish node at given position
47 +
48 +pp.finishNodeAt = function(node, type, pos, loc) {
49 + return finishNodeAt.call(this, node, type, pos, loc)
50 +}
1 +import {has, isArray} from "./util"
2 +import {SourceLocation} from "./locutil"
3 +
4 +// A second optional argument can be given to further configure
5 +// the parser process. These options are recognized:
6 +
7 +export const defaultOptions = {
8 + // `ecmaVersion` indicates the ECMAScript version to parse. Must
9 + // be either 3, or 5, or 6. This influences support for strict
10 + // mode, the set of reserved words, support for getters and
11 + // setters and other features.
12 + ecmaVersion: 5,
13 + // Source type ("script" or "module") for different semantics
14 + sourceType: "script",
15 + // `onInsertedSemicolon` can be a callback that will be called
16 + // when a semicolon is automatically inserted. It will be passed
17 + // th position of the comma as an offset, and if `locations` is
18 + // enabled, it is given the location as a `{line, column}` object
19 + // as second argument.
20 + onInsertedSemicolon: null,
21 + // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
22 + // trailing commas.
23 + onTrailingComma: null,
24 + // By default, reserved words are only enforced if ecmaVersion >= 5.
25 + // Set `allowReserved` to a boolean value to explicitly turn this on
26 + // an off. When this option has the value "never", reserved words
27 + // and keywords can also not be used as property names.
28 + allowReserved: null,
29 + // When enabled, a return at the top level is not considered an
30 + // error.
31 + allowReturnOutsideFunction: false,
32 + // When enabled, import/export statements are not constrained to
33 + // appearing at the top of the program.
34 + allowImportExportEverywhere: false,
35 + // When enabled, hashbang directive in the beginning of file
36 + // is allowed and treated as a line comment.
37 + allowHashBang: false,
38 + // When `locations` is on, `loc` properties holding objects with
39 + // `start` and `end` properties in `{line, column}` form (with
40 + // line being 1-based and column 0-based) will be attached to the
41 + // nodes.
42 + locations: false,
43 + // A function can be passed as `onToken` option, which will
44 + // cause Acorn to call that function with object in the same
45 + // format as tokens returned from `tokenizer().getToken()`. Note
46 + // that you are not allowed to call the parser from the
47 + // callback—that will corrupt its internal state.
48 + onToken: null,
49 + // A function can be passed as `onComment` option, which will
50 + // cause Acorn to call that function with `(block, text, start,
51 + // end)` parameters whenever a comment is skipped. `block` is a
52 + // boolean indicating whether this is a block (`/* */`) comment,
53 + // `text` is the content of the comment, and `start` and `end` are
54 + // character offsets that denote the start and end of the comment.
55 + // When the `locations` option is on, two more parameters are
56 + // passed, the full `{line, column}` locations of the start and
57 + // end of the comments. Note that you are not allowed to call the
58 + // parser from the callback—that will corrupt its internal state.
59 + onComment: null,
60 + // Nodes have their start and end characters offsets recorded in
61 + // `start` and `end` properties (directly on the node, rather than
62 + // the `loc` object, which holds line/column data. To also add a
63 + // [semi-standardized][range] `range` property holding a `[start,
64 + // end]` array with the same numbers, set the `ranges` option to
65 + // `true`.
66 + //
67 + // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
68 + ranges: false,
69 + // It is possible to parse multiple files into a single AST by
70 + // passing the tree produced by parsing the first file as
71 + // `program` option in subsequent parses. This will add the
72 + // toplevel forms of the parsed file to the `Program` (top) node
73 + // of an existing parse tree.
74 + program: null,
75 + // When `locations` is on, you can pass this to record the source
76 + // file in every node's `loc` object.
77 + sourceFile: null,
78 + // This value, if given, is stored in every node, whether
79 + // `locations` is on or off.
80 + directSourceFile: null,
81 + // When enabled, parenthesized expressions are represented by
82 + // (non-standard) ParenthesizedExpression nodes
83 + preserveParens: false,
84 + plugins: {}
85 +}
86 +
87 +// Interpret and default an options object
88 +
89 +export function getOptions(opts) {
90 + let options = {}
91 + for (let opt in defaultOptions)
92 + options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]
93 + if (options.allowReserved == null)
94 + options.allowReserved = options.ecmaVersion < 5
95 +
96 + if (isArray(options.onToken)) {
97 + let tokens = options.onToken
98 + options.onToken = (token) => tokens.push(token)
99 + }
100 + if (isArray(options.onComment))
101 + options.onComment = pushComment(options, options.onComment)
102 +
103 + return options
104 +}
105 +
106 +function pushComment(options, array) {
107 + return function (block, text, start, end, startLoc, endLoc) {
108 + let comment = {
109 + type: block ? 'Block' : 'Line',
110 + value: text,
111 + start: start,
112 + end: end
113 + }
114 + if (options.locations)
115 + comment.loc = new SourceLocation(this, startLoc, endLoc)
116 + if (options.ranges)
117 + comment.range = [start, end]
118 + array.push(comment)
119 + }
120 +}
121 +
1 +import {types as tt} from "./tokentype"
2 +import {Parser} from "./state"
3 +import {lineBreak} from "./whitespace"
4 +
5 +const pp = Parser.prototype
6 +
7 +// ## Parser utilities
8 +
9 +// Test whether a statement node is the string literal `"use strict"`.
10 +
11 +pp.isUseStrict = function(stmt) {
12 + return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" &&
13 + stmt.expression.type === "Literal" &&
14 + stmt.expression.raw.slice(1, -1) === "use strict"
15 +}
16 +
17 +// Predicate that tests whether the next token is of the given
18 +// type, and if yes, consumes it as a side effect.
19 +
20 +pp.eat = function(type) {
21 + if (this.type === type) {
22 + this.next()
23 + return true
24 + } else {
25 + return false
26 + }
27 +}
28 +
29 +// Tests whether parsed token is a contextual keyword.
30 +
31 +pp.isContextual = function(name) {
32 + return this.type === tt.name && this.value === name
33 +}
34 +
35 +// Consumes contextual keyword if possible.
36 +
37 +pp.eatContextual = function(name) {
38 + return this.value === name && this.eat(tt.name)
39 +}
40 +
41 +// Asserts that following token is given contextual keyword.
42 +
43 +pp.expectContextual = function(name) {
44 + if (!this.eatContextual(name)) this.unexpected()
45 +}
46 +
47 +// Test whether a semicolon can be inserted at the current position.
48 +
49 +pp.canInsertSemicolon = function() {
50 + return this.type === tt.eof ||
51 + this.type === tt.braceR ||
52 + lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
53 +}
54 +
55 +pp.insertSemicolon = function() {
56 + if (this.canInsertSemicolon()) {
57 + if (this.options.onInsertedSemicolon)
58 + this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc)
59 + return true
60 + }
61 +}
62 +
63 +// Consume a semicolon, or, failing that, see if we are allowed to
64 +// pretend that there is a semicolon at this position.
65 +
66 +pp.semicolon = function() {
67 + if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected()
68 +}
69 +
70 +pp.afterTrailingComma = function(tokType) {
71 + if (this.type == tokType) {
72 + if (this.options.onTrailingComma)
73 + this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc)
74 + this.next()
75 + return true
76 + }
77 +}
78 +
79 +// Expect a token of a given type. If found, consume it, otherwise,
80 +// raise an unexpected token error.
81 +
82 +pp.expect = function(type) {
83 + this.eat(type) || this.unexpected()
84 +}
85 +
86 +// Raise an unexpected token error.
87 +
88 +pp.unexpected = function(pos) {
89 + this.raise(pos != null ? pos : this.start, "Unexpected token")
90 +}
91 +
92 +pp.checkPatternErrors = function(refDestructuringErrors, andThrow) {
93 + let pos = refDestructuringErrors && refDestructuringErrors.trailingComma
94 + if (!andThrow) return !!pos
95 + if (pos) this.raise(pos, "Trailing comma is not permitted in destructuring patterns")
96 +}
97 +
98 +pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
99 + let pos = refDestructuringErrors && refDestructuringErrors.shorthandAssign
100 + if (!andThrow) return !!pos
101 + if (pos) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns")
102 +}
1 +import {reservedWords, keywords} from "./identifier"
2 +import {types as tt} from "./tokentype"
3 +import {lineBreak} from "./whitespace"
4 +import {getOptions} from "./options"
5 +
6 +// Registered plugins
7 +export const plugins = {}
8 +
9 +function keywordRegexp(words) {
10 + return new RegExp("^(" + words.replace(/ /g, "|") + ")$")
11 +}
12 +
13 +export class Parser {
14 + constructor(options, input, startPos) {
15 + this.options = options = getOptions(options)
16 + this.sourceFile = options.sourceFile
17 + this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])
18 + let reserved = options.allowReserved ? "" :
19 + reservedWords[options.ecmaVersion] + (options.sourceType == "module" ? " await" : "")
20 + this.reservedWords = keywordRegexp(reserved)
21 + let reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict
22 + this.reservedWordsStrict = keywordRegexp(reservedStrict)
23 + this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind)
24 + this.input = String(input)
25 +
26 + // Used to signal to callers of `readWord1` whether the word
27 + // contained any escape sequences. This is needed because words with
28 + // escape sequences must not be interpreted as keywords.
29 + this.containsEsc = false;
30 +
31 + // Load plugins
32 + this.loadPlugins(options.plugins)
33 +
34 + // Set up token state
35 +
36 + // The current position of the tokenizer in the input.
37 + if (startPos) {
38 + this.pos = startPos
39 + this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos))
40 + this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length
41 + } else {
42 + this.pos = this.lineStart = 0
43 + this.curLine = 1
44 + }
45 +
46 + // Properties of the current token:
47 + // Its type
48 + this.type = tt.eof
49 + // For tokens that include more information than their type, the value
50 + this.value = null
51 + // Its start and end offset
52 + this.start = this.end = this.pos
53 + // And, if locations are used, the {line, column} object
54 + // corresponding to those offsets
55 + this.startLoc = this.endLoc = this.curPosition()
56 +
57 + // Position information for the previous token
58 + this.lastTokEndLoc = this.lastTokStartLoc = null
59 + this.lastTokStart = this.lastTokEnd = this.pos
60 +
61 + // The context stack is used to superficially track syntactic
62 + // context to predict whether a regular expression is allowed in a
63 + // given position.
64 + this.context = this.initialContext()
65 + this.exprAllowed = true
66 +
67 + // Figure out if it's a module code.
68 + this.strict = this.inModule = options.sourceType === "module"
69 +
70 + // Used to signify the start of a potential arrow function
71 + this.potentialArrowAt = -1
72 +
73 + // Flags to track whether we are in a function, a generator.
74 + this.inFunction = this.inGenerator = false
75 + // Labels in scope.
76 + this.labels = []
77 +
78 + // If enabled, skip leading hashbang line.
79 + if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === '#!')
80 + this.skipLineComment(2)
81 + }
82 +
83 + // DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them
84 + isKeyword(word) { return this.keywords.test(word) }
85 + isReservedWord(word) { return this.reservedWords.test(word) }
86 +
87 + extend(name, f) {
88 + this[name] = f(this[name])
89 + }
90 +
91 + loadPlugins(pluginConfigs) {
92 + for (let name in pluginConfigs) {
93 + let plugin = plugins[name]
94 + if (!plugin) throw new Error("Plugin '" + name + "' not found")
95 + plugin(this, pluginConfigs[name])
96 + }
97 + }
98 +
99 + parse() {
100 + let node = this.options.program || this.startNode()
101 + this.nextToken()
102 + return this.parseTopLevel(node)
103 + }
104 +}
This diff is collapsed. Click to expand it.
1 +// The algorithm used to determine whether a regexp can appear at a
2 +// given point in the program is loosely based on sweet.js' approach.
3 +// See https://github.com/mozilla/sweet.js/wiki/design
4 +
5 +import {Parser} from "./state"
6 +import {types as tt} from "./tokentype"
7 +import {lineBreak} from "./whitespace"
8 +
9 +export class TokContext {
10 + constructor(token, isExpr, preserveSpace, override) {
11 + this.token = token
12 + this.isExpr = !!isExpr
13 + this.preserveSpace = !!preserveSpace
14 + this.override = override
15 + }
16 +}
17 +
18 +export const types = {
19 + b_stat: new TokContext("{", false),
20 + b_expr: new TokContext("{", true),
21 + b_tmpl: new TokContext("${", true),
22 + p_stat: new TokContext("(", false),
23 + p_expr: new TokContext("(", true),
24 + q_tmpl: new TokContext("`", true, true, p => p.readTmplToken()),
25 + f_expr: new TokContext("function", true)
26 +}
27 +
28 +const pp = Parser.prototype
29 +
30 +pp.initialContext = function() {
31 + return [types.b_stat]
32 +}
33 +
34 +pp.braceIsBlock = function(prevType) {
35 + if (prevType === tt.colon) {
36 + let parent = this.curContext()
37 + if (parent === types.b_stat || parent === types.b_expr)
38 + return !parent.isExpr
39 + }
40 + if (prevType === tt._return)
41 + return lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
42 + if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof || prevType === tt.parenR)
43 + return true
44 + if (prevType == tt.braceL)
45 + return this.curContext() === types.b_stat
46 + return !this.exprAllowed
47 +}
48 +
49 +pp.updateContext = function(prevType) {
50 + let update, type = this.type
51 + if (type.keyword && prevType == tt.dot)
52 + this.exprAllowed = false
53 + else if (update = type.updateContext)
54 + update.call(this, prevType)
55 + else
56 + this.exprAllowed = type.beforeExpr
57 +}
58 +
59 +// Token-specific context update code
60 +
61 +tt.parenR.updateContext = tt.braceR.updateContext = function() {
62 + if (this.context.length == 1) {
63 + this.exprAllowed = true
64 + return
65 + }
66 + let out = this.context.pop()
67 + if (out === types.b_stat && this.curContext() === types.f_expr) {
68 + this.context.pop()
69 + this.exprAllowed = false
70 + } else if (out === types.b_tmpl) {
71 + this.exprAllowed = true
72 + } else {
73 + this.exprAllowed = !out.isExpr
74 + }
75 +}
76 +
77 +tt.braceL.updateContext = function(prevType) {
78 + this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr)
79 + this.exprAllowed = true
80 +}
81 +
82 +tt.dollarBraceL.updateContext = function() {
83 + this.context.push(types.b_tmpl)
84 + this.exprAllowed = true
85 +}
86 +
87 +tt.parenL.updateContext = function(prevType) {
88 + let statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while
89 + this.context.push(statementParens ? types.p_stat : types.p_expr)
90 + this.exprAllowed = true
91 +}
92 +
93 +tt.incDec.updateContext = function() {
94 + // tokExprAllowed stays unchanged
95 +}
96 +
97 +tt._function.updateContext = function() {
98 + if (this.curContext() !== types.b_stat)
99 + this.context.push(types.f_expr)
100 + this.exprAllowed = false
101 +}
102 +
103 +tt.backQuote.updateContext = function() {
104 + if (this.curContext() === types.q_tmpl)
105 + this.context.pop()
106 + else
107 + this.context.push(types.q_tmpl)
108 + this.exprAllowed = false
109 +}
This diff is collapsed. Click to expand it.
1 +// ## Token types
2 +
3 +// The assignment of fine-grained, information-carrying type objects
4 +// allows the tokenizer to store the information it has about a
5 +// token in a way that is very cheap for the parser to look up.
6 +
7 +// All token type variables start with an underscore, to make them
8 +// easy to recognize.
9 +
10 +// The `beforeExpr` property is used to disambiguate between regular
11 +// expressions and divisions. It is set on all token types that can
12 +// be followed by an expression (thus, a slash after them would be a
13 +// regular expression).
14 +//
15 +// The `startsExpr` property is used to check if the token ends a
16 +// `yield` expression. It is set on all token types that either can
17 +// directly start an expression (like a quotation mark) or can
18 +// continue an expression (like the body of a string).
19 +//
20 +// `isLoop` marks a keyword as starting a loop, which is important
21 +// to know when parsing a label, in order to allow or disallow
22 +// continue jumps to that label.
23 +
24 +export class TokenType {
25 + constructor(label, conf = {}) {
26 + this.label = label
27 + this.keyword = conf.keyword
28 + this.beforeExpr = !!conf.beforeExpr
29 + this.startsExpr = !!conf.startsExpr
30 + this.isLoop = !!conf.isLoop
31 + this.isAssign = !!conf.isAssign
32 + this.prefix = !!conf.prefix
33 + this.postfix = !!conf.postfix
34 + this.binop = conf.binop || null
35 + this.updateContext = null
36 + }
37 +}
38 +
39 +function binop(name, prec) {
40 + return new TokenType(name, {beforeExpr: true, binop: prec})
41 +}
42 +const beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true}
43 +
44 +export const types = {
45 + num: new TokenType("num", startsExpr),
46 + regexp: new TokenType("regexp", startsExpr),
47 + string: new TokenType("string", startsExpr),
48 + name: new TokenType("name", startsExpr),
49 + eof: new TokenType("eof"),
50 +
51 + // Punctuation token types.
52 + bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
53 + bracketR: new TokenType("]"),
54 + braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
55 + braceR: new TokenType("}"),
56 + parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
57 + parenR: new TokenType(")"),
58 + comma: new TokenType(",", beforeExpr),
59 + semi: new TokenType(";", beforeExpr),
60 + colon: new TokenType(":", beforeExpr),
61 + dot: new TokenType("."),
62 + question: new TokenType("?", beforeExpr),
63 + arrow: new TokenType("=>", beforeExpr),
64 + template: new TokenType("template"),
65 + ellipsis: new TokenType("...", beforeExpr),
66 + backQuote: new TokenType("`", startsExpr),
67 + dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
68 +
69 + // Operators. These carry several kinds of properties to help the
70 + // parser use them properly (the presence of these properties is
71 + // what categorizes them as operators).
72 + //
73 + // `binop`, when present, specifies that this operator is a binary
74 + // operator, and will refer to its precedence.
75 + //
76 + // `prefix` and `postfix` mark the operator as a prefix or postfix
77 + // unary operator.
78 + //
79 + // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
80 + // binary operators with a very low precedence, that should result
81 + // in AssignmentExpression nodes.
82 +
83 + eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
84 + assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
85 + incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
86 + prefix: new TokenType("prefix", {beforeExpr: true, prefix: true, startsExpr: true}),
87 + logicalOR: binop("||", 1),
88 + logicalAND: binop("&&", 2),
89 + bitwiseOR: binop("|", 3),
90 + bitwiseXOR: binop("^", 4),
91 + bitwiseAND: binop("&", 5),
92 + equality: binop("==/!=", 6),
93 + relational: binop("</>", 7),
94 + bitShift: binop("<</>>", 8),
95 + plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
96 + modulo: binop("%", 10),
97 + star: binop("*", 10),
98 + slash: binop("/", 10)
99 +}
100 +
101 +// Map keyword names to token types.
102 +
103 +export const keywords = {}
104 +
105 +// Succinct definitions of keyword token types
106 +function kw(name, options = {}) {
107 + options.keyword = name
108 + keywords[name] = types["_" + name] = new TokenType(name, options)
109 +}
110 +
111 +kw("break")
112 +kw("case", beforeExpr)
113 +kw("catch")
114 +kw("continue")
115 +kw("debugger")
116 +kw("default", beforeExpr)
117 +kw("do", {isLoop: true, beforeExpr: true})
118 +kw("else", beforeExpr)
119 +kw("finally")
120 +kw("for", {isLoop: true})
121 +kw("function", startsExpr)
122 +kw("if")
123 +kw("return", beforeExpr)
124 +kw("switch")
125 +kw("throw", beforeExpr)
126 +kw("try")
127 +kw("var")
128 +kw("let")
129 +kw("const")
130 +kw("while", {isLoop: true})
131 +kw("with")
132 +kw("new", {beforeExpr: true, startsExpr: true})
133 +kw("this", startsExpr)
134 +kw("super", startsExpr)
135 +kw("class")
136 +kw("extends", beforeExpr)
137 +kw("export")
138 +kw("import")
139 +kw("yield", {beforeExpr: true, startsExpr: true})
140 +kw("null", startsExpr)
141 +kw("true", startsExpr)
142 +kw("false", startsExpr)
143 +kw("in", {beforeExpr: true, binop: 7})
144 +kw("instanceof", {beforeExpr: true, binop: 7})
145 +kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true})
146 +kw("void", {beforeExpr: true, prefix: true, startsExpr: true})
147 +kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
1 +export function isArray(obj) {
2 + return Object.prototype.toString.call(obj) === "[object Array]"
3 +}
4 +
5 +// Checks if an object has a property.
6 +
7 +export function has(obj, propName) {
8 + return Object.prototype.hasOwnProperty.call(obj, propName)
9 +}
This diff is collapsed. Click to expand it.
1 +// Matches a whole line break (where CRLF is considered a single
2 +// line break). Used to count lines.
3 +
4 +export const lineBreak = /\r\n?|\n|\u2028|\u2029/
5 +export const lineBreakG = new RegExp(lineBreak.source, "g")
6 +
7 +export function isNewLine(code) {
8 + return code === 10 || code === 13 || code === 0x2028 || code == 0x2029
9 +}
10 +
11 +export const nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/
12 +
1 +1.0.10 / 2018-02-15
2 +------------------
3 +
4 +- Use .concat instead of + for arrays, #122.
5 +
6 +
7 +1.0.9 / 2016-09-29
8 +------------------
9 +
10 +- Rerelease after 1.0.8 - deps cleanup.
11 +
12 +
13 +1.0.8 / 2016-09-29
14 +------------------
15 +
16 +- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
17 +
18 +
19 +1.0.7 / 2016-03-17
20 +------------------
21 +
22 +- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
23 +
24 +
25 +1.0.6 / 2016-02-06
26 +------------------
27 +
28 +- Maintenance: moved to eslint & updated CS.
29 +
30 +
31 +1.0.5 / 2016-02-05
32 +------------------
33 +
34 +- Removed lodash dependency to significantly reduce install size.
35 + Thanks to @mourner.
36 +
37 +
38 +1.0.4 / 2016-01-17
39 +------------------
40 +
41 +- Maintenance: lodash update to 4.0.0.
42 +
43 +
44 +1.0.3 / 2015-10-27
45 +------------------
46 +
47 +- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
48 +
49 +
50 +1.0.2 / 2015-03-22
51 +------------------
52 +
53 +- Relaxed lodash version dependency.
54 +
55 +
56 +1.0.1 / 2015-02-20
57 +------------------
58 +
59 +- Changed dependencies to be compatible with ancient nodejs.
60 +
61 +
62 +1.0.0 / 2015-02-19
63 +------------------
64 +
65 +- Maintenance release.
66 +- Replaced `underscore` with `lodash`.
67 +- Bumped version to 1.0.0 to better reflect semver meaning.
68 +- HISTORY.md -> CHANGELOG.md
69 +
70 +
71 +0.1.16 / 2013-12-01
72 +-------------------
73 +
74 +- Maintenance release. Updated dependencies and docs.
75 +
76 +
77 +0.1.15 / 2013-05-13
78 +-------------------
79 +
80 +- Fixed #55, @trebor89
81 +
82 +
83 +0.1.14 / 2013-05-12
84 +-------------------
85 +
86 +- Fixed #62, @maxtaco
87 +
88 +
89 +0.1.13 / 2013-04-08
90 +-------------------
91 +
92 +- Added `.npmignore` to reduce package size
93 +
94 +
95 +0.1.12 / 2013-02-10
96 +-------------------
97 +
98 +- Fixed conflictHandler (#46), @hpaulj
99 +
100 +
101 +0.1.11 / 2013-02-07
102 +-------------------
103 +
104 +- Multiple bugfixes, @hpaulj
105 +- Added 70+ tests (ported from python), @hpaulj
106 +- Added conflictHandler, @applepicke
107 +- Added fromfilePrefixChar, @hpaulj
108 +
109 +
110 +0.1.10 / 2012-12-30
111 +-------------------
112 +
113 +- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
114 + support, thanks to @hpaulj
115 +- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
116 +
117 +
118 +0.1.9 / 2012-12-27
119 +------------------
120 +
121 +- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
122 +- Fixed default value behavior with `*` positionals, thanks to @hpaulj
123 +- Improve `getDefault()` behavior, thanks to @hpaulj
124 +- Imrove negative argument parsing, thanks to @hpaulj
125 +
126 +
127 +0.1.8 / 2012-12-01
128 +------------------
129 +
130 +- Fixed parser parents (issue #19), thanks to @hpaulj
131 +- Fixed negative argument parse (issue #20), thanks to @hpaulj
132 +
133 +
134 +0.1.7 / 2012-10-14
135 +------------------
136 +
137 +- Fixed 'choices' argument parse (issue #16)
138 +- Fixed stderr output (issue #15)
139 +
140 +
141 +0.1.6 / 2012-09-09
142 +------------------
143 +
144 +- Fixed check for conflict of options (thanks to @tomxtobin)
145 +
146 +
147 +0.1.5 / 2012-09-03
148 +------------------
149 +
150 +- Fix parser #setDefaults method (thanks to @tomxtobin)
151 +
152 +
153 +0.1.4 / 2012-07-30
154 +------------------
155 +
156 +- Fixed pseudo-argument support (thanks to @CGamesPlay)
157 +- Fixed addHelp default (should be true), if not set (thanks to @benblank)
158 +
159 +
160 +0.1.3 / 2012-06-27
161 +------------------
162 +
163 +- Fixed formatter api name: Formatter -> HelpFormatter
164 +
165 +
166 +0.1.2 / 2012-05-29
167 +------------------
168 +
169 +- Added basic tests
170 +- Removed excess whitespace in help
171 +- Fixed error reporting, when parcer with subcommands
172 + called with empty arguments
173 +
174 +
175 +0.1.1 / 2012-05-23
176 +------------------
177 +
178 +- Fixed line wrapping in help formatter
179 +- Added better error reporting on invalid arguments
180 +
181 +
182 +0.1.0 / 2012-05-16
183 +------------------
184 +
185 +- First release.
1 +(The MIT License)
2 +
3 +Copyright (C) 2012 by Vitaly Puzrin
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 +argparse
2 +========
3 +
4 +[![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse)
5 +[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)
6 +
7 +CLI arguments parser for node.js. Javascript port of python's
8 +[argparse](http://docs.python.org/dev/library/argparse.html) module
9 +(original version 3.2). That's a full port, except some very rare options,
10 +recorded in issue tracker.
11 +
12 +**NB. Difference with original.**
13 +
14 +- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
15 +- Use `defaultValue` instead of `default`.
16 +- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
17 + similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
18 + (aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
19 + `SUPPRESS`.
20 +
21 +
22 +Example
23 +=======
24 +
25 +test.js file:
26 +
27 +```javascript
28 +#!/usr/bin/env node
29 +'use strict';
30 +
31 +var ArgumentParser = require('../lib/argparse').ArgumentParser;
32 +var parser = new ArgumentParser({
33 + version: '0.0.1',
34 + addHelp:true,
35 + description: 'Argparse example'
36 +});
37 +parser.addArgument(
38 + [ '-f', '--foo' ],
39 + {
40 + help: 'foo bar'
41 + }
42 +);
43 +parser.addArgument(
44 + [ '-b', '--bar' ],
45 + {
46 + help: 'bar foo'
47 + }
48 +);
49 +parser.addArgument(
50 + '--baz',
51 + {
52 + help: 'baz bar'
53 + }
54 +);
55 +var args = parser.parseArgs();
56 +console.dir(args);
57 +```
58 +
59 +Display help:
60 +
61 +```
62 +$ ./test.js -h
63 +usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
64 +
65 +Argparse example
66 +
67 +Optional arguments:
68 + -h, --help Show this help message and exit.
69 + -v, --version Show program's version number and exit.
70 + -f FOO, --foo FOO foo bar
71 + -b BAR, --bar BAR bar foo
72 + --baz BAZ baz bar
73 +```
74 +
75 +Parse arguments:
76 +
77 +```
78 +$ ./test.js -f=3 --bar=4 --baz 5
79 +{ foo: '3', bar: '4', baz: '5' }
80 +```
81 +
82 +More [examples](https://github.com/nodeca/argparse/tree/master/examples).
83 +
84 +
85 +ArgumentParser objects
86 +======================
87 +
88 +```
89 +new ArgumentParser({parameters hash});
90 +```
91 +
92 +Creates a new ArgumentParser object.
93 +
94 +**Supported params:**
95 +
96 +- ```description``` - Text to display before the argument help.
97 +- ```epilog``` - Text to display after the argument help.
98 +- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
99 +- ```argumentDefault``` - Set the global default value for arguments. (default: null)
100 +- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
101 +- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
102 +- ```formatterClass``` - A class for customizing the help output.
103 +- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
104 +- ```usage``` - The string describing the program usage (default: generated)
105 +- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
106 +
107 +**Not supported yet**
108 +
109 +- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
110 +
111 +
112 +Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
113 +
114 +
115 +addArgument() method
116 +====================
117 +
118 +```
119 +ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
120 +```
121 +
122 +Defines how a single command-line argument should be parsed.
123 +
124 +- ```name or flag or [name] or [flags...]``` - Either a positional name
125 + (e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
126 + of a single positional name (e.g., `['foo']`), or an array of options
127 + (e.g., `['-f', '--foo']`).
128 +
129 +Options:
130 +
131 +- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
132 +- ```nargs```- The number of command-line arguments that should be consumed.
133 +- ```constant``` - A constant value required by some action and nargs selections.
134 +- ```defaultValue``` - The value produced if the argument is absent from the command line.
135 +- ```type``` - The type to which the command-line argument should be converted.
136 +- ```choices``` - A container of the allowable values for the argument.
137 +- ```required``` - Whether or not the command-line option may be omitted (optionals only).
138 +- ```help``` - A brief description of what the argument does.
139 +- ```metavar``` - A name for the argument in usage messages.
140 +- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
141 +
142 +Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
143 +
144 +
145 +Action (some details)
146 +================
147 +
148 +ArgumentParser objects associate command-line arguments with actions.
149 +These actions can do just about anything with the command-line arguments associated
150 +with them, though most actions simply add an attribute to the object returned by
151 +parseArgs(). The action keyword argument specifies how the command-line arguments
152 +should be handled. The supported actions are:
153 +
154 +- ```store``` - Just stores the argument’s value. This is the default action.
155 +- ```storeConst``` - Stores value, specified by the const keyword argument.
156 + (Note that the const keyword argument defaults to the rather unhelpful None.)
157 + The 'storeConst' action is most commonly used with optional arguments, that
158 + specify some sort of flag.
159 +- ```storeTrue``` and ```storeFalse``` - Stores values True and False
160 + respectively. These are special cases of 'storeConst'.
161 +- ```append``` - Stores a list, and appends each argument value to the list.
162 + This is useful to allow an option to be specified multiple times.
163 +- ```appendConst``` - Stores a list, and appends value, specified by the
164 + const keyword argument to the list. (Note, that the const keyword argument defaults
165 + is None.) The 'appendConst' action is typically used when multiple arguments need
166 + to store constants to the same list.
167 +- ```count``` - Counts the number of times a keyword argument occurs. For example,
168 + used for increasing verbosity levels.
169 +- ```help``` - Prints a complete help message for all the options in the current
170 + parser and then exits. By default a help action is automatically added to the parser.
171 + See ArgumentParser for details of how the output is created.
172 +- ```version``` - Prints version information and exit. Expects a `version=`
173 + keyword argument in the addArgument() call.
174 +
175 +Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
176 +
177 +
178 +Sub-commands
179 +============
180 +
181 +ArgumentParser.addSubparsers()
182 +
183 +Many programs split their functionality into a number of sub-commands, for
184 +example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
185 +and `svn commit`. Splitting up functionality this way can be a particularly good
186 +idea when a program performs several different functions which require different
187 +kinds of command-line arguments. `ArgumentParser` supports creation of such
188 +sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
189 +normally called with no arguments and returns an special action object.
190 +This object has a single method `addParser()`, which takes a command name and
191 +any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
192 +that can be modified as usual.
193 +
194 +Example:
195 +
196 +sub_commands.js
197 +```javascript
198 +#!/usr/bin/env node
199 +'use strict';
200 +
201 +var ArgumentParser = require('../lib/argparse').ArgumentParser;
202 +var parser = new ArgumentParser({
203 + version: '0.0.1',
204 + addHelp:true,
205 + description: 'Argparse examples: sub-commands',
206 +});
207 +
208 +var subparsers = parser.addSubparsers({
209 + title:'subcommands',
210 + dest:"subcommand_name"
211 +});
212 +
213 +var bar = subparsers.addParser('c1', {addHelp:true});
214 +bar.addArgument(
215 + [ '-f', '--foo' ],
216 + {
217 + action: 'store',
218 + help: 'foo3 bar3'
219 + }
220 +);
221 +var bar = subparsers.addParser(
222 + 'c2',
223 + {aliases:['co'], addHelp:true}
224 +);
225 +bar.addArgument(
226 + [ '-b', '--bar' ],
227 + {
228 + action: 'store',
229 + type: 'int',
230 + help: 'foo3 bar3'
231 + }
232 +);
233 +
234 +var args = parser.parseArgs();
235 +console.dir(args);
236 +
237 +```
238 +
239 +Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
240 +
241 +
242 +Contributors
243 +============
244 +
245 +- [Eugene Shkuropat](https://github.com/shkuropat)
246 +- [Paul Jacobson](https://github.com/hpaulj)
247 +
248 +[others](https://github.com/nodeca/argparse/graphs/contributors)
249 +
250 +License
251 +=======
252 +
253 +Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
254 +Released under the MIT license. See
255 +[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
256 +
257 +
1 +'use strict';
2 +
3 +module.exports = require('./lib/argparse');
1 +/**
2 + * class Action
3 + *
4 + * Base class for all actions
5 + * Do not call in your code, use this class only for inherits your own action
6 + *
7 + * Information about how to convert command line strings to Javascript objects.
8 + * Action objects are used by an ArgumentParser to represent the information
9 + * needed to parse a single argument from one or more strings from the command
10 + * line. The keyword arguments to the Action constructor are also all attributes
11 + * of Action instances.
12 + *
13 + * ##### Allowed keywords:
14 + *
15 + * - `store`
16 + * - `storeConstant`
17 + * - `storeTrue`
18 + * - `storeFalse`
19 + * - `append`
20 + * - `appendConstant`
21 + * - `count`
22 + * - `help`
23 + * - `version`
24 + *
25 + * Information about action options see [[Action.new]]
26 + *
27 + * See also [original guide](http://docs.python.org/dev/library/argparse.html#action)
28 + *
29 + **/
30 +
31 +'use strict';
32 +
33 +
34 +// Constants
35 +var c = require('./const');
36 +
37 +
38 +/**
39 + * new Action(options)
40 + *
41 + * Base class for all actions. Used only for inherits
42 + *
43 + *
44 + * ##### Options:
45 + *
46 + * - `optionStrings` A list of command-line option strings for the action.
47 + * - `dest` Attribute to hold the created object(s)
48 + * - `nargs` The number of command-line arguments that should be consumed.
49 + * By default, one argument will be consumed and a single value will be
50 + * produced.
51 + * - `constant` Default value for an action with no value.
52 + * - `defaultValue` The value to be produced if the option is not specified.
53 + * - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If
54 + * None, 'string'.
55 + * - `choices` The choices available.
56 + * - `required` True if the action must always be specified at the command
57 + * line.
58 + * - `help` The help describing the argument.
59 + * - `metavar` The name to be used for the option's argument with the help
60 + * string. If None, the 'dest' value will be used as the name.
61 + *
62 + * ##### nargs supported values:
63 + *
64 + * - `N` (an integer) consumes N arguments (and produces a list)
65 + * - `?` consumes zero or one arguments
66 + * - `*` consumes zero or more arguments (and produces a list)
67 + * - `+` consumes one or more arguments (and produces a list)
68 + *
69 + * Note: that the difference between the default and nargs=1 is that with the
70 + * default, a single value will be produced, while with nargs=1, a list
71 + * containing a single value will be produced.
72 + **/
73 +var Action = module.exports = function Action(options) {
74 + options = options || {};
75 + this.optionStrings = options.optionStrings || [];
76 + this.dest = options.dest;
77 + this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
78 + this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
79 + this.defaultValue = options.defaultValue;
80 + this.type = typeof options.type !== 'undefined' ? options.type : null;
81 + this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
82 + this.required = typeof options.required !== 'undefined' ? options.required : false;
83 + this.help = typeof options.help !== 'undefined' ? options.help : null;
84 + this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;
85 +
86 + if (!(this.optionStrings instanceof Array)) {
87 + throw new Error('optionStrings should be an array');
88 + }
89 + if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
90 + throw new Error('required should be a boolean');
91 + }
92 +};
93 +
94 +/**
95 + * Action#getName -> String
96 + *
97 + * Tells action name
98 + **/
99 +Action.prototype.getName = function () {
100 + if (this.optionStrings.length > 0) {
101 + return this.optionStrings.join('/');
102 + } else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
103 + return this.metavar;
104 + } else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
105 + return this.dest;
106 + }
107 + return null;
108 +};
109 +
110 +/**
111 + * Action#isOptional -> Boolean
112 + *
113 + * Return true if optional
114 + **/
115 +Action.prototype.isOptional = function () {
116 + return !this.isPositional();
117 +};
118 +
119 +/**
120 + * Action#isPositional -> Boolean
121 + *
122 + * Return true if positional
123 + **/
124 +Action.prototype.isPositional = function () {
125 + return (this.optionStrings.length === 0);
126 +};
127 +
128 +/**
129 + * Action#call(parser, namespace, values, optionString) -> Void
130 + * - parser (ArgumentParser): current parser
131 + * - namespace (Namespace): namespace for output data
132 + * - values (Array): parsed values
133 + * - optionString (Array): input option string(not parsed)
134 + *
135 + * Call the action. Should be implemented in inherited classes
136 + *
137 + * ##### Example
138 + *
139 + * ActionCount.prototype.call = function (parser, namespace, values, optionString) {
140 + * namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
141 + * };
142 + *
143 + **/
144 +Action.prototype.call = function () {
145 + throw new Error('.call() not defined');// Not Implemented error
146 +};
1 +/*:nodoc:*
2 + * class ActionAppend
3 + *
4 + * This action stores a list, and appends each argument value to the list.
5 + * This is useful to allow an option to be specified multiple times.
6 + * This class inherided from [[Action]]
7 + *
8 + **/
9 +
10 +'use strict';
11 +
12 +var util = require('util');
13 +
14 +var Action = require('../action');
15 +
16 +// Constants
17 +var c = require('../const');
18 +
19 +/*:nodoc:*
20 + * new ActionAppend(options)
21 + * - options (object): options hash see [[Action.new]]
22 + *
23 + * Note: options.nargs should be optional for constants
24 + * and more then zero for other
25 + **/
26 +var ActionAppend = module.exports = function ActionAppend(options) {
27 + options = options || {};
28 + if (this.nargs <= 0) {
29 + throw new Error('nargs for append actions must be > 0; if arg ' +
30 + 'strings are not supplying the value to append, ' +
31 + 'the append const action may be more appropriate');
32 + }
33 + if (!!this.constant && this.nargs !== c.OPTIONAL) {
34 + throw new Error('nargs must be OPTIONAL to supply const');
35 + }
36 + Action.call(this, options);
37 +};
38 +util.inherits(ActionAppend, Action);
39 +
40 +/*:nodoc:*
41 + * ActionAppend#call(parser, namespace, values, optionString) -> Void
42 + * - parser (ArgumentParser): current parser
43 + * - namespace (Namespace): namespace for output data
44 + * - values (Array): parsed values
45 + * - optionString (Array): input option string(not parsed)
46 + *
47 + * Call the action. Save result in namespace object
48 + **/
49 +ActionAppend.prototype.call = function (parser, namespace, values) {
50 + var items = (namespace[this.dest] || []).slice();
51 + items.push(values);
52 + namespace.set(this.dest, items);
53 +};
1 +/*:nodoc:*
2 + * class ActionAppendConstant
3 + *
4 + * This stores a list, and appends the value specified by
5 + * the const keyword argument to the list.
6 + * (Note that the const keyword argument defaults to null.)
7 + * The 'appendConst' action is typically useful when multiple
8 + * arguments need to store constants to the same list.
9 + *
10 + * This class inherited from [[Action]]
11 + **/
12 +
13 +'use strict';
14 +
15 +var util = require('util');
16 +
17 +var Action = require('../../action');
18 +
19 +/*:nodoc:*
20 + * new ActionAppendConstant(options)
21 + * - options (object): options hash see [[Action.new]]
22 + *
23 + **/
24 +var ActionAppendConstant = module.exports = function ActionAppendConstant(options) {
25 + options = options || {};
26 + options.nargs = 0;
27 + if (typeof options.constant === 'undefined') {
28 + throw new Error('constant option is required for appendAction');
29 + }
30 + Action.call(this, options);
31 +};
32 +util.inherits(ActionAppendConstant, Action);
33 +
34 +/*:nodoc:*
35 + * ActionAppendConstant#call(parser, namespace, values, optionString) -> Void
36 + * - parser (ArgumentParser): current parser
37 + * - namespace (Namespace): namespace for output data
38 + * - values (Array): parsed values
39 + * - optionString (Array): input option string(not parsed)
40 + *
41 + * Call the action. Save result in namespace object
42 + **/
43 +ActionAppendConstant.prototype.call = function (parser, namespace) {
44 + var items = [].concat(namespace[this.dest] || []);
45 + items.push(this.constant);
46 + namespace.set(this.dest, items);
47 +};
1 +/*:nodoc:*
2 + * class ActionCount
3 + *
4 + * This counts the number of times a keyword argument occurs.
5 + * For example, this is useful for increasing verbosity levels
6 + *
7 + * This class inherided from [[Action]]
8 + *
9 + **/
10 +'use strict';
11 +
12 +var util = require('util');
13 +
14 +var Action = require('../action');
15 +
16 +/*:nodoc:*
17 + * new ActionCount(options)
18 + * - options (object): options hash see [[Action.new]]
19 + *
20 + **/
21 +var ActionCount = module.exports = function ActionCount(options) {
22 + options = options || {};
23 + options.nargs = 0;
24 +
25 + Action.call(this, options);
26 +};
27 +util.inherits(ActionCount, Action);
28 +
29 +/*:nodoc:*
30 + * ActionCount#call(parser, namespace, values, optionString) -> Void
31 + * - parser (ArgumentParser): current parser
32 + * - namespace (Namespace): namespace for output data
33 + * - values (Array): parsed values
34 + * - optionString (Array): input option string(not parsed)
35 + *
36 + * Call the action. Save result in namespace object
37 + **/
38 +ActionCount.prototype.call = function (parser, namespace) {
39 + namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
40 +};
1 +/*:nodoc:*
2 + * class ActionHelp
3 + *
4 + * Support action for printing help
5 + * This class inherided from [[Action]]
6 + **/
7 +'use strict';
8 +
9 +var util = require('util');
10 +
11 +var Action = require('../action');
12 +
13 +// Constants
14 +var c = require('../const');
15 +
16 +/*:nodoc:*
17 + * new ActionHelp(options)
18 + * - options (object): options hash see [[Action.new]]
19 + *
20 + **/
21 +var ActionHelp = module.exports = function ActionHelp(options) {
22 + options = options || {};
23 + if (options.defaultValue !== null) {
24 + options.defaultValue = options.defaultValue;
25 + } else {
26 + options.defaultValue = c.SUPPRESS;
27 + }
28 + options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
29 + options.nargs = 0;
30 + Action.call(this, options);
31 +
32 +};
33 +util.inherits(ActionHelp, Action);
34 +
35 +/*:nodoc:*
36 + * ActionHelp#call(parser, namespace, values, optionString)
37 + * - parser (ArgumentParser): current parser
38 + * - namespace (Namespace): namespace for output data
39 + * - values (Array): parsed values
40 + * - optionString (Array): input option string(not parsed)
41 + *
42 + * Print help and exit
43 + **/
44 +ActionHelp.prototype.call = function (parser) {
45 + parser.printHelp();
46 + parser.exit();
47 +};
1 +/*:nodoc:*
2 + * class ActionStore
3 + *
4 + * This action just stores the argument’s value. This is the default action.
5 + *
6 + * This class inherited from [[Action]]
7 + *
8 + **/
9 +'use strict';
10 +
11 +var util = require('util');
12 +
13 +var Action = require('../action');
14 +
15 +// Constants
16 +var c = require('../const');
17 +
18 +
19 +/*:nodoc:*
20 + * new ActionStore(options)
21 + * - options (object): options hash see [[Action.new]]
22 + *
23 + **/
24 +var ActionStore = module.exports = function ActionStore(options) {
25 + options = options || {};
26 + if (this.nargs <= 0) {
27 + throw new Error('nargs for store actions must be > 0; if you ' +
28 + 'have nothing to store, actions such as store ' +
29 + 'true or store const may be more appropriate');
30 +
31 + }
32 + if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
33 + throw new Error('nargs must be OPTIONAL to supply const');
34 + }
35 + Action.call(this, options);
36 +};
37 +util.inherits(ActionStore, Action);
38 +
39 +/*:nodoc:*
40 + * ActionStore#call(parser, namespace, values, optionString) -> Void
41 + * - parser (ArgumentParser): current parser
42 + * - namespace (Namespace): namespace for output data
43 + * - values (Array): parsed values
44 + * - optionString (Array): input option string(not parsed)
45 + *
46 + * Call the action. Save result in namespace object
47 + **/
48 +ActionStore.prototype.call = function (parser, namespace, values) {
49 + namespace.set(this.dest, values);
50 +};
1 +/*:nodoc:*
2 + * class ActionStoreConstant
3 + *
4 + * This action stores the value specified by the const keyword argument.
5 + * (Note that the const keyword argument defaults to the rather unhelpful null.)
6 + * The 'store_const' action is most commonly used with optional
7 + * arguments that specify some sort of flag.
8 + *
9 + * This class inherited from [[Action]]
10 + **/
11 +'use strict';
12 +
13 +var util = require('util');
14 +
15 +var Action = require('../../action');
16 +
17 +/*:nodoc:*
18 + * new ActionStoreConstant(options)
19 + * - options (object): options hash see [[Action.new]]
20 + *
21 + **/
22 +var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
23 + options = options || {};
24 + options.nargs = 0;
25 + if (typeof options.constant === 'undefined') {
26 + throw new Error('constant option is required for storeAction');
27 + }
28 + Action.call(this, options);
29 +};
30 +util.inherits(ActionStoreConstant, Action);
31 +
32 +/*:nodoc:*
33 + * ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
34 + * - parser (ArgumentParser): current parser
35 + * - namespace (Namespace): namespace for output data
36 + * - values (Array): parsed values
37 + * - optionString (Array): input option string(not parsed)
38 + *
39 + * Call the action. Save result in namespace object
40 + **/
41 +ActionStoreConstant.prototype.call = function (parser, namespace) {
42 + namespace.set(this.dest, this.constant);
43 +};
1 +/*:nodoc:*
2 + * class ActionStoreFalse
3 + *
4 + * This action store the values False respectively.
5 + * This is special cases of 'storeConst'
6 + *
7 + * This class inherited from [[Action]]
8 + **/
9 +
10 +'use strict';
11 +
12 +var util = require('util');
13 +
14 +var ActionStoreConstant = require('./constant');
15 +
16 +/*:nodoc:*
17 + * new ActionStoreFalse(options)
18 + * - options (object): hash of options see [[Action.new]]
19 + *
20 + **/
21 +var ActionStoreFalse = module.exports = function ActionStoreFalse(options) {
22 + options = options || {};
23 + options.constant = false;
24 + options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
25 + ActionStoreConstant.call(this, options);
26 +};
27 +util.inherits(ActionStoreFalse, ActionStoreConstant);
1 +/*:nodoc:*
2 + * class ActionStoreTrue
3 + *
4 + * This action store the values True respectively.
5 + * This isspecial cases of 'storeConst'
6 + *
7 + * This class inherited from [[Action]]
8 + **/
9 +'use strict';
10 +
11 +var util = require('util');
12 +
13 +var ActionStoreConstant = require('./constant');
14 +
15 +/*:nodoc:*
16 + * new ActionStoreTrue(options)
17 + * - options (object): options hash see [[Action.new]]
18 + *
19 + **/
20 +var ActionStoreTrue = module.exports = function ActionStoreTrue(options) {
21 + options = options || {};
22 + options.constant = true;
23 + options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
24 + ActionStoreConstant.call(this, options);
25 +};
26 +util.inherits(ActionStoreTrue, ActionStoreConstant);
1 +/** internal
2 + * class ActionSubparsers
3 + *
4 + * Support the creation of such sub-commands with the addSubparsers()
5 + *
6 + * This class inherited from [[Action]]
7 + **/
8 +'use strict';
9 +
10 +var util = require('util');
11 +var format = require('util').format;
12 +
13 +
14 +var Action = require('../action');
15 +
16 +// Constants
17 +var c = require('../const');
18 +
19 +// Errors
20 +var argumentErrorHelper = require('../argument/error');
21 +
22 +
23 +/*:nodoc:*
24 + * new ChoicesPseudoAction(name, help)
25 + *
26 + * Create pseudo action for correct help text
27 + *
28 + **/
29 +function ChoicesPseudoAction(name, help) {
30 + var options = {
31 + optionStrings: [],
32 + dest: name,
33 + help: help
34 + };
35 +
36 + Action.call(this, options);
37 +}
38 +
39 +util.inherits(ChoicesPseudoAction, Action);
40 +
41 +/**
42 + * new ActionSubparsers(options)
43 + * - options (object): options hash see [[Action.new]]
44 + *
45 + **/
46 +function ActionSubparsers(options) {
47 + options = options || {};
48 + options.dest = options.dest || c.SUPPRESS;
49 + options.nargs = c.PARSER;
50 +
51 + this.debug = (options.debug === true);
52 +
53 + this._progPrefix = options.prog;
54 + this._parserClass = options.parserClass;
55 + this._nameParserMap = {};
56 + this._choicesActions = [];
57 +
58 + options.choices = this._nameParserMap;
59 + Action.call(this, options);
60 +}
61 +
62 +util.inherits(ActionSubparsers, Action);
63 +
64 +/*:nodoc:*
65 + * ActionSubparsers#addParser(name, options) -> ArgumentParser
66 + * - name (string): sub-command name
67 + * - options (object): see [[ArgumentParser.new]]
68 + *
69 + * Note:
70 + * addParser supports an additional aliases option,
71 + * which allows multiple strings to refer to the same subparser.
72 + * This example, like svn, aliases co as a shorthand for checkout
73 + *
74 + **/
75 +ActionSubparsers.prototype.addParser = function (name, options) {
76 + var parser;
77 +
78 + var self = this;
79 +
80 + options = options || {};
81 +
82 + options.debug = (this.debug === true);
83 +
84 + // set program from the existing prefix
85 + if (!options.prog) {
86 + options.prog = this._progPrefix + ' ' + name;
87 + }
88 +
89 + var aliases = options.aliases || [];
90 +
91 + // create a pseudo-action to hold the choice help
92 + if (!!options.help || typeof options.help === 'string') {
93 + var help = options.help;
94 + delete options.help;
95 +
96 + var choiceAction = new ChoicesPseudoAction(name, help);
97 + this._choicesActions.push(choiceAction);
98 + }
99 +
100 + // create the parser and add it to the map
101 + parser = new this._parserClass(options);
102 + this._nameParserMap[name] = parser;
103 +
104 + // make parser available under aliases also
105 + aliases.forEach(function (alias) {
106 + self._nameParserMap[alias] = parser;
107 + });
108 +
109 + return parser;
110 +};
111 +
112 +ActionSubparsers.prototype._getSubactions = function () {
113 + return this._choicesActions;
114 +};
115 +
116 +/*:nodoc:*
117 + * ActionSubparsers#call(parser, namespace, values, optionString) -> Void
118 + * - parser (ArgumentParser): current parser
119 + * - namespace (Namespace): namespace for output data
120 + * - values (Array): parsed values
121 + * - optionString (Array): input option string(not parsed)
122 + *
123 + * Call the action. Parse input aguments
124 + **/
125 +ActionSubparsers.prototype.call = function (parser, namespace, values) {
126 + var parserName = values[0];
127 + var argStrings = values.slice(1);
128 +
129 + // set the parser name if requested
130 + if (this.dest !== c.SUPPRESS) {
131 + namespace[this.dest] = parserName;
132 + }
133 +
134 + // select the parser
135 + if (this._nameParserMap[parserName]) {
136 + parser = this._nameParserMap[parserName];
137 + } else {
138 + throw argumentErrorHelper(format(
139 + 'Unknown parser "%s" (choices: [%s]).',
140 + parserName,
141 + Object.keys(this._nameParserMap).join(', ')
142 + ));
143 + }
144 +
145 + // parse all the remaining options into the namespace
146 + parser.parseArgs(argStrings, namespace);
147 +};
148 +
149 +module.exports = ActionSubparsers;
1 +/*:nodoc:*
2 + * class ActionVersion
3 + *
4 + * Support action for printing program version
5 + * This class inherited from [[Action]]
6 + **/
7 +'use strict';
8 +
9 +var util = require('util');
10 +
11 +var Action = require('../action');
12 +
13 +//
14 +// Constants
15 +//
16 +var c = require('../const');
17 +
18 +/*:nodoc:*
19 + * new ActionVersion(options)
20 + * - options (object): options hash see [[Action.new]]
21 + *
22 + **/
23 +var ActionVersion = module.exports = function ActionVersion(options) {
24 + options = options || {};
25 + options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
26 + options.dest = (options.dest || c.SUPPRESS);
27 + options.nargs = 0;
28 + this.version = options.version;
29 + Action.call(this, options);
30 +};
31 +util.inherits(ActionVersion, Action);
32 +
33 +/*:nodoc:*
34 + * ActionVersion#call(parser, namespace, values, optionString) -> Void
35 + * - parser (ArgumentParser): current parser
36 + * - namespace (Namespace): namespace for output data
37 + * - values (Array): parsed values
38 + * - optionString (Array): input option string(not parsed)
39 + *
40 + * Print version and exit
41 + **/
42 +ActionVersion.prototype.call = function (parser) {
43 + var version = this.version || parser.version;
44 + var formatter = parser._getFormatter();
45 + formatter.addText(version);
46 + parser.exit(0, formatter.formatHelp());
47 +};
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +module.exports.ArgumentParser = require('./argument_parser.js');
4 +module.exports.Namespace = require('./namespace');
5 +module.exports.Action = require('./action');
6 +module.exports.HelpFormatter = require('./help/formatter.js');
7 +module.exports.Const = require('./const.js');
8 +
9 +module.exports.ArgumentDefaultsHelpFormatter =
10 + require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter;
11 +module.exports.RawDescriptionHelpFormatter =
12 + require('./help/added_formatters.js').RawDescriptionHelpFormatter;
13 +module.exports.RawTextHelpFormatter =
14 + require('./help/added_formatters.js').RawTextHelpFormatter;
1 +'use strict';
2 +
3 +
4 +var format = require('util').format;
5 +
6 +
7 +var ERR_CODE = 'ARGError';
8 +
9 +/*:nodoc:*
10 + * argumentError(argument, message) -> TypeError
11 + * - argument (Object): action with broken argument
12 + * - message (String): error message
13 + *
14 + * Error format helper. An error from creating or using an argument
15 + * (optional or positional). The string value of this exception
16 + * is the message, augmented with information
17 + * about the argument that caused it.
18 + *
19 + * #####Example
20 + *
21 + * var argumentErrorHelper = require('./argument/error');
22 + * if (conflictOptionals.length > 0) {
23 + * throw argumentErrorHelper(
24 + * action,
25 + * format('Conflicting option string(s): %s', conflictOptionals.join(', '))
26 + * );
27 + * }
28 + *
29 + **/
30 +module.exports = function (argument, message) {
31 + var argumentName = null;
32 + var errMessage;
33 + var err;
34 +
35 + if (argument.getName) {
36 + argumentName = argument.getName();
37 + } else {
38 + argumentName = '' + argument;
39 + }
40 +
41 + if (!argumentName) {
42 + errMessage = message;
43 + } else {
44 + errMessage = format('argument "%s": %s', argumentName, message);
45 + }
46 +
47 + err = new TypeError(errMessage);
48 + err.code = ERR_CODE;
49 + return err;
50 +};
1 +/** internal
2 + * class MutuallyExclusiveGroup
3 + *
4 + * Group arguments.
5 + * By default, ArgumentParser groups command-line arguments
6 + * into “positional arguments” and “optional arguments”
7 + * when displaying help messages. When there is a better
8 + * conceptual grouping of arguments than this default one,
9 + * appropriate groups can be created using the addArgumentGroup() method
10 + *
11 + * This class inherited from [[ArgumentContainer]]
12 + **/
13 +'use strict';
14 +
15 +var util = require('util');
16 +
17 +var ArgumentGroup = require('./group');
18 +
19 +/**
20 + * new MutuallyExclusiveGroup(container, options)
21 + * - container (object): main container
22 + * - options (object): options.required -> true/false
23 + *
24 + * `required` could be an argument itself, but making it a property of
25 + * the options argument is more consistent with the JS adaptation of the Python)
26 + **/
27 +var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
28 + var required;
29 + options = options || {};
30 + required = options.required || false;
31 + ArgumentGroup.call(this, container);
32 + this.required = required;
33 +
34 +};
35 +util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
36 +
37 +
38 +MutuallyExclusiveGroup.prototype._addAction = function (action) {
39 + var msg;
40 + if (action.required) {
41 + msg = 'mutually exclusive arguments must be optional';
42 + throw new Error(msg);
43 + }
44 + action = this._container._addAction(action);
45 + this._groupActions.push(action);
46 + return action;
47 +};
48 +
49 +
50 +MutuallyExclusiveGroup.prototype._removeAction = function (action) {
51 + this._container._removeAction(action);
52 + this._groupActions.remove(action);
53 +};
54 +
1 +/** internal
2 + * class ArgumentGroup
3 + *
4 + * Group arguments.
5 + * By default, ArgumentParser groups command-line arguments
6 + * into “positional arguments” and “optional arguments”
7 + * when displaying help messages. When there is a better
8 + * conceptual grouping of arguments than this default one,
9 + * appropriate groups can be created using the addArgumentGroup() method
10 + *
11 + * This class inherited from [[ArgumentContainer]]
12 + **/
13 +'use strict';
14 +
15 +var util = require('util');
16 +
17 +var ActionContainer = require('../action_container');
18 +
19 +
20 +/**
21 + * new ArgumentGroup(container, options)
22 + * - container (object): main container
23 + * - options (object): hash of group options
24 + *
25 + * #### options
26 + * - **prefixChars** group name prefix
27 + * - **argumentDefault** default argument value
28 + * - **title** group title
29 + * - **description** group description
30 + *
31 + **/
32 +var ArgumentGroup = module.exports = function ArgumentGroup(container, options) {
33 +
34 + options = options || {};
35 +
36 + // add any missing keyword arguments by checking the container
37 + options.conflictHandler = (options.conflictHandler || container.conflictHandler);
38 + options.prefixChars = (options.prefixChars || container.prefixChars);
39 + options.argumentDefault = (options.argumentDefault || container.argumentDefault);
40 +
41 + ActionContainer.call(this, options);
42 +
43 + // group attributes
44 + this.title = options.title;
45 + this._groupActions = [];
46 +
47 + // share most attributes with the container
48 + this._container = container;
49 + this._registries = container._registries;
50 + this._actions = container._actions;
51 + this._optionStringActions = container._optionStringActions;
52 + this._defaults = container._defaults;
53 + this._hasNegativeNumberOptionals = container._hasNegativeNumberOptionals;
54 + this._mutuallyExclusiveGroups = container._mutuallyExclusiveGroups;
55 +};
56 +util.inherits(ArgumentGroup, ActionContainer);
57 +
58 +
59 +ArgumentGroup.prototype._addAction = function (action) {
60 + // Parent add action
61 + action = ActionContainer.prototype._addAction.call(this, action);
62 + this._groupActions.push(action);
63 + return action;
64 +};
65 +
66 +
67 +ArgumentGroup.prototype._removeAction = function (action) {
68 + // Parent remove action
69 + ActionContainer.prototype._removeAction.call(this, action);
70 + var actionIndex = this._groupActions.indexOf(action);
71 + if (actionIndex >= 0) {
72 + this._groupActions.splice(actionIndex, 1);
73 + }
74 +};
75 +
This diff is collapsed. Click to expand it.
1 +//
2 +// Constants
3 +//
4 +
5 +'use strict';
6 +
7 +module.exports.EOL = '\n';
8 +
9 +module.exports.SUPPRESS = '==SUPPRESS==';
10 +
11 +module.exports.OPTIONAL = '?';
12 +
13 +module.exports.ZERO_OR_MORE = '*';
14 +
15 +module.exports.ONE_OR_MORE = '+';
16 +
17 +module.exports.PARSER = 'A...';
18 +
19 +module.exports.REMAINDER = '...';
20 +
21 +module.exports._UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args';
1 +'use strict';
2 +
3 +var util = require('util');
4 +
5 +// Constants
6 +var c = require('../const');
7 +
8 +var $$ = require('../utils');
9 +var HelpFormatter = require('./formatter.js');
10 +
11 +/**
12 + * new RawDescriptionHelpFormatter(options)
13 + * new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
14 + *
15 + * Help message formatter which adds default values to argument help.
16 + *
17 + * Only the name of this class is considered a public API. All the methods
18 + * provided by the class are considered an implementation detail.
19 + **/
20 +
21 +function ArgumentDefaultsHelpFormatter(options) {
22 + HelpFormatter.call(this, options);
23 +}
24 +
25 +util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);
26 +
27 +ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) {
28 + var help = action.help;
29 + if (action.help.indexOf('%(defaultValue)s') === -1) {
30 + if (action.defaultValue !== c.SUPPRESS) {
31 + var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
32 + if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {
33 + help += ' (default: %(defaultValue)s)';
34 + }
35 + }
36 + }
37 + return help;
38 +};
39 +
40 +module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter;
41 +
42 +/**
43 + * new RawDescriptionHelpFormatter(options)
44 + * new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
45 + *
46 + * Help message formatter which retains any formatting in descriptions.
47 + *
48 + * Only the name of this class is considered a public API. All the methods
49 + * provided by the class are considered an implementation detail.
50 + **/
51 +
52 +function RawDescriptionHelpFormatter(options) {
53 + HelpFormatter.call(this, options);
54 +}
55 +
56 +util.inherits(RawDescriptionHelpFormatter, HelpFormatter);
57 +
58 +RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) {
59 + var lines = text.split('\n');
60 + lines = lines.map(function (line) {
61 + return $$.trimEnd(indent + line);
62 + });
63 + return lines.join('\n');
64 +};
65 +module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter;
66 +
67 +/**
68 + * new RawTextHelpFormatter(options)
69 + * new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...})
70 + *
71 + * Help message formatter which retains formatting of all help text.
72 + *
73 + * Only the name of this class is considered a public API. All the methods
74 + * provided by the class are considered an implementation detail.
75 + **/
76 +
77 +function RawTextHelpFormatter(options) {
78 + RawDescriptionHelpFormatter.call(this, options);
79 +}
80 +
81 +util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);
82 +
83 +RawTextHelpFormatter.prototype._splitLines = function (text) {
84 + return text.split('\n');
85 +};
86 +
87 +module.exports.RawTextHelpFormatter = RawTextHelpFormatter;
This diff is collapsed. Click to expand it.
1 +/**
2 + * class Namespace
3 + *
4 + * Simple object for storing attributes. Implements equality by attribute names
5 + * and values, and provides a simple string representation.
6 + *
7 + * See also [original guide][1]
8 + *
9 + * [1]:http://docs.python.org/dev/library/argparse.html#the-namespace-object
10 + **/
11 +'use strict';
12 +
13 +var $$ = require('./utils');
14 +
15 +/**
16 + * new Namespace(options)
17 + * - options(object): predefined propertis for result object
18 + *
19 + **/
20 +var Namespace = module.exports = function Namespace(options) {
21 + $$.extend(this, options);
22 +};
23 +
24 +/**
25 + * Namespace#isset(key) -> Boolean
26 + * - key (string|number): property name
27 + *
28 + * Tells whenever `namespace` contains given `key` or not.
29 + **/
30 +Namespace.prototype.isset = function (key) {
31 + return $$.has(this, key);
32 +};
33 +
34 +/**
35 + * Namespace#set(key, value) -> self
36 + * -key (string|number|object): propery name
37 + * -value (mixed): new property value
38 + *
39 + * Set the property named key with value.
40 + * If key object then set all key properties to namespace object
41 + **/
42 +Namespace.prototype.set = function (key, value) {
43 + if (typeof (key) === 'object') {
44 + $$.extend(this, key);
45 + } else {
46 + this[key] = value;
47 + }
48 + return this;
49 +};
50 +
51 +/**
52 + * Namespace#get(key, defaultValue) -> mixed
53 + * - key (string|number): property name
54 + * - defaultValue (mixed): default value
55 + *
56 + * Return the property key or defaulValue if not set
57 + **/
58 +Namespace.prototype.get = function (key, defaultValue) {
59 + return !this[key] ? defaultValue : this[key];
60 +};
61 +
62 +/**
63 + * Namespace#unset(key, defaultValue) -> mixed
64 + * - key (string|number): property name
65 + * - defaultValue (mixed): default value
66 + *
67 + * Return data[key](and delete it) or defaultValue
68 + **/
69 +Namespace.prototype.unset = function (key, defaultValue) {
70 + var value = this[key];
71 + if (value !== null) {
72 + delete this[key];
73 + return value;
74 + }
75 + return defaultValue;
76 +};
1 +'use strict';
2 +
3 +exports.repeat = function (str, num) {
4 + var result = '';
5 + for (var i = 0; i < num; i++) { result += str; }
6 + return result;
7 +};
8 +
9 +exports.arrayEqual = function (a, b) {
10 + if (a.length !== b.length) { return false; }
11 + for (var i = 0; i < a.length; i++) {
12 + if (a[i] !== b[i]) { return false; }
13 + }
14 + return true;
15 +};
16 +
17 +exports.trimChars = function (str, chars) {
18 + var start = 0;
19 + var end = str.length - 1;
20 + while (chars.indexOf(str.charAt(start)) >= 0) { start++; }
21 + while (chars.indexOf(str.charAt(end)) >= 0) { end--; }
22 + return str.slice(start, end + 1);
23 +};
24 +
25 +exports.capitalize = function (str) {
26 + return str.charAt(0).toUpperCase() + str.slice(1);
27 +};
28 +
29 +exports.arrayUnion = function () {
30 + var result = [];
31 + for (var i = 0, values = {}; i < arguments.length; i++) {
32 + var arr = arguments[i];
33 + for (var j = 0; j < arr.length; j++) {
34 + if (!values[arr[j]]) {
35 + values[arr[j]] = true;
36 + result.push(arr[j]);
37 + }
38 + }
39 + }
40 + return result;
41 +};
42 +
43 +function has(obj, key) {
44 + return Object.prototype.hasOwnProperty.call(obj, key);
45 +}
46 +
47 +exports.has = has;
48 +
49 +exports.extend = function (dest, src) {
50 + for (var i in src) {
51 + if (has(src, i)) { dest[i] = src[i]; }
52 + }
53 +};
54 +
55 +exports.trimEnd = function (str) {
56 + return str.replace(/\s+$/g, '');
57 +};
1 +{
2 + "_from": "argparse@^1.0.7",
3 + "_id": "argparse@1.0.10",
4 + "_inBundle": false,
5 + "_integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
6 + "_location": "/argparse",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "argparse@^1.0.7",
12 + "name": "argparse",
13 + "escapedName": "argparse",
14 + "rawSpec": "^1.0.7",
15 + "saveSpec": null,
16 + "fetchSpec": "^1.0.7"
17 + },
18 + "_requiredBy": [
19 + "/js-yaml"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
22 + "_shasum": "bcd6791ea5ae09725e17e5ad988134cd40b3d911",
23 + "_spec": "argparse@^1.0.7",
24 + "_where": "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT\\node_modules\\js-yaml",
25 + "bugs": {
26 + "url": "https://github.com/nodeca/argparse/issues"
27 + },
28 + "bundleDependencies": false,
29 + "contributors": [
30 + {
31 + "name": "Eugene Shkuropat"
32 + },
33 + {
34 + "name": "Paul Jacobson"
35 + }
36 + ],
37 + "dependencies": {
38 + "sprintf-js": "~1.0.2"
39 + },
40 + "deprecated": false,
41 + "description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
42 + "devDependencies": {
43 + "eslint": "^2.13.1",
44 + "istanbul": "^0.4.5",
45 + "mocha": "^3.1.0",
46 + "ndoc": "^5.0.1"
47 + },
48 + "files": [
49 + "index.js",
50 + "lib/"
51 + ],
52 + "homepage": "https://github.com/nodeca/argparse#readme",
53 + "keywords": [
54 + "cli",
55 + "parser",
56 + "argparse",
57 + "option",
58 + "args"
59 + ],
60 + "license": "MIT",
61 + "name": "argparse",
62 + "repository": {
63 + "type": "git",
64 + "url": "git+https://github.com/nodeca/argparse.git"
65 + },
66 + "scripts": {
67 + "test": "make test"
68 + },
69 + "version": "1.0.10"
70 +}
1 +
2 +## 2.0.6
3 +
4 +Version 2.0.4 adds support for React Native by clarifying in package.json that
5 +the browser environment does not support Node.js domains.
6 +Why this is necessary, we leave as an exercise for the user.
7 +
8 +## 2.0.3
9 +
10 +Version 2.0.3 fixes a bug when adjusting the capacity of the task queue.
11 +
12 +## 2.0.1-2.02
13 +
14 +Version 2.0.1 fixes a bug in the way redirects were expressed that affected the
15 +function of Browserify, but which Mr would tolerate.
16 +
17 +## 2.0.0
18 +
19 +Version 2 of ASAP is a full rewrite with a few salient changes.
20 +First, the ASAP source is CommonJS only and designed with [Browserify][] and
21 +[Browserify-compatible][Mr] module loaders in mind.
22 +
23 +[Browserify]: https://github.com/substack/node-browserify
24 +[Mr]: https://github.com/montagejs/mr
25 +
26 +The new version has been refactored in two dimensions.
27 +Support for Node.js and browsers have been separated, using Browserify
28 +redirects and ASAP has been divided into two modules.
29 +The "raw" layer depends on the tasks to catch thrown exceptions and unravel
30 +Node.js domains.
31 +
32 +The full implementation of ASAP is loadable as `require("asap")` in both Node.js
33 +and browsers.
34 +
35 +The raw layer that lacks exception handling overhead is loadable as
36 +`require("asap/raw")`.
37 +The interface is the same for both layers.
38 +
39 +Tasks are no longer required to be functions, but can rather be any object that
40 +implements `task.call()`.
41 +With this feature you can recycle task objects to avoid garbage collector churn
42 +and avoid closures in general.
43 +
44 +The implementation has been rigorously documented so that our successors can
45 +understand the scope of the problem that this module solves and all of its
46 +nuances, ensuring that the next generation of implementations know what details
47 +are essential.
48 +
49 +- [asap.js](https://github.com/kriskowal/asap/blob/master/asap.js)
50 +- [raw.js](https://github.com/kriskowal/asap/blob/master/raw.js)
51 +- [browser-asap.js](https://github.com/kriskowal/asap/blob/master/browser-asap.js)
52 +- [browser-raw.js](https://github.com/kriskowal/asap/blob/master/browser-raw.js)
53 +
54 +The new version has also been rigorously tested across a broad spectrum of
55 +browsers, in both the window and worker context.
56 +The following charts capture the browser test results for the most recent
57 +release.
58 +The first chart shows test results for ASAP running in the main window context.
59 +The second chart shows test results for ASAP running in a web worker context.
60 +Test results are inconclusive (grey) on browsers that do not support web
61 +workers.
62 +These data are captured automatically by [Continuous
63 +Integration][].
64 +
65 +![Browser Compatibility](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-results-matrix.svg)
66 +
67 +![Compatibility in Web Workers](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-worker-results-matrix.svg)
68 +
69 +[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md
70 +
1 +
2 +Copyright 2009–2014 Contributors. All rights reserved.
3 +
4 +Permission is hereby granted, free of charge, to any person obtaining a copy
5 +of this software and associated documentation files (the "Software"), to
6 +deal in the Software without restriction, including without limitation the
7 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 +sell copies of the Software, and to permit persons to whom the Software is
9 +furnished to do so, subject to the following conditions:
10 +
11 +The above copyright notice and this permission notice shall be included in
12 +all copies or substantial portions of the Software.
13 +
14 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 +IN THE SOFTWARE.
21 +
1 +# ASAP
2 +
3 +[![Build Status](https://travis-ci.org/kriskowal/asap.png?branch=master)](https://travis-ci.org/kriskowal/asap)
4 +
5 +Promise and asynchronous observer libraries, as well as hand-rolled callback
6 +programs and libraries, often need a mechanism to postpone the execution of a
7 +callback until the next available event.
8 +(See [Designing API’s for Asynchrony][Zalgo].)
9 +The `asap` function executes a task **as soon as possible** but not before it
10 +returns, waiting only for the completion of the current event and previously
11 +scheduled tasks.
12 +
13 +```javascript
14 +asap(function () {
15 + // ...
16 +});
17 +```
18 +
19 +[Zalgo]: http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony
20 +
21 +This CommonJS package provides an `asap` module that exports a function that
22 +executes a task function *as soon as possible*.
23 +
24 +ASAP strives to schedule events to occur before yielding for IO, reflow,
25 +or redrawing.
26 +Each event receives an independent stack, with only platform code in parent
27 +frames and the events run in the order they are scheduled.
28 +
29 +ASAP provides a fast event queue that will execute tasks until it is
30 +empty before yielding to the JavaScript engine's underlying event-loop.
31 +When a task gets added to a previously empty event queue, ASAP schedules a flush
32 +event, preferring for that event to occur before the JavaScript engine has an
33 +opportunity to perform IO tasks or rendering, thus making the first task and
34 +subsequent tasks semantically indistinguishable.
35 +ASAP uses a variety of techniques to preserve this invariant on different
36 +versions of browsers and Node.js.
37 +
38 +By design, ASAP prevents input events from being handled until the task
39 +queue is empty.
40 +If the process is busy enough, this may cause incoming connection requests to be
41 +dropped, and may cause existing connections to inform the sender to reduce the
42 +transmission rate or stall.
43 +ASAP allows this on the theory that, if there is enough work to do, there is no
44 +sense in looking for trouble.
45 +As a consequence, ASAP can interfere with smooth animation.
46 +If your task should be tied to the rendering loop, consider using
47 +`requestAnimationFrame` instead.
48 +A long sequence of tasks can also effect the long running script dialog.
49 +If this is a problem, you may be able to use ASAP’s cousin `setImmediate` to
50 +break long processes into shorter intervals and periodically allow the browser
51 +to breathe.
52 +`setImmediate` will yield for IO, reflow, and repaint events.
53 +It also returns a handler and can be canceled.
54 +For a `setImmediate` shim, consider [YuzuJS setImmediate][setImmediate].
55 +
56 +[setImmediate]: https://github.com/YuzuJS/setImmediate
57 +
58 +Take care.
59 +ASAP can sustain infinite recursive calls without warning.
60 +It will not halt from a stack overflow, and it will not consume unbounded
61 +memory.
62 +This is behaviorally equivalent to an infinite loop.
63 +Just as with infinite loops, you can monitor a Node.js process for this behavior
64 +with a heart-beat signal.
65 +As with infinite loops, a very small amount of caution goes a long way to
66 +avoiding problems.
67 +
68 +```javascript
69 +function loop() {
70 + asap(loop);
71 +}
72 +loop();
73 +```
74 +
75 +In browsers, if a task throws an exception, it will not interrupt the flushing
76 +of high-priority tasks.
77 +The exception will be postponed to a later, low-priority event to avoid
78 +slow-downs.
79 +In Node.js, if a task throws an exception, ASAP will resume flushing only if—and
80 +only after—the error is handled by `domain.on("error")` or
81 +`process.on("uncaughtException")`.
82 +
83 +## Raw ASAP
84 +
85 +Checking for exceptions comes at a cost.
86 +The package also provides an `asap/raw` module that exports the underlying
87 +implementation which is faster but stalls if a task throws an exception.
88 +This internal version of the ASAP function does not check for errors.
89 +If a task does throw an error, it will stall the event queue unless you manually
90 +call `rawAsap.requestFlush()` before throwing the error, or any time after.
91 +
92 +In Node.js, `asap/raw` also runs all tasks outside any domain.
93 +If you need a task to be bound to your domain, you will have to do it manually.
94 +
95 +```js
96 +if (process.domain) {
97 + task = process.domain.bind(task);
98 +}
99 +rawAsap(task);
100 +```
101 +
102 +## Tasks
103 +
104 +A task may be any object that implements `call()`.
105 +A function will suffice, but closures tend not to be reusable and can cause
106 +garbage collector churn.
107 +Both `asap` and `rawAsap` accept task objects to give you the option of
108 +recycling task objects or using higher callable object abstractions.
109 +See the `asap` source for an illustration.
110 +
111 +
112 +## Compatibility
113 +
114 +ASAP is tested on Node.js v0.10 and in a broad spectrum of web browsers.
115 +The following charts capture the browser test results for the most recent
116 +release.
117 +The first chart shows test results for ASAP running in the main window context.
118 +The second chart shows test results for ASAP running in a web worker context.
119 +Test results are inconclusive (grey) on browsers that do not support web
120 +workers.
121 +These data are captured automatically by [Continuous
122 +Integration][].
123 +
124 +[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md
125 +
126 +![Browser Compatibility](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-results-matrix.svg)
127 +
128 +![Compatibility in Web Workers](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-worker-results-matrix.svg)
129 +
130 +## Caveats
131 +
132 +When a task is added to an empty event queue, it is not always possible to
133 +guarantee that the task queue will begin flushing immediately after the current
134 +event.
135 +However, once the task queue begins flushing, it will not yield until the queue
136 +is empty, even if the queue grows while executing tasks.
137 +
138 +The following browsers allow the use of [DOM mutation observers][] to access
139 +the HTML [microtask queue][], and thus begin flushing ASAP's task queue
140 +immediately at the end of the current event loop turn, before any rendering or
141 +IO:
142 +
143 +[microtask queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#microtask-queue
144 +[DOM mutation observers]: http://dom.spec.whatwg.org/#mutation-observers
145 +
146 +- Android 4–4.3
147 +- Chrome 26–34
148 +- Firefox 14–29
149 +- Internet Explorer 11
150 +- iPad Safari 6–7.1
151 +- iPhone Safari 7–7.1
152 +- Safari 6–7
153 +
154 +In the absense of mutation observers, there are a few browsers, and situations
155 +like web workers in some of the above browsers, where [message channels][]
156 +would be a useful way to avoid falling back to timers.
157 +Message channels give direct access to the HTML [task queue][], so the ASAP
158 +task queue would flush after any already queued rendering and IO tasks, but
159 +without having the minimum delay imposed by timers.
160 +However, among these browsers, Internet Explorer 10 and Safari do not reliably
161 +dispatch messages, so they are not worth the trouble to implement.
162 +
163 +[message channels]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#message-channels
164 +[task queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task
165 +
166 +- Internet Explorer 10
167 +- Safair 5.0-1
168 +- Opera 11-12
169 +
170 +In the absense of mutation observers, these browsers and the following browsers
171 +all fall back to using `setTimeout` and `setInterval` to ensure that a `flush`
172 +occurs.
173 +The implementation uses both and cancels whatever handler loses the race, since
174 +`setTimeout` tends to occasionally skip tasks in unisolated circumstances.
175 +Timers generally delay the flushing of ASAP's task queue for four milliseconds.
176 +
177 +- Firefox 3–13
178 +- Internet Explorer 6–10
179 +- iPad Safari 4.3
180 +- Lynx 2.8.7
181 +
182 +
183 +## Heritage
184 +
185 +ASAP has been factored out of the [Q][] asynchronous promise library.
186 +It originally had a naïve implementation in terms of `setTimeout`, but
187 +[Malte Ubl][NonBlocking] provided an insight that `postMessage` might be
188 +useful for creating a high-priority, no-delay event dispatch hack.
189 +Since then, Internet Explorer proposed and implemented `setImmediate`.
190 +Robert Katić began contributing to Q by measuring the performance of
191 +the internal implementation of `asap`, paying particular attention to
192 +error recovery.
193 +Domenic, Robert, and Kris Kowal collectively settled on the current strategy of
194 +unrolling the high-priority event queue internally regardless of what strategy
195 +we used to dispatch the potentially lower-priority flush event.
196 +Domenic went on to make ASAP cooperate with Node.js domains.
197 +
198 +[Q]: https://github.com/kriskowal/q
199 +[NonBlocking]: http://www.nonblocking.io/2011/06/windownexttick.html
200 +
201 +For further reading, Nicholas Zakas provided a thorough article on [The
202 +Case for setImmediate][NCZ].
203 +
204 +[NCZ]: http://www.nczonline.net/blog/2013/07/09/the-case-for-setimmediate/
205 +
206 +Ember’s RSVP promise implementation later [adopted][RSVP ASAP] the name ASAP but
207 +further developed the implentation.
208 +Particularly, The `MessagePort` implementation was abandoned due to interaction
209 +[problems with Mobile Internet Explorer][IE Problems] in favor of an
210 +implementation backed on the newer and more reliable DOM `MutationObserver`
211 +interface.
212 +These changes were back-ported into this library.
213 +
214 +[IE Problems]: https://github.com/cujojs/when/issues/197
215 +[RSVP ASAP]: https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
216 +
217 +In addition, ASAP factored into `asap` and `asap/raw`, such that `asap` remained
218 +exception-safe, but `asap/raw` provided a tight kernel that could be used for
219 +tasks that guaranteed that they would not throw exceptions.
220 +This core is useful for promise implementations that capture thrown errors in
221 +rejected promises and do not need a second safety net.
222 +At the same time, the exception handling in `asap` was factored into separate
223 +implementations for Node.js and browsers, using the the [Browserify][Browser
224 +Config] `browser` property in `package.json` to instruct browser module loaders
225 +and bundlers, including [Browserify][], [Mr][], and [Mop][], to use the
226 +browser-only implementation.
227 +
228 +[Browser Config]: https://gist.github.com/defunctzombie/4339901
229 +[Browserify]: https://github.com/substack/node-browserify
230 +[Mr]: https://github.com/montagejs/mr
231 +[Mop]: https://github.com/montagejs/mop
232 +
233 +## License
234 +
235 +Copyright 2009-2014 by Contributors
236 +MIT License (enclosed)
237 +
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 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 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 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 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 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 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 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.