hyeyeon-sun

chat system - parsing data

Showing 1000 changed files with 755 additions and 3283 deletions

Too many changes to show.

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

1 +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 +
3 +# dependencies
4 +/node_modules
5 +/.pnp
6 +.pnp.js
7 +
8 +# testing
9 +/coverage
10 +
11 +# production
12 +/build
13 +
14 +# misc
15 +.DS_Store
16 +.env.local
17 +.env.development.local
18 +.env.test.local
19 +.env.production.local
20 +
21 +npm-debug.log*
22 +yarn-debug.log*
23 +yarn-error.log*
1 +{
2 + // Use IntelliSense to learn about possible attributes.
3 + // Hover to view descriptions of existing attributes.
4 + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 + "version": "0.2.0",
6 + "configurations": [
7 + {
8 + "name": "Python: Current File",
9 + "type": "python",
10 + "request": "launch",
11 + "program": "${file}",
12 + "console": "integratedTerminal"
13 + }
14 + ]
15 +}
...\ No newline at end of file ...\ No newline at end of file
1 +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 +
3 +## Available Scripts
4 +
5 +In the project directory, you can run:
6 +
7 +### `yarn start`
8 +
9 +Runs the app in the development mode.<br />
10 +Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 +
12 +The page will reload if you make edits.<br />
13 +You will also see any lint errors in the console.
14 +
15 +### `yarn test`
16 +
17 +Launches the test runner in the interactive watch mode.<br />
18 +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 +
20 +### `yarn build`
21 +
22 +Builds the app for production to the `build` folder.<br />
23 +It correctly bundles React in production mode and optimizes the build for the best performance.
24 +
25 +The build is minified and the filenames include the hashes.<br />
26 +Your app is ready to be deployed!
27 +
28 +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 +
30 +### `yarn eject`
31 +
32 +**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 +
34 +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 +
36 +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 +
38 +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 +
40 +## Learn More
41 +
42 +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 +
44 +To learn React, check out the [React documentation](https://reactjs.org/).
45 +
46 +### Code Splitting
47 +
48 +This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 +
50 +### Analyzing the Bundle Size
51 +
52 +This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 +
54 +### Making a Progressive Web App
55 +
56 +This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 +
58 +### Advanced Configuration
59 +
60 +This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 +
62 +### Deployment
63 +
64 +This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 +
66 +### `yarn build` fails to minify
67 +
68 +This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
1 +Stack trace:
2 +Frame Function Args
3 +00600000010 001800617BE (00180251890, 0018023DFD1, 00000000058, 000FFFFB770)
4 +00600000010 001800490FA (00000000000, 00100000000, 00000000000, 00000000001)
5 +00600000010 00180049132 (00000000000, 00000000000, 00000000058, 0018031E980)
6 +00600000010 0018006D9C9 (0000000000A, 000FFFFC940, 001800458BF, 00000000000)
7 +00600000010 0018006DB92 (00000000003, 000FFFFC940, 001800458BF, 000FFFFC940)
8 +00600000010 0018006EA4C (000FFFFC940, 001802405E5, 001800EAF57, 0000000000D)
9 +00600000010 001800596A6 (000FFFF0000, 00000000000, 00000000000, E2DE0F8BFFFFFFFF)
10 +00600000010 0018005A9C5 (00000000002, 0018031E290, 001800BE5F9, 00600040000)
11 +00600000010 0018005AE89 (001800C7664, 00000000000, 00000000000, 00000000000)
12 +000FFFFCCE0 0018005B149 (000FFFFCE00, 00000000000, 00000000030, 0000000002F)
13 +000FFFFCCE0 00180049877 (00000000000, 00000000000, 00000000000, 00000000000)
14 +000FFFFFFF0 001800482C6 (00000000000, 00000000000, 00000000000, 00000000000)
15 +000FFFFFFF0 00180048374 (00000000000, 00000000000, 00000000000, 00000000000)
16 +End of stack trace
1 +# User specific files
2 +.mypy_cache/
3 +*.csv
4 +*.txt
5 +*.npy
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +import tensorflow as tf
2 +import numpy as np
3 +import re
4 +from collections import Counter
5 +import sys
6 +import math
7 +from random import randint
8 +import pickle
9 +import os
10 +
11 +# This Word2Vec implementation is largely based on this paper
12 +# https://papers.nips.cc/paper/5021-distributed-representations-of-words-and-phrases-and-their-compositionality.pdf
13 +# It's a bit old, but Word2Vec is still SOTA and relatively simple, so I'm going with it
14 +
15 +# Check out Tensorflow's documentation which is pretty good for Word2Vec
16 +# https://www.tensorflow.org/tutorials/word2vec
17 +
18 +wordVecDimensions = 100
19 +batchSize = 128
20 +numNegativeSample = 64
21 +windowSize = 5
22 +numIterations = 100000
23 +
24 +# This function just takes in the conversation data and makes it
25 +# into one huge string, and then uses a Counter to identify words
26 +# and the number of occurences
27 +def processDataset(filename):
28 + openedFile = open(filename, 'r')
29 + allLines = openedFile.readlines()
30 + myStr = ""
31 + for line in allLines:
32 + myStr += line
33 + finalDict = Counter(myStr.split())
34 + return myStr, finalDict
35 +
36 +def createTrainingMatrices(dictionary, corpus):
37 + allUniqueWords = list(dictionary.keys())
38 + allWords = corpus.split()
39 + numTotalWords = len(allWords)
40 + xTrain=[]
41 + yTrain=[]
42 + for i in range(numTotalWords):
43 + if i % 100000 == 0:
44 + print 'Finished %d/%d total words' % (i, numTotalWords)
45 + wordsAfter = allWords[i + 1:i + windowSize + 1]
46 + wordsBefore = allWords[max(0, i - windowSize):i]
47 + wordsAdded = wordsAfter + wordsBefore
48 + for word in wordsAdded:
49 + xTrain.append(allUniqueWords.index(allWords[i]))
50 + yTrain.append(allUniqueWords.index(word))
51 + return xTrain, yTrain
52 +
53 +def getTrainingBatch():
54 + num = randint(0,numTrainingExamples - batchSize - 1)
55 + arr = xTrain[num:num + batchSize]
56 + labels = yTrain[num:num + batchSize]
57 + return arr, labels[:,np.newaxis]
58 +
59 +continueWord2Vec = True
60 +# Loading the data structures if they are present in the directory
61 +if (os.path.isfile('Word2VecXTrain.npy') and os.path.isfile('Word2VecYTrain.npy') and os.path.isfile('wordList.txt')):
62 + xTrain = np.load('Word2VecXTrain.npy')
63 + yTrain = np.load('Word2VecYTrain.npy')
64 + print 'Finished loading training matrices'
65 + with open("wordList.txt", "rb") as fp:
66 + wordList = pickle.load(fp)
67 + print 'Finished loading word list'
68 +
69 +else:
70 + fullCorpus, datasetDictionary = processDataset('conversationData.txt')
71 + print 'Finished parsing and cleaning dataset'
72 + wordList = list(datasetDictionary.keys())
73 + createOwnVectors = raw_input('Do you want to create your own vectors through Word2Vec (y/n)?')
74 + if (createOwnVectors == 'y'):
75 + xTrain, yTrain = createTrainingMatrices(datasetDictionary, fullCorpus)
76 + print 'Finished creating training matrices'
77 + np.save('Word2VecXTrain.npy', xTrain)
78 + np.save('Word2VecYTrain.npy', yTrain)
79 + else:
80 + continueWord2Vec = False
81 + with open("wordList.txt", "wb") as fp:
82 + pickle.dump(wordList, fp)
83 +
84 +# If you do not want to create your own word vectors and you'd just like to
85 +# have Tensorflow's seq2seq take care of that, then you don't need to run
86 +# anything below this line.
87 +if (continueWord2Vec == False):
88 + sys.exit()
89 +
90 +numTrainingExamples = len(xTrain)
91 +vocabSize = len(wordList)
92 +
93 +sess = tf.Session()
94 +embeddingMatrix = tf.Variable(tf.random_uniform([vocabSize, wordVecDimensions], -1.0, 1.0))
95 +nceWeights = tf.Variable(tf.truncated_normal([vocabSize, wordVecDimensions], stddev=1.0 / math.sqrt(wordVecDimensions)))
96 +nceBiases = tf.Variable(tf.zeros([vocabSize]))
97 +
98 +inputs = tf.placeholder(tf.int32, shape=[batchSize])
99 +outputs = tf.placeholder(tf.int32, shape=[batchSize, 1])
100 +
101 +embed = tf.nn.embedding_lookup(embeddingMatrix, inputs)
102 +
103 +loss = tf.reduce_mean(
104 + tf.nn.nce_loss(weights=nceWeights,
105 + biases=nceBiases,
106 + labels=outputs,
107 + inputs=embed,
108 + num_sampled=numNegativeSample,
109 + num_classes=vocabSize))
110 +
111 +optimizer = tf.train.GradientDescentOptimizer(learning_rate=1.0).minimize(loss)
112 +
113 +sess.run(tf.global_variables_initializer())
114 +for i in range(numIterations):
115 + trainInputs, trainLabels = getTrainingBatch()
116 + _, curLoss = sess.run([optimizer, loss], feed_dict={inputs: trainInputs, outputs: trainLabels})
117 + if (i % 10000 == 0):
118 + print ('Current loss is:', curLoss)
119 +print 'Saving the word embedding matrix'
120 +embedMatrix = embeddingMatrix.eval(session=sess)
121 +np.save('embeddingMatrix.npy', embedMatrix)
This diff is collapsed. Click to expand it.
1 +'use strict'
2 +
3 +const express = require('express')
4 +const bodyParser = require('body-parser')
5 +const request = require('request')
6 +const app = express()
7 +
8 +app.set('port', (process.env.PORT || 5000))
9 +
10 +// Process application/x-www-form-urlencoded
11 +app.use(bodyParser.urlencoded({extended: false}))
12 +
13 +// Process application/json
14 +app.use(bodyParser.json())
15 +
16 +// Index route
17 +app.get('/', function (req, res) {
18 + res.send('Hello world, I am a chat bot')
19 +})
20 +
21 +// for Facebook verification
22 +app.get('/webhook/', function (req, res) {
23 + if (req.query['hub.verify_token'] === 'my_voice_is_my_password_verify_me') {
24 + res.send(req.query['hub.challenge'])
25 + }
26 + res.send('Error, wrong token')
27 +})
28 +
29 +const myID = 1960455644201170;
30 +
31 +app.post('/webhook/', function (req, res) {
32 + let messaging_events = req.body.entry[0].messaging
33 + for (let i = 0; i < messaging_events.length; i++) {
34 + let event = req.body.entry[0].messaging[i]
35 + let sender = event.sender.id
36 +
37 + if (event.message && event.message.text && sender != myID) {
38 + let text = event.message.text
39 + request({
40 + url: 'https://flask-server-seq2seq-chatbot.herokuapp.com/prediction',
41 + method: 'POST',
42 + body: {message: text.substring(0, 200)},
43 + headers: {'User-Agent': 'request'},
44 + json: true
45 + }, function(error, response, body) {
46 + sendTextMessage(sender, response.body)
47 + })
48 + }
49 + }
50 + res.sendStatus(200)
51 +})
52 +
53 +const token = process.env.FB_PAGE_ACCESS_TOKEN
54 +
55 +function sendTextMessage(sender, text) {
56 + let messageData = { text:text }
57 + request({
58 + url: 'https://graph.facebook.com/v2.6/me/messages',
59 + qs: {access_token:token},
60 + method: 'POST',
61 + json: {
62 + recipient: {id:sender},
63 + message: messageData,
64 + }
65 + }, function(error, response, body) {
66 + if (error) {
67 + console.log('Error sending messages: ', error)
68 + } else if (response.body.error) {
69 + console.log('Error: ', response.body.error)
70 + }
71 + })
72 +}
73 +
74 +// Spin up the server
75 +app.listen(app.get('port'), function() {
76 + console.log('running on port', app.get('port'))
77 +})
This diff is collapsed. Click to expand it.
1 +{
2 + "name": "chatbotserver",
3 + "version": "1.0.0",
4 + "description": "",
5 + "main": "index.js",
6 + "scripts": {
7 + "test": "echo \"Error: no test specified\" && exit 1"
8 + },
9 + "author": "",
10 + "license": "ISC",
11 + "dependencies": {
12 + "body-parser": "^1.17.2",
13 + "express": "^4.15.3",
14 + "request": "^2.81.0"
15 + }
16 +}
1 +456 78
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "make_your_own_chatbot",
3 + "version": "0.1.0",
4 + "private": true,
5 + "dependencies": {
6 + "@testing-library/jest-dom": "^4.2.4",
7 + "@testing-library/react": "^9.3.2",
8 + "@testing-library/user-event": "^7.1.2",
9 + "react": "^16.13.1",
10 + "react-dom": "^16.13.1",
11 + "react-scripts": "3.4.1"
12 + },
13 + "scripts": {
14 + "start": "react-scripts start",
15 + "build": "react-scripts build",
16 + "test": "react-scripts test",
17 + "eject": "react-scripts eject"
18 + },
19 + "eslintConfig": {
20 + "extends": "react-app"
21 + },
22 + "browserslist": {
23 + "production": [
24 + ">0.2%",
25 + "not dead",
26 + "not op_mini all"
27 + ],
28 + "development": [
29 + "last 1 chrome version",
30 + "last 1 firefox version",
31 + "last 1 safari version"
32 + ]
33 + }
34 +}
No preview for this file type
1 +<!DOCTYPE html>
2 +<html lang="en">
3 + <head>
4 + <meta charset="utf-8" />
5 + <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6 + <meta name="viewport" content="width=device-width, initial-scale=1" />
7 + <meta name="theme-color" content="#000000" />
8 + <meta
9 + name="description"
10 + content="Web site created using create-react-app"
11 + />
12 + <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13 + <!--
14 + manifest.json provides metadata used when your web app is installed on a
15 + user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16 + -->
17 + <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18 + <!--
19 + Notice the use of %PUBLIC_URL% in the tags above.
20 + It will be replaced with the URL of the `public` folder during the build.
21 + Only files inside the `public` folder can be referenced from the HTML.
22 +
23 + Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24 + work correctly both with client-side routing and a non-root public URL.
25 + Learn how to configure a non-root public URL by running `npm run build`.
26 + -->
27 + <title>React App</title>
28 + </head>
29 + <body>
30 + <noscript>You need to enable JavaScript to run this app.</noscript>
31 + <div id="root"></div>
32 + <!--
33 + This HTML file is a template.
34 + If you open it directly in the browser, you will see an empty page.
35 +
36 + You can add webfonts, meta tags, or analytics to this file.
37 + The build step will place the bundled scripts into the <body> tag.
38 +
39 + To begin the development, run `npm start` or `yarn start`.
40 + To create a production bundle, use `npm run build` or `yarn build`.
41 + -->
42 + </body>
43 +</html>
1 +{
2 + "short_name": "React App",
3 + "name": "Create React App Sample",
4 + "icons": [
5 + {
6 + "src": "favicon.ico",
7 + "sizes": "64x64 32x32 24x24 16x16",
8 + "type": "image/x-icon"
9 + },
10 + {
11 + "src": "logo192.png",
12 + "type": "image/png",
13 + "sizes": "192x192"
14 + },
15 + {
16 + "src": "logo512.png",
17 + "type": "image/png",
18 + "sizes": "512x512"
19 + }
20 + ],
21 + "start_url": ".",
22 + "display": "standalone",
23 + "theme_color": "#000000",
24 + "background_color": "#ffffff"
25 +}
1 +# https://www.robotstxt.org/robotstxt.html
2 +User-agent: *
3 +Disallow:
1 +.App {
2 + text-align: center;
3 +}
4 +
5 +.App-logo {
6 + height: 40vmin;
7 + pointer-events: none;
8 +}
9 +
10 +@media (prefers-reduced-motion: no-preference) {
11 + .App-logo {
12 + animation: App-logo-spin infinite 20s linear;
13 + }
14 +}
15 +
16 +.App-header {
17 + background-color: #282c34;
18 + min-height: 100vh;
19 + display: flex;
20 + flex-direction: column;
21 + align-items: center;
22 + justify-content: center;
23 + font-size: calc(10px + 2vmin);
24 + color: white;
25 +}
26 +
27 +.App-link {
28 + color: #61dafb;
29 +}
30 +
31 +@keyframes App-logo-spin {
32 + from {
33 + transform: rotate(0deg);
34 + }
35 + to {
36 + transform: rotate(360deg);
37 + }
38 +}
1 +import React from 'react';
2 +import './App.css';
3 +
4 +class App extends React.Component{
5 + render() {
6 + return (
7 + <div>
8 + let's start
9 + </div>
10 + )
11 + }
12 +}
13 +
14 +
15 +export default App;
1 +import React from 'react';
2 +import { render } from '@testing-library/react';
3 +import App from './App';
4 +
5 +test('renders learn react link', () => {
6 + const { getByText } = render(<App />);
7 + const linkElement = getByText(/learn react/i);
8 + expect(linkElement).toBeInTheDocument();
9 +});
1 +import react from 'react';
2 +
3 +class UploadChat extends React.Component {
4 +
5 + constructor(props) {
6 + super(props);
7 + this.state = {
8 + file: null,
9 + botName: '',
10 + fileName: ''
11 + }
12 + }
13 +
14 + addChat = () =>{
15 + const url = '/api/chats';
16 + const formData = new FormData();
17 + formData.append('chat', this.state.file);
18 + formData.append('name', this.state.botname);
19 + const config = {
20 + headers : {
21 + 'content-type': 'multipart/form-data'
22 + }
23 + }
24 + }
25 +
26 +
27 + render(){
28 + return(
29 + <form onSubmit={this.handleFormSubmit}>
30 + <h1>채팅 내역 올리기</h1>
31 + 채팅 내역: <input type="file" name="file" file={this.state.file} value = {this.state.fileName} onChange={this.handleFileChange}/><br/>
32 + 챗봇 이름 : <input type="text" name="userName" value={this.state.userName} onChange={this.handleValueChange}/><br/>
33 + <button type="submit"> 챗봇 생성하기 </button>
34 + </form>
35 + )
36 + }
37 +}
38 +
39 +export default UploadChat;
...\ No newline at end of file ...\ No newline at end of file
1 +body {
2 + margin: 0;
3 + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 + sans-serif;
6 + -webkit-font-smoothing: antialiased;
7 + -moz-osx-font-smoothing: grayscale;
8 +}
9 +
10 +code {
11 + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 + monospace;
13 +}
1 +import React from 'react';
2 +import ReactDOM from 'react-dom';
3 +import './index.css';
4 +import App from './App';
5 +import * as serviceWorker from './serviceWorker';
6 +
7 +ReactDOM.render(
8 + <React.StrictMode>
9 + <App />
10 + </React.StrictMode>,
11 + document.getElementById('root')
12 +);
13 +
14 +// If you want your app to work offline and load faster, you can change
15 +// unregister() to register() below. Note this comes with some pitfalls.
16 +// Learn more about service workers: https://bit.ly/CRA-PWA
17 +serviceWorker.unregister();
1 +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
2 + <g fill="#61DAFB">
3 + <path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
4 + <circle cx="420.9" cy="296.5" r="45.7"/>
5 + <path d="M520.5 78.1z"/>
6 + </g>
7 +</svg>
1 +// This optional code is used to register a service worker.
2 +// register() is not called by default.
3 +
4 +// This lets the app load faster on subsequent visits in production, and gives
5 +// it offline capabilities. However, it also means that developers (and users)
6 +// will only see deployed updates on subsequent visits to a page, after all the
7 +// existing tabs open on the page have been closed, since previously cached
8 +// resources are updated in the background.
9 +
10 +// To learn more about the benefits of this model and instructions on how to
11 +// opt-in, read https://bit.ly/CRA-PWA
12 +
13 +const isLocalhost = Boolean(
14 + window.location.hostname === 'localhost' ||
15 + // [::1] is the IPv6 localhost address.
16 + window.location.hostname === '[::1]' ||
17 + // 127.0.0.0/8 are considered localhost for IPv4.
18 + window.location.hostname.match(
19 + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 + )
21 +);
22 +
23 +export function register(config) {
24 + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 + // The URL constructor is available in all browsers that support SW.
26 + const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 + if (publicUrl.origin !== window.location.origin) {
28 + // Our service worker won't work if PUBLIC_URL is on a different origin
29 + // from what our page is served on. This might happen if a CDN is used to
30 + // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 + return;
32 + }
33 +
34 + window.addEventListener('load', () => {
35 + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 +
37 + if (isLocalhost) {
38 + // This is running on localhost. Let's check if a service worker still exists or not.
39 + checkValidServiceWorker(swUrl, config);
40 +
41 + // Add some additional logging to localhost, pointing developers to the
42 + // service worker/PWA documentation.
43 + navigator.serviceWorker.ready.then(() => {
44 + console.log(
45 + 'This web app is being served cache-first by a service ' +
46 + 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 + );
48 + });
49 + } else {
50 + // Is not localhost. Just register service worker
51 + registerValidSW(swUrl, config);
52 + }
53 + });
54 + }
55 +}
56 +
57 +function registerValidSW(swUrl, config) {
58 + navigator.serviceWorker
59 + .register(swUrl)
60 + .then(registration => {
61 + registration.onupdatefound = () => {
62 + const installingWorker = registration.installing;
63 + if (installingWorker == null) {
64 + return;
65 + }
66 + installingWorker.onstatechange = () => {
67 + if (installingWorker.state === 'installed') {
68 + if (navigator.serviceWorker.controller) {
69 + // At this point, the updated precached content has been fetched,
70 + // but the previous service worker will still serve the older
71 + // content until all client tabs are closed.
72 + console.log(
73 + 'New content is available and will be used when all ' +
74 + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 + );
76 +
77 + // Execute callback
78 + if (config && config.onUpdate) {
79 + config.onUpdate(registration);
80 + }
81 + } else {
82 + // At this point, everything has been precached.
83 + // It's the perfect time to display a
84 + // "Content is cached for offline use." message.
85 + console.log('Content is cached for offline use.');
86 +
87 + // Execute callback
88 + if (config && config.onSuccess) {
89 + config.onSuccess(registration);
90 + }
91 + }
92 + }
93 + };
94 + };
95 + })
96 + .catch(error => {
97 + console.error('Error during service worker registration:', error);
98 + });
99 +}
100 +
101 +function checkValidServiceWorker(swUrl, config) {
102 + // Check if the service worker can be found. If it can't reload the page.
103 + fetch(swUrl, {
104 + headers: { 'Service-Worker': 'script' },
105 + })
106 + .then(response => {
107 + // Ensure service worker exists, and that we really are getting a JS file.
108 + const contentType = response.headers.get('content-type');
109 + if (
110 + response.status === 404 ||
111 + (contentType != null && contentType.indexOf('javascript') === -1)
112 + ) {
113 + // No service worker found. Probably a different app. Reload the page.
114 + navigator.serviceWorker.ready.then(registration => {
115 + registration.unregister().then(() => {
116 + window.location.reload();
117 + });
118 + });
119 + } else {
120 + // Service worker found. Proceed as normal.
121 + registerValidSW(swUrl, config);
122 + }
123 + })
124 + .catch(() => {
125 + console.log(
126 + 'No internet connection found. App is running in offline mode.'
127 + );
128 + });
129 +}
130 +
131 +export function unregister() {
132 + if ('serviceWorker' in navigator) {
133 + navigator.serviceWorker.ready
134 + .then(registration => {
135 + registration.unregister();
136 + })
137 + .catch(error => {
138 + console.error(error.message);
139 + });
140 + }
141 +}
1 +// jest-dom adds custom jest matchers for asserting on DOM nodes.
2 +// allows you to do things like:
3 +// expect(element).toHaveTextContent(/react/i)
4 +// learn more: https://github.com/testing-library/jest-dom
5 +import '@testing-library/jest-dom/extend-expect';
This diff could not be displayed because it is too large.
1 # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 1 # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 2
3 +# database
4 +/database.json
5 +
3 # dependencies 6 # dependencies
4 /node_modules 7 /node_modules
5 /.pnp 8 /.pnp
......
This diff is collapsed. Click to expand it.
1 +const fs = require('fs');
1 const express = require('express'); 2 const express = require('express');
2 const bodyParser = require('body-parser'); 3 const bodyParser = require('body-parser');
3 const app = express(); 4 const app = express();
...@@ -6,35 +7,27 @@ const port = process.env.PORT || 5000; ...@@ -6,35 +7,27 @@ const port = process.env.PORT || 5000;
6 app.use(bodyParser.json()); 7 app.use(bodyParser.json());
7 app.use(bodyParser.urlencoded({ exrended : true })); 8 app.use(bodyParser.urlencoded({ exrended : true }));
8 9
10 +const data = fs.readFileSync('./database.json');
11 +const conf = JSON.parse(data);
12 +const mysql = require('mysql');
13 +
14 +const connection = mysql.createConnection({
15 + host: conf.host,
16 + user: conf.user,
17 + password: conf.password,
18 + port: conf.port,
19 + database: conf.databse
20 +});
21 +connection.connect();
22 +
23 +
9 app.get('/api/customers', (req, res) => { 24 app.get('/api/customers', (req, res) => {
10 - res.send([ 25 + connection.query(
11 - { 26 + "SELECT * FROM CUSTOMER",
12 - 'id': 1, 27 + (err,rows,fields) => {
13 - 'image': 'https://placeimg.com/64/64/any', 28 + res.send(rows);
14 - 'name': '이혜연',
15 - 'birthday': '000416',
16 - 'gender': '여자',
17 - 'job': '대학생'
18 - },
19 - {
20 - 'id': 2,
21 - 'image': 'https://placeimg.com/64/64/2',
22 - 'name': '김다은',
23 - 'birthday': '000101',
24 - 'gender': '여자',
25 - 'job': '재수생'
26 - },
27 - {
28 - 'id': 3,
29 - 'image': 'https://placeimg.com/64/64/3',
30 - 'name': '김석희',
31 - 'birthday': '900103',
32 - 'gender': '남자',
33 - 'job': '회사원'
34 } 29 }
35 - 30 + )
36 - ])
37 -
38 }) 31 })
39 32
40 app.listen(port, () => console.log(`Listening on port ${port}`)); 33 app.listen(port, () => console.log(`Listening on port ${port}`));
...\ 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/../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/../babylon/bin/babylon.js" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../babylon/bin/babylon.js" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\babylon\bin\babylon.js" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\babylon\bin\babylon.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/../mime/cli.js" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../mime/cli.js" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\mime\cli.js" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\mime\cli.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/../mkdirp/bin/cmd.js" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../mkdirp/bin/cmd.js" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\mkdirp\bin\cmd.js" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\mkdirp\bin\cmd.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 -#!/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/../uuid/bin/uuid" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../uuid/bin/uuid" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\uuid\bin\uuid" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\uuid\bin\uuid" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 - MIT License
2 -
3 - Copyright (c) Microsoft Corporation. All rights reserved.
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 all
13 - 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 THE
21 - SOFTWARE
1 -# Installation
2 -> `npm install --save @types/babel-types`
3 -
4 -# Summary
5 -This package contains type definitions for babel-types ( https://github.com/babel/babel/tree/master/packages/babel-types ).
6 -
7 -# Details
8 -Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel-types
9 -
10 -Additional Details
11 - * Last updated: Wed, 24 Apr 2019 17:31:13 GMT
12 - * Dependencies: none
13 - * Global values: none
14 -
15 -# Credits
16 -These definitions were written by Troy Gerwien <https://github.com/yortus>, Sam Baxter <https://github.com/baxtersa>, Marvin Hagemeister <https://github.com/marvinhagemeister>, Boris Cherny <https://github.com/bcherny>.
This diff could not be displayed because it is too large.
1 -{
2 - "_from": "@types/babel-types@^7.0.0",
3 - "_id": "@types/babel-types@7.0.7",
4 - "_inBundle": false,
5 - "_integrity": "sha512-dBtBbrc+qTHy1WdfHYjBwRln4+LWqASWakLHsWHR2NWHIFkv4W3O070IGoGLEBrJBvct3r0L1BUPuvURi7kYUQ==",
6 - "_location": "/@types/babel-types",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@types/babel-types@^7.0.0",
12 - "name": "@types/babel-types",
13 - "escapedName": "@types%2fbabel-types",
14 - "scope": "@types",
15 - "rawSpec": "^7.0.0",
16 - "saveSpec": null,
17 - "fetchSpec": "^7.0.0"
18 - },
19 - "_requiredBy": [
20 - "/@types/babylon",
21 - "/constantinople"
22 - ],
23 - "_resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.7.tgz",
24 - "_shasum": "667eb1640e8039436028055737d2b9986ee336e3",
25 - "_spec": "@types/babel-types@^7.0.0",
26 - "_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\constantinople",
27 - "bugs": {
28 - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
29 - },
30 - "bundleDependencies": false,
31 - "contributors": [
32 - {
33 - "name": "Troy Gerwien",
34 - "url": "https://github.com/yortus"
35 - },
36 - {
37 - "name": "Sam Baxter",
38 - "url": "https://github.com/baxtersa"
39 - },
40 - {
41 - "name": "Marvin Hagemeister",
42 - "url": "https://github.com/marvinhagemeister"
43 - },
44 - {
45 - "name": "Boris Cherny",
46 - "url": "https://github.com/bcherny"
47 - }
48 - ],
49 - "dependencies": {},
50 - "deprecated": false,
51 - "description": "TypeScript definitions for babel-types",
52 - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
53 - "license": "MIT",
54 - "main": "",
55 - "name": "@types/babel-types",
56 - "repository": {
57 - "type": "git",
58 - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
59 - "directory": "types/babel-types"
60 - },
61 - "scripts": {},
62 - "typeScriptVersion": "2.8",
63 - "types": "index",
64 - "typesPublisherContentHash": "c122ea7d3e140cb66493cf81db0d08d0d35d723c5a9fd0be9b29e7761609f366",
65 - "version": "7.0.7"
66 -}
1 - MIT License
2 -
3 - Copyright (c) Microsoft Corporation. All rights reserved.
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 all
13 - 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 THE
21 - SOFTWARE
1 -# Installation
2 -> `npm install --save @types/babylon`
3 -
4 -# Summary
5 -This package contains type definitions for babylon ( https://github.com/babel/babylon ).
6 -
7 -# Details
8 -Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babylon
9 -
10 -Additional Details
11 - * Last updated: Wed, 13 Feb 2019 16:16:46 GMT
12 - * Dependencies: @types/babel-types
13 - * Global values: none
14 -
15 -# Credits
16 -These definitions were written by Troy Gerwien <https://github.com/yortus>, Marvin Hagemeister <https://github.com/marvinhagemeister>.
1 -// Type definitions for babylon 6.16
2 -// Project: https://github.com/babel/babylon, https://babeljs.io
3 -// Definitions by: Troy Gerwien <https://github.com/yortus>
4 -// Marvin Hagemeister <https://github.com/marvinhagemeister>
5 -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6 -// TypeScript Version: 2.8
7 -
8 -import { File, Expression } from 'babel-types';
9 -
10 -export function parse(code: string, opts?: BabylonOptions): File;
11 -
12 -export function parseExpression(input: string, options?: BabylonOptions): Expression;
13 -
14 -export interface BabylonOptions {
15 - /**
16 - * By default, import and export declarations can only appear at a program's top level.
17 - * Setting this option to true allows them anywhere where a statement is allowed.
18 - */
19 - allowImportExportEverywhere?: boolean;
20 -
21 - /**
22 - * By default, a return statement at the top level raises an error. Set this to true to accept such code.
23 - */
24 - allowReturnOutsideFunction?: boolean;
25 -
26 - allowSuperOutsideMethod?: boolean;
27 -
28 - /**
29 - * Indicate the mode the code should be parsed in. Can be either "script" or "module".
30 - */
31 - sourceType?: 'script' | 'module';
32 -
33 - /**
34 - * Correlate output AST nodes with their source filename. Useful when
35 - * generating code and source maps from the ASTs of multiple input files.
36 - */
37 - sourceFilename?: string;
38 -
39 - /**
40 - * Array containing the plugins that you want to enable.
41 - */
42 - plugins?: PluginName[];
43 -}
44 -
45 -export type PluginName =
46 - 'estree' |
47 - 'jsx' |
48 - 'flow' |
49 - 'typescript' |
50 - 'classConstructorCall' |
51 - 'doExpressions' |
52 - 'objectRestSpread' |
53 - 'decorators' |
54 - 'classProperties' |
55 - 'exportExtensions' |
56 - 'asyncGenerators' |
57 - 'functionBind' |
58 - 'functionSent' |
59 - 'dynamicImport';
1 -{
2 - "_from": "@types/babylon@^6.16.2",
3 - "_id": "@types/babylon@6.16.5",
4 - "_inBundle": false,
5 - "_integrity": "sha512-xH2e58elpj1X4ynnKp9qSnWlsRTIs6n3tgLGNfwAGHwePw0mulHQllV34n0T25uYSu1k0hRKkWXF890B1yS47w==",
6 - "_location": "/@types/babylon",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@types/babylon@^6.16.2",
12 - "name": "@types/babylon",
13 - "escapedName": "@types%2fbabylon",
14 - "scope": "@types",
15 - "rawSpec": "^6.16.2",
16 - "saveSpec": null,
17 - "fetchSpec": "^6.16.2"
18 - },
19 - "_requiredBy": [
20 - "/constantinople"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/@types/babylon/-/babylon-6.16.5.tgz",
23 - "_shasum": "1c5641db69eb8cdf378edd25b4be7754beeb48b4",
24 - "_spec": "@types/babylon@^6.16.2",
25 - "_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\constantinople",
26 - "bugs": {
27 - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28 - },
29 - "bundleDependencies": false,
30 - "contributors": [
31 - {
32 - "name": "Troy Gerwien",
33 - "url": "https://github.com/yortus"
34 - },
35 - {
36 - "name": "Marvin Hagemeister",
37 - "url": "https://github.com/marvinhagemeister"
38 - }
39 - ],
40 - "dependencies": {
41 - "@types/babel-types": "*"
42 - },
43 - "deprecated": false,
44 - "description": "TypeScript definitions for babylon",
45 - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
46 - "license": "MIT",
47 - "main": "",
48 - "name": "@types/babylon",
49 - "repository": {
50 - "type": "git",
51 - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
52 - },
53 - "scripts": {},
54 - "typeScriptVersion": "2.8",
55 - "types": "index",
56 - "typesPublisherContentHash": "d6861e06508c0c54a6a46d7b72e96db7907de3621ac44aab8a3e647b8431cddd",
57 - "version": "6.16.5"
58 -}
1 -1.3.7 / 2019-04-29
2 -==================
3 -
4 - * deps: negotiator@0.6.2
5 - - Fix sorting charset, encoding, and language with extra parameters
6 -
7 -1.3.6 / 2019-04-28
8 -==================
9 -
10 - * deps: mime-types@~2.1.24
11 - - deps: mime-db@~1.40.0
12 -
13 -1.3.5 / 2018-02-28
14 -==================
15 -
16 - * deps: mime-types@~2.1.18
17 - - deps: mime-db@~1.33.0
18 -
19 -1.3.4 / 2017-08-22
20 -==================
21 -
22 - * deps: mime-types@~2.1.16
23 - - deps: mime-db@~1.29.0
24 -
25 -1.3.3 / 2016-05-02
26 -==================
27 -
28 - * deps: mime-types@~2.1.11
29 - - deps: mime-db@~1.23.0
30 - * deps: negotiator@0.6.1
31 - - perf: improve `Accept` parsing speed
32 - - perf: improve `Accept-Charset` parsing speed
33 - - perf: improve `Accept-Encoding` parsing speed
34 - - perf: improve `Accept-Language` parsing speed
35 -
36 -1.3.2 / 2016-03-08
37 -==================
38 -
39 - * deps: mime-types@~2.1.10
40 - - Fix extension of `application/dash+xml`
41 - - Update primary extension for `audio/mp4`
42 - - deps: mime-db@~1.22.0
43 -
44 -1.3.1 / 2016-01-19
45 -==================
46 -
47 - * deps: mime-types@~2.1.9
48 - - deps: mime-db@~1.21.0
49 -
50 -1.3.0 / 2015-09-29
51 -==================
52 -
53 - * deps: mime-types@~2.1.7
54 - - deps: mime-db@~1.19.0
55 - * deps: negotiator@0.6.0
56 - - Fix including type extensions in parameters in `Accept` parsing
57 - - Fix parsing `Accept` parameters with quoted equals
58 - - Fix parsing `Accept` parameters with quoted semicolons
59 - - Lazy-load modules from main entry point
60 - - perf: delay type concatenation until needed
61 - - perf: enable strict mode
62 - - perf: hoist regular expressions
63 - - perf: remove closures getting spec properties
64 - - perf: remove a closure from media type parsing
65 - - perf: remove property delete from media type parsing
66 -
67 -1.2.13 / 2015-09-06
68 -===================
69 -
70 - * deps: mime-types@~2.1.6
71 - - deps: mime-db@~1.18.0
72 -
73 -1.2.12 / 2015-07-30
74 -===================
75 -
76 - * deps: mime-types@~2.1.4
77 - - deps: mime-db@~1.16.0
78 -
79 -1.2.11 / 2015-07-16
80 -===================
81 -
82 - * deps: mime-types@~2.1.3
83 - - deps: mime-db@~1.15.0
84 -
85 -1.2.10 / 2015-07-01
86 -===================
87 -
88 - * deps: mime-types@~2.1.2
89 - - deps: mime-db@~1.14.0
90 -
91 -1.2.9 / 2015-06-08
92 -==================
93 -
94 - * deps: mime-types@~2.1.1
95 - - perf: fix deopt during mapping
96 -
97 -1.2.8 / 2015-06-07
98 -==================
99 -
100 - * deps: mime-types@~2.1.0
101 - - deps: mime-db@~1.13.0
102 - * perf: avoid argument reassignment & argument slice
103 - * perf: avoid negotiator recursive construction
104 - * perf: enable strict mode
105 - * perf: remove unnecessary bitwise operator
106 -
107 -1.2.7 / 2015-05-10
108 -==================
109 -
110 - * deps: negotiator@0.5.3
111 - - Fix media type parameter matching to be case-insensitive
112 -
113 -1.2.6 / 2015-05-07
114 -==================
115 -
116 - * deps: mime-types@~2.0.11
117 - - deps: mime-db@~1.9.1
118 - * deps: negotiator@0.5.2
119 - - Fix comparing media types with quoted values
120 - - Fix splitting media types with quoted commas
121 -
122 -1.2.5 / 2015-03-13
123 -==================
124 -
125 - * deps: mime-types@~2.0.10
126 - - deps: mime-db@~1.8.0
127 -
128 -1.2.4 / 2015-02-14
129 -==================
130 -
131 - * Support Node.js 0.6
132 - * deps: mime-types@~2.0.9
133 - - deps: mime-db@~1.7.0
134 - * deps: negotiator@0.5.1
135 - - Fix preference sorting to be stable for long acceptable lists
136 -
137 -1.2.3 / 2015-01-31
138 -==================
139 -
140 - * deps: mime-types@~2.0.8
141 - - deps: mime-db@~1.6.0
142 -
143 -1.2.2 / 2014-12-30
144 -==================
145 -
146 - * deps: mime-types@~2.0.7
147 - - deps: mime-db@~1.5.0
148 -
149 -1.2.1 / 2014-12-30
150 -==================
151 -
152 - * deps: mime-types@~2.0.5
153 - - deps: mime-db@~1.3.1
154 -
155 -1.2.0 / 2014-12-19
156 -==================
157 -
158 - * deps: negotiator@0.5.0
159 - - Fix list return order when large accepted list
160 - - Fix missing identity encoding when q=0 exists
161 - - Remove dynamic building of Negotiator class
162 -
163 -1.1.4 / 2014-12-10
164 -==================
165 -
166 - * deps: mime-types@~2.0.4
167 - - deps: mime-db@~1.3.0
168 -
169 -1.1.3 / 2014-11-09
170 -==================
171 -
172 - * deps: mime-types@~2.0.3
173 - - deps: mime-db@~1.2.0
174 -
175 -1.1.2 / 2014-10-14
176 -==================
177 -
178 - * deps: negotiator@0.4.9
179 - - Fix error when media type has invalid parameter
180 -
181 -1.1.1 / 2014-09-28
182 -==================
183 -
184 - * deps: mime-types@~2.0.2
185 - - deps: mime-db@~1.1.0
186 - * deps: negotiator@0.4.8
187 - - Fix all negotiations to be case-insensitive
188 - - Stable sort preferences of same quality according to client order
189 -
190 -1.1.0 / 2014-09-02
191 -==================
192 -
193 - * update `mime-types`
194 -
195 -1.0.7 / 2014-07-04
196 -==================
197 -
198 - * Fix wrong type returned from `type` when match after unknown extension
199 -
200 -1.0.6 / 2014-06-24
201 -==================
202 -
203 - * deps: negotiator@0.4.7
204 -
205 -1.0.5 / 2014-06-20
206 -==================
207 -
208 - * fix crash when unknown extension given
209 -
210 -1.0.4 / 2014-06-19
211 -==================
212 -
213 - * use `mime-types`
214 -
215 -1.0.3 / 2014-06-11
216 -==================
217 -
218 - * deps: negotiator@0.4.6
219 - - Order by specificity when quality is the same
220 -
221 -1.0.2 / 2014-05-29
222 -==================
223 -
224 - * Fix interpretation when header not in request
225 - * deps: pin negotiator@0.4.5
226 -
227 -1.0.1 / 2014-01-18
228 -==================
229 -
230 - * Identity encoding isn't always acceptable
231 - * deps: negotiator@~0.4.0
232 -
233 -1.0.0 / 2013-12-27
234 -==================
235 -
236 - * Genesis
1 -(The MIT License)
2 -
3 -Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 -Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 -
6 -Permission is hereby granted, free of charge, to any person obtaining
7 -a copy of this software and associated documentation files (the
8 -'Software'), to deal in the Software without restriction, including
9 -without limitation the rights to use, copy, modify, merge, publish,
10 -distribute, sublicense, and/or sell copies of the Software, and to
11 -permit persons to whom the Software is furnished to do so, subject to
12 -the following conditions:
13 -
14 -The above copyright notice and this permission notice shall be
15 -included in all copies or substantial portions of the Software.
16 -
17 -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# accepts
2 -
3 -[![NPM Version][npm-version-image]][npm-url]
4 -[![NPM Downloads][npm-downloads-image]][npm-url]
5 -[![Node.js Version][node-version-image]][node-version-url]
6 -[![Build Status][travis-image]][travis-url]
7 -[![Test Coverage][coveralls-image]][coveralls-url]
8 -
9 -Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 -Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 -
12 -In addition to negotiator, it allows:
13 -
14 -- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 - as well as `('text/html', 'application/json')`.
16 -- Allows type shorthands such as `json`.
17 -- Returns `false` when no types match
18 -- Treats non-existent headers as `*`
19 -
20 -## Installation
21 -
22 -This is a [Node.js](https://nodejs.org/en/) module available through the
23 -[npm registry](https://www.npmjs.com/). Installation is done using the
24 -[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 -
26 -```sh
27 -$ npm install accepts
28 -```
29 -
30 -## API
31 -
32 -<!-- eslint-disable no-unused-vars -->
33 -
34 -```js
35 -var accepts = require('accepts')
36 -```
37 -
38 -### accepts(req)
39 -
40 -Create a new `Accepts` object for the given `req`.
41 -
42 -#### .charset(charsets)
43 -
44 -Return the first accepted charset. If nothing in `charsets` is accepted,
45 -then `false` is returned.
46 -
47 -#### .charsets()
48 -
49 -Return the charsets that the request accepts, in the order of the client's
50 -preference (most preferred first).
51 -
52 -#### .encoding(encodings)
53 -
54 -Return the first accepted encoding. If nothing in `encodings` is accepted,
55 -then `false` is returned.
56 -
57 -#### .encodings()
58 -
59 -Return the encodings that the request accepts, in the order of the client's
60 -preference (most preferred first).
61 -
62 -#### .language(languages)
63 -
64 -Return the first accepted language. If nothing in `languages` is accepted,
65 -then `false` is returned.
66 -
67 -#### .languages()
68 -
69 -Return the languages that the request accepts, in the order of the client's
70 -preference (most preferred first).
71 -
72 -#### .type(types)
73 -
74 -Return the first accepted type (and it is returned as the same text as what
75 -appears in the `types` array). If nothing in `types` is accepted, then `false`
76 -is returned.
77 -
78 -The `types` array can contain full MIME types or file extensions. Any value
79 -that is not a full MIME types is passed to `require('mime-types').lookup`.
80 -
81 -#### .types()
82 -
83 -Return the types that the request accepts, in the order of the client's
84 -preference (most preferred first).
85 -
86 -## Examples
87 -
88 -### Simple type negotiation
89 -
90 -This simple example shows how to use `accepts` to return a different typed
91 -respond body based on what the client wants to accept. The server lists it's
92 -preferences in order and will get back the best match between the client and
93 -server.
94 -
95 -```js
96 -var accepts = require('accepts')
97 -var http = require('http')
98 -
99 -function app (req, res) {
100 - var accept = accepts(req)
101 -
102 - // the order of this list is significant; should be server preferred order
103 - switch (accept.type(['json', 'html'])) {
104 - case 'json':
105 - res.setHeader('Content-Type', 'application/json')
106 - res.write('{"hello":"world!"}')
107 - break
108 - case 'html':
109 - res.setHeader('Content-Type', 'text/html')
110 - res.write('<b>hello, world!</b>')
111 - break
112 - default:
113 - // the fallback is text/plain, so no need to specify it above
114 - res.setHeader('Content-Type', 'text/plain')
115 - res.write('hello, world!')
116 - break
117 - }
118 -
119 - res.end()
120 -}
121 -
122 -http.createServer(app).listen(3000)
123 -```
124 -
125 -You can test this out with the cURL program:
126 -```sh
127 -curl -I -H'Accept: text/html' http://localhost:3000/
128 -```
129 -
130 -## License
131 -
132 -[MIT](LICENSE)
133 -
134 -[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
135 -[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
136 -[node-version-image]: https://badgen.net/npm/node/accepts
137 -[node-version-url]: https://nodejs.org/en/download
138 -[npm-downloads-image]: https://badgen.net/npm/dm/accepts
139 -[npm-url]: https://npmjs.org/package/accepts
140 -[npm-version-image]: https://badgen.net/npm/v/accepts
141 -[travis-image]: https://badgen.net/travis/jshttp/accepts/master
142 -[travis-url]: https://travis-ci.org/jshttp/accepts
1 -/*!
2 - * accepts
3 - * Copyright(c) 2014 Jonathan Ong
4 - * Copyright(c) 2015 Douglas Christopher Wilson
5 - * MIT Licensed
6 - */
7 -
8 -'use strict'
9 -
10 -/**
11 - * Module dependencies.
12 - * @private
13 - */
14 -
15 -var Negotiator = require('negotiator')
16 -var mime = require('mime-types')
17 -
18 -/**
19 - * Module exports.
20 - * @public
21 - */
22 -
23 -module.exports = Accepts
24 -
25 -/**
26 - * Create a new Accepts object for the given req.
27 - *
28 - * @param {object} req
29 - * @public
30 - */
31 -
32 -function Accepts (req) {
33 - if (!(this instanceof Accepts)) {
34 - return new Accepts(req)
35 - }
36 -
37 - this.headers = req.headers
38 - this.negotiator = new Negotiator(req)
39 -}
40 -
41 -/**
42 - * Check if the given `type(s)` is acceptable, returning
43 - * the best match when true, otherwise `undefined`, in which
44 - * case you should respond with 406 "Not Acceptable".
45 - *
46 - * The `type` value may be a single mime type string
47 - * such as "application/json", the extension name
48 - * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 - * or array is given the _best_ match, if any is returned.
50 - *
51 - * Examples:
52 - *
53 - * // Accept: text/html
54 - * this.types('html');
55 - * // => "html"
56 - *
57 - * // Accept: text/*, application/json
58 - * this.types('html');
59 - * // => "html"
60 - * this.types('text/html');
61 - * // => "text/html"
62 - * this.types('json', 'text');
63 - * // => "json"
64 - * this.types('application/json');
65 - * // => "application/json"
66 - *
67 - * // Accept: text/*, application/json
68 - * this.types('image/png');
69 - * this.types('png');
70 - * // => undefined
71 - *
72 - * // Accept: text/*;q=.5, application/json
73 - * this.types(['html', 'json']);
74 - * this.types('html', 'json');
75 - * // => "json"
76 - *
77 - * @param {String|Array} types...
78 - * @return {String|Array|Boolean}
79 - * @public
80 - */
81 -
82 -Accepts.prototype.type =
83 -Accepts.prototype.types = function (types_) {
84 - var types = types_
85 -
86 - // support flattened arguments
87 - if (types && !Array.isArray(types)) {
88 - types = new Array(arguments.length)
89 - for (var i = 0; i < types.length; i++) {
90 - types[i] = arguments[i]
91 - }
92 - }
93 -
94 - // no types, return all requested types
95 - if (!types || types.length === 0) {
96 - return this.negotiator.mediaTypes()
97 - }
98 -
99 - // no accept header, return first given type
100 - if (!this.headers.accept) {
101 - return types[0]
102 - }
103 -
104 - var mimes = types.map(extToMime)
105 - var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 - var first = accepts[0]
107 -
108 - return first
109 - ? types[mimes.indexOf(first)]
110 - : false
111 -}
112 -
113 -/**
114 - * Return accepted encodings or best fit based on `encodings`.
115 - *
116 - * Given `Accept-Encoding: gzip, deflate`
117 - * an array sorted by quality is returned:
118 - *
119 - * ['gzip', 'deflate']
120 - *
121 - * @param {String|Array} encodings...
122 - * @return {String|Array}
123 - * @public
124 - */
125 -
126 -Accepts.prototype.encoding =
127 -Accepts.prototype.encodings = function (encodings_) {
128 - var encodings = encodings_
129 -
130 - // support flattened arguments
131 - if (encodings && !Array.isArray(encodings)) {
132 - encodings = new Array(arguments.length)
133 - for (var i = 0; i < encodings.length; i++) {
134 - encodings[i] = arguments[i]
135 - }
136 - }
137 -
138 - // no encodings, return all requested encodings
139 - if (!encodings || encodings.length === 0) {
140 - return this.negotiator.encodings()
141 - }
142 -
143 - return this.negotiator.encodings(encodings)[0] || false
144 -}
145 -
146 -/**
147 - * Return accepted charsets or best fit based on `charsets`.
148 - *
149 - * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 - * an array sorted by quality is returned:
151 - *
152 - * ['utf-8', 'utf-7', 'iso-8859-1']
153 - *
154 - * @param {String|Array} charsets...
155 - * @return {String|Array}
156 - * @public
157 - */
158 -
159 -Accepts.prototype.charset =
160 -Accepts.prototype.charsets = function (charsets_) {
161 - var charsets = charsets_
162 -
163 - // support flattened arguments
164 - if (charsets && !Array.isArray(charsets)) {
165 - charsets = new Array(arguments.length)
166 - for (var i = 0; i < charsets.length; i++) {
167 - charsets[i] = arguments[i]
168 - }
169 - }
170 -
171 - // no charsets, return all requested charsets
172 - if (!charsets || charsets.length === 0) {
173 - return this.negotiator.charsets()
174 - }
175 -
176 - return this.negotiator.charsets(charsets)[0] || false
177 -}
178 -
179 -/**
180 - * Return accepted languages or best fit based on `langs`.
181 - *
182 - * Given `Accept-Language: en;q=0.8, es, pt`
183 - * an array sorted by quality is returned:
184 - *
185 - * ['es', 'pt', 'en']
186 - *
187 - * @param {String|Array} langs...
188 - * @return {Array|String}
189 - * @public
190 - */
191 -
192 -Accepts.prototype.lang =
193 -Accepts.prototype.langs =
194 -Accepts.prototype.language =
195 -Accepts.prototype.languages = function (languages_) {
196 - var languages = languages_
197 -
198 - // support flattened arguments
199 - if (languages && !Array.isArray(languages)) {
200 - languages = new Array(arguments.length)
201 - for (var i = 0; i < languages.length; i++) {
202 - languages[i] = arguments[i]
203 - }
204 - }
205 -
206 - // no languages, return all requested languages
207 - if (!languages || languages.length === 0) {
208 - return this.negotiator.languages()
209 - }
210 -
211 - return this.negotiator.languages(languages)[0] || false
212 -}
213 -
214 -/**
215 - * Convert extnames to mime.
216 - *
217 - * @param {String} type
218 - * @return {String}
219 - * @private
220 - */
221 -
222 -function extToMime (type) {
223 - return type.indexOf('/') === -1
224 - ? mime.lookup(type)
225 - : type
226 -}
227 -
228 -/**
229 - * Check if mime is valid.
230 - *
231 - * @param {String} type
232 - * @return {String}
233 - * @private
234 - */
235 -
236 -function validMime (type) {
237 - return typeof type === 'string'
238 -}
1 -{
2 - "_from": "accepts@~1.3.7",
3 - "_id": "accepts@1.3.7",
4 - "_inBundle": false,
5 - "_integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
6 - "_location": "/accepts",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "accepts@~1.3.7",
12 - "name": "accepts",
13 - "escapedName": "accepts",
14 - "rawSpec": "~1.3.7",
15 - "saveSpec": null,
16 - "fetchSpec": "~1.3.7"
17 - },
18 - "_requiredBy": [
19 - "/express"
20 - ],
21 - "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
22 - "_shasum": "531bc726517a3b2b41f850021c6cc15eaab507cd",
23 - "_spec": "accepts@~1.3.7",
24 - "_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\express",
25 - "bugs": {
26 - "url": "https://github.com/jshttp/accepts/issues"
27 - },
28 - "bundleDependencies": false,
29 - "contributors": [
30 - {
31 - "name": "Douglas Christopher Wilson",
32 - "email": "doug@somethingdoug.com"
33 - },
34 - {
35 - "name": "Jonathan Ong",
36 - "email": "me@jongleberry.com",
37 - "url": "http://jongleberry.com"
38 - }
39 - ],
40 - "dependencies": {
41 - "mime-types": "~2.1.24",
42 - "negotiator": "0.6.2"
43 - },
44 - "deprecated": false,
45 - "description": "Higher-level content negotiation",
46 - "devDependencies": {
47 - "deep-equal": "1.0.1",
48 - "eslint": "5.16.0",
49 - "eslint-config-standard": "12.0.0",
50 - "eslint-plugin-import": "2.17.2",
51 - "eslint-plugin-markdown": "1.0.0",
52 - "eslint-plugin-node": "8.0.1",
53 - "eslint-plugin-promise": "4.1.1",
54 - "eslint-plugin-standard": "4.0.0",
55 - "mocha": "6.1.4",
56 - "nyc": "14.0.0"
57 - },
58 - "engines": {
59 - "node": ">= 0.6"
60 - },
61 - "files": [
62 - "LICENSE",
63 - "HISTORY.md",
64 - "index.js"
65 - ],
66 - "homepage": "https://github.com/jshttp/accepts#readme",
67 - "keywords": [
68 - "content",
69 - "negotiation",
70 - "accept",
71 - "accepts"
72 - ],
73 - "license": "MIT",
74 - "name": "accepts",
75 - "repository": {
76 - "type": "git",
77 - "url": "git+https://github.com/jshttp/accepts.git"
78 - },
79 - "scripts": {
80 - "lint": "eslint --plugin markdown --ext js,md .",
81 - "test": "mocha --reporter spec --check-leaks --bail test/",
82 - "test-cov": "nyc --reporter=html --reporter=text npm test",
83 - "test-travis": "nyc --reporter=text npm test"
84 - },
85 - "version": "1.3.7"
86 -}
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 - return acorn.parse(source, {
23 - allowReturnOutsideFunction: true,
24 - allowImportExportEverywhere: true,
25 - allowHashBang: true
26 - });
27 -}
28 -module.exports = findGlobals;
29 -module.exports.parse = reallyParse;
30 -function findGlobals(source) {
31 - var globals = [];
32 - var ast;
33 - // istanbul ignore else
34 - if (typeof source === 'string') {
35 - ast = reallyParse(source);
36 - } else {
37 - ast = source;
38 - }
39 - // istanbul ignore if
40 - if (!(ast && typeof ast === 'object' && ast.type === 'Program')) {
41 - throw new TypeError('Source must be either a string of JavaScript or an acorn AST');
42 - }
43 - var declareFunction = function (node) {
44 - var fn = node;
45 - fn.locals = fn.locals || {};
46 - node.params.forEach(function (node) {
47 - declarePattern(node, fn);
48 - });
49 - if (node.id) {
50 - fn.locals[node.id.name] = true;
51 - }
52 - }
53 - var declarePattern = function (node, parent) {
54 - switch (node.type) {
55 - case 'Identifier':
56 - parent.locals[node.name] = true;
57 - break;
58 - case 'ObjectPattern':
59 - node.properties.forEach(function (node) {
60 - declarePattern(node.value, parent);
61 - });
62 - break;
63 - case 'ArrayPattern':
64 - node.elements.forEach(function (node) {
65 - if (node) declarePattern(node, parent);
66 - });
67 - break;
68 - case 'RestElement':
69 - declarePattern(node.argument, parent);
70 - break;
71 - case 'AssignmentPattern':
72 - declarePattern(node.left, parent);
73 - break;
74 - // istanbul ignore next
75 - default:
76 - throw new Error('Unrecognized pattern type: ' + node.type);
77 - }
78 - }
79 - var declareModuleSpecifier = function (node, parents) {
80 - ast.locals = ast.locals || {};
81 - ast.locals[node.local.name] = true;
82 - }
83 - walk.ancestor(ast, {
84 - 'VariableDeclaration': function (node, parents) {
85 - var parent = null;
86 - for (var i = parents.length - 1; i >= 0 && parent === null; i--) {
87 - if (node.kind === 'var' ? isScope(parents[i]) : isBlockScope(parents[i])) {
88 - parent = parents[i];
89 - }
90 - }
91 - parent.locals = parent.locals || {};
92 - node.declarations.forEach(function (declaration) {
93 - declarePattern(declaration.id, parent);
94 - });
95 - },
96 - 'FunctionDeclaration': function (node, parents) {
97 - var parent = null;
98 - for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
99 - if (isScope(parents[i])) {
100 - parent = parents[i];
101 - }
102 - }
103 - parent.locals = parent.locals || {};
104 - parent.locals[node.id.name] = true;
105 - declareFunction(node);
106 - },
107 - 'Function': declareFunction,
108 - 'ClassDeclaration': function (node, parents) {
109 - var parent = null;
110 - for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
111 - if (isScope(parents[i])) {
112 - parent = parents[i];
113 - }
114 - }
115 - parent.locals = parent.locals || {};
116 - parent.locals[node.id.name] = true;
117 - },
118 - 'TryStatement': function (node) {
119 - if (node.handler === null) return;
120 - node.handler.locals = node.handler.locals || {};
121 - node.handler.locals[node.handler.param.name] = true;
122 - },
123 - 'ImportDefaultSpecifier': declareModuleSpecifier,
124 - 'ImportSpecifier': declareModuleSpecifier,
125 - 'ImportNamespaceSpecifier': declareModuleSpecifier
126 - });
127 - function identifier(node, parents) {
128 - var name = node.name;
129 - if (name === 'undefined') return;
130 - for (var i = 0; i < parents.length; i++) {
131 - if (name === 'arguments' && declaresArguments(parents[i])) {
132 - return;
133 - }
134 - if (parents[i].locals && name in parents[i].locals) {
135 - return;
136 - }
137 - }
138 - node.parents = parents;
139 - globals.push(node);
140 - }
141 - walk.ancestor(ast, {
142 - 'VariablePattern': identifier,
143 - 'Identifier': identifier,
144 - 'ThisExpression': function (node, parents) {
145 - for (var i = 0; i < parents.length; i++) {
146 - if (declaresThis(parents[i])) {
147 - return;
148 - }
149 - }
150 - node.parents = parents;
151 - globals.push(node);
152 - }
153 - });
154 - var groupedGlobals = {};
155 - globals.forEach(function (node) {
156 - var name = node.type === 'ThisExpression' ? 'this' : node.name;
157 - groupedGlobals[name] = (groupedGlobals[name] || []);
158 - groupedGlobals[name].push(node);
159 - });
160 - return Object.keys(groupedGlobals).sort().map(function (name) {
161 - return {name: name, nodes: groupedGlobals[name]};
162 - });
163 -}
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 -/.tern-port
2 -/test
3 -/local
4 -/rollup
5 -/bin/generate-identifier-regex.js
6 -/bin/update_authors.sh
7 -.editorconfig
8 -.gitattributes
9 -.tern-project
10 -.travis.yml
1 -List of Acorn contributors. Updated before every release.
2 -
3 -Adrian Rakovsky
4 -Alistair Braidwood
5 -Amila Welihinda
6 -Andres Suarez
7 -Angelo
8 -Aparajita Fishman
9 -Arian Stolwijk
10 -Artem Govorov
11 -Brandon Mills
12 -Charles Hughes
13 -Conrad Irwin
14 -Daniel Tschinder
15 -David Bonnet
16 -Domenico Matteo
17 -Forbes Lindesay
18 -Gilad Peleg
19 -impinball
20 -Ingvar Stepanyan
21 -Jackson Ray Hamilton
22 -Jesse McCarthy
23 -Jiaxing Wang
24 -Joel Kemp
25 -Johannes Herr
26 -Jordan Klassen
27 -Jürg Lehni
28 -Kai Cataldo
29 -keeyipchan
30 -Keheliya Gallaba
31 -Kevin Irish
32 -Kevin Kwok
33 -krator
34 -Marijn Haverbeke
35 -Martin Carlberg
36 -Mat Garcia
37 -Mathias Bynens
38 -Mathieu 'p01' Henri
39 -Matthew Bastien
40 -Max Schaefer
41 -Max Zerzouri
42 -Mihai Bazon
43 -Mike Rennie
44 -naoh
45 -Nicholas C. Zakas
46 -Nick Fitzgerald
47 -Olivier Thomann
48 -Oskar Schöldström
49 -Paul Harper
50 -Peter Rust
51 -PlNG
52 -Prayag Verma
53 -ReadmeCritic
54 -r-e-d
55 -Richard Gibson
56 -Rich Harris
57 -Sebastian McKenzie
58 -Simen Bekkhus
59 -Timothy Gu
60 -Toru Nagashima
61 -Wexpo Lyu
62 -zsjforcn
1 -## 4.0.11 (2017-02-07)
2 -
3 -### Bug fixes
4 -
5 -Allow all forms of member expressions to be parenthesized as lvalue.
6 -
7 -## 4.0.10 (2017-02-07)
8 -
9 -### Bug fixes
10 -
11 -Don't expect semicolons after default-exported functions or classes,
12 -even when they are expressions.
13 -
14 -Check for use of `'use strict'` directives in non-simple parameter
15 -functions, even when already in strict mode.
16 -
17 -## 4.0.9 (2017-02-06)
18 -
19 -### Bug fixes
20 -
21 -Fix incorrect error raised for parenthesized simple assignment
22 -targets, so that `(x) = 1` parses again.
23 -
24 -## 4.0.8 (2017-02-03)
25 -
26 -### Bug fixes
27 -
28 -Solve spurious parenthesized pattern errors by temporarily erring on
29 -the side of accepting programs that our delayed errors don't handle
30 -correctly yet.
31 -
32 -## 4.0.7 (2017-02-02)
33 -
34 -### Bug fixes
35 -
36 -Accept invalidly rejected code like `(x).y = 2` again.
37 -
38 -Don't raise an error when a function _inside_ strict code has a
39 -non-simple parameter list.
40 -
41 -## 4.0.6 (2017-02-02)
42 -
43 -### Bug fixes
44 -
45 -Fix exponential behavior (manifesting itself as a complete hang for
46 -even relatively small source files) introduced by the new 'use strict'
47 -check.
48 -
49 -## 4.0.5 (2017-02-02)
50 -
51 -### Bug fixes
52 -
53 -Disallow parenthesized pattern expressions.
54 -
55 -Allow keywords as export names.
56 -
57 -Don't allow the `async` keyword to be parenthesized.
58 -
59 -Properly raise an error when a keyword contains a character escape.
60 -
61 -Allow `"use strict"` to appear after other string literal expressions.
62 -
63 -Disallow labeled declarations.
64 -
65 -## 4.0.4 (2016-12-19)
66 -
67 -### Bug fixes
68 -
69 -Fix issue with loading acorn_loose.js with an AMD loader.
70 -
71 -Fix crash when `export` was followed by a keyword that can't be
72 -exported.
73 -
74 -## 4.0.3 (2016-08-16)
75 -
76 -### Bug fixes
77 -
78 -Allow regular function declarations inside single-statement `if`
79 -branches in loose mode. Forbid them entirely in strict mode.
80 -
81 -Properly parse properties named `async` in ES2017 mode.
82 -
83 -Fix bug where reserved words were broken in ES2017 mode.
84 -
85 -## 4.0.2 (2016-08-11)
86 -
87 -### Bug fixes
88 -
89 -Don't ignore period or 'e' characters after octal numbers.
90 -
91 -Fix broken parsing for call expressions in default parameter values
92 -of arrow functions.
93 -
94 -## 4.0.1 (2016-08-08)
95 -
96 -### Bug fixes
97 -
98 -Fix false positives in duplicated export name errors.
99 -
100 -## 4.0.0 (2016-08-07)
101 -
102 -### Breaking changes
103 -
104 -The default `ecmaVersion` option value is now 7.
105 -
106 -A number of internal method signatures changed, so plugins might need
107 -to be updated.
108 -
109 -### Bug fixes
110 -
111 -The parser now raises errors on duplicated export names.
112 -
113 -`arguments` and `eval` can now be used in shorthand properties.
114 -
115 -Duplicate parameter names in non-simple argument lists now always
116 -produce an error.
117 -
118 -### New features
119 -
120 -The `ecmaVersion` option now also accepts year-style version numbers
121 -(2015, etc).
122 -
123 -Support for `async`/`await` syntax when `ecmaVersion` is >= 8.
124 -
125 -Support for trailing commas in call expressions when `ecmaVersion`
126 -is >= 8.
127 -
128 -## 3.3.0 (2016-07-25)
129 -
130 -### Bug fixes
131 -
132 -Fix bug in tokenizing of regexp operator after a function declaration.
133 -
134 -Fix parser crash when parsing an array pattern with a hole.
135 -
136 -### New features
137 -
138 -Implement check against complex argument lists in functions that
139 -enable strict mode in ES7.
140 -
141 -## 3.2.0 (2016-06-07)
142 -
143 -### Bug fixes
144 -
145 -Improve handling of lack of unicode regexp support in host
146 -environment.
147 -
148 -Properly reject shorthand properties whose name is a keyword.
149 -
150 -Don't crash when the loose parser is called without options object.
151 -
152 -### New features
153 -
154 -Visitors created with `visit.make` now have their base as _prototype_,
155 -rather than copying properties into a fresh object.
156 -
157 -Make it possible to use `visit.ancestor` with a walk state.
158 -
159 -## 3.1.0 (2016-04-18)
160 -
161 -### Bug fixes
162 -
163 -Fix issue where the loose parser created invalid TemplateElement nodes
164 -for unclosed template literals.
165 -
166 -Properly tokenize the division operator directly after a function
167 -expression.
168 -
169 -Allow trailing comma in destructuring arrays.
170 -
171 -### New features
172 -
173 -The walker now allows defining handlers for `CatchClause` nodes.
174 -
175 -## 3.0.4 (2016-02-25)
176 -
177 -### Fixes
178 -
179 -Allow update expressions as left-hand-side of the ES7 exponential
180 -operator.
181 -
182 -## 3.0.2 (2016-02-10)
183 -
184 -### Fixes
185 -
186 -Fix bug that accidentally made `undefined` a reserved word when
187 -parsing ES7.
188 -
189 -## 3.0.0 (2016-02-10)
190 -
191 -### Breaking changes
192 -
193 -The default value of the `ecmaVersion` option is now 6 (used to be 5).
194 -
195 -Support for comprehension syntax (which was dropped from the draft
196 -spec) has been removed.
197 -
198 -### Fixes
199 -
200 -`let` and `yield` are now “contextual keywords”, meaning you can
201 -mostly use them as identifiers in ES5 non-strict code.
202 -
203 -A parenthesized class or function expression after `export default` is
204 -now parsed correctly.
205 -
206 -### New features
207 -
208 -When `ecmaVersion` is set to 7, Acorn will parse the exponentiation
209 -operator (`**`).
210 -
211 -The identifier character ranges are now based on Unicode 8.0.0.
212 -
213 -Plugins can now override the `raiseRecoverable` method to override the
214 -way non-critical errors are handled.
215 -
216 -## 2.7.0 (2016-01-04)
217 -
218 -### Fixes
219 -
220 -Stop allowing rest parameters in setters.
221 -
222 -Make sure the loose parser always attaches a `local` property to
223 -`ImportNamespaceSpecifier` nodes.
224 -
225 -Disallow `y` rexexp flag in ES5.
226 -
227 -Disallow `\00` and `\000` escapes in strict mode.
228 -
229 -Raise an error when an import name is a reserved word.
230 -
231 -## 2.6.4 (2015-11-12)
232 -
233 -### Fixes
234 -
235 -Fix crash in loose parser when parsing invalid object pattern.
236 -
237 -### New features
238 -
239 -Support plugins in the loose parser.
240 -
241 -## 2.6.2 (2015-11-10)
242 -
243 -### Fixes
244 -
245 -Don't crash when no options object is passed.
246 -
247 -## 2.6.0 (2015-11-09)
248 -
249 -### Fixes
250 -
251 -Add `await` as a reserved word in module sources.
252 -
253 -Disallow `yield` in a parameter default value for a generator.
254 -
255 -Forbid using a comma after a rest pattern in an array destructuring.
256 -
257 -### New features
258 -
259 -Support parsing stdin in command-line tool.
260 -
261 -## 2.5.2 (2015-10-27)
262 -
263 -### Fixes
264 -
265 -Fix bug where the walker walked an exported `let` statement as an
266 -expression.
267 -
268 -## 2.5.0 (2015-10-27)
269 -
270 -### Fixes
271 -
272 -Fix tokenizer support in the command-line tool.
273 -
274 -In the loose parser, don't allow non-string-literals as import
275 -sources.
276 -
277 -Stop allowing `new.target` outside of functions.
278 -
279 -Remove legacy `guard` and `guardedHandler` properties from try nodes.
280 -
281 -Stop allowing multiple `__proto__` properties on an object literal in
282 -strict mode.
283 -
284 -Don't allow rest parameters to be non-identifier patterns.
285 -
286 -Check for duplicate paramter names in arrow functions.
1 -Copyright (C) 2012-2016 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 -var path = require('path');
5 -var fs = require('fs');
6 -var acorn = require('../dist/acorn.js');
7 -
8 -var infile;
9 -var forceFile;
10 -var silent = false;
11 -var compact = false;
12 -var tokenize = false;
13 -var options = {}
14 -
15 -function help(status) {
16 - var print = (status == 0) ? console.log : console.error
17 - print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|...|--ecma2015|--ecma2016|...]")
18 - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]")
19 - process.exit(status)
20 -}
21 -
22 -for (var i = 2; i < process.argv.length; ++i) {
23 - var arg = process.argv[i]
24 - if ((arg == "-" || arg[0] != "-") && !infile) infile = arg
25 - else if (arg == "--" && !infile && i + 2 == process.argv.length) forceFile = infile = process.argv[++i]
26 - else if (arg == "--locations") options.locations = true
27 - else if (arg == "--allow-hash-bang") options.allowHashBang = true
28 - else if (arg == "--silent") silent = true
29 - else if (arg == "--compact") compact = true
30 - else if (arg == "--help") help(0)
31 - else if (arg == "--tokenize") tokenize = true
32 - else if (arg == "--module") options.sourceType = 'module'
33 - else {
34 - var match = arg.match(/^--ecma(\d+)$/)
35 - if (match)
36 - options.ecmaVersion = +match[1]
37 - else
38 - help(1)
39 - }
40 -}
41 -
42 -function run(code) {
43 - var result
44 - if (!tokenize) {
45 - try { result = acorn.parse(code, options) }
46 - catch(e) { console.error(e.message); process.exit(1) }
47 - } else {
48 - result = []
49 - var tokenizer = acorn.tokenizer(code, options), token
50 - while (true) {
51 - try { token = tokenizer.getToken() }
52 - catch(e) { console.error(e.message); process.exit(1) }
53 - result.push(token)
54 - if (token.type == acorn.tokTypes.eof) break
55 - }
56 - }
57 - if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2))
58 -}
59 -
60 -if (forceFile || infile && infile != "-") {
61 - run(fs.readFileSync(infile, "utf8"))
62 -} else {
63 - var code = ""
64 - process.stdin.resume()
65 - process.stdin.on("data", function (chunk) { return code += chunk; })
66 - process.stdin.on("end", function () { return run(code); })
67 -}
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
1 -{
2 - "_from": "acorn@^4.0.4",
3 - "_id": "acorn@4.0.13",
4 - "_inBundle": false,
5 - "_integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=",
6 - "_location": "/acorn-globals/acorn",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "acorn@^4.0.4",
12 - "name": "acorn",
13 - "escapedName": "acorn",
14 - "rawSpec": "^4.0.4",
15 - "saveSpec": null,
16 - "fetchSpec": "^4.0.4"
17 - },
18 - "_requiredBy": [
19 - "/acorn-globals"
20 - ],
21 - "_resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz",
22 - "_shasum": "105495ae5361d697bd195c825192e1ad7f253787",
23 - "_spec": "acorn@^4.0.4",
24 - "_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\acorn-globals",
25 - "bin": {
26 - "acorn": "./bin/acorn"
27 - },
28 - "bugs": {
29 - "url": "https://github.com/ternjs/acorn/issues"
30 - },
31 - "bundleDependencies": false,
32 - "contributors": [
33 - {
34 - "name": "List of Acorn contributors. Updated before every release."
35 - },
36 - {
37 - "name": "Adrian Rakovsky"
38 - },
39 - {
40 - "name": "Alistair Braidwood"
41 - },
42 - {
43 - "name": "Amila Welihinda"
44 - },
45 - {
46 - "name": "Andres Suarez"
47 - },
48 - {
49 - "name": "Angelo"
50 - },
51 - {
52 - "name": "Aparajita Fishman"
53 - },
54 - {
55 - "name": "Arian Stolwijk"
56 - },
57 - {
58 - "name": "Artem Govorov"
59 - },
60 - {
61 - "name": "Brandon Mills"
62 - },
63 - {
64 - "name": "Charles Hughes"
65 - },
66 - {
67 - "name": "Conrad Irwin"
68 - },
69 - {
70 - "name": "Daniel Tschinder"
71 - },
72 - {
73 - "name": "David Bonnet"
74 - },
75 - {
76 - "name": "Domenico Matteo"
77 - },
78 - {
79 - "name": "Forbes Lindesay"
80 - },
81 - {
82 - "name": "Gilad Peleg"
83 - },
84 - {
85 - "name": "impinball"
86 - },
87 - {
88 - "name": "Ingvar Stepanyan"
89 - },
90 - {
91 - "name": "Jackson Ray Hamilton"
92 - },
93 - {
94 - "name": "Jesse McCarthy"
95 - },
96 - {
97 - "name": "Jiaxing Wang"
98 - },
99 - {
100 - "name": "Joel Kemp"
101 - },
102 - {
103 - "name": "Johannes Herr"
104 - },
105 - {
106 - "name": "Jordan Klassen"
107 - },
108 - {
109 - "name": "Jürg Lehni"
110 - },
111 - {
112 - "name": "Kai Cataldo"
113 - },
114 - {
115 - "name": "keeyipchan"
116 - },
117 - {
118 - "name": "Keheliya Gallaba"
119 - },
120 - {
121 - "name": "Kevin Irish"
122 - },
123 - {
124 - "name": "Kevin Kwok"
125 - },
126 - {
127 - "name": "krator"
128 - },
129 - {
130 - "name": "Marijn Haverbeke"
131 - },
132 - {
133 - "name": "Martin Carlberg"
134 - },
135 - {
136 - "name": "Mat Garcia"
137 - },
138 - {
139 - "name": "Mathias Bynens"
140 - },
141 - {
142 - "name": "Mathieu 'p01' Henri"
143 - },
144 - {
145 - "name": "Matthew Bastien"
146 - },
147 - {
148 - "name": "Max Schaefer"
149 - },
150 - {
151 - "name": "Max Zerzouri"
152 - },
153 - {
154 - "name": "Mihai Bazon"
155 - },
156 - {
157 - "name": "Mike Rennie"
158 - },
159 - {
160 - "name": "naoh"
161 - },
162 - {
163 - "name": "Nicholas C. Zakas"
164 - },
165 - {
166 - "name": "Nick Fitzgerald"
167 - },
168 - {
169 - "name": "Olivier Thomann"
170 - },
171 - {
172 - "name": "Oskar Schöldström"
173 - },
174 - {
175 - "name": "Paul Harper"
176 - },
177 - {
178 - "name": "Peter Rust"
179 - },
180 - {
181 - "name": "PlNG"
182 - },
183 - {
184 - "name": "Prayag Verma"
185 - },
186 - {
187 - "name": "ReadmeCritic"
188 - },
189 - {
190 - "name": "r-e-d"
191 - },
192 - {
193 - "name": "Richard Gibson"
194 - },
195 - {
196 - "name": "Rich Harris"
197 - },
198 - {
199 - "name": "Sebastian McKenzie"
200 - },
201 - {
202 - "name": "Simen Bekkhus"
203 - },
204 - {
205 - "name": "Timothy Gu"
206 - },
207 - {
208 - "name": "Toru Nagashima"
209 - },
210 - {
211 - "name": "Wexpo Lyu"
212 - },
213 - {
214 - "name": "zsjforcn"
215 - }
216 - ],
217 - "deprecated": false,
218 - "description": "ECMAScript parser",
219 - "devDependencies": {
220 - "rollup": "^0.34.1",
221 - "rollup-plugin-buble": "^0.11.0",
222 - "unicode-9.0.0": "^0.7.0"
223 - },
224 - "engines": {
225 - "node": ">=0.4.0"
226 - },
227 - "homepage": "https://github.com/ternjs/acorn",
228 - "jsnext:main": "dist/acorn.es.js",
229 - "license": "MIT",
230 - "main": "dist/acorn.js",
231 - "maintainers": [
232 - {
233 - "name": "Marijn Haverbeke",
234 - "email": "marijnh@gmail.com",
235 - "url": "http://marijnhaverbeke.nl"
236 - },
237 - {
238 - "name": "Ingvar Stepanyan",
239 - "email": "me@rreverser.com",
240 - "url": "http://rreverser.com/"
241 - }
242 - ],
243 - "name": "acorn",
244 - "repository": {
245 - "type": "git",
246 - "url": "git+https://github.com/ternjs/acorn.git"
247 - },
248 - "scripts": {
249 - "build": "npm run build:main && npm run build:walk && npm run build:loose && npm run build:bin",
250 - "build:bin": "rollup -c rollup/config.bin.js",
251 - "build:loose": "rollup -c rollup/config.loose.js",
252 - "build:main": "rollup -c rollup/config.main.js",
253 - "build:walk": "rollup -c rollup/config.walk.js",
254 - "prepublish": "npm test",
255 - "pretest": "npm run build",
256 - "test": "node test/run.js"
257 - },
258 - "version": "4.0.13"
259 -}
1 -import {basename} from "path"
2 -import {readFileSync as readFile} from "fs"
3 -import * as acorn from "acorn"
4 -
5 -let infile, forceFile, silent = false, compact = false, tokenize = false
6 -const options = {}
7 -
8 -function help(status) {
9 - const print = (status == 0) ? console.log : console.error
10 - print("usage: " + basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|...|--ecma2015|--ecma2016|...]")
11 - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]")
12 - process.exit(status)
13 -}
14 -
15 -for (let i = 2; i < process.argv.length; ++i) {
16 - const arg = process.argv[i]
17 - if ((arg == "-" || arg[0] != "-") && !infile) infile = arg
18 - else if (arg == "--" && !infile && i + 2 == process.argv.length) forceFile = infile = process.argv[++i]
19 - else if (arg == "--locations") options.locations = true
20 - else if (arg == "--allow-hash-bang") options.allowHashBang = true
21 - else if (arg == "--silent") silent = true
22 - else if (arg == "--compact") compact = true
23 - else if (arg == "--help") help(0)
24 - else if (arg == "--tokenize") tokenize = true
25 - else if (arg == "--module") options.sourceType = 'module'
26 - else {
27 - let match = arg.match(/^--ecma(\d+)$/)
28 - if (match)
29 - options.ecmaVersion = +match[1]
30 - else
31 - help(1)
32 - }
33 -}
34 -
35 -function run(code) {
36 - let result
37 - if (!tokenize) {
38 - try { result = acorn.parse(code, options) }
39 - catch(e) { console.error(e.message); process.exit(1) }
40 - } else {
41 - result = []
42 - let tokenizer = acorn.tokenizer(code, options), token
43 - while (true) {
44 - try { token = tokenizer.getToken() }
45 - catch(e) { console.error(e.message); process.exit(1) }
46 - result.push(token)
47 - if (token.type == acorn.tokTypes.eof) break
48 - }
49 - }
50 - if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2))
51 -}
52 -
53 -if (forceFile || infile && infile != "-") {
54 - run(readFile(infile, "utf8"))
55 -} else {
56 - let code = ""
57 - process.stdin.resume()
58 - process.stdin.on("data", chunk => code += chunk)
59 - process.stdin.on("end", () => run(code))
60 -}
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, keywords as keywordTypes} 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 = "4.0.11"
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 -}
68 -
69 -// This is a terrible kludge to support the existing, pre-ES6
70 -// interface where the loose parser module retroactively adds exports
71 -// to this module.
72 -export let parse_dammit, LooseParser, pluginsLoose
73 -export function addLooseExports(parse, Parser, plugins) {
74 - parse_dammit = parse
75 - LooseParser = Parser
76 - pluginsLoose = plugins
77 -}
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.raiseRecoverable = pp.raise
21 -
22 -pp.curPosition = function() {
23 - if (this.options.locations) {
24 - return new Position(this.curLine, this.pos - this.lineStart)
25 - }
26 -}
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 -}
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 {addLooseExports, defaultOptions} from "../index"
33 -import {LooseParser, pluginsLoose} from "./state"
34 -import "./tokenize"
35 -import "./statement"
36 -import "./expression"
37 -
38 -export {LooseParser, pluginsLoose} from "./state"
39 -
40 -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 -addLooseExports(parse_dammit, LooseParser, 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 "../index"
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 - this.inAsync = false
22 - // Load plugins
23 - this.options.pluginsLoose = options.pluginsLoose || {}
24 - this.loadPlugins(this.options.pluginsLoose)
25 - }
26 -
27 - startNode() {
28 - return new Node(this.toks, this.tok.start, this.options.locations ? this.tok.loc.start : null)
29 - }
30 -
31 - storeCurrentPos() {
32 - return this.options.locations ? [this.tok.start, this.tok.loc.start] : this.tok.start
33 - }
34 -
35 - startNodeAt(pos) {
36 - if (this.options.locations) {
37 - return new Node(this.toks, pos[0], pos[1])
38 - } else {
39 - return new Node(this.toks, pos)
40 - }
41 - }
42 -
43 - finishNode(node, type) {
44 - node.type = type
45 - node.end = this.last.end
46 - if (this.options.locations)
47 - node.loc.end = this.last.loc.end
48 - if (this.options.ranges)
49 - node.range[1] = this.last.end
50 - return node
51 - }
52 -
53 - dummyNode(type) {
54 - let dummy = this.startNode()
55 - dummy.type = type
56 - dummy.end = dummy.start
57 - if (this.options.locations)
58 - dummy.loc.end = dummy.loc.start
59 - if (this.options.ranges)
60 - dummy.range[1] = dummy.start
61 - this.last = {type: tt.name, start: dummy.start, end: dummy.start, loc: dummy.loc}
62 - return dummy
63 - }
64 -
65 - dummyIdent() {
66 - let dummy = this.dummyNode("Identifier")
67 - dummy.name = "✖"
68 - return dummy
69 - }
70 -
71 - dummyString() {
72 - let dummy = this.dummyNode("Literal")
73 - dummy.value = dummy.raw = "✖"
74 - return dummy
75 - }
76 -
77 - eat(type) {
78 - if (this.tok.type === type) {
79 - this.next()
80 - return true
81 - } else {
82 - return false
83 - }
84 - }
85 -
86 - isContextual(name) {
87 - return this.tok.type === tt.name && this.tok.value === name
88 - }
89 -
90 - eatContextual(name) {
91 - return this.tok.value === name && this.eat(tt.name)
92 - }
93 -
94 - canInsertSemicolon() {
95 - return this.tok.type === tt.eof || this.tok.type === tt.braceR ||
96 - lineBreak.test(this.input.slice(this.last.end, this.tok.start))
97 - }
98 -
99 - semicolon() {
100 - return this.eat(tt.semi)
101 - }
102 -
103 - expect(type) {
104 - if (this.eat(type)) return true
105 - for (let i = 1; i <= 2; i++) {
106 - if (this.lookAhead(i).type == type) {
107 - for (let j = 0; j < i; j++) this.next()
108 - return true
109 - }
110 - }
111 - }
112 -
113 - pushCx() {
114 - this.context.push(this.curIndent)
115 - }
116 -
117 - popCx() {
118 - this.curIndent = this.context.pop()
119 - }
120 -
121 - lineEnd(pos) {
122 - while (pos < this.input.length && !isNewLine(this.input.charCodeAt(pos))) ++pos
123 - return pos
124 - }
125 -
126 - indentationAfter(pos) {
127 - for (let count = 0;; ++pos) {
128 - let ch = this.input.charCodeAt(pos)
129 - if (ch === 32) ++count
130 - else if (ch === 9) count += this.options.tabSize
131 - else return count
132 - }
133 - }
134 -
135 - closes(closeTok, indent, line, blockHeuristic) {
136 - if (this.tok.type === closeTok || this.tok.type === tt.eof) return true
137 - return line != this.curLineStart && this.curIndent < indent && this.tokenStartsLine() &&
138 - (!blockHeuristic || this.nextLineStart >= this.input.length ||
139 - this.indentationAfter(this.nextLineStart) < indent)
140 - }
141 -
142 - tokenStartsLine() {
143 - for (let p = this.tok.start - 1; p >= this.curLineStart; --p) {
144 - let ch = this.input.charCodeAt(p)
145 - if (ch !== 9 && ch !== 32) return false
146 - }
147 - return true
148 - }
149 -
150 - extend(name, f) {
151 - this[name] = f(this[name])
152 - }
153 -
154 - loadPlugins(pluginConfigs) {
155 - for (let name in pluginConfigs) {
156 - let plugin = pluginsLoose[name]
157 - if (!plugin) throw new Error("Plugin '" + name + "' not found")
158 - plugin(this, pluginConfigs[name])
159 - }
160 - }
161 -}
1 -import {tokTypes as tt, Token, isNewLine, SourceLocation, getLineInfo, lineBreakG} from "../index"
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 - if (this.inAsync && node.name === "await")
15 - this.raise(node.start, "Can not use 'await' as identifier inside an async function")
16 - break
17 -
18 - case "ObjectPattern":
19 - case "ArrayPattern":
20 - break
21 -
22 - case "ObjectExpression":
23 - node.type = "ObjectPattern"
24 - for (let i = 0; i < node.properties.length; i++) {
25 - let prop = node.properties[i]
26 - if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter")
27 - this.toAssignable(prop.value, isBinding)
28 - }
29 - break
30 -
31 - case "ArrayExpression":
32 - node.type = "ArrayPattern"
33 - this.toAssignableList(node.elements, isBinding)
34 - break
35 -
36 - case "AssignmentExpression":
37 - if (node.operator === "=") {
38 - node.type = "AssignmentPattern"
39 - delete node.operator
40 - this.toAssignable(node.left, isBinding)
41 - // falls through to AssignmentPattern
42 - } else {
43 - this.raise(node.left.end, "Only '=' operator can be used for specifying default value.")
44 - break
45 - }
46 -
47 - case "AssignmentPattern":
48 - break
49 -
50 - case "ParenthesizedExpression":
51 - node.expression = this.toAssignable(node.expression, isBinding)
52 - break
53 -
54 - case "MemberExpression":
55 - if (!isBinding) break
56 -
57 - default:
58 - this.raise(node.start, "Assigning to rvalue")
59 - }
60 - }
61 - return node
62 -}
63 -
64 -// Convert list of expression atoms to binding list.
65 -
66 -pp.toAssignableList = function(exprList, isBinding) {
67 - let end = exprList.length
68 - if (end) {
69 - let last = exprList[end - 1]
70 - if (last && last.type == "RestElement") {
71 - --end
72 - } else if (last && last.type == "SpreadElement") {
73 - last.type = "RestElement"
74 - let arg = last.argument
75 - this.toAssignable(arg, isBinding)
76 - if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern")
77 - this.unexpected(arg.start)
78 - --end
79 - }
80 -
81 - if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
82 - this.unexpected(last.argument.start)
83 - }
84 - for (let i = 0; i < end; i++) {
85 - let elt = exprList[i]
86 - if (elt) this.toAssignable(elt, isBinding)
87 - }
88 - return exprList
89 -}
90 -
91 -// Parses spread element.
92 -
93 -pp.parseSpread = function(refDestructuringErrors) {
94 - let node = this.startNode()
95 - this.next()
96 - node.argument = this.parseMaybeAssign(false, refDestructuringErrors)
97 - return this.finishNode(node, "SpreadElement")
98 -}
99 -
100 -pp.parseRest = function(allowNonIdent) {
101 - let node = this.startNode()
102 - this.next()
103 -
104 - // RestElement inside of a function parameter must be an identifier
105 - if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected()
106 - else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected()
107 -
108 - return this.finishNode(node, "RestElement")
109 -}
110 -
111 -// Parses lvalue (assignable) atom.
112 -
113 -pp.parseBindingAtom = function() {
114 - if (this.options.ecmaVersion < 6) return this.parseIdent()
115 - switch (this.type) {
116 - case tt.name:
117 - return this.parseIdent()
118 -
119 - case tt.bracketL:
120 - let node = this.startNode()
121 - this.next()
122 - node.elements = this.parseBindingList(tt.bracketR, true, true)
123 - return this.finishNode(node, "ArrayPattern")
124 -
125 - case tt.braceL:
126 - return this.parseObj(true)
127 -
128 - default:
129 - this.unexpected()
130 - }
131 -}
132 -
133 -pp.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) {
134 - let elts = [], first = true
135 - while (!this.eat(close)) {
136 - if (first) first = false
137 - else this.expect(tt.comma)
138 - if (allowEmpty && this.type === tt.comma) {
139 - elts.push(null)
140 - } else if (allowTrailingComma && this.afterTrailingComma(close)) {
141 - break
142 - } else if (this.type === tt.ellipsis) {
143 - let rest = this.parseRest(allowNonIdent)
144 - this.parseBindingListItem(rest)
145 - elts.push(rest)
146 - if (this.type === tt.comma) this.raise(this.start, "Comma is not permitted after the rest element")
147 - this.expect(close)
148 - break
149 - } else {
150 - let elem = this.parseMaybeDefault(this.start, this.startLoc)
151 - this.parseBindingListItem(elem)
152 - elts.push(elem)
153 - }
154 - }
155 - return elts
156 -}
157 -
158 -pp.parseBindingListItem = function(param) {
159 - return param
160 -}
161 -
162 -// Parses assignment pattern around given atom if possible.
163 -
164 -pp.parseMaybeDefault = function(startPos, startLoc, left) {
165 - left = left || this.parseBindingAtom()
166 - if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left
167 - let node = this.startNodeAt(startPos, startLoc)
168 - node.left = left
169 - node.right = this.parseMaybeAssign()
170 - return this.finishNode(node, "AssignmentPattern")
171 -}
172 -
173 -// Verify that a node is an lval — something that can be assigned
174 -// to.
175 -
176 -pp.checkLVal = function(expr, isBinding, checkClashes) {
177 - switch (expr.type) {
178 - case "Identifier":
179 - if (this.strict && this.reservedWordsStrictBind.test(expr.name))
180 - this.raiseRecoverable(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode")
181 - if (checkClashes) {
182 - if (has(checkClashes, expr.name))
183 - this.raiseRecoverable(expr.start, "Argument name clash")
184 - checkClashes[expr.name] = true
185 - }
186 - break
187 -
188 - case "MemberExpression":
189 - if (isBinding) this.raiseRecoverable(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression")
190 - break
191 -
192 - case "ObjectPattern":
193 - for (let i = 0; i < expr.properties.length; i++)
194 - this.checkLVal(expr.properties[i].value, isBinding, checkClashes)
195 - break
196 -
197 - case "ArrayPattern":
198 - for (let i = 0; i < expr.elements.length; i++) {
199 - let elem = expr.elements[i]
200 - if (elem) this.checkLVal(elem, isBinding, checkClashes)
201 - }
202 - break
203 -
204 - case "AssignmentPattern":
205 - this.checkLVal(expr.left, isBinding, checkClashes)
206 - break
207 -
208 - case "RestElement":
209 - this.checkLVal(expr.argument, isBinding, checkClashes)
210 - break
211 -
212 - case "ParenthesizedExpression":
213 - this.checkLVal(expr.expression, isBinding, checkClashes)
214 - break
215 -
216 - default:
217 - this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue")
218 - }
219 -}
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, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support
10 - // for strict mode, the set of reserved words, and support for
11 - // new syntax features. The default is 7.
12 - ecmaVersion: 7,
13 - // `sourceType` indicates the mode the code should be parsed in.
14 - // Can be either `"script"` or `"module"`. This influences global
15 - // strict mode and parsing of `import` and `export` declarations.
16 - sourceType: "script",
17 - // `onInsertedSemicolon` can be a callback that will be called
18 - // when a semicolon is automatically inserted. It will be passed
19 - // th position of the comma as an offset, and if `locations` is
20 - // enabled, it is given the location as a `{line, column}` object
21 - // as second argument.
22 - onInsertedSemicolon: null,
23 - // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
24 - // trailing commas.
25 - onTrailingComma: null,
26 - // By default, reserved words are only enforced if ecmaVersion >= 5.
27 - // Set `allowReserved` to a boolean value to explicitly turn this on
28 - // an off. When this option has the value "never", reserved words
29 - // and keywords can also not be used as property names.
30 - allowReserved: null,
31 - // When enabled, a return at the top level is not considered an
32 - // error.
33 - allowReturnOutsideFunction: false,
34 - // When enabled, import/export statements are not constrained to
35 - // appearing at the top of the program.
36 - allowImportExportEverywhere: false,
37 - // When enabled, hashbang directive in the beginning of file
38 - // is allowed and treated as a line comment.
39 - allowHashBang: false,
40 - // When `locations` is on, `loc` properties holding objects with
41 - // `start` and `end` properties in `{line, column}` form (with
42 - // line being 1-based and column 0-based) will be attached to the
43 - // nodes.
44 - locations: false,
45 - // A function can be passed as `onToken` option, which will
46 - // cause Acorn to call that function with object in the same
47 - // format as tokens returned from `tokenizer().getToken()`. Note
48 - // that you are not allowed to call the parser from the
49 - // callback—that will corrupt its internal state.
50 - onToken: null,
51 - // A function can be passed as `onComment` option, which will
52 - // cause Acorn to call that function with `(block, text, start,
53 - // end)` parameters whenever a comment is skipped. `block` is a
54 - // boolean indicating whether this is a block (`/* */`) comment,
55 - // `text` is the content of the comment, and `start` and `end` are
56 - // character offsets that denote the start and end of the comment.
57 - // When the `locations` option is on, two more parameters are
58 - // passed, the full `{line, column}` locations of the start and
59 - // end of the comments. Note that you are not allowed to call the
60 - // parser from the callback—that will corrupt its internal state.
61 - onComment: null,
62 - // Nodes have their start and end characters offsets recorded in
63 - // `start` and `end` properties (directly on the node, rather than
64 - // the `loc` object, which holds line/column data. To also add a
65 - // [semi-standardized][range] `range` property holding a `[start,
66 - // end]` array with the same numbers, set the `ranges` option to
67 - // `true`.
68 - //
69 - // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
70 - ranges: false,
71 - // It is possible to parse multiple files into a single AST by
72 - // passing the tree produced by parsing the first file as
73 - // `program` option in subsequent parses. This will add the
74 - // toplevel forms of the parsed file to the `Program` (top) node
75 - // of an existing parse tree.
76 - program: null,
77 - // When `locations` is on, you can pass this to record the source
78 - // file in every node's `loc` object.
79 - sourceFile: null,
80 - // This value, if given, is stored in every node, whether
81 - // `locations` is on or off.
82 - directSourceFile: null,
83 - // When enabled, parenthesized expressions are represented by
84 - // (non-standard) ParenthesizedExpression nodes
85 - preserveParens: false,
86 - plugins: {}
87 -}
88 -
89 -// Interpret and default an options object
90 -
91 -export function getOptions(opts) {
92 - let options = {}
93 -
94 - for (let opt in defaultOptions)
95 - options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]
96 -
97 - if (options.ecmaVersion >= 2015)
98 - options.ecmaVersion -= 2009
99 -
100 - if (options.allowReserved == null)
101 - options.allowReserved = options.ecmaVersion < 5
102 -
103 - if (isArray(options.onToken)) {
104 - let tokens = options.onToken
105 - options.onToken = (token) => tokens.push(token)
106 - }
107 - if (isArray(options.onComment))
108 - options.onComment = pushComment(options, options.onComment)
109 -
110 - return options
111 -}
112 -
113 -function pushComment(options, array) {
114 - return function (block, text, start, end, startLoc, endLoc) {
115 - let comment = {
116 - type: block ? 'Block' : 'Line',
117 - value: text,
118 - start: start,
119 - end: end
120 - }
121 - if (options.locations)
122 - comment.loc = new SourceLocation(this, startLoc, endLoc)
123 - if (options.ranges)
124 - comment.range = [start, end]
125 - array.push(comment)
126 - }
127 -}
128 -
1 -import {types as tt} from "./tokentype"
2 -import {Parser} from "./state"
3 -import {lineBreak, skipWhiteSpace} from "./whitespace"
4 -
5 -const pp = Parser.prototype
6 -
7 -// ## Parser utilities
8 -
9 -const literal = /^(?:'((?:[^\']|\.)*)'|"((?:[^\"]|\.)*)"|;)/
10 -pp.strictDirective = function(start) {
11 - for (;;) {
12 - skipWhiteSpace.lastIndex = start
13 - start += skipWhiteSpace.exec(this.input)[0].length
14 - let match = literal.exec(this.input.slice(start))
15 - if (!match) return false
16 - if ((match[1] || match[2]) == "use strict") return true
17 - start += match[0].length
18 - }
19 -}
20 -
21 -// Predicate that tests whether the next token is of the given
22 -// type, and if yes, consumes it as a side effect.
23 -
24 -pp.eat = function(type) {
25 - if (this.type === type) {
26 - this.next()
27 - return true
28 - } else {
29 - return false
30 - }
31 -}
32 -
33 -// Tests whether parsed token is a contextual keyword.
34 -
35 -pp.isContextual = function(name) {
36 - return this.type === tt.name && this.value === name
37 -}
38 -
39 -// Consumes contextual keyword if possible.
40 -
41 -pp.eatContextual = function(name) {
42 - return this.value === name && this.eat(tt.name)
43 -}
44 -
45 -// Asserts that following token is given contextual keyword.
46 -
47 -pp.expectContextual = function(name) {
48 - if (!this.eatContextual(name)) this.unexpected()
49 -}
50 -
51 -// Test whether a semicolon can be inserted at the current position.
52 -
53 -pp.canInsertSemicolon = function() {
54 - return this.type === tt.eof ||
55 - this.type === tt.braceR ||
56 - lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
57 -}
58 -
59 -pp.insertSemicolon = function() {
60 - if (this.canInsertSemicolon()) {
61 - if (this.options.onInsertedSemicolon)
62 - this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc)
63 - return true
64 - }
65 -}
66 -
67 -// Consume a semicolon, or, failing that, see if we are allowed to
68 -// pretend that there is a semicolon at this position.
69 -
70 -pp.semicolon = function() {
71 - if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected()
72 -}
73 -
74 -pp.afterTrailingComma = function(tokType, notNext) {
75 - if (this.type == tokType) {
76 - if (this.options.onTrailingComma)
77 - this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc)
78 - if (!notNext)
79 - this.next()
80 - return true
81 - }
82 -}
83 -
84 -// Expect a token of a given type. If found, consume it, otherwise,
85 -// raise an unexpected token error.
86 -
87 -pp.expect = function(type) {
88 - this.eat(type) || this.unexpected()
89 -}
90 -
91 -// Raise an unexpected token error.
92 -
93 -pp.unexpected = function(pos) {
94 - this.raise(pos != null ? pos : this.start, "Unexpected token")
95 -}
96 -
97 -export class DestructuringErrors {
98 - constructor() {
99 - this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = -1
100 - }
101 -}
102 -
103 -pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
104 - if (!refDestructuringErrors) return
105 - if (refDestructuringErrors.trailingComma > -1)
106 - this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element")
107 - let parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind
108 - if (parens > -1) this.raiseRecoverable(parens, "Parenthesized pattern")
109 -}
110 -
111 -pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
112 - let pos = refDestructuringErrors ? refDestructuringErrors.shorthandAssign : -1
113 - if (!andThrow) return pos >= 0
114 - if (pos > -1) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns")
115 -}
116 -
117 -pp.checkYieldAwaitInDefaultParams = function() {
118 - if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
119 - this.raise(this.yieldPos, "Yield expression cannot be a default value")
120 - if (this.awaitPos)
121 - this.raise(this.awaitPos, "Await expression cannot be a default value")
122 -}
123 -
124 -pp.isSimpleAssignTarget = function(expr) {
125 - if (expr.type === "ParenthesizedExpression")
126 - return this.isSimpleAssignTarget(expr.expression)
127 - return expr.type === "Identifier" || expr.type === "MemberExpression"
128 -}
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 = ""
19 - if (!options.allowReserved) {
20 - for (let v = options.ecmaVersion;; v--)
21 - if (reserved = reservedWords[v]) break
22 - if (options.sourceType == "module") reserved += " await"
23 - }
24 - this.reservedWords = keywordRegexp(reserved)
25 - let reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict
26 - this.reservedWordsStrict = keywordRegexp(reservedStrict)
27 - this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind)
28 - this.input = String(input)
29 -
30 - // Used to signal to callers of `readWord1` whether the word
31 - // contained any escape sequences. This is needed because words with
32 - // escape sequences must not be interpreted as keywords.
33 - this.containsEsc = false
34 -
35 - // Load plugins
36 - this.loadPlugins(options.plugins)
37 -
38 - // Set up token state
39 -
40 - // The current position of the tokenizer in the input.
41 - if (startPos) {
42 - this.pos = startPos
43 - this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1
44 - this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length
45 - } else {
46 - this.pos = this.lineStart = 0
47 - this.curLine = 1
48 - }
49 -
50 - // Properties of the current token:
51 - // Its type
52 - this.type = tt.eof
53 - // For tokens that include more information than their type, the value
54 - this.value = null
55 - // Its start and end offset
56 - this.start = this.end = this.pos
57 - // And, if locations are used, the {line, column} object
58 - // corresponding to those offsets
59 - this.startLoc = this.endLoc = this.curPosition()
60 -
61 - // Position information for the previous token
62 - this.lastTokEndLoc = this.lastTokStartLoc = null
63 - this.lastTokStart = this.lastTokEnd = this.pos
64 -
65 - // The context stack is used to superficially track syntactic
66 - // context to predict whether a regular expression is allowed in a
67 - // given position.
68 - this.context = this.initialContext()
69 - this.exprAllowed = true
70 -
71 - // Figure out if it's a module code.
72 - this.inModule = options.sourceType === "module"
73 - this.strict = this.inModule || this.strictDirective(this.pos)
74 -
75 - // Used to signify the start of a potential arrow function
76 - this.potentialArrowAt = -1
77 -
78 - // Flags to track whether we are in a function, a generator, an async function.
79 - this.inFunction = this.inGenerator = this.inAsync = false
80 - // Positions to delayed-check that yield/await does not exist in default parameters.
81 - this.yieldPos = this.awaitPos = 0
82 - // Labels in scope.
83 - this.labels = []
84 -
85 - // If enabled, skip leading hashbang line.
86 - if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === '#!')
87 - this.skipLineComment(2)
88 - }
89 -
90 - // DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them
91 - isKeyword(word) { return this.keywords.test(word) }
92 - isReservedWord(word) { return this.reservedWords.test(word) }
93 -
94 - extend(name, f) {
95 - this[name] = f(this[name])
96 - }
97 -
98 - loadPlugins(pluginConfigs) {
99 - for (let name in pluginConfigs) {
100 - let plugin = plugins[name]
101 - if (!plugin) throw new Error("Plugin '" + name + "' not found")
102 - plugin(this, pluginConfigs[name])
103 - }
104 - }
105 -
106 - parse() {
107 - let node = this.options.program || this.startNode()
108 - this.nextToken()
109 - return this.parseTopLevel(node)
110 - }
111 -}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 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 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 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 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 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 could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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.