es6-crawler-detect 3.3.0 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/.babelrc +1 -1
  2. package/.mocharc.json +5 -0
  3. package/README.md +1 -0
  4. package/dist/index.d.ts +5 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +18 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/crawler/crawlers.d.ts +5 -0
  9. package/dist/lib/crawler/crawlers.d.ts.map +1 -0
  10. package/dist/lib/crawler/crawlers.js +1400 -0
  11. package/dist/lib/crawler/crawlers.js.map +1 -0
  12. package/dist/lib/crawler/exclusions.d.ts +5 -0
  13. package/dist/lib/crawler/exclusions.d.ts.map +1 -0
  14. package/dist/lib/crawler/exclusions.js +59 -0
  15. package/dist/lib/crawler/exclusions.js.map +1 -0
  16. package/dist/lib/crawler/headers.d.ts +5 -0
  17. package/dist/lib/crawler/headers.d.ts.map +1 -0
  18. package/dist/lib/crawler/headers.js +21 -0
  19. package/dist/lib/crawler/headers.js.map +1 -0
  20. package/dist/lib/crawler/provider.d.ts +4 -0
  21. package/dist/lib/crawler/provider.d.ts.map +1 -0
  22. package/dist/lib/crawler/provider.js +3 -0
  23. package/dist/lib/crawler/provider.js.map +1 -0
  24. package/dist/lib/crawler.d.ts +21 -0
  25. package/dist/lib/crawler.d.ts.map +1 -0
  26. package/dist/lib/crawler.js +98 -0
  27. package/dist/lib/crawler.js.map +1 -0
  28. package/dist/types.d.ts +9 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +3 -0
  31. package/dist/types.js.map +1 -0
  32. package/eslint.config.mjs +62 -0
  33. package/example/node/package.json +1 -1
  34. package/example/node/yarn.lock +222 -99
  35. package/package.json +30 -24
  36. package/src/index.ts +18 -0
  37. package/src/lib/crawler/{crawlers.js → crawlers.ts} +1397 -1403
  38. package/src/lib/crawler/{exclusions.js → exclusions.ts} +56 -62
  39. package/src/lib/crawler/{headers.js → headers.ts} +4 -10
  40. package/src/lib/crawler/provider.ts +3 -0
  41. package/src/lib/crawler.ts +128 -0
  42. package/src/types.ts +15 -0
  43. package/test/lib/crawler.spec.ts +116 -0
  44. package/tsconfig.json +28 -0
  45. package/.eslintignore +0 -6
  46. package/.eslintrc.json +0 -30
  47. package/dist/main.bundle.js +0 -1
  48. package/example/node/dist/crawler.min.js +0 -1
  49. package/example/node/node_modules/.bin/mime +0 -15
  50. package/example/node/node_modules/.bin/mime.cmd +0 -7
  51. package/example/node/node_modules/.yarn-integrity +0 -67
  52. package/example/node/node_modules/accepts/HISTORY.md +0 -236
  53. package/example/node/node_modules/accepts/LICENSE +0 -23
  54. package/example/node/node_modules/accepts/README.md +0 -142
  55. package/example/node/node_modules/accepts/index.js +0 -238
  56. package/example/node/node_modules/accepts/package.json +0 -47
  57. package/example/node/node_modules/array-flatten/LICENSE +0 -21
  58. package/example/node/node_modules/array-flatten/README.md +0 -43
  59. package/example/node/node_modules/array-flatten/array-flatten.js +0 -64
  60. package/example/node/node_modules/array-flatten/package.json +0 -39
  61. package/example/node/node_modules/body-parser/HISTORY.md +0 -624
  62. package/example/node/node_modules/body-parser/LICENSE +0 -23
  63. package/example/node/node_modules/body-parser/README.md +0 -456
  64. package/example/node/node_modules/body-parser/index.js +0 -157
  65. package/example/node/node_modules/body-parser/lib/read.js +0 -181
  66. package/example/node/node_modules/body-parser/lib/types/json.js +0 -230
  67. package/example/node/node_modules/body-parser/lib/types/raw.js +0 -101
  68. package/example/node/node_modules/body-parser/lib/types/text.js +0 -121
  69. package/example/node/node_modules/body-parser/lib/types/urlencoded.js +0 -284
  70. package/example/node/node_modules/body-parser/package.json +0 -52
  71. package/example/node/node_modules/bytes/History.md +0 -92
  72. package/example/node/node_modules/bytes/LICENSE +0 -23
  73. package/example/node/node_modules/bytes/Readme.md +0 -152
  74. package/example/node/node_modules/bytes/index.js +0 -166
  75. package/example/node/node_modules/bytes/package.json +0 -42
  76. package/example/node/node_modules/content-disposition/HISTORY.md +0 -60
  77. package/example/node/node_modules/content-disposition/LICENSE +0 -22
  78. package/example/node/node_modules/content-disposition/README.md +0 -142
  79. package/example/node/node_modules/content-disposition/index.js +0 -458
  80. package/example/node/node_modules/content-disposition/package.json +0 -44
  81. package/example/node/node_modules/content-type/HISTORY.md +0 -24
  82. package/example/node/node_modules/content-type/LICENSE +0 -22
  83. package/example/node/node_modules/content-type/README.md +0 -92
  84. package/example/node/node_modules/content-type/index.js +0 -222
  85. package/example/node/node_modules/content-type/package.json +0 -40
  86. package/example/node/node_modules/cookie/HISTORY.md +0 -128
  87. package/example/node/node_modules/cookie/LICENSE +0 -24
  88. package/example/node/node_modules/cookie/README.md +0 -257
  89. package/example/node/node_modules/cookie/index.js +0 -202
  90. package/example/node/node_modules/cookie/package.json +0 -40
  91. package/example/node/node_modules/cookie-signature/History.md +0 -38
  92. package/example/node/node_modules/cookie-signature/Readme.md +0 -42
  93. package/example/node/node_modules/cookie-signature/index.js +0 -51
  94. package/example/node/node_modules/cookie-signature/package.json +0 -18
  95. package/example/node/node_modules/debug/.coveralls.yml +0 -1
  96. package/example/node/node_modules/debug/.eslintrc +0 -11
  97. package/example/node/node_modules/debug/.travis.yml +0 -14
  98. package/example/node/node_modules/debug/CHANGELOG.md +0 -362
  99. package/example/node/node_modules/debug/LICENSE +0 -19
  100. package/example/node/node_modules/debug/Makefile +0 -50
  101. package/example/node/node_modules/debug/README.md +0 -312
  102. package/example/node/node_modules/debug/component.json +0 -19
  103. package/example/node/node_modules/debug/karma.conf.js +0 -70
  104. package/example/node/node_modules/debug/node.js +0 -1
  105. package/example/node/node_modules/debug/package.json +0 -49
  106. package/example/node/node_modules/debug/src/browser.js +0 -185
  107. package/example/node/node_modules/debug/src/debug.js +0 -202
  108. package/example/node/node_modules/debug/src/index.js +0 -10
  109. package/example/node/node_modules/debug/src/inspector-log.js +0 -15
  110. package/example/node/node_modules/debug/src/node.js +0 -248
  111. package/example/node/node_modules/depd/History.md +0 -96
  112. package/example/node/node_modules/depd/LICENSE +0 -22
  113. package/example/node/node_modules/depd/Readme.md +0 -280
  114. package/example/node/node_modules/depd/index.js +0 -522
  115. package/example/node/node_modules/depd/lib/browser/index.js +0 -77
  116. package/example/node/node_modules/depd/lib/compat/callsite-tostring.js +0 -103
  117. package/example/node/node_modules/depd/lib/compat/event-listener-count.js +0 -22
  118. package/example/node/node_modules/depd/lib/compat/index.js +0 -79
  119. package/example/node/node_modules/depd/package.json +0 -41
  120. package/example/node/node_modules/destroy/LICENSE +0 -22
  121. package/example/node/node_modules/destroy/README.md +0 -60
  122. package/example/node/node_modules/destroy/index.js +0 -75
  123. package/example/node/node_modules/destroy/package.json +0 -37
  124. package/example/node/node_modules/ee-first/LICENSE +0 -22
  125. package/example/node/node_modules/ee-first/README.md +0 -80
  126. package/example/node/node_modules/ee-first/index.js +0 -95
  127. package/example/node/node_modules/ee-first/package.json +0 -29
  128. package/example/node/node_modules/encodeurl/HISTORY.md +0 -14
  129. package/example/node/node_modules/encodeurl/LICENSE +0 -22
  130. package/example/node/node_modules/encodeurl/README.md +0 -128
  131. package/example/node/node_modules/encodeurl/index.js +0 -60
  132. package/example/node/node_modules/encodeurl/package.json +0 -40
  133. package/example/node/node_modules/escape-html/LICENSE +0 -24
  134. package/example/node/node_modules/escape-html/Readme.md +0 -43
  135. package/example/node/node_modules/escape-html/index.js +0 -78
  136. package/example/node/node_modules/escape-html/package.json +0 -24
  137. package/example/node/node_modules/etag/HISTORY.md +0 -83
  138. package/example/node/node_modules/etag/LICENSE +0 -22
  139. package/example/node/node_modules/etag/README.md +0 -159
  140. package/example/node/node_modules/etag/index.js +0 -131
  141. package/example/node/node_modules/etag/package.json +0 -47
  142. package/example/node/node_modules/express/History.md +0 -3510
  143. package/example/node/node_modules/express/LICENSE +0 -24
  144. package/example/node/node_modules/express/Readme.md +0 -158
  145. package/example/node/node_modules/express/index.js +0 -11
  146. package/example/node/node_modules/express/lib/application.js +0 -644
  147. package/example/node/node_modules/express/lib/express.js +0 -116
  148. package/example/node/node_modules/express/lib/middleware/init.js +0 -43
  149. package/example/node/node_modules/express/lib/middleware/query.js +0 -47
  150. package/example/node/node_modules/express/lib/request.js +0 -525
  151. package/example/node/node_modules/express/lib/response.js +0 -1147
  152. package/example/node/node_modules/express/lib/router/index.js +0 -668
  153. package/example/node/node_modules/express/lib/router/layer.js +0 -181
  154. package/example/node/node_modules/express/lib/router/route.js +0 -216
  155. package/example/node/node_modules/express/lib/utils.js +0 -302
  156. package/example/node/node_modules/express/lib/view.js +0 -182
  157. package/example/node/node_modules/express/package.json +0 -99
  158. package/example/node/node_modules/finalhandler/HISTORY.md +0 -187
  159. package/example/node/node_modules/finalhandler/LICENSE +0 -22
  160. package/example/node/node_modules/finalhandler/README.md +0 -148
  161. package/example/node/node_modules/finalhandler/index.js +0 -331
  162. package/example/node/node_modules/finalhandler/package.json +0 -45
  163. package/example/node/node_modules/forwarded/HISTORY.md +0 -21
  164. package/example/node/node_modules/forwarded/LICENSE +0 -22
  165. package/example/node/node_modules/forwarded/README.md +0 -57
  166. package/example/node/node_modules/forwarded/index.js +0 -90
  167. package/example/node/node_modules/forwarded/package.json +0 -45
  168. package/example/node/node_modules/fresh/HISTORY.md +0 -70
  169. package/example/node/node_modules/fresh/LICENSE +0 -23
  170. package/example/node/node_modules/fresh/README.md +0 -119
  171. package/example/node/node_modules/fresh/index.js +0 -137
  172. package/example/node/node_modules/fresh/package.json +0 -46
  173. package/example/node/node_modules/http-errors/HISTORY.md +0 -165
  174. package/example/node/node_modules/http-errors/LICENSE +0 -23
  175. package/example/node/node_modules/http-errors/README.md +0 -169
  176. package/example/node/node_modules/http-errors/index.js +0 -299
  177. package/example/node/node_modules/http-errors/package.json +0 -49
  178. package/example/node/node_modules/iconv-lite/Changelog.md +0 -162
  179. package/example/node/node_modules/iconv-lite/LICENSE +0 -21
  180. package/example/node/node_modules/iconv-lite/README.md +0 -156
  181. package/example/node/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -555
  182. package/example/node/node_modules/iconv-lite/encodings/dbcs-data.js +0 -176
  183. package/example/node/node_modules/iconv-lite/encodings/index.js +0 -22
  184. package/example/node/node_modules/iconv-lite/encodings/internal.js +0 -188
  185. package/example/node/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  186. package/example/node/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  187. package/example/node/node_modules/iconv-lite/encodings/sbcs-data.js +0 -174
  188. package/example/node/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  189. package/example/node/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  190. package/example/node/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  191. package/example/node/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  192. package/example/node/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  193. package/example/node/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  194. package/example/node/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -55
  195. package/example/node/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  196. package/example/node/node_modules/iconv-lite/encodings/utf16.js +0 -177
  197. package/example/node/node_modules/iconv-lite/encodings/utf7.js +0 -290
  198. package/example/node/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  199. package/example/node/node_modules/iconv-lite/lib/extend-node.js +0 -217
  200. package/example/node/node_modules/iconv-lite/lib/index.d.ts +0 -24
  201. package/example/node/node_modules/iconv-lite/lib/index.js +0 -153
  202. package/example/node/node_modules/iconv-lite/lib/streams.js +0 -121
  203. package/example/node/node_modules/iconv-lite/package.json +0 -46
  204. package/example/node/node_modules/inherits/LICENSE +0 -16
  205. package/example/node/node_modules/inherits/README.md +0 -42
  206. package/example/node/node_modules/inherits/inherits.js +0 -9
  207. package/example/node/node_modules/inherits/inherits_browser.js +0 -27
  208. package/example/node/node_modules/inherits/package.json +0 -29
  209. package/example/node/node_modules/ipaddr.js/LICENSE +0 -19
  210. package/example/node/node_modules/ipaddr.js/README.md +0 -233
  211. package/example/node/node_modules/ipaddr.js/ipaddr.min.js +0 -1
  212. package/example/node/node_modules/ipaddr.js/lib/ipaddr.js +0 -673
  213. package/example/node/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +0 -68
  214. package/example/node/node_modules/ipaddr.js/package.json +0 -35
  215. package/example/node/node_modules/media-typer/HISTORY.md +0 -22
  216. package/example/node/node_modules/media-typer/LICENSE +0 -22
  217. package/example/node/node_modules/media-typer/README.md +0 -81
  218. package/example/node/node_modules/media-typer/index.js +0 -270
  219. package/example/node/node_modules/media-typer/package.json +0 -26
  220. package/example/node/node_modules/merge-descriptors/HISTORY.md +0 -21
  221. package/example/node/node_modules/merge-descriptors/LICENSE +0 -23
  222. package/example/node/node_modules/merge-descriptors/README.md +0 -48
  223. package/example/node/node_modules/merge-descriptors/index.js +0 -60
  224. package/example/node/node_modules/merge-descriptors/package.json +0 -32
  225. package/example/node/node_modules/methods/HISTORY.md +0 -29
  226. package/example/node/node_modules/methods/LICENSE +0 -24
  227. package/example/node/node_modules/methods/README.md +0 -51
  228. package/example/node/node_modules/methods/index.js +0 -69
  229. package/example/node/node_modules/methods/package.json +0 -36
  230. package/example/node/node_modules/mime/CHANGELOG.md +0 -164
  231. package/example/node/node_modules/mime/LICENSE +0 -21
  232. package/example/node/node_modules/mime/README.md +0 -90
  233. package/example/node/node_modules/mime/cli.js +0 -8
  234. package/example/node/node_modules/mime/mime.js +0 -108
  235. package/example/node/node_modules/mime/package.json +0 -44
  236. package/example/node/node_modules/mime/src/build.js +0 -53
  237. package/example/node/node_modules/mime/src/test.js +0 -60
  238. package/example/node/node_modules/mime/types.json +0 -1
  239. package/example/node/node_modules/mime-db/HISTORY.md +0 -499
  240. package/example/node/node_modules/mime-db/LICENSE +0 -22
  241. package/example/node/node_modules/mime-db/README.md +0 -100
  242. package/example/node/node_modules/mime-db/db.json +0 -8471
  243. package/example/node/node_modules/mime-db/index.js +0 -11
  244. package/example/node/node_modules/mime-db/package.json +0 -59
  245. package/example/node/node_modules/mime-types/HISTORY.md +0 -388
  246. package/example/node/node_modules/mime-types/LICENSE +0 -23
  247. package/example/node/node_modules/mime-types/README.md +0 -113
  248. package/example/node/node_modules/mime-types/index.js +0 -188
  249. package/example/node/node_modules/mime-types/package.json +0 -44
  250. package/example/node/node_modules/ms/index.js +0 -152
  251. package/example/node/node_modules/ms/license.md +0 -21
  252. package/example/node/node_modules/ms/package.json +0 -37
  253. package/example/node/node_modules/ms/readme.md +0 -51
  254. package/example/node/node_modules/negotiator/HISTORY.md +0 -103
  255. package/example/node/node_modules/negotiator/LICENSE +0 -24
  256. package/example/node/node_modules/negotiator/README.md +0 -203
  257. package/example/node/node_modules/negotiator/index.js +0 -124
  258. package/example/node/node_modules/negotiator/lib/charset.js +0 -169
  259. package/example/node/node_modules/negotiator/lib/encoding.js +0 -184
  260. package/example/node/node_modules/negotiator/lib/language.js +0 -179
  261. package/example/node/node_modules/negotiator/lib/mediaType.js +0 -294
  262. package/example/node/node_modules/negotiator/package.json +0 -42
  263. package/example/node/node_modules/on-finished/HISTORY.md +0 -88
  264. package/example/node/node_modules/on-finished/LICENSE +0 -23
  265. package/example/node/node_modules/on-finished/README.md +0 -154
  266. package/example/node/node_modules/on-finished/index.js +0 -196
  267. package/example/node/node_modules/on-finished/package.json +0 -31
  268. package/example/node/node_modules/parseurl/HISTORY.md +0 -58
  269. package/example/node/node_modules/parseurl/LICENSE +0 -24
  270. package/example/node/node_modules/parseurl/README.md +0 -133
  271. package/example/node/node_modules/parseurl/index.js +0 -158
  272. package/example/node/node_modules/parseurl/package.json +0 -40
  273. package/example/node/node_modules/path-to-regexp/History.md +0 -36
  274. package/example/node/node_modules/path-to-regexp/LICENSE +0 -21
  275. package/example/node/node_modules/path-to-regexp/Readme.md +0 -35
  276. package/example/node/node_modules/path-to-regexp/index.js +0 -129
  277. package/example/node/node_modules/path-to-regexp/package.json +0 -30
  278. package/example/node/node_modules/proxy-addr/HISTORY.md +0 -161
  279. package/example/node/node_modules/proxy-addr/LICENSE +0 -22
  280. package/example/node/node_modules/proxy-addr/README.md +0 -139
  281. package/example/node/node_modules/proxy-addr/index.js +0 -327
  282. package/example/node/node_modules/proxy-addr/package.json +0 -47
  283. package/example/node/node_modules/qs/.editorconfig +0 -39
  284. package/example/node/node_modules/qs/.eslintignore +0 -2
  285. package/example/node/node_modules/qs/.eslintrc +0 -35
  286. package/example/node/node_modules/qs/.github/FUNDING.yml +0 -12
  287. package/example/node/node_modules/qs/.nycrc +0 -13
  288. package/example/node/node_modules/qs/CHANGELOG.md +0 -359
  289. package/example/node/node_modules/qs/LICENSE.md +0 -29
  290. package/example/node/node_modules/qs/README.md +0 -604
  291. package/example/node/node_modules/qs/dist/qs.js +0 -832
  292. package/example/node/node_modules/qs/lib/formats.js +0 -23
  293. package/example/node/node_modules/qs/lib/index.js +0 -11
  294. package/example/node/node_modules/qs/lib/parse.js +0 -257
  295. package/example/node/node_modules/qs/lib/stringify.js +0 -278
  296. package/example/node/node_modules/qs/lib/utils.js +0 -251
  297. package/example/node/node_modules/qs/package.json +0 -69
  298. package/example/node/node_modules/qs/test/parse.js +0 -772
  299. package/example/node/node_modules/qs/test/stringify.js +0 -793
  300. package/example/node/node_modules/qs/test/utils.js +0 -136
  301. package/example/node/node_modules/range-parser/HISTORY.md +0 -56
  302. package/example/node/node_modules/range-parser/LICENSE +0 -23
  303. package/example/node/node_modules/range-parser/README.md +0 -84
  304. package/example/node/node_modules/range-parser/index.js +0 -162
  305. package/example/node/node_modules/range-parser/package.json +0 -44
  306. package/example/node/node_modules/raw-body/HISTORY.md +0 -284
  307. package/example/node/node_modules/raw-body/LICENSE +0 -22
  308. package/example/node/node_modules/raw-body/README.md +0 -217
  309. package/example/node/node_modules/raw-body/index.d.ts +0 -87
  310. package/example/node/node_modules/raw-body/index.js +0 -286
  311. package/example/node/node_modules/raw-body/package.json +0 -48
  312. package/example/node/node_modules/safe-buffer/LICENSE +0 -21
  313. package/example/node/node_modules/safe-buffer/README.md +0 -584
  314. package/example/node/node_modules/safe-buffer/index.d.ts +0 -187
  315. package/example/node/node_modules/safe-buffer/index.js +0 -65
  316. package/example/node/node_modules/safe-buffer/package.json +0 -51
  317. package/example/node/node_modules/safer-buffer/LICENSE +0 -21
  318. package/example/node/node_modules/safer-buffer/Porting-Buffer.md +0 -268
  319. package/example/node/node_modules/safer-buffer/Readme.md +0 -156
  320. package/example/node/node_modules/safer-buffer/dangerous.js +0 -58
  321. package/example/node/node_modules/safer-buffer/package.json +0 -34
  322. package/example/node/node_modules/safer-buffer/safer.js +0 -77
  323. package/example/node/node_modules/safer-buffer/tests.js +0 -406
  324. package/example/node/node_modules/send/HISTORY.md +0 -506
  325. package/example/node/node_modules/send/LICENSE +0 -23
  326. package/example/node/node_modules/send/README.md +0 -327
  327. package/example/node/node_modules/send/index.js +0 -1133
  328. package/example/node/node_modules/send/node_modules/.bin/mime +0 -15
  329. package/example/node/node_modules/send/node_modules/.bin/mime.cmd +0 -7
  330. package/example/node/node_modules/send/node_modules/ms/index.js +0 -162
  331. package/example/node/node_modules/send/node_modules/ms/license.md +0 -21
  332. package/example/node/node_modules/send/node_modules/ms/package.json +0 -38
  333. package/example/node/node_modules/send/node_modules/ms/readme.md +0 -59
  334. package/example/node/node_modules/send/package.json +0 -61
  335. package/example/node/node_modules/serve-static/HISTORY.md +0 -459
  336. package/example/node/node_modules/serve-static/LICENSE +0 -25
  337. package/example/node/node_modules/serve-static/README.md +0 -257
  338. package/example/node/node_modules/serve-static/index.js +0 -210
  339. package/example/node/node_modules/serve-static/package.json +0 -42
  340. package/example/node/node_modules/setprototypeof/LICENSE +0 -13
  341. package/example/node/node_modules/setprototypeof/README.md +0 -31
  342. package/example/node/node_modules/setprototypeof/index.d.ts +0 -2
  343. package/example/node/node_modules/setprototypeof/index.js +0 -17
  344. package/example/node/node_modules/setprototypeof/package.json +0 -38
  345. package/example/node/node_modules/setprototypeof/test/index.js +0 -24
  346. package/example/node/node_modules/statuses/HISTORY.md +0 -65
  347. package/example/node/node_modules/statuses/LICENSE +0 -23
  348. package/example/node/node_modules/statuses/README.md +0 -127
  349. package/example/node/node_modules/statuses/codes.json +0 -66
  350. package/example/node/node_modules/statuses/index.js +0 -113
  351. package/example/node/node_modules/statuses/package.json +0 -48
  352. package/example/node/node_modules/toidentifier/HISTORY.md +0 -9
  353. package/example/node/node_modules/toidentifier/LICENSE +0 -21
  354. package/example/node/node_modules/toidentifier/README.md +0 -61
  355. package/example/node/node_modules/toidentifier/index.js +0 -32
  356. package/example/node/node_modules/toidentifier/package.json +0 -38
  357. package/example/node/node_modules/type-is/HISTORY.md +0 -259
  358. package/example/node/node_modules/type-is/LICENSE +0 -23
  359. package/example/node/node_modules/type-is/README.md +0 -170
  360. package/example/node/node_modules/type-is/index.js +0 -266
  361. package/example/node/node_modules/type-is/package.json +0 -45
  362. package/example/node/node_modules/unpipe/HISTORY.md +0 -4
  363. package/example/node/node_modules/unpipe/LICENSE +0 -22
  364. package/example/node/node_modules/unpipe/README.md +0 -43
  365. package/example/node/node_modules/unpipe/index.js +0 -69
  366. package/example/node/node_modules/unpipe/package.json +0 -27
  367. package/example/node/node_modules/utils-merge/LICENSE +0 -20
  368. package/example/node/node_modules/utils-merge/README.md +0 -34
  369. package/example/node/node_modules/utils-merge/index.js +0 -23
  370. package/example/node/node_modules/utils-merge/package.json +0 -40
  371. package/example/node/node_modules/vary/HISTORY.md +0 -39
  372. package/example/node/node_modules/vary/LICENSE +0 -22
  373. package/example/node/node_modules/vary/README.md +0 -101
  374. package/example/node/node_modules/vary/index.js +0 -149
  375. package/example/node/node_modules/vary/package.json +0 -43
  376. package/example/node/server.js +0 -38
  377. package/src/index.js +0 -16
  378. package/src/lib/crawler/provider.js +0 -11
  379. package/src/lib/crawler.js +0 -130
  380. package/test/lib/crawler.test.js +0 -94
  381. package/webpack.common.js +0 -20
  382. package/webpack.dev.js +0 -7
  383. package/webpack.prod.js +0 -14
@@ -1,555 +0,0 @@
1
- "use strict";
2
- var Buffer = require("safer-buffer").Buffer;
3
-
4
- // Multibyte codec. In this scheme, a character is represented by 1 or more bytes.
5
- // Our codec supports UTF-16 surrogates, extensions for GB18030 and unicode sequences.
6
- // To save memory and loading time, we read table files only when requested.
7
-
8
- exports._dbcs = DBCSCodec;
9
-
10
- var UNASSIGNED = -1,
11
- GB18030_CODE = -2,
12
- SEQ_START = -10,
13
- NODE_START = -1000,
14
- UNASSIGNED_NODE = new Array(0x100),
15
- DEF_CHAR = -1;
16
-
17
- for (var i = 0; i < 0x100; i++)
18
- UNASSIGNED_NODE[i] = UNASSIGNED;
19
-
20
-
21
- // Class DBCSCodec reads and initializes mapping tables.
22
- function DBCSCodec(codecOptions, iconv) {
23
- this.encodingName = codecOptions.encodingName;
24
- if (!codecOptions)
25
- throw new Error("DBCS codec is called without the data.")
26
- if (!codecOptions.table)
27
- throw new Error("Encoding '" + this.encodingName + "' has no data.");
28
-
29
- // Load tables.
30
- var mappingTable = codecOptions.table();
31
-
32
-
33
- // Decode tables: MBCS -> Unicode.
34
-
35
- // decodeTables is a trie, encoded as an array of arrays of integers. Internal arrays are trie nodes and all have len = 256.
36
- // Trie root is decodeTables[0].
37
- // Values: >= 0 -> unicode character code. can be > 0xFFFF
38
- // == UNASSIGNED -> unknown/unassigned sequence.
39
- // == GB18030_CODE -> this is the end of a GB18030 4-byte sequence.
40
- // <= NODE_START -> index of the next node in our trie to process next byte.
41
- // <= SEQ_START -> index of the start of a character code sequence, in decodeTableSeq.
42
- this.decodeTables = [];
43
- this.decodeTables[0] = UNASSIGNED_NODE.slice(0); // Create root node.
44
-
45
- // Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here.
46
- this.decodeTableSeq = [];
47
-
48
- // Actual mapping tables consist of chunks. Use them to fill up decode tables.
49
- for (var i = 0; i < mappingTable.length; i++)
50
- this._addDecodeChunk(mappingTable[i]);
51
-
52
- this.defaultCharUnicode = iconv.defaultCharUnicode;
53
-
54
-
55
- // Encode tables: Unicode -> DBCS.
56
-
57
- // `encodeTable` is array mapping from unicode char to encoded char. All its values are integers for performance.
58
- // Because it can be sparse, it is represented as array of buckets by 256 chars each. Bucket can be null.
59
- // Values: >= 0 -> it is a normal char. Write the value (if <=256 then 1 byte, if <=65536 then 2 bytes, etc.).
60
- // == UNASSIGNED -> no conversion found. Output a default char.
61
- // <= SEQ_START -> it's an index in encodeTableSeq, see below. The character starts a sequence.
62
- this.encodeTable = [];
63
-
64
- // `encodeTableSeq` is used when a sequence of unicode characters is encoded as a single code. We use a tree of
65
- // objects where keys correspond to characters in sequence and leafs are the encoded dbcs values. A special DEF_CHAR key
66
- // means end of sequence (needed when one sequence is a strict subsequence of another).
67
- // Objects are kept separately from encodeTable to increase performance.
68
- this.encodeTableSeq = [];
69
-
70
- // Some chars can be decoded, but need not be encoded.
71
- var skipEncodeChars = {};
72
- if (codecOptions.encodeSkipVals)
73
- for (var i = 0; i < codecOptions.encodeSkipVals.length; i++) {
74
- var val = codecOptions.encodeSkipVals[i];
75
- if (typeof val === 'number')
76
- skipEncodeChars[val] = true;
77
- else
78
- for (var j = val.from; j <= val.to; j++)
79
- skipEncodeChars[j] = true;
80
- }
81
-
82
- // Use decode trie to recursively fill out encode tables.
83
- this._fillEncodeTable(0, 0, skipEncodeChars);
84
-
85
- // Add more encoding pairs when needed.
86
- if (codecOptions.encodeAdd) {
87
- for (var uChar in codecOptions.encodeAdd)
88
- if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar))
89
- this._setEncodeChar(uChar.charCodeAt(0), codecOptions.encodeAdd[uChar]);
90
- }
91
-
92
- this.defCharSB = this.encodeTable[0][iconv.defaultCharSingleByte.charCodeAt(0)];
93
- if (this.defCharSB === UNASSIGNED) this.defCharSB = this.encodeTable[0]['?'];
94
- if (this.defCharSB === UNASSIGNED) this.defCharSB = "?".charCodeAt(0);
95
-
96
-
97
- // Load & create GB18030 tables when needed.
98
- if (typeof codecOptions.gb18030 === 'function') {
99
- this.gb18030 = codecOptions.gb18030(); // Load GB18030 ranges.
100
-
101
- // Add GB18030 decode tables.
102
- var thirdByteNodeIdx = this.decodeTables.length;
103
- var thirdByteNode = this.decodeTables[thirdByteNodeIdx] = UNASSIGNED_NODE.slice(0);
104
-
105
- var fourthByteNodeIdx = this.decodeTables.length;
106
- var fourthByteNode = this.decodeTables[fourthByteNodeIdx] = UNASSIGNED_NODE.slice(0);
107
-
108
- for (var i = 0x81; i <= 0xFE; i++) {
109
- var secondByteNodeIdx = NODE_START - this.decodeTables[0][i];
110
- var secondByteNode = this.decodeTables[secondByteNodeIdx];
111
- for (var j = 0x30; j <= 0x39; j++)
112
- secondByteNode[j] = NODE_START - thirdByteNodeIdx;
113
- }
114
- for (var i = 0x81; i <= 0xFE; i++)
115
- thirdByteNode[i] = NODE_START - fourthByteNodeIdx;
116
- for (var i = 0x30; i <= 0x39; i++)
117
- fourthByteNode[i] = GB18030_CODE
118
- }
119
- }
120
-
121
- DBCSCodec.prototype.encoder = DBCSEncoder;
122
- DBCSCodec.prototype.decoder = DBCSDecoder;
123
-
124
- // Decoder helpers
125
- DBCSCodec.prototype._getDecodeTrieNode = function(addr) {
126
- var bytes = [];
127
- for (; addr > 0; addr >>= 8)
128
- bytes.push(addr & 0xFF);
129
- if (bytes.length == 0)
130
- bytes.push(0);
131
-
132
- var node = this.decodeTables[0];
133
- for (var i = bytes.length-1; i > 0; i--) { // Traverse nodes deeper into the trie.
134
- var val = node[bytes[i]];
135
-
136
- if (val == UNASSIGNED) { // Create new node.
137
- node[bytes[i]] = NODE_START - this.decodeTables.length;
138
- this.decodeTables.push(node = UNASSIGNED_NODE.slice(0));
139
- }
140
- else if (val <= NODE_START) { // Existing node.
141
- node = this.decodeTables[NODE_START - val];
142
- }
143
- else
144
- throw new Error("Overwrite byte in " + this.encodingName + ", addr: " + addr.toString(16));
145
- }
146
- return node;
147
- }
148
-
149
-
150
- DBCSCodec.prototype._addDecodeChunk = function(chunk) {
151
- // First element of chunk is the hex mbcs code where we start.
152
- var curAddr = parseInt(chunk[0], 16);
153
-
154
- // Choose the decoding node where we'll write our chars.
155
- var writeTable = this._getDecodeTrieNode(curAddr);
156
- curAddr = curAddr & 0xFF;
157
-
158
- // Write all other elements of the chunk to the table.
159
- for (var k = 1; k < chunk.length; k++) {
160
- var part = chunk[k];
161
- if (typeof part === "string") { // String, write as-is.
162
- for (var l = 0; l < part.length;) {
163
- var code = part.charCodeAt(l++);
164
- if (0xD800 <= code && code < 0xDC00) { // Decode surrogate
165
- var codeTrail = part.charCodeAt(l++);
166
- if (0xDC00 <= codeTrail && codeTrail < 0xE000)
167
- writeTable[curAddr++] = 0x10000 + (code - 0xD800) * 0x400 + (codeTrail - 0xDC00);
168
- else
169
- throw new Error("Incorrect surrogate pair in " + this.encodingName + " at chunk " + chunk[0]);
170
- }
171
- else if (0x0FF0 < code && code <= 0x0FFF) { // Character sequence (our own encoding used)
172
- var len = 0xFFF - code + 2;
173
- var seq = [];
174
- for (var m = 0; m < len; m++)
175
- seq.push(part.charCodeAt(l++)); // Simple variation: don't support surrogates or subsequences in seq.
176
-
177
- writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;
178
- this.decodeTableSeq.push(seq);
179
- }
180
- else
181
- writeTable[curAddr++] = code; // Basic char
182
- }
183
- }
184
- else if (typeof part === "number") { // Integer, meaning increasing sequence starting with prev character.
185
- var charCode = writeTable[curAddr - 1] + 1;
186
- for (var l = 0; l < part; l++)
187
- writeTable[curAddr++] = charCode++;
188
- }
189
- else
190
- throw new Error("Incorrect type '" + typeof part + "' given in " + this.encodingName + " at chunk " + chunk[0]);
191
- }
192
- if (curAddr > 0xFF)
193
- throw new Error("Incorrect chunk in " + this.encodingName + " at addr " + chunk[0] + ": too long" + curAddr);
194
- }
195
-
196
- // Encoder helpers
197
- DBCSCodec.prototype._getEncodeBucket = function(uCode) {
198
- var high = uCode >> 8; // This could be > 0xFF because of astral characters.
199
- if (this.encodeTable[high] === undefined)
200
- this.encodeTable[high] = UNASSIGNED_NODE.slice(0); // Create bucket on demand.
201
- return this.encodeTable[high];
202
- }
203
-
204
- DBCSCodec.prototype._setEncodeChar = function(uCode, dbcsCode) {
205
- var bucket = this._getEncodeBucket(uCode);
206
- var low = uCode & 0xFF;
207
- if (bucket[low] <= SEQ_START)
208
- this.encodeTableSeq[SEQ_START-bucket[low]][DEF_CHAR] = dbcsCode; // There's already a sequence, set a single-char subsequence of it.
209
- else if (bucket[low] == UNASSIGNED)
210
- bucket[low] = dbcsCode;
211
- }
212
-
213
- DBCSCodec.prototype._setEncodeSequence = function(seq, dbcsCode) {
214
-
215
- // Get the root of character tree according to first character of the sequence.
216
- var uCode = seq[0];
217
- var bucket = this._getEncodeBucket(uCode);
218
- var low = uCode & 0xFF;
219
-
220
- var node;
221
- if (bucket[low] <= SEQ_START) {
222
- // There's already a sequence with - use it.
223
- node = this.encodeTableSeq[SEQ_START-bucket[low]];
224
- }
225
- else {
226
- // There was no sequence object - allocate a new one.
227
- node = {};
228
- if (bucket[low] !== UNASSIGNED) node[DEF_CHAR] = bucket[low]; // If a char was set before - make it a single-char subsequence.
229
- bucket[low] = SEQ_START - this.encodeTableSeq.length;
230
- this.encodeTableSeq.push(node);
231
- }
232
-
233
- // Traverse the character tree, allocating new nodes as needed.
234
- for (var j = 1; j < seq.length-1; j++) {
235
- var oldVal = node[uCode];
236
- if (typeof oldVal === 'object')
237
- node = oldVal;
238
- else {
239
- node = node[uCode] = {}
240
- if (oldVal !== undefined)
241
- node[DEF_CHAR] = oldVal
242
- }
243
- }
244
-
245
- // Set the leaf to given dbcsCode.
246
- uCode = seq[seq.length-1];
247
- node[uCode] = dbcsCode;
248
- }
249
-
250
- DBCSCodec.prototype._fillEncodeTable = function(nodeIdx, prefix, skipEncodeChars) {
251
- var node = this.decodeTables[nodeIdx];
252
- for (var i = 0; i < 0x100; i++) {
253
- var uCode = node[i];
254
- var mbCode = prefix + i;
255
- if (skipEncodeChars[mbCode])
256
- continue;
257
-
258
- if (uCode >= 0)
259
- this._setEncodeChar(uCode, mbCode);
260
- else if (uCode <= NODE_START)
261
- this._fillEncodeTable(NODE_START - uCode, mbCode << 8, skipEncodeChars);
262
- else if (uCode <= SEQ_START)
263
- this._setEncodeSequence(this.decodeTableSeq[SEQ_START - uCode], mbCode);
264
- }
265
- }
266
-
267
-
268
-
269
- // == Encoder ==================================================================
270
-
271
- function DBCSEncoder(options, codec) {
272
- // Encoder state
273
- this.leadSurrogate = -1;
274
- this.seqObj = undefined;
275
-
276
- // Static data
277
- this.encodeTable = codec.encodeTable;
278
- this.encodeTableSeq = codec.encodeTableSeq;
279
- this.defaultCharSingleByte = codec.defCharSB;
280
- this.gb18030 = codec.gb18030;
281
- }
282
-
283
- DBCSEncoder.prototype.write = function(str) {
284
- var newBuf = Buffer.alloc(str.length * (this.gb18030 ? 4 : 3)),
285
- leadSurrogate = this.leadSurrogate,
286
- seqObj = this.seqObj, nextChar = -1,
287
- i = 0, j = 0;
288
-
289
- while (true) {
290
- // 0. Get next character.
291
- if (nextChar === -1) {
292
- if (i == str.length) break;
293
- var uCode = str.charCodeAt(i++);
294
- }
295
- else {
296
- var uCode = nextChar;
297
- nextChar = -1;
298
- }
299
-
300
- // 1. Handle surrogates.
301
- if (0xD800 <= uCode && uCode < 0xE000) { // Char is one of surrogates.
302
- if (uCode < 0xDC00) { // We've got lead surrogate.
303
- if (leadSurrogate === -1) {
304
- leadSurrogate = uCode;
305
- continue;
306
- } else {
307
- leadSurrogate = uCode;
308
- // Double lead surrogate found.
309
- uCode = UNASSIGNED;
310
- }
311
- } else { // We've got trail surrogate.
312
- if (leadSurrogate !== -1) {
313
- uCode = 0x10000 + (leadSurrogate - 0xD800) * 0x400 + (uCode - 0xDC00);
314
- leadSurrogate = -1;
315
- } else {
316
- // Incomplete surrogate pair - only trail surrogate found.
317
- uCode = UNASSIGNED;
318
- }
319
-
320
- }
321
- }
322
- else if (leadSurrogate !== -1) {
323
- // Incomplete surrogate pair - only lead surrogate found.
324
- nextChar = uCode; uCode = UNASSIGNED; // Write an error, then current char.
325
- leadSurrogate = -1;
326
- }
327
-
328
- // 2. Convert uCode character.
329
- var dbcsCode = UNASSIGNED;
330
- if (seqObj !== undefined && uCode != UNASSIGNED) { // We are in the middle of the sequence
331
- var resCode = seqObj[uCode];
332
- if (typeof resCode === 'object') { // Sequence continues.
333
- seqObj = resCode;
334
- continue;
335
-
336
- } else if (typeof resCode == 'number') { // Sequence finished. Write it.
337
- dbcsCode = resCode;
338
-
339
- } else if (resCode == undefined) { // Current character is not part of the sequence.
340
-
341
- // Try default character for this sequence
342
- resCode = seqObj[DEF_CHAR];
343
- if (resCode !== undefined) {
344
- dbcsCode = resCode; // Found. Write it.
345
- nextChar = uCode; // Current character will be written too in the next iteration.
346
-
347
- } else {
348
- // TODO: What if we have no default? (resCode == undefined)
349
- // Then, we should write first char of the sequence as-is and try the rest recursively.
350
- // Didn't do it for now because no encoding has this situation yet.
351
- // Currently, just skip the sequence and write current char.
352
- }
353
- }
354
- seqObj = undefined;
355
- }
356
- else if (uCode >= 0) { // Regular character
357
- var subtable = this.encodeTable[uCode >> 8];
358
- if (subtable !== undefined)
359
- dbcsCode = subtable[uCode & 0xFF];
360
-
361
- if (dbcsCode <= SEQ_START) { // Sequence start
362
- seqObj = this.encodeTableSeq[SEQ_START-dbcsCode];
363
- continue;
364
- }
365
-
366
- if (dbcsCode == UNASSIGNED && this.gb18030) {
367
- // Use GB18030 algorithm to find character(s) to write.
368
- var idx = findIdx(this.gb18030.uChars, uCode);
369
- if (idx != -1) {
370
- var dbcsCode = this.gb18030.gbChars[idx] + (uCode - this.gb18030.uChars[idx]);
371
- newBuf[j++] = 0x81 + Math.floor(dbcsCode / 12600); dbcsCode = dbcsCode % 12600;
372
- newBuf[j++] = 0x30 + Math.floor(dbcsCode / 1260); dbcsCode = dbcsCode % 1260;
373
- newBuf[j++] = 0x81 + Math.floor(dbcsCode / 10); dbcsCode = dbcsCode % 10;
374
- newBuf[j++] = 0x30 + dbcsCode;
375
- continue;
376
- }
377
- }
378
- }
379
-
380
- // 3. Write dbcsCode character.
381
- if (dbcsCode === UNASSIGNED)
382
- dbcsCode = this.defaultCharSingleByte;
383
-
384
- if (dbcsCode < 0x100) {
385
- newBuf[j++] = dbcsCode;
386
- }
387
- else if (dbcsCode < 0x10000) {
388
- newBuf[j++] = dbcsCode >> 8; // high byte
389
- newBuf[j++] = dbcsCode & 0xFF; // low byte
390
- }
391
- else {
392
- newBuf[j++] = dbcsCode >> 16;
393
- newBuf[j++] = (dbcsCode >> 8) & 0xFF;
394
- newBuf[j++] = dbcsCode & 0xFF;
395
- }
396
- }
397
-
398
- this.seqObj = seqObj;
399
- this.leadSurrogate = leadSurrogate;
400
- return newBuf.slice(0, j);
401
- }
402
-
403
- DBCSEncoder.prototype.end = function() {
404
- if (this.leadSurrogate === -1 && this.seqObj === undefined)
405
- return; // All clean. Most often case.
406
-
407
- var newBuf = Buffer.alloc(10), j = 0;
408
-
409
- if (this.seqObj) { // We're in the sequence.
410
- var dbcsCode = this.seqObj[DEF_CHAR];
411
- if (dbcsCode !== undefined) { // Write beginning of the sequence.
412
- if (dbcsCode < 0x100) {
413
- newBuf[j++] = dbcsCode;
414
- }
415
- else {
416
- newBuf[j++] = dbcsCode >> 8; // high byte
417
- newBuf[j++] = dbcsCode & 0xFF; // low byte
418
- }
419
- } else {
420
- // See todo above.
421
- }
422
- this.seqObj = undefined;
423
- }
424
-
425
- if (this.leadSurrogate !== -1) {
426
- // Incomplete surrogate pair - only lead surrogate found.
427
- newBuf[j++] = this.defaultCharSingleByte;
428
- this.leadSurrogate = -1;
429
- }
430
-
431
- return newBuf.slice(0, j);
432
- }
433
-
434
- // Export for testing
435
- DBCSEncoder.prototype.findIdx = findIdx;
436
-
437
-
438
- // == Decoder ==================================================================
439
-
440
- function DBCSDecoder(options, codec) {
441
- // Decoder state
442
- this.nodeIdx = 0;
443
- this.prevBuf = Buffer.alloc(0);
444
-
445
- // Static data
446
- this.decodeTables = codec.decodeTables;
447
- this.decodeTableSeq = codec.decodeTableSeq;
448
- this.defaultCharUnicode = codec.defaultCharUnicode;
449
- this.gb18030 = codec.gb18030;
450
- }
451
-
452
- DBCSDecoder.prototype.write = function(buf) {
453
- var newBuf = Buffer.alloc(buf.length*2),
454
- nodeIdx = this.nodeIdx,
455
- prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length,
456
- seqStart = -this.prevBuf.length, // idx of the start of current parsed sequence.
457
- uCode;
458
-
459
- if (prevBufOffset > 0) // Make prev buf overlap a little to make it easier to slice later.
460
- prevBuf = Buffer.concat([prevBuf, buf.slice(0, 10)]);
461
-
462
- for (var i = 0, j = 0; i < buf.length; i++) {
463
- var curByte = (i >= 0) ? buf[i] : prevBuf[i + prevBufOffset];
464
-
465
- // Lookup in current trie node.
466
- var uCode = this.decodeTables[nodeIdx][curByte];
467
-
468
- if (uCode >= 0) {
469
- // Normal character, just use it.
470
- }
471
- else if (uCode === UNASSIGNED) { // Unknown char.
472
- // TODO: Callback with seq.
473
- //var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i+1) : prevBuf.slice(seqStart + prevBufOffset, i+1 + prevBufOffset);
474
- i = seqStart; // Try to parse again, after skipping first byte of the sequence ('i' will be incremented by 'for' cycle).
475
- uCode = this.defaultCharUnicode.charCodeAt(0);
476
- }
477
- else if (uCode === GB18030_CODE) {
478
- var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i+1) : prevBuf.slice(seqStart + prevBufOffset, i+1 + prevBufOffset);
479
- var ptr = (curSeq[0]-0x81)*12600 + (curSeq[1]-0x30)*1260 + (curSeq[2]-0x81)*10 + (curSeq[3]-0x30);
480
- var idx = findIdx(this.gb18030.gbChars, ptr);
481
- uCode = this.gb18030.uChars[idx] + ptr - this.gb18030.gbChars[idx];
482
- }
483
- else if (uCode <= NODE_START) { // Go to next trie node.
484
- nodeIdx = NODE_START - uCode;
485
- continue;
486
- }
487
- else if (uCode <= SEQ_START) { // Output a sequence of chars.
488
- var seq = this.decodeTableSeq[SEQ_START - uCode];
489
- for (var k = 0; k < seq.length - 1; k++) {
490
- uCode = seq[k];
491
- newBuf[j++] = uCode & 0xFF;
492
- newBuf[j++] = uCode >> 8;
493
- }
494
- uCode = seq[seq.length-1];
495
- }
496
- else
497
- throw new Error("iconv-lite internal error: invalid decoding table value " + uCode + " at " + nodeIdx + "/" + curByte);
498
-
499
- // Write the character to buffer, handling higher planes using surrogate pair.
500
- if (uCode > 0xFFFF) {
501
- uCode -= 0x10000;
502
- var uCodeLead = 0xD800 + Math.floor(uCode / 0x400);
503
- newBuf[j++] = uCodeLead & 0xFF;
504
- newBuf[j++] = uCodeLead >> 8;
505
-
506
- uCode = 0xDC00 + uCode % 0x400;
507
- }
508
- newBuf[j++] = uCode & 0xFF;
509
- newBuf[j++] = uCode >> 8;
510
-
511
- // Reset trie node.
512
- nodeIdx = 0; seqStart = i+1;
513
- }
514
-
515
- this.nodeIdx = nodeIdx;
516
- this.prevBuf = (seqStart >= 0) ? buf.slice(seqStart) : prevBuf.slice(seqStart + prevBufOffset);
517
- return newBuf.slice(0, j).toString('ucs2');
518
- }
519
-
520
- DBCSDecoder.prototype.end = function() {
521
- var ret = '';
522
-
523
- // Try to parse all remaining chars.
524
- while (this.prevBuf.length > 0) {
525
- // Skip 1 character in the buffer.
526
- ret += this.defaultCharUnicode;
527
- var buf = this.prevBuf.slice(1);
528
-
529
- // Parse remaining as usual.
530
- this.prevBuf = Buffer.alloc(0);
531
- this.nodeIdx = 0;
532
- if (buf.length > 0)
533
- ret += this.write(buf);
534
- }
535
-
536
- this.nodeIdx = 0;
537
- return ret;
538
- }
539
-
540
- // Binary search for GB18030. Returns largest i such that table[i] <= val.
541
- function findIdx(table, val) {
542
- if (table[0] > val)
543
- return -1;
544
-
545
- var l = 0, r = table.length;
546
- while (l < r-1) { // always table[l] <= val < table[r]
547
- var mid = l + Math.floor((r-l+1)/2);
548
- if (table[mid] <= val)
549
- l = mid;
550
- else
551
- r = mid;
552
- }
553
- return l;
554
- }
555
-