김건

Merge branch 'server' into 'master'

Server

Front end 구현

See merge request !5
Showing 602 changed files with 4078 additions and 805 deletions
No preview for this file type
1 -# Byte-compiled / optimized / DLL files
2 -__pycache__/
3 -*.py[cod]
4 -
5 -# C extensions
6 -*.so
7 -
8 -# Distribution / packaging
9 -.Python
10 -env/
11 -build/
12 -develop-eggs/
13 -dist/
14 -downloads/
15 -eggs/
16 -.eggs/
17 -lib/
18 -lib64/
19 -parts/
20 -sdist/
21 -var/
22 -*.egg-info/
23 -.installed.cfg
24 -*.egg
25 -
26 -# PyInstaller
27 -# Usually these files are written by a python script from a template
28 -# before PyInstaller builds the exe, so as to inject date/other infos into it.
29 -*.manifest
30 -*.spec
31 -
32 -# Installer logs
33 -pip-log.txt
34 -pip-delete-this-directory.txt
35 -
36 -# Unit test / coverage reports
37 -htmlcov/
38 -.tox/
39 -.coverage
40 -.coverage.*
41 -.cache
42 -nosetests.xml
43 -coverage.xml
44 -*,cover
45 -
46 -# Translations
47 -*.mo
48 -*.pot
49 -
50 -# Django stuff:
51 -*.log
52 -
53 -# Sphinx documentation
54 -docs/_build/
55 -
56 -# PyBuilder
57 -target/
1 -# youtube-comment-downloader
2 -Simple script for downloading Youtube comments without using the Youtube API. The output is in line delimited JSON.
3 -
4 -### Dependencies
5 -* Python 2.7+
6 -* requests
7 -* lxml
8 -* cssselect
9 -
10 -The python packages can be installed with
11 -
12 - pip install requests
13 - pip install lxml
14 - pip install cssselect
15 -
16 -### Usage
17 -```
18 -usage: downloader.py [--help] [--youtubeid YOUTUBEID] [--output OUTPUT]
19 -
20 -Download Youtube comments without using the Youtube API
21 -
22 -optional arguments:
23 - --help, -h Show this help message and exit
24 - --youtubeid YOUTUBEID, -y YOUTUBEID
25 - ID of Youtube video for which to download the comments
26 - --output OUTPUT, -o OUTPUT
27 - Output filename (output format is line delimited JSON)
28 -```
1 -#!/usr/bin/env python
2 -
3 -from __future__ import print_function
4 -import sys
5 -import os
6 -import time
7 -import json
8 -import requests
9 -import argparse
10 -import lxml.html
11 -import io
12 -from urllib.parse import urlparse, parse_qs
13 -from lxml.cssselect import CSSSelector
14 -
15 -YOUTUBE_COMMENTS_URL = 'https://www.youtube.com/all_comments?v={youtube_id}'
16 -YOUTUBE_COMMENTS_AJAX_URL = 'https://www.youtube.com/comment_ajax'
17 -
18 -USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'
19 -
20 -
21 -def find_value(html, key, num_chars=2):
22 - pos_begin = html.find(key) + len(key) + num_chars
23 - pos_end = html.find('"', pos_begin)
24 - return html[pos_begin: pos_end]
25 -
26 -
27 -def extract_comments(html):
28 - tree = lxml.html.fromstring(html)
29 - item_sel = CSSSelector('.comment-item')
30 - text_sel = CSSSelector('.comment-text-content')
31 - time_sel = CSSSelector('.time')
32 - author_sel = CSSSelector('.user-name')
33 -
34 - for item in item_sel(tree):
35 - yield {'cid': item.get('data-cid'),
36 - 'text': text_sel(item)[0].text_content(),
37 - 'time': time_sel(item)[0].text_content().strip(),
38 - 'author': author_sel(item)[0].text_content()}
39 -
40 -
41 -def extract_reply_cids(html):
42 - tree = lxml.html.fromstring(html)
43 - sel = CSSSelector('.comment-replies-header > .load-comments')
44 - return [i.get('data-cid') for i in sel(tree)]
45 -
46 -
47 -def ajax_request(session, url, params, data, retries=10, sleep=20):
48 - for _ in range(retries):
49 - response = session.post(url, params=params, data=data)
50 - if response.status_code == 200:
51 - response_dict = json.loads(response.text)
52 - return response_dict.get('page_token', None), response_dict['html_content']
53 - else:
54 - time.sleep(sleep)
55 -
56 -
57 -def download_comments(youtube_id, sleep=1):
58 - session = requests.Session()
59 - session.headers['User-Agent'] = USER_AGENT
60 - # Get Youtube page with initial comments
61 - response = session.get(YOUTUBE_COMMENTS_URL.format(youtube_id=youtube_id))
62 - html = response.text
63 - reply_cids = extract_reply_cids(html)
64 -
65 - ret_cids = []
66 - for comment in extract_comments(html):
67 - ret_cids.append(comment['cid'])
68 - yield comment
69 - page_token = find_value(html, 'data-token')
70 - session_token = find_value(html, 'XSRF_TOKEN', 4)
71 - first_iteration = True
72 -
73 - # Get remaining comments (the same as pressing the 'Show more' button)
74 - while page_token:
75 - data = {'video_id': youtube_id,
76 - 'session_token': session_token}
77 -
78 - params = {'action_load_comments': 1,
79 - 'order_by_time': True,
80 - 'filter': youtube_id}
81 -
82 - if first_iteration:
83 - params['order_menu'] = True
84 - else:
85 - data['page_token'] = page_token
86 -
87 - response = ajax_request(session, YOUTUBE_COMMENTS_AJAX_URL, params, data)
88 - if not response:
89 - break
90 -
91 - page_token, html = response
92 -
93 - reply_cids += extract_reply_cids(html)
94 - for comment in extract_comments(html):
95 - if comment['cid'] not in ret_cids:
96 - ret_cids.append(comment['cid'])
97 - yield comment
98 -
99 - first_iteration = False
100 - time.sleep(sleep)
101 - # Get replies (the same as pressing the 'View all X replies' link)
102 - for cid in reply_cids:
103 - data = {'comment_id': cid,
104 - 'video_id': youtube_id,
105 - 'can_reply': 1,
106 - 'session_token': session_token}
107 - params = {'action_load_replies': 1,
108 - 'order_by_time': True,
109 - 'filter': youtube_id,
110 - 'tab': 'inbox'}
111 - response = ajax_request(session, YOUTUBE_COMMENTS_AJAX_URL, params, data)
112 - if not response:
113 - break
114 -
115 - _, html = response
116 -
117 - for comment in extract_comments(html):
118 - if comment['cid'] not in ret_cids:
119 - ret_cids.append(comment['cid'])
120 - yield comment
121 - time.sleep(sleep)
122 -
123 -## input video 값 parsing
124 -def video_id(value):
125 - query = urlparse(value)
126 - if query.hostname == 'youtu.be':
127 - return query.path[1:]
128 - if query.hostname in ('www.youtube.com', 'youtube.com'):
129 - if query.path == '/watch':
130 - p = parse_qs(query.query)
131 - return p['v'][0]
132 - if query.path[:7] == '/embed/':
133 - return query.path.split('/')[2]
134 - if query.path[:3] == '/v/':
135 - return query.path.split('/')[2]
136 - # fail?
137 - return None
138 -
139 -
140 -def main():
141 -
142 - #parser = argparse.ArgumentParser(add_help=False, description=('Download Youtube comments without using the Youtube API'))
143 - #parser.add_argument('--help', '-h', action='help', default=argparse.SUPPRESS, help='Show this help message and exit')
144 - #parser.add_argument('--youtubeid', '-y', help='ID of Youtube video for which to download the comments')
145 - #parser.add_argument('--output', '-o', help='Output filename (output format is line delimited JSON)')
146 - #parser.add_argument('--limit', '-l', type=int, help='Limit the number of comments')
147 - Youtube_id1 = input('Youtube_ID 입력 :')
148 - ## Cutting Link를 받고 id만 딸 수 있도록
149 - Youtube_id1 = video_id(Youtube_id1)
150 - youtube_id = Youtube_id1
151 - try:
152 - # args = parser.parse_args(argv)
153 -
154 - #youtube_id = args.youtubeid
155 - #output = args.output
156 - #limit = args.limit
157 - result_List = []
158 - ## input 값을 받고 값에 할당
159 -
160 - ## Limit에 빈 값이 들어갈 경우 Default 값으로 100을 넣게 하였음
161 - if not youtube_id :
162 - #parser.print_usage()
163 - #raise ValueError('you need to specify a Youtube ID and an output filename')
164 - raise ValueError('올바른 입력 값을 입력하세요')
165 -
166 - print('Downloading Youtube comments for video:', youtube_id)
167 - Number = input(' 저장 - 0 저장 안함- 1 : ')
168 - if Number == '0' :
169 - Output1 = input('결과를 받을 파일 입력 :')
170 - Limit1 = input('제한 갯수 입력 : ')
171 - if Limit1 == '' :
172 - Limit1 = 100
173 - Limit1 = int(Limit1)
174 - limit = int(Limit1)
175 -
176 - output = Output1
177 - ##### argument로 받지 않고 input으로 받기 위한 것
178 - with io.open(output, 'w', encoding='utf8') as fp:
179 - for comment in download_comments(youtube_id):
180 - comment_json = json.dumps(comment, ensure_ascii=False)
181 - print(comment_json.decode('utf-8') if isinstance(comment_json, bytes) else comment_json, file=fp)
182 - count += 1
183 - sys.stdout.flush()
184 - if limit and count >= limit:
185 - print('Downloaded {} comment(s)\r'.format(count))
186 - print('\nDone!')
187 - break
188 -
189 - else :
190 - count = 0
191 - i = 0
192 - limit = 40
193 - for comment in download_comments(youtube_id):
194 - dic = {}
195 - dic['cid'] = comment['cid']
196 - dic['text'] = comment['text']
197 - dic['time'] = comment['time']
198 - dic['author'] = comment['author']
199 - result_List.append(dic)
200 - count += 1
201 - i += 1
202 - if limit == count :
203 - print(' Comment Thread 생성 완료')
204 - print ('\n\n\n\n\n\n\n')
205 - break
206 - return result_List
207 - #goto_Menu(result_List)
208 -
209 -
210 -
211 - except Exception as e:
212 - print('Error:', str(e))
213 - sys.exit(1)
214 -
215 -
216 -if __name__ == "__main__":
217 - main()
1 -import downloader
2 -from time import sleep
3 -from konlpy.tag import Twitter
4 -from collections import Counter
5 -from matplotlib import rc
6 -import matplotlib.pyplot as plt
7 -from matplotlib import font_manager as fm
8 -import pytagcloud
9 -import operator
10 -def get_tags (Comment_List) :
11 -
12 - okja = []
13 - for temp in Comment_List :
14 - okja.append(temp['text'])
15 - twitter = Twitter()
16 - sentence_tag =[]
17 - for sentence in okja:
18 - morph = twitter.pos(sentence)
19 - sentence_tag.append(morph)
20 - print(morph)
21 - print('-'*30)
22 - print(sentence_tag)
23 - print(len(sentence_tag))
24 - print('\n'*3)
25 -
26 - noun_adj_list = []
27 - for sentence1 in sentence_tag:
28 - for word,tag in sentence1:
29 - if len(word) >=2 and tag == 'Noun':
30 - noun_adj_list.append(word)
31 - counts = Counter(noun_adj_list)
32 - print(' 가장 많이 등장한 10개의 키워드. \n')
33 - print(counts.most_common(10))
34 - tags2 = counts.most_common(10)
35 - taglist = pytagcloud.make_tags(tags2,maxsize=80)
36 - pytagcloud.create_tag_image(taglist,'wordcloud.jpg',size =(900,600),fontname ='Nanum Gothic', rectangular = False)
37 -
38 -def print_result(Comment_List) :
39 - for var in Comment_List :
40 - print(var)
41 - print('******* 검색 완료 *******')
42 - print('\n\n\n')
43 -
44 -def search_by_author(Comment_List,author_name) :
45 - result_List = []
46 -
47 - for var in Comment_List :
48 - if (var['author'] == author_name) :
49 - result_List.append(var)
50 -
51 - return result_List
52 -def search_by_keyword(Comment_List,keyword) :
53 - result_List = []
54 - for var in Comment_List :
55 - print(var['text'])
56 - if ( keyword in var['text']) :
57 - result_List.append(var)
58 -
59 - return result_List
60 -def search_by_time(Comment_List,Time_input) :
61 - result_List = []
62 - for var in Comment_List :
63 - if(var['time'] == Time_input) :
64 - result_List.append(var)
65 - return result_List
66 -
67 -def make_time_chart (Comment_List) :
68 - result_List = []
69 - save_List = []
70 - day_dict = {}
71 - month_dict = {}
72 - year_dict = {}
73 - hour_dict = {}
74 - minute_dict = {}
75 - week_dict = {}
76 - for var in Comment_List :
77 - result_List.append(var['time'])
78 - for i in range(len(result_List)) :
79 - print(result_List[i] + ' ')
80 - print('\n\n\n\n')
81 - temp_List = list(set(result_List))
82 - for i in range(len(temp_List)) :
83 - print(temp_List[i] + ' ')
84 - print('\n\n\n\n')
85 - for i in range (len(temp_List)) :
86 - result_dict = {}
87 - a = result_List.count(temp_List[i])
88 - result_dict[temp_List[i]] = a
89 - save_List.append(result_dict)
90 -
91 - for i in range (len(save_List)):
92 - num = ''
93 - data = 0
94 - for j in save_List[i] :
95 - num = j
96 - for k in save_List[i].values() :
97 - data = k
98 - if num.find('개월') >= 0 :
99 - month_dict[num] = k
100 - elif num.find('일') >= 0 :
101 - day_dict[num] = k
102 - elif num.find('년') >= 0 :
103 - year_dict[num] = k
104 - elif num.find('시간') >= 0 :
105 - hour_dict[num] = k
106 - elif num.find('주') >= 0 :
107 - week_dict[num] = k
108 - elif num.find('분') >= 0 :
109 - minute_dict[num] = k
110 - year_data = sorted(year_dict.items(), key=operator.itemgetter(0))
111 - month_data = sorted(month_dict.items(), key=operator.itemgetter(0))
112 - week_data = sorted(week_dict.items(), key=operator.itemgetter(0))
113 - day_data = sorted(day_dict.items(), key=operator.itemgetter(0))
114 - hour_data = sorted(hour_dict.items(), key=operator.itemgetter(0))
115 - minute_data = sorted(minute_dict.items(), key=operator.itemgetter(0))
116 - #print(month_data)
117 - #print(week_data)
118 - #print(day_data)
119 - make_chart(year_data,month_data,week_data,day_data,hour_data,minute_data)
120 -
121 -def make_chart(year_data,month_data,week_data,day_data,hour_data,minute_data) :
122 - temp_list = [year_data,month_data,week_data,day_data,hour_data,minute_data]
123 - x_list = []
124 - y_list = []
125 - print(temp_list)
126 - for var1 in temp_list :
127 - for var2 in var1 :
128 - if(var2[0].find('년')>=0):
129 - temp1 = var2[0][0] + 'years'
130 - temp2 = int(var2[1])
131 - x_list.append(temp1)
132 - y_list.append(temp2)
133 - elif(var2[0].find('개월')>=0):
134 - temp1 = var2[0][0] + 'months'
135 - temp2 = int(var2[1])
136 - x_list.append(temp1)
137 - y_list.append(temp2)
138 - elif(var2[0].find('주')>=0):
139 - temp1 = var2[0][0] + 'weeks'
140 - temp2 = int(var2[1])
141 - x_list.append(temp1)
142 - y_list.append(temp2)
143 - elif(var2[0].find('일')>=0):
144 - temp1 = var2[0][0] + 'days'
145 - temp2 = int(var2[1])
146 - x_list.append(temp1)
147 - y_list.append(temp2)
148 - elif(var2[0].find('시간')>=0):
149 - temp1 = var2[0][0] + 'hours'
150 - temp2 = int(var2[1])
151 - x_list.append(temp1)
152 - y_list.append(temp2)
153 - else:
154 - temp1 = var2[0][0] + 'minutes'
155 - temp2 = int(var2[1])
156 - x_list.append(temp1)
157 - y_list.append(temp2)
158 - print(x_list)
159 - plt.bar(x_list,y_list,width = 0.5 , color = "blue")
160 - # plt.show() -> 출력
161 - plt.savefig('chart.png',dpi=300)
162 - # plt.savefig('chart.png', dpi=300)
163 -
164 -def call_main ():
165 - print(' Comment Thread 생성중 \n')
166 -
167 - sleep(1)
168 - print(' **************************************************************')
169 - print(' **************************************************************')
170 - print(' **************************************************************')
171 - print(' **************** 생성 완료 정보를 입력하세요. **************** ')
172 - print(' **************************************************************')
173 - print(' **************************************************************')
174 - print(' **************************************************************')
175 - a = downloader.main()
176 -
177 - return a
178 -
179 -if __name__ == "__main__":
180 - CommentList = call_main()
181 - make_time_chart(CommentList)
182 - ##author_results = search_by_author(CommentList,'광고제거기')
183 - ##text_resutls = search_by_keyword(CommentList,'지현')
184 - ##get_tags(CommentList)
185 - ##print_result(author_results)
186 - ##print_result(text_resutls)
1 -requests
2 -beautifulsoup4
3 -lxml
4 -cssselect
5 -### ũѸ
6 -pygame
7 -pytagcloud
8 -### wordcloud
9 -Jpye1
10 -### Ű м
11 -python -m pip install -U matplotlib==3.2.0rc1
1 -1. Data 받아오기
2 - 1) selenuim을 이용하여 웹페이지에서 데이터를 검색
3 - 2) 원하는 URL 입력받는다
4 - 3) headless하게 구현하기 위해 chrome option 적용하여 driver 생성
5 - 4) naverNews는 댓글 영역 하단 부 '더보기'를 지속적으로 눌러줘야하므로
6 - driver의 find_element_by_css_selector함수로 해당 class인
7 - u_cbox_btn_more을 페이지가 끝날 때까지 돌림
8 - 5) 위의 과정에서 얻은 페이지 소스를 beautifulSoup을 이용하여, find_all을 통해 {사용자ID, 댓글, 작성시간}의 데이터를 각각 raw하게 뽑음. (naverNews의 제한적인 특징으로 사용자ID 뒤 4자리는 비공개처리됨)
9 -
10 -2. 사용할 DataSet으로 가공
11 - 1) 리스트 형태로 각각 nicknames(사용자ID), comments(댓글), times(작성시간)을 뽑아냄
12 - 2) 세 리스트에서 짝을 이루는 쌍을 dictionary형태로 {사용자ID, 댓글, 작성시간} 다음과 같이 저장
13 - 3) 저장된 dictionary list(info_dic)을 최종 결과 리스트인 naverNewsList에 저장한다.
14 -
15 -3. 함수 구현
16 - 1) KEYWORD 기반 검색 기능
17 - 2) 가장 자주 나온 단어 검색 기능
18 - 3) ID 기반 검색 기능
19 - 4) 시간 대별 검색 기능
20 - 등 여러 함수 구현 예정
21 -
22 -=> 수정사항
23 -
24 - data를 get하여 정제하는 파일을 모듈로 분리해 내어 list형태로 저장된 데이터셋을 반환하여
25 - main 에서 사용할 수 있도록 한다. 이 후 main에서 리스트를 받아와 url을 입력받아 데이터를
26 - 받아오는 방식으로 사용한다. 이 후, keyword기반, id기반, 시간대 기반 검색 함수를 구현하였고
27 - 시간대별 검색 함수의 기능 보강과 가장 자주 나온 단어 검색 기능을 추가 구현할 예정이다.
28 -
29 -* 4차 수정사항
30 -
31 - 기존파일의 분리 관리 시, import관련 오류 문제 해결 완료(하나의 파일로 관리)
32 - 사용자 UI의 틀을 구축해놓았고, 곧바로 함수별 추가 세부 구현 예정
33 -
34 -* 5차 수정사항
35 -
36 - 1) 네이버 댓글공간엑서 받아온 날짜 정보를 YYYY-MM-DD형식으로 바꿈. ('방금 전, 몇 분 전, 몇 시간 전, 몇 일 전'의 경우를 처리하기 위해 dateTime과 timeDelta 모듈을 활용하여
37 - 현재 날짜를 기준으로 계산하여 YYYY-MM-DD로 저장될 수 있도록
38 - 코드 추가)
39 - 2) 시간대별로 (시작시간, 끝시간)을 입력하여 그 시간에 해당하는 기사를 출력해주는 함수 구현
40 -
41 - 가장 자주 많이 나온 단어 검색과 MATPLOTLIB을 활용한 시각적 표현 구현 예정
42 -
43 -* 6차 수정사항
44 -
45 - konlpy를 활용한 명사 추출 및 단어 빈도수가 많으 순대로 사용자가 입력한 limit만큼 출력해주는 함수 구현 완료
...\ No newline at end of file ...\ No newline at end of file
1 -from selenium import webdriver
2 -from selenium.common import exceptions
3 -from bs4 import BeautifulSoup
4 -from datetime import datetime, timedelta
5 -from konlpy.tag import Twitter
6 -from collections import Counter
7 -import time
8 -
9 -
10 -def getData(url):
11 - ## chrome option걸기 (headless하게 웹 크롤링 수행하기 위해<웹페이지 안보이게 하기>)
12 - options = webdriver.ChromeOptions()
13 - #options.add_argument('headless')
14 - #options.add_argument("disable-gpu")
15 - #_url = "https://entertain.naver.com/ranking/comment/list?oid=144&aid=0000642175" # 크롤링할 URL
16 - _url = url # 크롤링할 URL
17 - webDriver = "C:\\Users\\user\\Desktop\\chromedriver_win32\\chromedriver.exe" # 내 웹드라이버 위치
18 - driver = webdriver.Chrome(webDriver,chrome_options=options)
19 - #driver = webdriver.Chrome(webDriver)
20 - driver.get(_url)
21 - pageCnt = 0
22 - driver.implicitly_wait(3) # 페이지가 다 로드 될때까지 기다리게함
23 - try:
24 - while True: # 댓글 페이지 끝날때까지 돌림
25 - #driver의 find_element_by_css_selector함수로 '네이버 뉴스'의 댓글 '더보기' 버튼을 찾아서 계속 클릭해준다(끝까지)
26 - driver.find_element_by_css_selector(".u_cbox_btn_more").click()
27 - pageCnt = pageCnt+1
28 -
29 - except exceptions.ElementNotVisibleException as e: # 페이지가 끝남
30 - pass
31 -
32 - except Exception as e: # 다른 예외 발생시 확인
33 - print(e)
34 -
35 - pageSource = driver.page_source # 페이지 소스를 따와서
36 - result = BeautifulSoup(pageSource, "lxml") # 빠르게 뽑아오기 위해 lxml 사용
37 -
38 - # nickname, text, time을 raw하게 뽑아온다
39 - comments_raw = result.find_all("span", {"class" : "u_cbox_contents"})
40 - nicknames_raw = result.find_all("span", {"class" : "u_cbox_nick"})
41 - times_raw = result.find_all("span", {"class" : "u_cbox_date"})
42 -
43 - # nickname, text, time 값 만을 뽑아내어 리스트로 정리한다
44 - comments = [comment.text for comment in comments_raw]
45 - nicknames = [nickname.text for nickname in nicknames_raw]
46 - times = [time.text for time in times_raw]
47 -
48 - naverNewsList = []
49 -
50 - for i in range(len(comments)):
51 - info_dic = {'userID' : nicknames[i], 'comment' : comments[i], 'time' : times[i]}
52 - naverNewsList.append(info_dic)
53 -
54 - return naverNewsList
55 - #driver.quit()
56 -
57 -from time import sleep
58 -
59 -def print_cList(c_List) :
60 - for item in c_List :
61 - print(item)
62 -
63 -def search_by_author(c_List,user_ID) :
64 - result_List = []
65 - for item in c_List :
66 - #print(item['userID'])
67 - if ( user_ID in item['userID']) :
68 - result_List.append(item)
69 - return result_List
70 -
71 -def search_by_keyword(c_List,keyword) :
72 - result_List = []
73 - for item in c_List :
74 - #print(item['comment'])
75 - if ( keyword in item['comment']) :
76 - result_List.append(item)
77 - return result_List
78 -
79 -def refine_time(c_List): # 시간에서 몇일 전, 몇 분 전, 방금 전 등의 형태를 YYYY.MM.DD로 바꿔준다
80 - now = datetime.now()
81 -
82 - for item in c_List:
83 - if (item['time'].find('전') != -1): # ~~전이 있으면
84 - if (item['time'].find('일 전') != -1): # ~일 전이라면
85 - _day = -(int)(item['time'][0]) # 몇 일전인지에 대한 정수형 변수
86 - tempTime = now + timedelta(days=_day)
87 - item['time'] = str(tempTime)
88 - item['time'] = item['time'][0:10]
89 - continue
90 - elif (item['time'].find('시간 전') != -1):
91 - _index = item['time'].index('시')
92 - _time = -(int)(item['time'][0:_index]) # 몇 시간 전인지에 대한 정수형 변수
93 - tempTime = now + timedelta(hours = _time)
94 - item['time'] = str(tempTime)
95 - item['time'] = item['time'][0:10]
96 - continue
97 - elif (item['time'].find('분 전') != -1):
98 - _index = item['time'].index('분')
99 - _minute = -(int)(item['time'][0:_index]) # 몇 분 전인지에 대한 정수형 변수
100 - tempTime = now + timedelta(minutes = _minute)
101 - item['time'] = str(tempTime)
102 - item['time'] = item['time'][0:10]
103 - continue
104 - elif (item['time'].find('방금 전') != -1):
105 - tempTime = now
106 - item['time'] = str(tempTime)
107 - item['time'] = item['time'][0:10]
108 - continue
109 - else:
110 - item['time'] = item['time'][0:10]
111 - continue
112 -
113 -
114 -
115 -
116 -
117 -def search_by_time(c_List,startTime, endTime) :
118 - result_List = []
119 -
120 - startYear = int(startTime[0:4])
121 -
122 - if (int(startTime[5]) == 0): # 한자리의 월일 때
123 - startMonth = int(startTime[6])
124 - else:
125 - startMonth = int(startTime[5:7])
126 -
127 - if (int(startTime[8]) == 0): # 한자리의 일일 때
128 - startDay = int(startTime[9])
129 - else:
130 - startDay = int(startTime[8:10])
131 -
132 -
133 -
134 - endYear = int(endTime[0:4])
135 -
136 - if (int(endTime[5]) == 0): # 한자리의 월일 때
137 - endMonth = int(endTime[6])
138 - else:
139 - endMonth = int(endTime[5:7])
140 -
141 - if (int(endTime[8]) == 0): # 한자리의 일일 때
142 - endDay = int(endTime[9])
143 - else:
144 - endDay = int(endTime[8:10])
145 -
146 - for item in c_List:
147 - itemYear = int(item['time'][0:4])
148 -
149 - if (int(item['time'][5]) == 0): # 한자리의 월일 때
150 - itemMonth = int(item['time'][6])
151 - else:
152 - itemMonth = int(item['time'][5:7])
153 -
154 - if (int(item['time'][8]) == 0): # 한자리의 일일 때
155 - itemDay = int(item['time'][9])
156 - else:
157 - itemDay = int(item['time'][8:10])
158 -
159 - if (itemYear >= startYear and itemYear <= endYear):
160 - if (itemMonth >= startMonth and itemMonth <= endMonth):
161 - if(itemDay >= startDay and itemDay <= endDay):
162 - result_List.append(item)
163 -
164 - return result_List
165 -
166 -def printMostShowed(c_List,limit):
167 - temp = ""
168 - result = ""
169 - for item in c_List:
170 - temp = str(item['comment']) + " "
171 - result = result + temp
172 -
173 - sp = Twitter()
174 -
175 - nouns = sp.nouns(result)
176 -
177 - _cnt = Counter(nouns)
178 -
179 - tempList = []
180 - repCnt = 0
181 -
182 - for i,j in _cnt.most_common(limit):
183 - print(str(repCnt+1)+'. '+str(i)+" : "+str(j))
184 - repCnt += 1
185 -
186 -def printResult(c_List):
187 - for i in range(0,len(c_List)):
188 - print(c_List[i])
189 -
190 -def main ():
191 - ## 시작화면
192 -
193 - _star = '*'
194 - print(_star.center(30,'*'))
195 - print('\n')
196 - headString = '< Naver News Crawling >'
197 - print(headString.center(30,'*'))
198 - print('\n')
199 - print(_star.center(30,'*'))
200 -
201 -
202 - # 검색하고자 하는 url을 입력받는다
203 - _url = input('검색하고자 하는 url을 입력해주세요: ')
204 - print('comment_list를 가져오는 중.....')
205 - cList = getData(_url)
206 - refine_time(cList)
207 - #printMostShowed(cList,10)
208 - print('\n')
209 - print('comment_list를 다 가져왔습니다!')
210 -
211 - while(True):
212 - print('***********************************')
213 - print('1.닉네임 기반 검색')
214 - print('2.키워드 기반 검색')
215 - print('3.작성시간 기반 검색')
216 - print('4.자주 나타난 단어 출력')
217 - menu = input('메뉴를 입력해주세요: ')
218 -
219 - if(menu == str(1)):
220 - print('***********************************')
221 - inputID = input('검색할 닉네임 앞 4자리를 입력해주세요(전 단계로 가시려면 -1을 입력해주세요): ')
222 - if(inputID == str(-1)):
223 - continue
224 - _result = search_by_author(cList,inputID)
225 - printResult(_result)
226 - print(_result)
227 - elif(menu == str(2)):
228 - print('***********************************')
229 - inputKW = input('검색할 키워드를 입력해주세요(전 단계로 가시려면 -1을 입력해주세요): ')
230 - if(inputKW == str(-1)):
231 - continue
232 - _result = search_by_keyword(cList,inputKW)
233 - printResult(_result)
234 - elif(menu == str(3)):
235 - print('***********************************')
236 - print('전 단계로 돌아가시려면 -1을 입력해주세요')
237 - startTime = input('검색할 시간대의 시작일을 입력해주세요(YYYY-MM-DD): ')
238 - endTime = input('검색할 시간대의 마지막 일을 입력해주세요(YYYY-MM-DD): ')
239 -
240 - if(startTime == str(-1) or endTime == str(-1)):
241 - continue
242 -
243 - _result = search_by_time(cList,startTime,endTime)
244 - printResult(_result)
245 - elif(menu == str(4)):
246 - print('***********************************')
247 - inputLimit = input('상위 몇 개 까지 보고 싶은지 입력하세요(1~20): ')
248 - while(True):
249 - if (int(inputLimit) <= 0 or int(inputLimit) > 20):
250 - inputLimit = input('상위 몇 개 까지 보고 싶은지 입력하세요(1~20): ')
251 - else:
252 - break
253 -
254 - printMostShowed(cList,int(inputLimit))
255 - else:
256 - print('잘못된 입력입니다')
257 - continue
258 -
259 -
260 -
261 -main()
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../mime/cli.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../mime/cli.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@ECHO off
2 +SETLOCAL
3 +CALL :find_dp0
4 +
5 +IF EXIST "%dp0%\node.exe" (
6 + SET "_prog=%dp0%\node.exe"
7 +) ELSE (
8 + SET "_prog=node"
9 + SET PATHEXT=%PATHEXT:;.JS;=;%
10 +)
11 +
12 +"%_prog%" "%dp0%\..\mime\cli.js" %*
13 +ENDLOCAL
14 +EXIT /b %errorlevel%
15 +:find_dp0
16 +SET dp0=%~dp0
17 +EXIT /b
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
13 + $ret=$LASTEXITCODE
14 +} else {
15 + & "node$exe" "$basedir/../mime/cli.js" $args
16 + $ret=$LASTEXITCODE
17 +}
18 +exit $ret
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\\k2cates\\Desktop\\asdfsa sd\\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 +The MIT License (MIT)
2 +
3 +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# Array Flatten
2 +
3 +[![NPM version][npm-image]][npm-url]
4 +[![NPM downloads][downloads-image]][downloads-url]
5 +[![Build status][travis-image]][travis-url]
6 +[![Test coverage][coveralls-image]][coveralls-url]
7 +
8 +> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
9 +
10 +## Installation
11 +
12 +```
13 +npm install array-flatten --save
14 +```
15 +
16 +## Usage
17 +
18 +```javascript
19 +var flatten = require('array-flatten')
20 +
21 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
22 +//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
23 +
24 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
25 +//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
26 +
27 +(function () {
28 + flatten(arguments) //=> [1, 2, 3]
29 +})(1, [2, 3])
30 +```
31 +
32 +## License
33 +
34 +MIT
35 +
36 +[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
37 +[npm-url]: https://npmjs.org/package/array-flatten
38 +[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
39 +[downloads-url]: https://npmjs.org/package/array-flatten
40 +[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
41 +[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
42 +[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
43 +[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
1 +'use strict'
2 +
3 +/**
4 + * Expose `arrayFlatten`.
5 + */
6 +module.exports = arrayFlatten
7 +
8 +/**
9 + * Recursive flatten function with depth.
10 + *
11 + * @param {Array} array
12 + * @param {Array} result
13 + * @param {Number} depth
14 + * @return {Array}
15 + */
16 +function flattenWithDepth (array, result, depth) {
17 + for (var i = 0; i < array.length; i++) {
18 + var value = array[i]
19 +
20 + if (depth > 0 && Array.isArray(value)) {
21 + flattenWithDepth(value, result, depth - 1)
22 + } else {
23 + result.push(value)
24 + }
25 + }
26 +
27 + return result
28 +}
29 +
30 +/**
31 + * Recursive flatten function. Omitting depth is slightly faster.
32 + *
33 + * @param {Array} array
34 + * @param {Array} result
35 + * @return {Array}
36 + */
37 +function flattenForever (array, result) {
38 + for (var i = 0; i < array.length; i++) {
39 + var value = array[i]
40 +
41 + if (Array.isArray(value)) {
42 + flattenForever(value, result)
43 + } else {
44 + result.push(value)
45 + }
46 + }
47 +
48 + return result
49 +}
50 +
51 +/**
52 + * Flatten an array, with the ability to define a depth.
53 + *
54 + * @param {Array} array
55 + * @param {Number} depth
56 + * @return {Array}
57 + */
58 +function arrayFlatten (array, depth) {
59 + if (depth == null) {
60 + return flattenForever(array, [])
61 + }
62 +
63 + return flattenWithDepth(array, [], depth)
64 +}
1 +{
2 + "_from": "array-flatten@1.1.1",
3 + "_id": "array-flatten@1.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=",
6 + "_location": "/array-flatten",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "array-flatten@1.1.1",
12 + "name": "array-flatten",
13 + "escapedName": "array-flatten",
14 + "rawSpec": "1.1.1",
15 + "saveSpec": null,
16 + "fetchSpec": "1.1.1"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
22 + "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2",
23 + "_spec": "array-flatten@1.1.1",
24 + "_where": "C:\\Users\\k2cates\\Desktop\\asdfsa sd\\node_modules\\express",
25 + "author": {
26 + "name": "Blake Embrey",
27 + "email": "hello@blakeembrey.com",
28 + "url": "http://blakeembrey.me"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/blakeembrey/array-flatten/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "Flatten an array of nested arrays into a single flat array",
36 + "devDependencies": {
37 + "istanbul": "^0.3.13",
38 + "mocha": "^2.2.4",
39 + "pre-commit": "^1.0.7",
40 + "standard": "^3.7.3"
41 + },
42 + "files": [
43 + "array-flatten.js",
44 + "LICENSE"
45 + ],
46 + "homepage": "https://github.com/blakeembrey/array-flatten",
47 + "keywords": [
48 + "array",
49 + "flatten",
50 + "arguments",
51 + "depth"
52 + ],
53 + "license": "MIT",
54 + "main": "array-flatten.js",
55 + "name": "array-flatten",
56 + "repository": {
57 + "type": "git",
58 + "url": "git://github.com/blakeembrey/array-flatten.git"
59 + },
60 + "scripts": {
61 + "test": "istanbul cover _mocha -- -R spec"
62 + },
63 + "version": "1.1.1"
64 +}
1 +#### 7.2.1
2 +* 24/05/2018
3 +* Add `browser` field to *package.json*.
4 +
5 +#### 7.2.0
6 +* 22/05/2018
7 +* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
8 +
9 +#### 7.1.0
10 +* 18/05/2018
11 +* Add `module` field to *package.json* for *bignumber.mjs*.
12 +
13 +#### 7.0.2
14 +* 17/05/2018
15 +* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
16 +* Add note to *README* regarding creating BigNumbers from Number values.
17 +
18 +#### 7.0.1
19 +* 26/04/2018
20 +* #158 Fix global object variable name typo.
21 +
22 +#### 7.0.0
23 +* 26/04/2018
24 +* #143 Remove global BigNumber from typings.
25 +* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
26 +* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
27 +* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
28 +* #154 `exponentiatedBy`: allow BigNumber exponent.
29 +* #156 Prevent Content Security Policy *unsafe-eval* issue.
30 +* `toFraction`: allow `Infinity` maximum denominator.
31 +* Comment-out some excess tests to reduce test time.
32 +* Amend indentation and other spacing.
33 +
34 +#### 6.0.0
35 +* 26/01/2018
36 +* #137 Implement `APLHABET` configuration option.
37 +* Remove `ERRORS` configuration option.
38 +* Remove `toDigits` method; extend `precision` method accordingly.
39 +* Remove s`round` method; extend `decimalPlaces` method accordingly.
40 +* Remove methods: `ceil`, `floor`, and `truncated`.
41 +* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
42 +* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
43 +* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
44 +* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
45 +* Refactor test suite.
46 +* Add *CHANGELOG.md*.
47 +* Rewrite *bignumber.d.ts*.
48 +* Redo API image.
49 +
50 +#### 5.0.0
51 +* 27/11/2017
52 +* #81 Don't throw on constructor call without `new`.
53 +
54 +#### 4.1.0
55 +* 26/09/2017
56 +* Remove node 0.6 from *.travis.yml*.
57 +* Add *bignumber.mjs*.
58 +
59 +#### 4.0.4
60 +* 03/09/2017
61 +* Add missing aliases to *bignumber.d.ts*.
62 +
63 +#### 4.0.3
64 +* 30/08/2017
65 +* Add types: *bignumber.d.ts*.
66 +
67 +#### 4.0.2
68 +* 03/05/2017
69 +* #120 Workaround Safari/Webkit bug.
70 +
71 +#### 4.0.1
72 +* 05/04/2017
73 +* #121 BigNumber.default to BigNumber['default'].
74 +
75 +#### 4.0.0
76 +* 09/01/2017
77 +* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
78 +
79 +#### 3.1.2
80 +* 08/01/2017
81 +* Minor documentation edit.
82 +
83 +#### 3.1.1
84 +* 08/01/2017
85 +* Uncomment `isBigNumber` tests.
86 +* Ignore dot files.
87 +
88 +#### 3.1.0
89 +* 08/01/2017
90 +* Add `isBigNumber` method.
91 +
92 +#### 3.0.2
93 +* 08/01/2017
94 +* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
95 +
96 +#### 3.0.1
97 +* 23/11/2016
98 +* Apply fix for old ipads with `%` issue, see #57 and #102.
99 +* Correct error message.
100 +
101 +#### 3.0.0
102 +* 09/11/2016
103 +* Remove `require('crypto')` - leave it to the user.
104 +* Add `BigNumber.set` as `BigNumber.config` alias.
105 +* Default `POW_PRECISION` to `0`.
106 +
107 +#### 2.4.0
108 +* 14/07/2016
109 +* #97 Add exports to support ES6 imports.
110 +
111 +#### 2.3.0
112 +* 07/03/2016
113 +* #86 Add modulus parameter to `toPower`.
114 +
115 +#### 2.2.0
116 +* 03/03/2016
117 +* #91 Permit larger JS integers.
118 +
119 +#### 2.1.4
120 +* 15/12/2015
121 +* Correct UMD.
122 +
123 +#### 2.1.3
124 +* 13/12/2015
125 +* Refactor re global object and crypto availability when bundling.
126 +
127 +#### 2.1.2
128 +* 10/12/2015
129 +* Bugfix: `window.crypto` not assigned to `crypto`.
130 +
131 +#### 2.1.1
132 +* 09/12/2015
133 +* Prevent code bundler from adding `crypto` shim.
134 +
135 +#### 2.1.0
136 +* 26/10/2015
137 +* For `valueOf` and `toJSON`, include the minus sign with negative zero.
138 +
139 +#### 2.0.8
140 +* 2/10/2015
141 +* Internal round function bugfix.
142 +
143 +#### 2.0.6
144 +* 31/03/2015
145 +* Add bower.json. Tweak division after in-depth review.
146 +
147 +#### 2.0.5
148 +* 25/03/2015
149 +* Amend README. Remove bitcoin address.
150 +
151 +#### 2.0.4
152 +* 25/03/2015
153 +* Critical bugfix #58: division.
154 +
155 +#### 2.0.3
156 +* 18/02/2015
157 +* Amend README. Add source map.
158 +
159 +#### 2.0.2
160 +* 18/02/2015
161 +* Correct links.
162 +
163 +#### 2.0.1
164 +* 18/02/2015
165 +* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
166 +* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
167 +* Add an `another` method to enable multiple independent constructors to be created.
168 +* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
169 +* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
170 +* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
171 +* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
172 +* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
173 +* Improve code quality.
174 +* Improve documentation.
175 +
176 +#### 2.0.0
177 +* 29/12/2014
178 +* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
179 +* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
180 +* Store a BigNumber's coefficient in base 1e14, rather than base 10.
181 +* Add fast path for integers to BigNumber constructor.
182 +* Incorporate the library into the online documentation.
183 +
184 +#### 1.5.0
185 +* 13/11/2014
186 +* Add `toJSON` and `decimalPlaces` methods.
187 +
188 +#### 1.4.1
189 +* 08/06/2014
190 +* Amend README.
191 +
192 +#### 1.4.0
193 +* 08/05/2014
194 +* Add `toNumber`.
195 +
196 +#### 1.3.0
197 +* 08/11/2013
198 +* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
199 +* Maximum radix to 64.
200 +
201 +#### 1.2.1
202 +* 17/10/2013
203 +* Sign of zero when x < 0 and x + (-x) = 0.
204 +
205 +#### 1.2.0
206 +* 19/9/2013
207 +* Throw Error objects for stack.
208 +
209 +#### 1.1.1
210 +* 22/8/2013
211 +* Show original value in constructor error message.
212 +
213 +#### 1.1.0
214 +* 1/8/2013
215 +* Allow numbers with trailing radix point.
216 +
217 +#### 1.0.1
218 +* Bugfix: error messages with incorrect method name
219 +
220 +#### 1.0.0
221 +* 8/11/2012
222 +* Initial release
1 +The MIT Licence.
2 +
3 +Copyright (c) 2018 Michael Mclaughlin
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 +
1 +![bignumber.js](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/bignumberjs.png)
2 +
3 +A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
4 +
5 +[![Build Status](https://travis-ci.org/MikeMcl/bignumber.js.svg)](https://travis-ci.org/MikeMcl/bignumber.js)
6 +
7 +<br />
8 +
9 +## Features
10 +
11 + - Integers and decimals
12 + - Simple API but full-featured
13 + - Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
14 + - 8 KB minified and gzipped
15 + - Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
16 + - Includes a `toFraction` and a correctly-rounded `squareRoot` method
17 + - Supports cryptographically-secure pseudo-random number generation
18 + - No dependencies
19 + - Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
20 + - Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set
21 +
22 +![API](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/API.png)
23 +
24 +If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
25 +It's less than half the size but only works with decimal numbers and only has half the methods.
26 +It also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
27 +
28 +See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.
29 +
30 +## Load
31 +
32 +The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).
33 +
34 +Browser:
35 +
36 +```html
37 +<script src='path/to/bignumber.js'></script>
38 +```
39 +
40 +[Node.js](http://nodejs.org):
41 +
42 +```bash
43 +$ npm install --save bignumber.js
44 +```
45 +
46 +```javascript
47 +var BigNumber = require('bignumber.js');
48 +```
49 +
50 +ES6 module (*bignumber.mjs*):
51 +
52 +```javascript
53 +//import BigNumber from 'bignumber.js';
54 +import {BigNumber} from 'bignumber.js';
55 +```
56 +
57 +AMD loader libraries such as [requireJS](http://requirejs.org/):
58 +
59 +```javascript
60 +require(['bignumber'], function(BigNumber) {
61 + // Use BigNumber here in local scope. No global BigNumber.
62 +});
63 +```
64 +
65 +## Use
66 +
67 +*In all examples below, `var`, semicolons and `toString` calls are not shown.
68 +If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
69 +
70 +The library exports a single function: `BigNumber`, the constructor of BigNumber instances.
71 +
72 +It accepts a value of type Number, String or BigNumber,
73 +
74 +```javascript
75 +x = new BigNumber(123.4567)
76 +y = BigNumber('123456.7e-3')
77 +z = new BigNumber(x)
78 +x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z) // true
79 +```
80 +
81 +and a base can be specified.
82 +
83 +```javascript
84 +a = new BigNumber(1011, 2) // "11"
85 +b = new BigNumber('zz.9', 36) // "1295.25"
86 +c = x.plus(y) // "1306.25"
87 +```
88 +
89 +Note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2.
90 +
91 +```javascript
92 +new BigNumber(Number.MAX_VALUE.toString(2), 2)
93 +```
94 +
95 +If the limited precision of Number values is not well understood, **it is recommended to pass String values rather than Number values** to avoid a potential loss of precision.
96 +
97 +```javascript
98 +// Precision loss from using numeric literals with more than 15 significant digits.
99 +new BigNumber(1.0000000000000001); // '1'
100 +new BigNumber(88259496234518.57); // '88259496234518.56'
101 +new BigNumber(99999999999999999999); // '100000000000000000000'
102 +
103 +// Precision loss from using numeric literals outside the range of Number values.
104 +new BigNumber(2e+308); // 'Infinity'
105 +new BigNumber(1e-324); // '0'
106 +
107 +// Precision loss from the unexpected result of arithmetic with Number values.
108 +new BigNumber(0.7 + 0.1); // '0.7999999999999999'
109 +```
110 +
111 +A BigNumber is immutable in the sense that it is not changed by its methods.
112 +
113 +```javascript
114 +0.3 - 0.1 // 0.19999999999999998
115 +x = new BigNumber(0.3)
116 +x.minus(0.1) // "0.2"
117 +x // "0.3"
118 +```
119 +
120 +The methods that return a BigNumber can be chained.
121 +
122 +```javascript
123 +x.dividedBy(y).plus(z).times(9)
124 +x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue()
125 +```
126 +
127 +Some of the longer method names have a shorter alias.
128 +
129 +```javascript
130 +x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo( x.sqrt().div(y).pow(3) ) // true
131 +x.modulo(y).multipliedBy(z).eq( x.mod(y).times(z) ) // true
132 +```
133 +
134 +As with JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods
135 +
136 +```javascript
137 +x = new BigNumber(255.5)
138 +x.toExponential(5) // "2.55500e+2"
139 +x.toFixed(5) // "255.50000"
140 +x.toPrecision(5) // "255.50"
141 +x.toNumber() // 255.5
142 +```
143 +
144 + and a base can be specified for `toString`.
145 +
146 + ```javascript
147 + x.toString(16) // "ff.8"
148 + ```
149 +
150 +There is also a `toFormat` method which may be useful for internationalisation
151 +
152 +```javascript
153 +y = new BigNumber('1234567.898765')
154 +y.toFormat(2) // "1,234,567.90"
155 +```
156 +
157 +The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `config` method of the `BigNumber` constructor.
158 +
159 +The other arithmetic operations always give the exact result.
160 +
161 +```javascript
162 +BigNumber.config({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })
163 +
164 +x = new BigNumber(2);
165 +y = new BigNumber(3);
166 +z = x.dividedBy(y) // "0.6666666667"
167 +z.squareRoot() // "0.8164965809"
168 +z.exponentiatedBy(-3) // "3.3749999995"
169 +z.toString(2) // "0.1010101011"
170 +z.multipliedBy(z) // "0.44444444448888888889"
171 +z.multipliedBy(z).decimalPlaces(10) // "0.4444444445"
172 +```
173 +
174 +There is a `toFraction` method with an optional *maximum denominator* argument
175 +
176 +```javascript
177 +y = new BigNumber(355)
178 +pi = y.dividedBy(113) // "3.1415929204"
179 +pi.toFraction() // [ "7853982301", "2500000000" ]
180 +pi.toFraction(1000) // [ "355", "113" ]
181 +```
182 +
183 +and `isNaN` and `isFinite` methods, as `NaN` and `Infinity` are valid `BigNumber` values.
184 +
185 +```javascript
186 +x = new BigNumber(NaN) // "NaN"
187 +y = new BigNumber(Infinity) // "Infinity"
188 +x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
189 +```
190 +
191 +The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
192 +
193 +```javascript
194 +x = new BigNumber(-123.456);
195 +x.c // [ 123, 45600000000000 ] coefficient (i.e. significand)
196 +x.e // 2 exponent
197 +x.s // -1 sign
198 +```
199 +
200 +For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration which applies to all BigNumber's created from it.
201 +
202 +```javascript
203 +// Set DECIMAL_PLACES for the original BigNumber constructor
204 +BigNumber.config({ DECIMAL_PLACES: 10 })
205 +
206 +// Create another BigNumber constructor, optionally passing in a configuration object
207 +BN = BigNumber.clone({ DECIMAL_PLACES: 5 })
208 +
209 +x = new BigNumber(1)
210 +y = new BN(1)
211 +
212 +x.div(3) // '0.3333333333'
213 +y.div(3) // '0.33333'
214 +```
215 +
216 +For futher information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.
217 +
218 +## Test
219 +
220 +The *test/modules* directory contains the test scripts for each method.
221 +
222 +The tests can be run with Node.js or a browser. For Node.js use
223 +
224 + $ npm test
225 +
226 +or
227 +
228 + $ node test/test
229 +
230 +To test a single method, use, for example
231 +
232 + $ node test/methods/toFraction
233 +
234 +For the browser, open *test/test.html*.
235 +
236 +## Performance
237 +
238 +See the [README](https://github.com/MikeMcl/bignumber.js/tree/master/perf) in the *perf* directory.
239 +
240 +## Build
241 +
242 +For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
243 +
244 + npm install uglify-js -g
245 +
246 +then
247 +
248 + npm run build
249 +
250 +will create *bignumber.min.js*.
251 +
252 +A source map will also be created in the root directory.
253 +
254 +## Feedback
255 +
256 +Open an issue, or email
257 +
258 +Michael
259 +
260 +<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
261 +
262 +## Licence
263 +
264 +The MIT Licence.
265 +
266 +See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +{
2 + "name": "bignumber.js",
3 + "main": "bignumber.js",
4 + "version": "7.2.1",
5 + "homepage": "https://github.com/MikeMcl/bignumber.js",
6 + "authors": [
7 + "Michael Mclaughlin <M8ch88l@gmail.com>"
8 + ],
9 + "description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
10 + "moduleType": [
11 + "amd",
12 + "globals",
13 + "node"
14 + ],
15 + "keywords": [
16 + "arbitrary",
17 + "precision",
18 + "arithmetic",
19 + "big",
20 + "number",
21 + "decimal",
22 + "float",
23 + "biginteger",
24 + "bigdecimal",
25 + "bignumber",
26 + "bigint",
27 + "bignum"
28 + ],
29 + "license": "MIT",
30 + "ignore": [
31 + ".*",
32 + "*.json",
33 + "test"
34 + ]
35 +}
36 +
This diff is collapsed. Click to expand it.
1 +{
2 + "_from": "bignumber.js@7.2.1",
3 + "_id": "bignumber.js@7.2.1",
4 + "_inBundle": false,
5 + "_integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==",
6 + "_location": "/bignumber.js",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "bignumber.js@7.2.1",
12 + "name": "bignumber.js",
13 + "escapedName": "bignumber.js",
14 + "rawSpec": "7.2.1",
15 + "saveSpec": null,
16 + "fetchSpec": "7.2.1"
17 + },
18 + "_requiredBy": [
19 + "/mysql"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz",
22 + "_shasum": "80c048759d826800807c4bfd521e50edbba57a5f",
23 + "_spec": "bignumber.js@7.2.1",
24 + "_where": "C:\\Users\\k2cates\\Desktop\\디비 테스트\\node_modules\\mysql",
25 + "author": {
26 + "name": "Michael Mclaughlin",
27 + "email": "M8ch88l@gmail.com"
28 + },
29 + "browser": "bignumber.js",
30 + "bugs": {
31 + "url": "https://github.com/MikeMcl/bignumber.js/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
36 + "engines": {
37 + "node": "*"
38 + },
39 + "homepage": "https://github.com/MikeMcl/bignumber.js#readme",
40 + "keywords": [
41 + "arbitrary",
42 + "precision",
43 + "arithmetic",
44 + "big",
45 + "number",
46 + "decimal",
47 + "float",
48 + "biginteger",
49 + "bigdecimal",
50 + "bignumber",
51 + "bigint",
52 + "bignum"
53 + ],
54 + "license": "MIT",
55 + "main": "bignumber",
56 + "module": "bignumber.mjs",
57 + "name": "bignumber.js",
58 + "repository": {
59 + "type": "git",
60 + "url": "git+https://github.com/MikeMcl/bignumber.js.git"
61 + },
62 + "scripts": {
63 + "build": "uglifyjs bignumber.js --source-map bignumber.js.map -c -m -o bignumber.min.js --preamble \"/* bignumber.js v7.2.1 https://github.com/MikeMcl/bignumber.js/LICENCE */\"",
64 + "test": "node test/test"
65 + },
66 + "types": "bignumber.d.ts",
67 + "version": "7.2.1"
68 +}
This diff is collapsed. Click to expand it.
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2014-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.
This diff is collapsed. Click to expand it.
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + * @private
12 + */
13 +
14 +var deprecate = require('depd')('body-parser')
15 +
16 +/**
17 + * Cache of loaded parsers.
18 + * @private
19 + */
20 +
21 +var parsers = Object.create(null)
22 +
23 +/**
24 + * @typedef Parsers
25 + * @type {function}
26 + * @property {function} json
27 + * @property {function} raw
28 + * @property {function} text
29 + * @property {function} urlencoded
30 + */
31 +
32 +/**
33 + * Module exports.
34 + * @type {Parsers}
35 + */
36 +
37 +exports = module.exports = deprecate.function(bodyParser,
38 + 'bodyParser: use individual json/urlencoded middlewares')
39 +
40 +/**
41 + * JSON parser.
42 + * @public
43 + */
44 +
45 +Object.defineProperty(exports, 'json', {
46 + configurable: true,
47 + enumerable: true,
48 + get: createParserGetter('json')
49 +})
50 +
51 +/**
52 + * Raw parser.
53 + * @public
54 + */
55 +
56 +Object.defineProperty(exports, 'raw', {
57 + configurable: true,
58 + enumerable: true,
59 + get: createParserGetter('raw')
60 +})
61 +
62 +/**
63 + * Text parser.
64 + * @public
65 + */
66 +
67 +Object.defineProperty(exports, 'text', {
68 + configurable: true,
69 + enumerable: true,
70 + get: createParserGetter('text')
71 +})
72 +
73 +/**
74 + * URL-encoded parser.
75 + * @public
76 + */
77 +
78 +Object.defineProperty(exports, 'urlencoded', {
79 + configurable: true,
80 + enumerable: true,
81 + get: createParserGetter('urlencoded')
82 +})
83 +
84 +/**
85 + * Create a middleware to parse json and urlencoded bodies.
86 + *
87 + * @param {object} [options]
88 + * @return {function}
89 + * @deprecated
90 + * @public
91 + */
92 +
93 +function bodyParser (options) {
94 + var opts = {}
95 +
96 + // exclude type option
97 + if (options) {
98 + for (var prop in options) {
99 + if (prop !== 'type') {
100 + opts[prop] = options[prop]
101 + }
102 + }
103 + }
104 +
105 + var _urlencoded = exports.urlencoded(opts)
106 + var _json = exports.json(opts)
107 +
108 + return function bodyParser (req, res, next) {
109 + _json(req, res, function (err) {
110 + if (err) return next(err)
111 + _urlencoded(req, res, next)
112 + })
113 + }
114 +}
115 +
116 +/**
117 + * Create a getter for loading a parser.
118 + * @private
119 + */
120 +
121 +function createParserGetter (name) {
122 + return function get () {
123 + return loadParser(name)
124 + }
125 +}
126 +
127 +/**
128 + * Load a parser module.
129 + * @private
130 + */
131 +
132 +function loadParser (parserName) {
133 + var parser = parsers[parserName]
134 +
135 + if (parser !== undefined) {
136 + return parser
137 + }
138 +
139 + // this uses a switch for static require analysis
140 + switch (parserName) {
141 + case 'json':
142 + parser = require('./lib/types/json')
143 + break
144 + case 'raw':
145 + parser = require('./lib/types/raw')
146 + break
147 + case 'text':
148 + parser = require('./lib/types/text')
149 + break
150 + case 'urlencoded':
151 + parser = require('./lib/types/urlencoded')
152 + break
153 + }
154 +
155 + // store to prevent invoking require()
156 + return (parsers[parserName] = parser)
157 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + * @private
12 + */
13 +
14 +var createError = require('http-errors')
15 +var getBody = require('raw-body')
16 +var iconv = require('iconv-lite')
17 +var onFinished = require('on-finished')
18 +var zlib = require('zlib')
19 +
20 +/**
21 + * Module exports.
22 + */
23 +
24 +module.exports = read
25 +
26 +/**
27 + * Read a request into a buffer and parse.
28 + *
29 + * @param {object} req
30 + * @param {object} res
31 + * @param {function} next
32 + * @param {function} parse
33 + * @param {function} debug
34 + * @param {object} options
35 + * @private
36 + */
37 +
38 +function read (req, res, next, parse, debug, options) {
39 + var length
40 + var opts = options
41 + var stream
42 +
43 + // flag as parsed
44 + req._body = true
45 +
46 + // read options
47 + var encoding = opts.encoding !== null
48 + ? opts.encoding
49 + : null
50 + var verify = opts.verify
51 +
52 + try {
53 + // get the content stream
54 + stream = contentstream(req, debug, opts.inflate)
55 + length = stream.length
56 + stream.length = undefined
57 + } catch (err) {
58 + return next(err)
59 + }
60 +
61 + // set raw-body options
62 + opts.length = length
63 + opts.encoding = verify
64 + ? null
65 + : encoding
66 +
67 + // assert charset is supported
68 + if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
69 + return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
70 + charset: encoding.toLowerCase(),
71 + type: 'charset.unsupported'
72 + }))
73 + }
74 +
75 + // read body
76 + debug('read body')
77 + getBody(stream, opts, function (error, body) {
78 + if (error) {
79 + var _error
80 +
81 + if (error.type === 'encoding.unsupported') {
82 + // echo back charset
83 + _error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
84 + charset: encoding.toLowerCase(),
85 + type: 'charset.unsupported'
86 + })
87 + } else {
88 + // set status code on error
89 + _error = createError(400, error)
90 + }
91 +
92 + // read off entire request
93 + stream.resume()
94 + onFinished(req, function onfinished () {
95 + next(createError(400, _error))
96 + })
97 + return
98 + }
99 +
100 + // verify
101 + if (verify) {
102 + try {
103 + debug('verify body')
104 + verify(req, res, body, encoding)
105 + } catch (err) {
106 + next(createError(403, err, {
107 + body: body,
108 + type: err.type || 'entity.verify.failed'
109 + }))
110 + return
111 + }
112 + }
113 +
114 + // parse
115 + var str = body
116 + try {
117 + debug('parse body')
118 + str = typeof body !== 'string' && encoding !== null
119 + ? iconv.decode(body, encoding)
120 + : body
121 + req.body = parse(str)
122 + } catch (err) {
123 + next(createError(400, err, {
124 + body: str,
125 + type: err.type || 'entity.parse.failed'
126 + }))
127 + return
128 + }
129 +
130 + next()
131 + })
132 +}
133 +
134 +/**
135 + * Get the content stream of the request.
136 + *
137 + * @param {object} req
138 + * @param {function} debug
139 + * @param {boolean} [inflate=true]
140 + * @return {object}
141 + * @api private
142 + */
143 +
144 +function contentstream (req, debug, inflate) {
145 + var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
146 + var length = req.headers['content-length']
147 + var stream
148 +
149 + debug('content-encoding "%s"', encoding)
150 +
151 + if (inflate === false && encoding !== 'identity') {
152 + throw createError(415, 'content encoding unsupported', {
153 + encoding: encoding,
154 + type: 'encoding.unsupported'
155 + })
156 + }
157 +
158 + switch (encoding) {
159 + case 'deflate':
160 + stream = zlib.createInflate()
161 + debug('inflate body')
162 + req.pipe(stream)
163 + break
164 + case 'gzip':
165 + stream = zlib.createGunzip()
166 + debug('gunzip body')
167 + req.pipe(stream)
168 + break
169 + case 'identity':
170 + stream = req
171 + stream.length = length
172 + break
173 + default:
174 + throw createError(415, 'unsupported content encoding "' + encoding + '"', {
175 + encoding: encoding,
176 + type: 'encoding.unsupported'
177 + })
178 + }
179 +
180 + return stream
181 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var bytes = require('bytes')
16 +var contentType = require('content-type')
17 +var createError = require('http-errors')
18 +var debug = require('debug')('body-parser:json')
19 +var read = require('../read')
20 +var typeis = require('type-is')
21 +
22 +/**
23 + * Module exports.
24 + */
25 +
26 +module.exports = json
27 +
28 +/**
29 + * RegExp to match the first non-space in a string.
30 + *
31 + * Allowed whitespace is defined in RFC 7159:
32 + *
33 + * ws = *(
34 + * %x20 / ; Space
35 + * %x09 / ; Horizontal tab
36 + * %x0A / ; Line feed or New line
37 + * %x0D ) ; Carriage return
38 + */
39 +
40 +var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*(.)/ // eslint-disable-line no-control-regex
41 +
42 +/**
43 + * Create a middleware to parse JSON bodies.
44 + *
45 + * @param {object} [options]
46 + * @return {function}
47 + * @public
48 + */
49 +
50 +function json (options) {
51 + var opts = options || {}
52 +
53 + var limit = typeof opts.limit !== 'number'
54 + ? bytes.parse(opts.limit || '100kb')
55 + : opts.limit
56 + var inflate = opts.inflate !== false
57 + var reviver = opts.reviver
58 + var strict = opts.strict !== false
59 + var type = opts.type || 'application/json'
60 + var verify = opts.verify || false
61 +
62 + if (verify !== false && typeof verify !== 'function') {
63 + throw new TypeError('option verify must be function')
64 + }
65 +
66 + // create the appropriate type checking function
67 + var shouldParse = typeof type !== 'function'
68 + ? typeChecker(type)
69 + : type
70 +
71 + function parse (body) {
72 + if (body.length === 0) {
73 + // special-case empty json body, as it's a common client-side mistake
74 + // TODO: maybe make this configurable or part of "strict" option
75 + return {}
76 + }
77 +
78 + if (strict) {
79 + var first = firstchar(body)
80 +
81 + if (first !== '{' && first !== '[') {
82 + debug('strict violation')
83 + throw createStrictSyntaxError(body, first)
84 + }
85 + }
86 +
87 + try {
88 + debug('parse json')
89 + return JSON.parse(body, reviver)
90 + } catch (e) {
91 + throw normalizeJsonSyntaxError(e, {
92 + message: e.message,
93 + stack: e.stack
94 + })
95 + }
96 + }
97 +
98 + return function jsonParser (req, res, next) {
99 + if (req._body) {
100 + debug('body already parsed')
101 + next()
102 + return
103 + }
104 +
105 + req.body = req.body || {}
106 +
107 + // skip requests without bodies
108 + if (!typeis.hasBody(req)) {
109 + debug('skip empty body')
110 + next()
111 + return
112 + }
113 +
114 + debug('content-type %j', req.headers['content-type'])
115 +
116 + // determine if request should be parsed
117 + if (!shouldParse(req)) {
118 + debug('skip parsing')
119 + next()
120 + return
121 + }
122 +
123 + // assert charset per RFC 7159 sec 8.1
124 + var charset = getCharset(req) || 'utf-8'
125 + if (charset.substr(0, 4) !== 'utf-') {
126 + debug('invalid charset')
127 + next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
128 + charset: charset,
129 + type: 'charset.unsupported'
130 + }))
131 + return
132 + }
133 +
134 + // read
135 + read(req, res, next, parse, debug, {
136 + encoding: charset,
137 + inflate: inflate,
138 + limit: limit,
139 + verify: verify
140 + })
141 + }
142 +}
143 +
144 +/**
145 + * Create strict violation syntax error matching native error.
146 + *
147 + * @param {string} str
148 + * @param {string} char
149 + * @return {Error}
150 + * @private
151 + */
152 +
153 +function createStrictSyntaxError (str, char) {
154 + var index = str.indexOf(char)
155 + var partial = str.substring(0, index) + '#'
156 +
157 + try {
158 + JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
159 + } catch (e) {
160 + return normalizeJsonSyntaxError(e, {
161 + message: e.message.replace('#', char),
162 + stack: e.stack
163 + })
164 + }
165 +}
166 +
167 +/**
168 + * Get the first non-whitespace character in a string.
169 + *
170 + * @param {string} str
171 + * @return {function}
172 + * @private
173 + */
174 +
175 +function firstchar (str) {
176 + return FIRST_CHAR_REGEXP.exec(str)[1]
177 +}
178 +
179 +/**
180 + * Get the charset of a request.
181 + *
182 + * @param {object} req
183 + * @api private
184 + */
185 +
186 +function getCharset (req) {
187 + try {
188 + return (contentType.parse(req).parameters.charset || '').toLowerCase()
189 + } catch (e) {
190 + return undefined
191 + }
192 +}
193 +
194 +/**
195 + * Normalize a SyntaxError for JSON.parse.
196 + *
197 + * @param {SyntaxError} error
198 + * @param {object} obj
199 + * @return {SyntaxError}
200 + */
201 +
202 +function normalizeJsonSyntaxError (error, obj) {
203 + var keys = Object.getOwnPropertyNames(error)
204 +
205 + for (var i = 0; i < keys.length; i++) {
206 + var key = keys[i]
207 + if (key !== 'stack' && key !== 'message') {
208 + delete error[key]
209 + }
210 + }
211 +
212 + // replace stack before message for Node.js 0.10 and below
213 + error.stack = obj.stack.replace(error.message, obj.message)
214 + error.message = obj.message
215 +
216 + return error
217 +}
218 +
219 +/**
220 + * Get the simple type checker.
221 + *
222 + * @param {string} type
223 + * @return {function}
224 + */
225 +
226 +function typeChecker (type) {
227 + return function checkType (req) {
228 + return Boolean(typeis(req, type))
229 + }
230 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + */
12 +
13 +var bytes = require('bytes')
14 +var debug = require('debug')('body-parser:raw')
15 +var read = require('../read')
16 +var typeis = require('type-is')
17 +
18 +/**
19 + * Module exports.
20 + */
21 +
22 +module.exports = raw
23 +
24 +/**
25 + * Create a middleware to parse raw bodies.
26 + *
27 + * @param {object} [options]
28 + * @return {function}
29 + * @api public
30 + */
31 +
32 +function raw (options) {
33 + var opts = options || {}
34 +
35 + var inflate = opts.inflate !== false
36 + var limit = typeof opts.limit !== 'number'
37 + ? bytes.parse(opts.limit || '100kb')
38 + : opts.limit
39 + var type = opts.type || 'application/octet-stream'
40 + var verify = opts.verify || false
41 +
42 + if (verify !== false && typeof verify !== 'function') {
43 + throw new TypeError('option verify must be function')
44 + }
45 +
46 + // create the appropriate type checking function
47 + var shouldParse = typeof type !== 'function'
48 + ? typeChecker(type)
49 + : type
50 +
51 + function parse (buf) {
52 + return buf
53 + }
54 +
55 + return function rawParser (req, res, next) {
56 + if (req._body) {
57 + debug('body already parsed')
58 + next()
59 + return
60 + }
61 +
62 + req.body = req.body || {}
63 +
64 + // skip requests without bodies
65 + if (!typeis.hasBody(req)) {
66 + debug('skip empty body')
67 + next()
68 + return
69 + }
70 +
71 + debug('content-type %j', req.headers['content-type'])
72 +
73 + // determine if request should be parsed
74 + if (!shouldParse(req)) {
75 + debug('skip parsing')
76 + next()
77 + return
78 + }
79 +
80 + // read
81 + read(req, res, next, parse, debug, {
82 + encoding: null,
83 + inflate: inflate,
84 + limit: limit,
85 + verify: verify
86 + })
87 + }
88 +}
89 +
90 +/**
91 + * Get the simple type checker.
92 + *
93 + * @param {string} type
94 + * @return {function}
95 + */
96 +
97 +function typeChecker (type) {
98 + return function checkType (req) {
99 + return Boolean(typeis(req, type))
100 + }
101 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + */
12 +
13 +var bytes = require('bytes')
14 +var contentType = require('content-type')
15 +var debug = require('debug')('body-parser:text')
16 +var read = require('../read')
17 +var typeis = require('type-is')
18 +
19 +/**
20 + * Module exports.
21 + */
22 +
23 +module.exports = text
24 +
25 +/**
26 + * Create a middleware to parse text bodies.
27 + *
28 + * @param {object} [options]
29 + * @return {function}
30 + * @api public
31 + */
32 +
33 +function text (options) {
34 + var opts = options || {}
35 +
36 + var defaultCharset = opts.defaultCharset || 'utf-8'
37 + var inflate = opts.inflate !== false
38 + var limit = typeof opts.limit !== 'number'
39 + ? bytes.parse(opts.limit || '100kb')
40 + : opts.limit
41 + var type = opts.type || 'text/plain'
42 + var verify = opts.verify || false
43 +
44 + if (verify !== false && typeof verify !== 'function') {
45 + throw new TypeError('option verify must be function')
46 + }
47 +
48 + // create the appropriate type checking function
49 + var shouldParse = typeof type !== 'function'
50 + ? typeChecker(type)
51 + : type
52 +
53 + function parse (buf) {
54 + return buf
55 + }
56 +
57 + return function textParser (req, res, next) {
58 + if (req._body) {
59 + debug('body already parsed')
60 + next()
61 + return
62 + }
63 +
64 + req.body = req.body || {}
65 +
66 + // skip requests without bodies
67 + if (!typeis.hasBody(req)) {
68 + debug('skip empty body')
69 + next()
70 + return
71 + }
72 +
73 + debug('content-type %j', req.headers['content-type'])
74 +
75 + // determine if request should be parsed
76 + if (!shouldParse(req)) {
77 + debug('skip parsing')
78 + next()
79 + return
80 + }
81 +
82 + // get charset
83 + var charset = getCharset(req) || defaultCharset
84 +
85 + // read
86 + read(req, res, next, parse, debug, {
87 + encoding: charset,
88 + inflate: inflate,
89 + limit: limit,
90 + verify: verify
91 + })
92 + }
93 +}
94 +
95 +/**
96 + * Get the charset of a request.
97 + *
98 + * @param {object} req
99 + * @api private
100 + */
101 +
102 +function getCharset (req) {
103 + try {
104 + return (contentType.parse(req).parameters.charset || '').toLowerCase()
105 + } catch (e) {
106 + return undefined
107 + }
108 +}
109 +
110 +/**
111 + * Get the simple type checker.
112 + *
113 + * @param {string} type
114 + * @return {function}
115 + */
116 +
117 +function typeChecker (type) {
118 + return function checkType (req) {
119 + return Boolean(typeis(req, type))
120 + }
121 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var bytes = require('bytes')
16 +var contentType = require('content-type')
17 +var createError = require('http-errors')
18 +var debug = require('debug')('body-parser:urlencoded')
19 +var deprecate = require('depd')('body-parser')
20 +var read = require('../read')
21 +var typeis = require('type-is')
22 +
23 +/**
24 + * Module exports.
25 + */
26 +
27 +module.exports = urlencoded
28 +
29 +/**
30 + * Cache of parser modules.
31 + */
32 +
33 +var parsers = Object.create(null)
34 +
35 +/**
36 + * Create a middleware to parse urlencoded bodies.
37 + *
38 + * @param {object} [options]
39 + * @return {function}
40 + * @public
41 + */
42 +
43 +function urlencoded (options) {
44 + var opts = options || {}
45 +
46 + // notice because option default will flip in next major
47 + if (opts.extended === undefined) {
48 + deprecate('undefined extended: provide extended option')
49 + }
50 +
51 + var extended = opts.extended !== false
52 + var inflate = opts.inflate !== false
53 + var limit = typeof opts.limit !== 'number'
54 + ? bytes.parse(opts.limit || '100kb')
55 + : opts.limit
56 + var type = opts.type || 'application/x-www-form-urlencoded'
57 + var verify = opts.verify || false
58 +
59 + if (verify !== false && typeof verify !== 'function') {
60 + throw new TypeError('option verify must be function')
61 + }
62 +
63 + // create the appropriate query parser
64 + var queryparse = extended
65 + ? extendedparser(opts)
66 + : simpleparser(opts)
67 +
68 + // create the appropriate type checking function
69 + var shouldParse = typeof type !== 'function'
70 + ? typeChecker(type)
71 + : type
72 +
73 + function parse (body) {
74 + return body.length
75 + ? queryparse(body)
76 + : {}
77 + }
78 +
79 + return function urlencodedParser (req, res, next) {
80 + if (req._body) {
81 + debug('body already parsed')
82 + next()
83 + return
84 + }
85 +
86 + req.body = req.body || {}
87 +
88 + // skip requests without bodies
89 + if (!typeis.hasBody(req)) {
90 + debug('skip empty body')
91 + next()
92 + return
93 + }
94 +
95 + debug('content-type %j', req.headers['content-type'])
96 +
97 + // determine if request should be parsed
98 + if (!shouldParse(req)) {
99 + debug('skip parsing')
100 + next()
101 + return
102 + }
103 +
104 + // assert charset
105 + var charset = getCharset(req) || 'utf-8'
106 + if (charset !== 'utf-8') {
107 + debug('invalid charset')
108 + next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
109 + charset: charset,
110 + type: 'charset.unsupported'
111 + }))
112 + return
113 + }
114 +
115 + // read
116 + read(req, res, next, parse, debug, {
117 + debug: debug,
118 + encoding: charset,
119 + inflate: inflate,
120 + limit: limit,
121 + verify: verify
122 + })
123 + }
124 +}
125 +
126 +/**
127 + * Get the extended query parser.
128 + *
129 + * @param {object} options
130 + */
131 +
132 +function extendedparser (options) {
133 + var parameterLimit = options.parameterLimit !== undefined
134 + ? options.parameterLimit
135 + : 1000
136 + var parse = parser('qs')
137 +
138 + if (isNaN(parameterLimit) || parameterLimit < 1) {
139 + throw new TypeError('option parameterLimit must be a positive number')
140 + }
141 +
142 + if (isFinite(parameterLimit)) {
143 + parameterLimit = parameterLimit | 0
144 + }
145 +
146 + return function queryparse (body) {
147 + var paramCount = parameterCount(body, parameterLimit)
148 +
149 + if (paramCount === undefined) {
150 + debug('too many parameters')
151 + throw createError(413, 'too many parameters', {
152 + type: 'parameters.too.many'
153 + })
154 + }
155 +
156 + var arrayLimit = Math.max(100, paramCount)
157 +
158 + debug('parse extended urlencoding')
159 + return parse(body, {
160 + allowPrototypes: true,
161 + arrayLimit: arrayLimit,
162 + depth: Infinity,
163 + parameterLimit: parameterLimit
164 + })
165 + }
166 +}
167 +
168 +/**
169 + * Get the charset of a request.
170 + *
171 + * @param {object} req
172 + * @api private
173 + */
174 +
175 +function getCharset (req) {
176 + try {
177 + return (contentType.parse(req).parameters.charset || '').toLowerCase()
178 + } catch (e) {
179 + return undefined
180 + }
181 +}
182 +
183 +/**
184 + * Count the number of parameters, stopping once limit reached
185 + *
186 + * @param {string} body
187 + * @param {number} limit
188 + * @api private
189 + */
190 +
191 +function parameterCount (body, limit) {
192 + var count = 0
193 + var index = 0
194 +
195 + while ((index = body.indexOf('&', index)) !== -1) {
196 + count++
197 + index++
198 +
199 + if (count === limit) {
200 + return undefined
201 + }
202 + }
203 +
204 + return count
205 +}
206 +
207 +/**
208 + * Get parser for module name dynamically.
209 + *
210 + * @param {string} name
211 + * @return {function}
212 + * @api private
213 + */
214 +
215 +function parser (name) {
216 + var mod = parsers[name]
217 +
218 + if (mod !== undefined) {
219 + return mod.parse
220 + }
221 +
222 + // this uses a switch for static require analysis
223 + switch (name) {
224 + case 'qs':
225 + mod = require('qs')
226 + break
227 + case 'querystring':
228 + mod = require('querystring')
229 + break
230 + }
231 +
232 + // store to prevent invoking require()
233 + parsers[name] = mod
234 +
235 + return mod.parse
236 +}
237 +
238 +/**
239 + * Get the simple query parser.
240 + *
241 + * @param {object} options
242 + */
243 +
244 +function simpleparser (options) {
245 + var parameterLimit = options.parameterLimit !== undefined
246 + ? options.parameterLimit
247 + : 1000
248 + var parse = parser('querystring')
249 +
250 + if (isNaN(parameterLimit) || parameterLimit < 1) {
251 + throw new TypeError('option parameterLimit must be a positive number')
252 + }
253 +
254 + if (isFinite(parameterLimit)) {
255 + parameterLimit = parameterLimit | 0
256 + }
257 +
258 + return function queryparse (body) {
259 + var paramCount = parameterCount(body, parameterLimit)
260 +
261 + if (paramCount === undefined) {
262 + debug('too many parameters')
263 + throw createError(413, 'too many parameters', {
264 + type: 'parameters.too.many'
265 + })
266 + }
267 +
268 + debug('parse urlencoding')
269 + return parse(body, undefined, undefined, { maxKeys: parameterLimit })
270 + }
271 +}
272 +
273 +/**
274 + * Get the simple type checker.
275 + *
276 + * @param {string} type
277 + * @return {function}
278 + */
279 +
280 +function typeChecker (type) {
281 + return function checkType (req) {
282 + return Boolean(typeis(req, type))
283 + }
284 +}
1 +{
2 + "_from": "body-parser",
3 + "_id": "body-parser@1.19.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
6 + "_location": "/body-parser",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "tag",
10 + "registry": true,
11 + "raw": "body-parser",
12 + "name": "body-parser",
13 + "escapedName": "body-parser",
14 + "rawSpec": "",
15 + "saveSpec": null,
16 + "fetchSpec": "latest"
17 + },
18 + "_requiredBy": [
19 + "#USER",
20 + "/",
21 + "/express"
22 + ],
23 + "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
24 + "_shasum": "96b2709e57c9c4e09a6fd66a8fd979844f69f08a",
25 + "_spec": "body-parser",
26 + "_where": "C:\\Users\\k2cates\\Desktop\\asdfsa sd",
27 + "bugs": {
28 + "url": "https://github.com/expressjs/body-parser/issues"
29 + },
30 + "bundleDependencies": false,
31 + "contributors": [
32 + {
33 + "name": "Douglas Christopher Wilson",
34 + "email": "doug@somethingdoug.com"
35 + },
36 + {
37 + "name": "Jonathan Ong",
38 + "email": "me@jongleberry.com",
39 + "url": "http://jongleberry.com"
40 + }
41 + ],
42 + "dependencies": {
43 + "bytes": "3.1.0",
44 + "content-type": "~1.0.4",
45 + "debug": "2.6.9",
46 + "depd": "~1.1.2",
47 + "http-errors": "1.7.2",
48 + "iconv-lite": "0.4.24",
49 + "on-finished": "~2.3.0",
50 + "qs": "6.7.0",
51 + "raw-body": "2.4.0",
52 + "type-is": "~1.6.17"
53 + },
54 + "deprecated": false,
55 + "description": "Node.js body parsing middleware",
56 + "devDependencies": {
57 + "eslint": "5.16.0",
58 + "eslint-config-standard": "12.0.0",
59 + "eslint-plugin-import": "2.17.2",
60 + "eslint-plugin-markdown": "1.0.0",
61 + "eslint-plugin-node": "8.0.1",
62 + "eslint-plugin-promise": "4.1.1",
63 + "eslint-plugin-standard": "4.0.0",
64 + "istanbul": "0.4.5",
65 + "methods": "1.1.2",
66 + "mocha": "6.1.4",
67 + "safe-buffer": "5.1.2",
68 + "supertest": "4.0.2"
69 + },
70 + "engines": {
71 + "node": ">= 0.8"
72 + },
73 + "files": [
74 + "lib/",
75 + "LICENSE",
76 + "HISTORY.md",
77 + "index.js"
78 + ],
79 + "homepage": "https://github.com/expressjs/body-parser#readme",
80 + "license": "MIT",
81 + "name": "body-parser",
82 + "repository": {
83 + "type": "git",
84 + "url": "git+https://github.com/expressjs/body-parser.git"
85 + },
86 + "scripts": {
87 + "lint": "eslint --plugin markdown --ext js,md .",
88 + "test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
89 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/",
90 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/"
91 + },
92 + "version": "1.19.0"
93 +}
1 +3.1.0 / 2019-01-22
2 +==================
3 +
4 + * Add petabyte (`pb`) support
5 +
6 +3.0.0 / 2017-08-31
7 +==================
8 +
9 + * Change "kB" to "KB" in format output
10 + * Remove support for Node.js 0.6
11 + * Remove support for ComponentJS
12 +
13 +2.5.0 / 2017-03-24
14 +==================
15 +
16 + * Add option "unit"
17 +
18 +2.4.0 / 2016-06-01
19 +==================
20 +
21 + * Add option "unitSeparator"
22 +
23 +2.3.0 / 2016-02-15
24 +==================
25 +
26 + * Drop partial bytes on all parsed units
27 + * Fix non-finite numbers to `.format` to return `null`
28 + * Fix parsing byte string that looks like hex
29 + * perf: hoist regular expressions
30 +
31 +2.2.0 / 2015-11-13
32 +==================
33 +
34 + * add option "decimalPlaces"
35 + * add option "fixedDecimals"
36 +
37 +2.1.0 / 2015-05-21
38 +==================
39 +
40 + * add `.format` export
41 + * add `.parse` export
42 +
43 +2.0.2 / 2015-05-20
44 +==================
45 +
46 + * remove map recreation
47 + * remove unnecessary object construction
48 +
49 +2.0.1 / 2015-05-07
50 +==================
51 +
52 + * fix browserify require
53 + * remove node.extend dependency
54 +
55 +2.0.0 / 2015-04-12
56 +==================
57 +
58 + * add option "case"
59 + * add option "thousandsSeparator"
60 + * return "null" on invalid parse input
61 + * support proper round-trip: bytes(bytes(num)) === num
62 + * units no longer case sensitive when parsing
63 +
64 +1.0.0 / 2014-05-05
65 +==================
66 +
67 + * add negative support. fixes #6
68 +
69 +0.3.0 / 2014-03-19
70 +==================
71 +
72 + * added terabyte support
73 +
74 +0.2.1 / 2013-04-01
75 +==================
76 +
77 + * add .component
78 +
79 +0.2.0 / 2012-10-28
80 +==================
81 +
82 + * bytes(200).should.eql('200b')
83 +
84 +0.1.0 / 2012-07-04
85 +==================
86 +
87 + * add bytes to string conversion [yields]
1 +(The MIT License)
2 +
3 +Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca>
4 +Copyright (c) 2015 Jed Watson <jed.watson@me.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 +# Bytes utility
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Build Status][travis-image]][travis-url]
6 +[![Test Coverage][coveralls-image]][coveralls-url]
7 +
8 +Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
9 +
10 +## Installation
11 +
12 +This is a [Node.js](https://nodejs.org/en/) module available through the
13 +[npm registry](https://www.npmjs.com/). Installation is done using the
14 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
15 +
16 +```bash
17 +$ npm install bytes
18 +```
19 +
20 +## Usage
21 +
22 +```js
23 +var bytes = require('bytes');
24 +```
25 +
26 +#### bytes.format(number value, [options]): string|null
27 +
28 +Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
29 + rounded.
30 +
31 +**Arguments**
32 +
33 +| Name | Type | Description |
34 +|---------|----------|--------------------|
35 +| value | `number` | Value in bytes |
36 +| options | `Object` | Conversion options |
37 +
38 +**Options**
39 +
40 +| Property | Type | Description |
41 +|-------------------|--------|-----------------------------------------------------------------------------------------|
42 +| decimalPlaces | `number``null` | Maximum number of decimal places to include in output. Default value to `2`. |
43 +| fixedDecimals | `boolean``null` | Whether to always display the maximum number of decimal places. Default value to `false` |
44 +| thousandsSeparator | `string``null` | Example of values: `' '`, `','` and `.`... Default value to `''`. |
45 +| unit | `string``null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
46 +| unitSeparator | `string``null` | Separator to use between number and unit. Default value to `''`. |
47 +
48 +**Returns**
49 +
50 +| Name | Type | Description |
51 +|---------|------------------|-------------------------------------------------|
52 +| results | `string``null` | Return null upon error. String value otherwise. |
53 +
54 +**Example**
55 +
56 +```js
57 +bytes(1024);
58 +// output: '1KB'
59 +
60 +bytes(1000);
61 +// output: '1000B'
62 +
63 +bytes(1000, {thousandsSeparator: ' '});
64 +// output: '1 000B'
65 +
66 +bytes(1024 * 1.7, {decimalPlaces: 0});
67 +// output: '2KB'
68 +
69 +bytes(1024, {unitSeparator: ' '});
70 +// output: '1 KB'
71 +
72 +```
73 +
74 +#### bytes.parse(string|number value): number|null
75 +
76 +Parse the string value into an integer in bytes. If no unit is given, or `value`
77 +is a number, it is assumed the value is in bytes.
78 +
79 +Supported units and abbreviations are as follows and are case-insensitive:
80 +
81 + * `b` for bytes
82 + * `kb` for kilobytes
83 + * `mb` for megabytes
84 + * `gb` for gigabytes
85 + * `tb` for terabytes
86 + * `pb` for petabytes
87 +
88 +The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
89 +
90 +**Arguments**
91 +
92 +| Name | Type | Description |
93 +|---------------|--------|--------------------|
94 +| value | `string``number` | String to parse, or number in bytes. |
95 +
96 +**Returns**
97 +
98 +| Name | Type | Description |
99 +|---------|-------------|-------------------------|
100 +| results | `number``null` | Return null upon error. Value in bytes otherwise. |
101 +
102 +**Example**
103 +
104 +```js
105 +bytes('1KB');
106 +// output: 1024
107 +
108 +bytes('1024');
109 +// output: 1024
110 +
111 +bytes(1024);
112 +// output: 1KB
113 +```
114 +
115 +## License
116 +
117 +[MIT](LICENSE)
118 +
119 +[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
120 +[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
121 +[downloads-image]: https://badgen.net/npm/dm/bytes
122 +[downloads-url]: https://npmjs.org/package/bytes
123 +[npm-image]: https://badgen.net/npm/node/bytes
124 +[npm-url]: https://npmjs.org/package/bytes
125 +[travis-image]: https://badgen.net/travis/visionmedia/bytes.js/master
126 +[travis-url]: https://travis-ci.org/visionmedia/bytes.js
1 +/*!
2 + * bytes
3 + * Copyright(c) 2012-2014 TJ Holowaychuk
4 + * Copyright(c) 2015 Jed Watson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict';
9 +
10 +/**
11 + * Module exports.
12 + * @public
13 + */
14 +
15 +module.exports = bytes;
16 +module.exports.format = format;
17 +module.exports.parse = parse;
18 +
19 +/**
20 + * Module variables.
21 + * @private
22 + */
23 +
24 +var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
25 +
26 +var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
27 +
28 +var map = {
29 + b: 1,
30 + kb: 1 << 10,
31 + mb: 1 << 20,
32 + gb: 1 << 30,
33 + tb: Math.pow(1024, 4),
34 + pb: Math.pow(1024, 5),
35 +};
36 +
37 +var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
38 +
39 +/**
40 + * Convert the given value in bytes into a string or parse to string to an integer in bytes.
41 + *
42 + * @param {string|number} value
43 + * @param {{
44 + * case: [string],
45 + * decimalPlaces: [number]
46 + * fixedDecimals: [boolean]
47 + * thousandsSeparator: [string]
48 + * unitSeparator: [string]
49 + * }} [options] bytes options.
50 + *
51 + * @returns {string|number|null}
52 + */
53 +
54 +function bytes(value, options) {
55 + if (typeof value === 'string') {
56 + return parse(value);
57 + }
58 +
59 + if (typeof value === 'number') {
60 + return format(value, options);
61 + }
62 +
63 + return null;
64 +}
65 +
66 +/**
67 + * Format the given value in bytes into a string.
68 + *
69 + * If the value is negative, it is kept as such. If it is a float,
70 + * it is rounded.
71 + *
72 + * @param {number} value
73 + * @param {object} [options]
74 + * @param {number} [options.decimalPlaces=2]
75 + * @param {number} [options.fixedDecimals=false]
76 + * @param {string} [options.thousandsSeparator=]
77 + * @param {string} [options.unit=]
78 + * @param {string} [options.unitSeparator=]
79 + *
80 + * @returns {string|null}
81 + * @public
82 + */
83 +
84 +function format(value, options) {
85 + if (!Number.isFinite(value)) {
86 + return null;
87 + }
88 +
89 + var mag = Math.abs(value);
90 + var thousandsSeparator = (options && options.thousandsSeparator) || '';
91 + var unitSeparator = (options && options.unitSeparator) || '';
92 + var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
93 + var fixedDecimals = Boolean(options && options.fixedDecimals);
94 + var unit = (options && options.unit) || '';
95 +
96 + if (!unit || !map[unit.toLowerCase()]) {
97 + if (mag >= map.pb) {
98 + unit = 'PB';
99 + } else if (mag >= map.tb) {
100 + unit = 'TB';
101 + } else if (mag >= map.gb) {
102 + unit = 'GB';
103 + } else if (mag >= map.mb) {
104 + unit = 'MB';
105 + } else if (mag >= map.kb) {
106 + unit = 'KB';
107 + } else {
108 + unit = 'B';
109 + }
110 + }
111 +
112 + var val = value / map[unit.toLowerCase()];
113 + var str = val.toFixed(decimalPlaces);
114 +
115 + if (!fixedDecimals) {
116 + str = str.replace(formatDecimalsRegExp, '$1');
117 + }
118 +
119 + if (thousandsSeparator) {
120 + str = str.replace(formatThousandsRegExp, thousandsSeparator);
121 + }
122 +
123 + return str + unitSeparator + unit;
124 +}
125 +
126 +/**
127 + * Parse the string value into an integer in bytes.
128 + *
129 + * If no unit is given, it is assumed the value is in bytes.
130 + *
131 + * @param {number|string} val
132 + *
133 + * @returns {number|null}
134 + * @public
135 + */
136 +
137 +function parse(val) {
138 + if (typeof val === 'number' && !isNaN(val)) {
139 + return val;
140 + }
141 +
142 + if (typeof val !== 'string') {
143 + return null;
144 + }
145 +
146 + // Test if the string passed is valid
147 + var results = parseRegExp.exec(val);
148 + var floatValue;
149 + var unit = 'b';
150 +
151 + if (!results) {
152 + // Nothing could be extracted from the given string
153 + floatValue = parseInt(val, 10);
154 + unit = 'b'
155 + } else {
156 + // Retrieve the value and the unit
157 + floatValue = parseFloat(results[1]);
158 + unit = results[4].toLowerCase();
159 + }
160 +
161 + return Math.floor(map[unit] * floatValue);
162 +}
1 +{
2 + "_from": "bytes@3.1.0",
3 + "_id": "bytes@3.1.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==",
6 + "_location": "/bytes",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "bytes@3.1.0",
12 + "name": "bytes",
13 + "escapedName": "bytes",
14 + "rawSpec": "3.1.0",
15 + "saveSpec": null,
16 + "fetchSpec": "3.1.0"
17 + },
18 + "_requiredBy": [
19 + "/body-parser",
20 + "/raw-body"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
23 + "_shasum": "f6cf7933a360e0588fa9fde85651cdc7f805d1f6",
24 + "_spec": "bytes@3.1.0",
25 + "_where": "C:\\Users\\k2cates\\Desktop\\asdfsa sd\\node_modules\\body-parser",
26 + "author": {
27 + "name": "TJ Holowaychuk",
28 + "email": "tj@vision-media.ca",
29 + "url": "http://tjholowaychuk.com"
30 + },
31 + "bugs": {
32 + "url": "https://github.com/visionmedia/bytes.js/issues"
33 + },
34 + "bundleDependencies": false,
35 + "contributors": [
36 + {
37 + "name": "Jed Watson",
38 + "email": "jed.watson@me.com"
39 + },
40 + {
41 + "name": "Théo FIDRY",
42 + "email": "theo.fidry@gmail.com"
43 + }
44 + ],
45 + "deprecated": false,
46 + "description": "Utility to parse a string bytes to bytes and vice-versa",
47 + "devDependencies": {
48 + "eslint": "5.12.1",
49 + "mocha": "5.2.0",
50 + "nyc": "13.1.0"
51 + },
52 + "engines": {
53 + "node": ">= 0.8"
54 + },
55 + "files": [
56 + "History.md",
57 + "LICENSE",
58 + "Readme.md",
59 + "index.js"
60 + ],
61 + "homepage": "https://github.com/visionmedia/bytes.js#readme",
62 + "keywords": [
63 + "byte",
64 + "bytes",
65 + "utility",
66 + "parse",
67 + "parser",
68 + "convert",
69 + "converter"
70 + ],
71 + "license": "MIT",
72 + "name": "bytes",
73 + "repository": {
74 + "type": "git",
75 + "url": "git+https://github.com/visionmedia/bytes.js.git"
76 + },
77 + "scripts": {
78 + "lint": "eslint .",
79 + "test": "mocha --check-leaks --reporter spec",
80 + "test-ci": "nyc --reporter=text npm test",
81 + "test-cov": "nyc --reporter=html --reporter=text npm test"
82 + },
83 + "version": "3.1.0"
84 +}
1 +0.5.3 / 2018-12-17
2 +==================
3 +
4 + * Use `safe-buffer` for improved Buffer API
5 +
6 +0.5.2 / 2016-12-08
7 +==================
8 +
9 + * Fix `parse` to accept any linear whitespace character
10 +
11 +0.5.1 / 2016-01-17
12 +==================
13 +
14 + * perf: enable strict mode
15 +
16 +0.5.0 / 2014-10-11
17 +==================
18 +
19 + * Add `parse` function
20 +
21 +0.4.0 / 2014-09-21
22 +==================
23 +
24 + * Expand non-Unicode `filename` to the full ISO-8859-1 charset
25 +
26 +0.3.0 / 2014-09-20
27 +==================
28 +
29 + * Add `fallback` option
30 + * Add `type` option
31 +
32 +0.2.0 / 2014-09-19
33 +==================
34 +
35 + * Reduce ambiguity of file names with hex escape in buggy browsers
36 +
37 +0.1.2 / 2014-09-19
38 +==================
39 +
40 + * Fix periodic invalid Unicode filename header
41 +
42 +0.1.1 / 2014-09-19
43 +==================
44 +
45 + * Fix invalid characters appearing in `filename*` parameter
46 +
47 +0.1.0 / 2014-09-18
48 +==================
49 +
50 + * Make the `filename` argument optional
51 +
52 +0.0.0 / 2014-09-18
53 +==================
54 +
55 + * Initial release
1 +(The MIT License)
2 +
3 +Copyright (c) 2014-2017 Douglas Christopher Wilson
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# content-disposition
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-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 +Create and parse HTTP `Content-Disposition` header
10 +
11 +## Installation
12 +
13 +```sh
14 +$ npm install content-disposition
15 +```
16 +
17 +## API
18 +
19 +<!-- eslint-disable no-unused-vars -->
20 +
21 +```js
22 +var contentDisposition = require('content-disposition')
23 +```
24 +
25 +### contentDisposition(filename, options)
26 +
27 +Create an attachment `Content-Disposition` header value using the given file name,
28 +if supplied. The `filename` is optional and if no file name is desired, but you
29 +want to specify `options`, set `filename` to `undefined`.
30 +
31 +<!-- eslint-disable no-undef -->
32 +
33 +```js
34 +res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf'))
35 +```
36 +
37 +**note** HTTP headers are of the ISO-8859-1 character set. If you are writing this
38 +header through a means different from `setHeader` in Node.js, you'll want to specify
39 +the `'binary'` encoding in Node.js.
40 +
41 +#### Options
42 +
43 +`contentDisposition` accepts these properties in the options object.
44 +
45 +##### fallback
46 +
47 +If the `filename` option is outside ISO-8859-1, then the file name is actually
48 +stored in a supplemental field for clients that support Unicode file names and
49 +a ISO-8859-1 version of the file name is automatically generated.
50 +
51 +This specifies the ISO-8859-1 file name to override the automatic generation or
52 +disables the generation all together, defaults to `true`.
53 +
54 + - A string will specify the ISO-8859-1 file name to use in place of automatic
55 + generation.
56 + - `false` will disable including a ISO-8859-1 file name and only include the
57 + Unicode version (unless the file name is already ISO-8859-1).
58 + - `true` will enable automatic generation if the file name is outside ISO-8859-1.
59 +
60 +If the `filename` option is ISO-8859-1 and this option is specified and has a
61 +different value, then the `filename` option is encoded in the extended field
62 +and this set as the fallback field, even though they are both ISO-8859-1.
63 +
64 +##### type
65 +
66 +Specifies the disposition type, defaults to `"attachment"`. This can also be
67 +`"inline"`, or any other value (all values except inline are treated like
68 +`attachment`, but can convey additional information if both parties agree to
69 +it). The type is normalized to lower-case.
70 +
71 +### contentDisposition.parse(string)
72 +
73 +<!-- eslint-disable no-undef, no-unused-vars -->
74 +
75 +```js
76 +var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt')
77 +```
78 +
79 +Parse a `Content-Disposition` header string. This automatically handles extended
80 +("Unicode") parameters by decoding them and providing them under the standard
81 +parameter name. This will return an object with the following properties (examples
82 +are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`):
83 +
84 + - `type`: The disposition type (always lower case). Example: `'attachment'`
85 +
86 + - `parameters`: An object of the parameters in the disposition (name of parameter
87 + always lower case and extended versions replace non-extended versions). Example:
88 + `{filename: "€ rates.txt"}`
89 +
90 +## Examples
91 +
92 +### Send a file for download
93 +
94 +```js
95 +var contentDisposition = require('content-disposition')
96 +var destroy = require('destroy')
97 +var fs = require('fs')
98 +var http = require('http')
99 +var onFinished = require('on-finished')
100 +
101 +var filePath = '/path/to/public/plans.pdf'
102 +
103 +http.createServer(function onRequest (req, res) {
104 + // set headers
105 + res.setHeader('Content-Type', 'application/pdf')
106 + res.setHeader('Content-Disposition', contentDisposition(filePath))
107 +
108 + // send file
109 + var stream = fs.createReadStream(filePath)
110 + stream.pipe(res)
111 + onFinished(res, function () {
112 + destroy(stream)
113 + })
114 +})
115 +```
116 +
117 +## Testing
118 +
119 +```sh
120 +$ npm test
121 +```
122 +
123 +## References
124 +
125 +- [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616]
126 +- [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987]
127 +- [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266]
128 +- [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231]
129 +
130 +[rfc-2616]: https://tools.ietf.org/html/rfc2616
131 +[rfc-5987]: https://tools.ietf.org/html/rfc5987
132 +[rfc-6266]: https://tools.ietf.org/html/rfc6266
133 +[tc-2231]: http://greenbytes.de/tech/tc2231/
134 +
135 +## License
136 +
137 +[MIT](LICENSE)
138 +
139 +[npm-image]: https://img.shields.io/npm/v/content-disposition.svg
140 +[npm-url]: https://npmjs.org/package/content-disposition
141 +[node-version-image]: https://img.shields.io/node/v/content-disposition.svg
142 +[node-version-url]: https://nodejs.org/en/download
143 +[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg
144 +[travis-url]: https://travis-ci.org/jshttp/content-disposition
145 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg
146 +[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master
147 +[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg
148 +[downloads-url]: https://npmjs.org/package/content-disposition
This diff is collapsed. Click to expand it.
1 +{
2 + "_from": "content-disposition@0.5.3",
3 + "_id": "content-disposition@0.5.3",
4 + "_inBundle": false,
5 + "_integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
6 + "_location": "/content-disposition",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "content-disposition@0.5.3",
12 + "name": "content-disposition",
13 + "escapedName": "content-disposition",
14 + "rawSpec": "0.5.3",
15 + "saveSpec": null,
16 + "fetchSpec": "0.5.3"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
22 + "_shasum": "e130caf7e7279087c5616c2007d0485698984fbd",
23 + "_spec": "content-disposition@0.5.3",
24 + "_where": "C:\\Users\\k2cates\\Desktop\\asdfsa sd\\node_modules\\express",
25 + "author": {
26 + "name": "Douglas Christopher Wilson",
27 + "email": "doug@somethingdoug.com"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/jshttp/content-disposition/issues"
31 + },
32 + "bundleDependencies": false,
33 + "dependencies": {
34 + "safe-buffer": "5.1.2"
35 + },
36 + "deprecated": false,
37 + "description": "Create and parse Content-Disposition header",
38 + "devDependencies": {
39 + "deep-equal": "1.0.1",
40 + "eslint": "5.10.0",
41 + "eslint-config-standard": "12.0.0",
42 + "eslint-plugin-import": "2.14.0",
43 + "eslint-plugin-markdown": "1.0.0-rc.1",
44 + "eslint-plugin-node": "7.0.1",
45 + "eslint-plugin-promise": "4.0.1",
46 + "eslint-plugin-standard": "4.0.0",
47 + "istanbul": "0.4.5",
48 + "mocha": "5.2.0"
49 + },
50 + "engines": {
51 + "node": ">= 0.6"
52 + },
53 + "files": [
54 + "LICENSE",
55 + "HISTORY.md",
56 + "README.md",
57 + "index.js"
58 + ],
59 + "homepage": "https://github.com/jshttp/content-disposition#readme",
60 + "keywords": [
61 + "content-disposition",
62 + "http",
63 + "rfc6266",
64 + "res"
65 + ],
66 + "license": "MIT",
67 + "name": "content-disposition",
68 + "repository": {
69 + "type": "git",
70 + "url": "git+https://github.com/jshttp/content-disposition.git"
71 + },
72 + "scripts": {
73 + "lint": "eslint --plugin markdown --ext js,md .",
74 + "test": "mocha --reporter spec --bail --check-leaks test/",
75 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
76 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
77 + },
78 + "version": "0.5.3"
79 +}
1 +1.0.4 / 2017-09-11
2 +==================
3 +
4 + * perf: skip parameter parsing when no parameters
5 +
6 +1.0.3 / 2017-09-10
7 +==================
8 +
9 + * perf: remove argument reassignment
10 +
11 +1.0.2 / 2016-05-09
12 +==================
13 +
14 + * perf: enable strict mode
15 +
16 +1.0.1 / 2015-02-13
17 +==================
18 +
19 + * Improve missing `Content-Type` header error message
20 +
21 +1.0.0 / 2015-02-01
22 +==================
23 +
24 + * Initial implementation, derived from `media-typer@0.3.0`
1 +(The MIT License)
2 +
3 +Copyright (c) 2015 Douglas Christopher Wilson
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# content-type
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-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 +Create and parse HTTP Content-Type header according to RFC 7231
10 +
11 +## Installation
12 +
13 +```sh
14 +$ npm install content-type
15 +```
16 +
17 +## API
18 +
19 +```js
20 +var contentType = require('content-type')
21 +```
22 +
23 +### contentType.parse(string)
24 +
25 +```js
26 +var obj = contentType.parse('image/svg+xml; charset=utf-8')
27 +```
28 +
29 +Parse a content type string. This will return an object with the following
30 +properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
31 +
32 + - `type`: The media type (the type and subtype, always lower case).
33 + Example: `'image/svg+xml'`
34 +
35 + - `parameters`: An object of the parameters in the media type (name of parameter
36 + always lower case). Example: `{charset: 'utf-8'}`
37 +
38 +Throws a `TypeError` if the string is missing or invalid.
39 +
40 +### contentType.parse(req)
41 +
42 +```js
43 +var obj = contentType.parse(req)
44 +```
45 +
46 +Parse the `content-type` header from the given `req`. Short-cut for
47 +`contentType.parse(req.headers['content-type'])`.
48 +
49 +Throws a `TypeError` if the `Content-Type` header is missing or invalid.
50 +
51 +### contentType.parse(res)
52 +
53 +```js
54 +var obj = contentType.parse(res)
55 +```
56 +
57 +Parse the `content-type` header set on the given `res`. Short-cut for
58 +`contentType.parse(res.getHeader('content-type'))`.
59 +
60 +Throws a `TypeError` if the `Content-Type` header is missing or invalid.
61 +
62 +### contentType.format(obj)
63 +
64 +```js
65 +var str = contentType.format({type: 'image/svg+xml'})
66 +```
67 +
68 +Format an object into a content type string. This will return a string of the
69 +content type for the given object with the following properties (examples are
70 +shown that produce the string `'image/svg+xml; charset=utf-8'`):
71 +
72 + - `type`: The media type (will be lower-cased). Example: `'image/svg+xml'`
73 +
74 + - `parameters`: An object of the parameters in the media type (name of the
75 + parameter will be lower-cased). Example: `{charset: 'utf-8'}`
76 +
77 +Throws a `TypeError` if the object contains an invalid type or parameter names.
78 +
79 +## License
80 +
81 +[MIT](LICENSE)
82 +
83 +[npm-image]: https://img.shields.io/npm/v/content-type.svg
84 +[npm-url]: https://npmjs.org/package/content-type
85 +[node-version-image]: https://img.shields.io/node/v/content-type.svg
86 +[node-version-url]: http://nodejs.org/download/
87 +[travis-image]: https://img.shields.io/travis/jshttp/content-type/master.svg
88 +[travis-url]: https://travis-ci.org/jshttp/content-type
89 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-type/master.svg
90 +[coveralls-url]: https://coveralls.io/r/jshttp/content-type
91 +[downloads-image]: https://img.shields.io/npm/dm/content-type.svg
92 +[downloads-url]: https://npmjs.org/package/content-type
1 +/*!
2 + * content-type
3 + * Copyright(c) 2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
11 + *
12 + * parameter = token "=" ( token / quoted-string )
13 + * token = 1*tchar
14 + * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
15 + * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
16 + * / DIGIT / ALPHA
17 + * ; any VCHAR, except delimiters
18 + * quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
19 + * qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
20 + * obs-text = %x80-FF
21 + * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
22 + */
23 +var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g
24 +var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/
25 +var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/
26 +
27 +/**
28 + * RegExp to match quoted-pair in RFC 7230 sec 3.2.6
29 + *
30 + * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
31 + * obs-text = %x80-FF
32 + */
33 +var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g
34 +
35 +/**
36 + * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
37 + */
38 +var QUOTE_REGEXP = /([\\"])/g
39 +
40 +/**
41 + * RegExp to match type in RFC 7231 sec 3.1.1.1
42 + *
43 + * media-type = type "/" subtype
44 + * type = token
45 + * subtype = token
46 + */
47 +var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/
48 +
49 +/**
50 + * Module exports.
51 + * @public
52 + */
53 +
54 +exports.format = format
55 +exports.parse = parse
56 +
57 +/**
58 + * Format object to media type.
59 + *
60 + * @param {object} obj
61 + * @return {string}
62 + * @public
63 + */
64 +
65 +function format (obj) {
66 + if (!obj || typeof obj !== 'object') {
67 + throw new TypeError('argument obj is required')
68 + }
69 +
70 + var parameters = obj.parameters
71 + var type = obj.type
72 +
73 + if (!type || !TYPE_REGEXP.test(type)) {
74 + throw new TypeError('invalid type')
75 + }
76 +
77 + var string = type
78 +
79 + // append parameters
80 + if (parameters && typeof parameters === 'object') {
81 + var param
82 + var params = Object.keys(parameters).sort()
83 +
84 + for (var i = 0; i < params.length; i++) {
85 + param = params[i]
86 +
87 + if (!TOKEN_REGEXP.test(param)) {
88 + throw new TypeError('invalid parameter name')
89 + }
90 +
91 + string += '; ' + param + '=' + qstring(parameters[param])
92 + }
93 + }
94 +
95 + return string
96 +}
97 +
98 +/**
99 + * Parse media type to object.
100 + *
101 + * @param {string|object} string
102 + * @return {Object}
103 + * @public
104 + */
105 +
106 +function parse (string) {
107 + if (!string) {
108 + throw new TypeError('argument string is required')
109 + }
110 +
111 + // support req/res-like objects as argument
112 + var header = typeof string === 'object'
113 + ? getcontenttype(string)
114 + : string
115 +
116 + if (typeof header !== 'string') {
117 + throw new TypeError('argument string is required to be a string')
118 + }
119 +
120 + var index = header.indexOf(';')
121 + var type = index !== -1
122 + ? header.substr(0, index).trim()
123 + : header.trim()
124 +
125 + if (!TYPE_REGEXP.test(type)) {
126 + throw new TypeError('invalid media type')
127 + }
128 +
129 + var obj = new ContentType(type.toLowerCase())
130 +
131 + // parse parameters
132 + if (index !== -1) {
133 + var key
134 + var match
135 + var value
136 +
137 + PARAM_REGEXP.lastIndex = index
138 +
139 + while ((match = PARAM_REGEXP.exec(header))) {
140 + if (match.index !== index) {
141 + throw new TypeError('invalid parameter format')
142 + }
143 +
144 + index += match[0].length
145 + key = match[1].toLowerCase()
146 + value = match[2]
147 +
148 + if (value[0] === '"') {
149 + // remove quotes and escapes
150 + value = value
151 + .substr(1, value.length - 2)
152 + .replace(QESC_REGEXP, '$1')
153 + }
154 +
155 + obj.parameters[key] = value
156 + }
157 +
158 + if (index !== header.length) {
159 + throw new TypeError('invalid parameter format')
160 + }
161 + }
162 +
163 + return obj
164 +}
165 +
166 +/**
167 + * Get content-type from req/res objects.
168 + *
169 + * @param {object}
170 + * @return {Object}
171 + * @private
172 + */
173 +
174 +function getcontenttype (obj) {
175 + var header
176 +
177 + if (typeof obj.getHeader === 'function') {
178 + // res-like
179 + header = obj.getHeader('content-type')
180 + } else if (typeof obj.headers === 'object') {
181 + // req-like
182 + header = obj.headers && obj.headers['content-type']
183 + }
184 +
185 + if (typeof header !== 'string') {
186 + throw new TypeError('content-type header is missing from object')
187 + }
188 +
189 + return header
190 +}
191 +
192 +/**
193 + * Quote a string if necessary.
194 + *
195 + * @param {string} val
196 + * @return {string}
197 + * @private
198 + */
199 +
200 +function qstring (val) {
201 + var str = String(val)
202 +
203 + // no need to quote tokens
204 + if (TOKEN_REGEXP.test(str)) {
205 + return str
206 + }
207 +
208 + if (str.length > 0 && !TEXT_REGEXP.test(str)) {
209 + throw new TypeError('invalid parameter value')
210 + }
211 +
212 + return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
213 +}
214 +
215 +/**
216 + * Class to represent a content type.
217 + * @private
218 + */
219 +function ContentType (type) {
220 + this.parameters = Object.create(null)
221 + this.type = type
222 +}
1 +{
2 + "_from": "content-type@~1.0.4",
3 + "_id": "content-type@1.0.4",
4 + "_inBundle": false,
5 + "_integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
6 + "_location": "/content-type",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "content-type@~1.0.4",
12 + "name": "content-type",
13 + "escapedName": "content-type",
14 + "rawSpec": "~1.0.4",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.0.4"
17 + },
18 + "_requiredBy": [
19 + "/body-parser",
20 + "/express"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
23 + "_shasum": "e138cc75e040c727b1966fe5e5f8c9aee256fe3b",
24 + "_spec": "content-type@~1.0.4",
25 + "_where": "C:\\Users\\k2cates\\Desktop\\asdfsa sd\\node_modules\\express",
26 + "author": {
27 + "name": "Douglas Christopher Wilson",
28 + "email": "doug@somethingdoug.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/jshttp/content-type/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "Create and parse HTTP Content-Type header",
36 + "devDependencies": {
37 + "eslint": "3.19.0",
38 + "eslint-config-standard": "10.2.1",
39 + "eslint-plugin-import": "2.7.0",
40 + "eslint-plugin-node": "5.1.1",
41 + "eslint-plugin-promise": "3.5.0",
42 + "eslint-plugin-standard": "3.0.1",
43 + "istanbul": "0.4.5",
44 + "mocha": "~1.21.5"
45 + },
46 + "engines": {
47 + "node": ">= 0.6"
48 + },
49 + "files": [
50 + "LICENSE",
51 + "HISTORY.md",
52 + "README.md",
53 + "index.js"
54 + ],
55 + "homepage": "https://github.com/jshttp/content-type#readme",
56 + "keywords": [
57 + "content-type",
58 + "http",
59 + "req",
60 + "res",
61 + "rfc7231"
62 + ],
63 + "license": "MIT",
64 + "name": "content-type",
65 + "repository": {
66 + "type": "git",
67 + "url": "git+https://github.com/jshttp/content-type.git"
68 + },
69 + "scripts": {
70 + "lint": "eslint .",
71 + "test": "mocha --reporter spec --check-leaks --bail test/",
72 + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
73 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
74 + },
75 + "version": "1.0.4"
76 +}
1 +support
2 +test
3 +examples
4 +*.sock
1 +1.0.6 / 2015-02-03
2 +==================
3 +
4 +* use `npm test` instead of `make test` to run tests
5 +* clearer assertion messages when checking input
6 +
7 +
8 +1.0.5 / 2014-09-05
9 +==================
10 +
11 +* add license to package.json
12 +
13 +1.0.4 / 2014-06-25
14 +==================
15 +
16 + * corrected avoidance of timing attacks (thanks @tenbits!)
17 +
18 +1.0.3 / 2014-01-28
19 +==================
20 +
21 + * [incorrect] fix for timing attacks
22 +
23 +1.0.2 / 2014-01-28
24 +==================
25 +
26 + * fix missing repository warning
27 + * fix typo in test
28 +
29 +1.0.1 / 2013-04-15
30 +==================
31 +
32 + * Revert "Changed underlying HMAC algo. to sha512."
33 + * Revert "Fix for timing attacks on MAC verification."
34 +
35 +0.0.1 / 2010-01-03
36 +==================
37 +
38 + * Initial release
1 +
2 +# cookie-signature
3 +
4 + Sign and unsign cookies.
5 +
6 +## Example
7 +
8 +```js
9 +var cookie = require('cookie-signature');
10 +
11 +var val = cookie.sign('hello', 'tobiiscool');
12 +val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');
13 +
14 +var val = cookie.sign('hello', 'tobiiscool');
15 +cookie.unsign(val, 'tobiiscool').should.equal('hello');
16 +cookie.unsign(val, 'luna').should.be.false;
17 +```
18 +
19 +## License
20 +
21 +(The MIT License)
22 +
23 +Copyright (c) 2012 LearnBoost &lt;tj@learnboost.com&gt;
24 +
25 +Permission is hereby granted, free of charge, to any person obtaining
26 +a copy of this software and associated documentation files (the
27 +'Software'), to deal in the Software without restriction, including
28 +without limitation the rights to use, copy, modify, merge, publish,
29 +distribute, sublicense, and/or sell copies of the Software, and to
30 +permit persons to whom the Software is furnished to do so, subject to
31 +the following conditions:
32 +
33 +The above copyright notice and this permission notice shall be
34 +included in all copies or substantial portions of the Software.
35 +
36 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
37 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
39 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
40 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
41 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
42 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 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 could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.