box-content-preview 3.40.0

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 (339) hide show
  1. package/LICENSE +397 -0
  2. package/README.md +435 -0
  3. package/dist/lib/237.js +34 -0
  4. package/dist/lib/274.js +103 -0
  5. package/dist/lib/2a7d8bfaf2d43f53bd71.mjs +21 -0
  6. package/dist/lib/3683cfffdcbd73685ff2.svg +8 -0
  7. package/dist/lib/42e4e1954f25f8c7b965.svg +6 -0
  8. package/dist/lib/492.js +34 -0
  9. package/dist/lib/59fe962b3e6bd8bfdda7.svg +3 -0
  10. package/dist/lib/5ea0869845becef03a06.svg +4 -0
  11. package/dist/lib/671.js +34 -0
  12. package/dist/lib/76692c54994797ddfb04.svg +3 -0
  13. package/dist/lib/815.js +34 -0
  14. package/dist/lib/8475f8e672ed83e24520.svg +6 -0
  15. package/dist/lib/88.css +23 -0
  16. package/dist/lib/9fb032a1799ca2a1c751.svg +3 -0
  17. package/dist/lib/assets/loading_ghost.gif +0 -0
  18. package/dist/lib/bb72d81b39be40898db2.svg +3 -0
  19. package/dist/lib/cmaps/78-EUC-H.bcmap +0 -0
  20. package/dist/lib/cmaps/78-EUC-V.bcmap +0 -0
  21. package/dist/lib/cmaps/78-H.bcmap +0 -0
  22. package/dist/lib/cmaps/78-RKSJ-H.bcmap +0 -0
  23. package/dist/lib/cmaps/78-RKSJ-V.bcmap +0 -0
  24. package/dist/lib/cmaps/78-V.bcmap +0 -0
  25. package/dist/lib/cmaps/78ms-RKSJ-H.bcmap +0 -0
  26. package/dist/lib/cmaps/78ms-RKSJ-V.bcmap +0 -0
  27. package/dist/lib/cmaps/83pv-RKSJ-H.bcmap +0 -0
  28. package/dist/lib/cmaps/90ms-RKSJ-H.bcmap +0 -0
  29. package/dist/lib/cmaps/90ms-RKSJ-V.bcmap +0 -0
  30. package/dist/lib/cmaps/90msp-RKSJ-H.bcmap +0 -0
  31. package/dist/lib/cmaps/90msp-RKSJ-V.bcmap +0 -0
  32. package/dist/lib/cmaps/90pv-RKSJ-H.bcmap +0 -0
  33. package/dist/lib/cmaps/90pv-RKSJ-V.bcmap +0 -0
  34. package/dist/lib/cmaps/Add-H.bcmap +0 -0
  35. package/dist/lib/cmaps/Add-RKSJ-H.bcmap +0 -0
  36. package/dist/lib/cmaps/Add-RKSJ-V.bcmap +0 -0
  37. package/dist/lib/cmaps/Add-V.bcmap +0 -0
  38. package/dist/lib/cmaps/Adobe-CNS1-0.bcmap +0 -0
  39. package/dist/lib/cmaps/Adobe-CNS1-1.bcmap +0 -0
  40. package/dist/lib/cmaps/Adobe-CNS1-2.bcmap +0 -0
  41. package/dist/lib/cmaps/Adobe-CNS1-3.bcmap +0 -0
  42. package/dist/lib/cmaps/Adobe-CNS1-4.bcmap +0 -0
  43. package/dist/lib/cmaps/Adobe-CNS1-5.bcmap +0 -0
  44. package/dist/lib/cmaps/Adobe-CNS1-6.bcmap +0 -0
  45. package/dist/lib/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  46. package/dist/lib/cmaps/Adobe-GB1-0.bcmap +0 -0
  47. package/dist/lib/cmaps/Adobe-GB1-1.bcmap +0 -0
  48. package/dist/lib/cmaps/Adobe-GB1-2.bcmap +0 -0
  49. package/dist/lib/cmaps/Adobe-GB1-3.bcmap +0 -0
  50. package/dist/lib/cmaps/Adobe-GB1-4.bcmap +0 -0
  51. package/dist/lib/cmaps/Adobe-GB1-5.bcmap +0 -0
  52. package/dist/lib/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  53. package/dist/lib/cmaps/Adobe-Japan1-0.bcmap +0 -0
  54. package/dist/lib/cmaps/Adobe-Japan1-1.bcmap +0 -0
  55. package/dist/lib/cmaps/Adobe-Japan1-2.bcmap +0 -0
  56. package/dist/lib/cmaps/Adobe-Japan1-3.bcmap +0 -0
  57. package/dist/lib/cmaps/Adobe-Japan1-4.bcmap +0 -0
  58. package/dist/lib/cmaps/Adobe-Japan1-5.bcmap +0 -0
  59. package/dist/lib/cmaps/Adobe-Japan1-6.bcmap +0 -0
  60. package/dist/lib/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  61. package/dist/lib/cmaps/Adobe-Korea1-0.bcmap +0 -0
  62. package/dist/lib/cmaps/Adobe-Korea1-1.bcmap +0 -0
  63. package/dist/lib/cmaps/Adobe-Korea1-2.bcmap +0 -0
  64. package/dist/lib/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  65. package/dist/lib/cmaps/B5-H.bcmap +0 -0
  66. package/dist/lib/cmaps/B5-V.bcmap +0 -0
  67. package/dist/lib/cmaps/B5pc-H.bcmap +0 -0
  68. package/dist/lib/cmaps/B5pc-V.bcmap +0 -0
  69. package/dist/lib/cmaps/CNS-EUC-H.bcmap +0 -0
  70. package/dist/lib/cmaps/CNS-EUC-V.bcmap +0 -0
  71. package/dist/lib/cmaps/CNS1-H.bcmap +0 -0
  72. package/dist/lib/cmaps/CNS1-V.bcmap +0 -0
  73. package/dist/lib/cmaps/CNS2-H.bcmap +0 -0
  74. package/dist/lib/cmaps/CNS2-V.bcmap +3 -0
  75. package/dist/lib/cmaps/ETHK-B5-H.bcmap +0 -0
  76. package/dist/lib/cmaps/ETHK-B5-V.bcmap +0 -0
  77. package/dist/lib/cmaps/ETen-B5-H.bcmap +0 -0
  78. package/dist/lib/cmaps/ETen-B5-V.bcmap +0 -0
  79. package/dist/lib/cmaps/ETenms-B5-H.bcmap +3 -0
  80. package/dist/lib/cmaps/ETenms-B5-V.bcmap +0 -0
  81. package/dist/lib/cmaps/EUC-H.bcmap +0 -0
  82. package/dist/lib/cmaps/EUC-V.bcmap +0 -0
  83. package/dist/lib/cmaps/Ext-H.bcmap +0 -0
  84. package/dist/lib/cmaps/Ext-RKSJ-H.bcmap +0 -0
  85. package/dist/lib/cmaps/Ext-RKSJ-V.bcmap +0 -0
  86. package/dist/lib/cmaps/Ext-V.bcmap +0 -0
  87. package/dist/lib/cmaps/GB-EUC-H.bcmap +0 -0
  88. package/dist/lib/cmaps/GB-EUC-V.bcmap +0 -0
  89. package/dist/lib/cmaps/GB-H.bcmap +4 -0
  90. package/dist/lib/cmaps/GB-V.bcmap +0 -0
  91. package/dist/lib/cmaps/GBK-EUC-H.bcmap +0 -0
  92. package/dist/lib/cmaps/GBK-EUC-V.bcmap +0 -0
  93. package/dist/lib/cmaps/GBK2K-H.bcmap +0 -0
  94. package/dist/lib/cmaps/GBK2K-V.bcmap +0 -0
  95. package/dist/lib/cmaps/GBKp-EUC-H.bcmap +0 -0
  96. package/dist/lib/cmaps/GBKp-EUC-V.bcmap +0 -0
  97. package/dist/lib/cmaps/GBT-EUC-H.bcmap +0 -0
  98. package/dist/lib/cmaps/GBT-EUC-V.bcmap +0 -0
  99. package/dist/lib/cmaps/GBT-H.bcmap +0 -0
  100. package/dist/lib/cmaps/GBT-V.bcmap +0 -0
  101. package/dist/lib/cmaps/GBTpc-EUC-H.bcmap +0 -0
  102. package/dist/lib/cmaps/GBTpc-EUC-V.bcmap +0 -0
  103. package/dist/lib/cmaps/GBpc-EUC-H.bcmap +0 -0
  104. package/dist/lib/cmaps/GBpc-EUC-V.bcmap +0 -0
  105. package/dist/lib/cmaps/H.bcmap +0 -0
  106. package/dist/lib/cmaps/HKdla-B5-H.bcmap +0 -0
  107. package/dist/lib/cmaps/HKdla-B5-V.bcmap +0 -0
  108. package/dist/lib/cmaps/HKdlb-B5-H.bcmap +0 -0
  109. package/dist/lib/cmaps/HKdlb-B5-V.bcmap +0 -0
  110. package/dist/lib/cmaps/HKgccs-B5-H.bcmap +0 -0
  111. package/dist/lib/cmaps/HKgccs-B5-V.bcmap +0 -0
  112. package/dist/lib/cmaps/HKm314-B5-H.bcmap +0 -0
  113. package/dist/lib/cmaps/HKm314-B5-V.bcmap +0 -0
  114. package/dist/lib/cmaps/HKm471-B5-H.bcmap +0 -0
  115. package/dist/lib/cmaps/HKm471-B5-V.bcmap +0 -0
  116. package/dist/lib/cmaps/HKscs-B5-H.bcmap +0 -0
  117. package/dist/lib/cmaps/HKscs-B5-V.bcmap +0 -0
  118. package/dist/lib/cmaps/Hankaku.bcmap +0 -0
  119. package/dist/lib/cmaps/Hiragana.bcmap +0 -0
  120. package/dist/lib/cmaps/KSC-EUC-H.bcmap +0 -0
  121. package/dist/lib/cmaps/KSC-EUC-V.bcmap +0 -0
  122. package/dist/lib/cmaps/KSC-H.bcmap +0 -0
  123. package/dist/lib/cmaps/KSC-Johab-H.bcmap +0 -0
  124. package/dist/lib/cmaps/KSC-Johab-V.bcmap +0 -0
  125. package/dist/lib/cmaps/KSC-V.bcmap +0 -0
  126. package/dist/lib/cmaps/KSCms-UHC-H.bcmap +0 -0
  127. package/dist/lib/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  128. package/dist/lib/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  129. package/dist/lib/cmaps/KSCms-UHC-V.bcmap +0 -0
  130. package/dist/lib/cmaps/KSCpc-EUC-H.bcmap +0 -0
  131. package/dist/lib/cmaps/KSCpc-EUC-V.bcmap +0 -0
  132. package/dist/lib/cmaps/Katakana.bcmap +0 -0
  133. package/dist/lib/cmaps/LICENSE +36 -0
  134. package/dist/lib/cmaps/NWP-H.bcmap +0 -0
  135. package/dist/lib/cmaps/NWP-V.bcmap +0 -0
  136. package/dist/lib/cmaps/RKSJ-H.bcmap +0 -0
  137. package/dist/lib/cmaps/RKSJ-V.bcmap +0 -0
  138. package/dist/lib/cmaps/Roman.bcmap +0 -0
  139. package/dist/lib/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  140. package/dist/lib/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  141. package/dist/lib/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  142. package/dist/lib/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  143. package/dist/lib/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  144. package/dist/lib/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  145. package/dist/lib/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  146. package/dist/lib/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  147. package/dist/lib/cmaps/UniGB-UCS2-H.bcmap +0 -0
  148. package/dist/lib/cmaps/UniGB-UCS2-V.bcmap +0 -0
  149. package/dist/lib/cmaps/UniGB-UTF16-H.bcmap +0 -0
  150. package/dist/lib/cmaps/UniGB-UTF16-V.bcmap +0 -0
  151. package/dist/lib/cmaps/UniGB-UTF32-H.bcmap +0 -0
  152. package/dist/lib/cmaps/UniGB-UTF32-V.bcmap +0 -0
  153. package/dist/lib/cmaps/UniGB-UTF8-H.bcmap +0 -0
  154. package/dist/lib/cmaps/UniGB-UTF8-V.bcmap +0 -0
  155. package/dist/lib/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  156. package/dist/lib/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  157. package/dist/lib/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  158. package/dist/lib/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  159. package/dist/lib/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  160. package/dist/lib/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  161. package/dist/lib/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  162. package/dist/lib/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  163. package/dist/lib/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  164. package/dist/lib/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  165. package/dist/lib/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  166. package/dist/lib/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  167. package/dist/lib/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  168. package/dist/lib/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  169. package/dist/lib/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  170. package/dist/lib/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  171. package/dist/lib/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  172. package/dist/lib/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  173. package/dist/lib/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  174. package/dist/lib/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  175. package/dist/lib/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  176. package/dist/lib/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  177. package/dist/lib/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  178. package/dist/lib/cmaps/UniKS-UCS2-H.bcmap +0 -0
  179. package/dist/lib/cmaps/UniKS-UCS2-V.bcmap +0 -0
  180. package/dist/lib/cmaps/UniKS-UTF16-H.bcmap +0 -0
  181. package/dist/lib/cmaps/UniKS-UTF16-V.bcmap +0 -0
  182. package/dist/lib/cmaps/UniKS-UTF32-H.bcmap +0 -0
  183. package/dist/lib/cmaps/UniKS-UTF32-V.bcmap +0 -0
  184. package/dist/lib/cmaps/UniKS-UTF8-H.bcmap +0 -0
  185. package/dist/lib/cmaps/UniKS-UTF8-V.bcmap +0 -0
  186. package/dist/lib/cmaps/V.bcmap +0 -0
  187. package/dist/lib/cmaps/WP-Symbol.bcmap +0 -0
  188. package/dist/lib/exif/exif-reader.min.js +8 -0
  189. package/dist/lib/exif/exif.js +822 -0
  190. package/dist/lib/exif/exif.min.js +21 -0
  191. package/dist/lib/fde82a50e6de20239861.svg +5 -0
  192. package/dist/lib/ff2dfa442d903d9d5e30.gif +0 -0
  193. package/dist/lib/index.css +84 -0
  194. package/dist/lib/index.d.ts +147 -0
  195. package/dist/lib/index.js +41639 -0
  196. package/dist/lib/pdfjs-lib.js +46 -0
  197. package/dist/lib/pdfjs-viewer-css.js +36 -0
  198. package/dist/lib/pdfjs-viewer.js +8118 -0
  199. package/dist/lib/third-party/media/0.127.0/shaka-player.compiled.js +371 -0
  200. package/dist/lib/third-party/media/1.30.0/shaka-player.compiled.js +438 -0
  201. package/dist/lib/third-party/media/1.33.0/shaka-player.compiled.js +438 -0
  202. package/dist/lib/third-party/media/1.8.0/shaka-player.compiled.js +376 -0
  203. package/dist/lib/third-party/media/2.14.0/shaka-player.compiled.js +609 -0
  204. package/dist/lib/third-party/media/2.66.0/manifest.json +8 -0
  205. package/dist/lib/third-party/media/2.66.0/shaka-player.compiled.js +752 -0
  206. package/dist/lib/third-party/media/2.93.0/manifest.json +8 -0
  207. package/dist/lib/third-party/media/2.93.0/shaka-player.compiled.js +975 -0
  208. package/dist/lib/third-party/media/3.25.0/manifest.json +8 -0
  209. package/dist/lib/third-party/media/3.25.0/shaka-player.compiled.js +1780 -0
  210. package/dist/lib/third-party/model3d/1.10.1/WebVR/VRConfig.js +49 -0
  211. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  212. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  213. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  214. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  215. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  216. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/entities.json +322 -0
  217. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchLeft/entities.json +755 -0
  218. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchLeft/geometry.bin +0 -0
  219. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchRight/entities.json +746 -0
  220. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchRight/geometry.bin +0 -0
  221. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/entities.json +1811 -0
  222. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/geometry.bin +0 -0
  223. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/1024/1.png +0 -0
  224. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/1024/2.jpg +0 -0
  225. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/1024/3.jpg +0 -0
  226. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/1.png +0 -0
  227. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/2.jpg +0 -0
  228. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/3.jpg +0 -0
  229. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/4.png +0 -0
  230. package/dist/lib/third-party/model3d/1.10.1/box3d-player.json +1 -0
  231. package/dist/lib/third-party/model3d/1.10.1/box3d-runtime.min.js +2 -0
  232. package/dist/lib/third-party/model3d/1.10.1/boxsdk.min.js +2 -0
  233. package/dist/lib/third-party/model3d/1.10.1/matcap.png +0 -0
  234. package/dist/lib/third-party/model3d/1.10.1/three.min.js +882 -0
  235. package/dist/lib/third-party/model3d/1.10.1/webvr-polyfill.js +6341 -0
  236. package/dist/lib/third-party/model3d/1.12.0/WebVR/VRConfig.js +49 -0
  237. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  238. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  239. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  240. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  241. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  242. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/entities.json +322 -0
  243. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchLeft/entities.json +755 -0
  244. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchLeft/geometry.bin +0 -0
  245. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchRight/entities.json +746 -0
  246. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchRight/geometry.bin +0 -0
  247. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/entities.json +1811 -0
  248. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/geometry.bin +0 -0
  249. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/1024/1.png +0 -0
  250. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/1024/2.jpg +0 -0
  251. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/1024/3.jpg +0 -0
  252. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/1.png +0 -0
  253. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/2.jpg +0 -0
  254. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/3.jpg +0 -0
  255. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/4.png +0 -0
  256. package/dist/lib/third-party/model3d/1.12.0/box3d-player.json +1 -0
  257. package/dist/lib/third-party/model3d/1.12.0/box3d-runtime.min.js +2 -0
  258. package/dist/lib/third-party/model3d/1.12.0/boxsdk.min.js +2 -0
  259. package/dist/lib/third-party/model3d/1.12.0/matcap.png +0 -0
  260. package/dist/lib/third-party/model3d/1.12.0/three.min.js +882 -0
  261. package/dist/lib/third-party/model3d/1.12.0/webvr-polyfill.js +6341 -0
  262. package/dist/lib/third-party/model3d/1.6.1/WebVR/VRConfig.js +49 -0
  263. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  264. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  265. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  266. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  267. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  268. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/entities.json +439 -0
  269. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchLeft/entities.json +755 -0
  270. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchLeft/geometry.bin +0 -0
  271. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchRight/entities.json +746 -0
  272. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchRight/geometry.bin +0 -0
  273. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/entities.json +1869 -0
  274. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/geometry.bin +0 -0
  275. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/1024/1.png +0 -0
  276. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/1024/2.jpg +0 -0
  277. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/1024/3.jpg +0 -0
  278. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/1.png +0 -0
  279. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/2.jpg +0 -0
  280. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/3.jpg +0 -0
  281. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/4.png +0 -0
  282. package/dist/lib/third-party/model3d/1.6.1/box3d-player.json +1 -0
  283. package/dist/lib/third-party/model3d/1.6.1/box3d-runtime.min.js +2 -0
  284. package/dist/lib/third-party/model3d/1.6.1/boxsdk.min.js +2 -0
  285. package/dist/lib/third-party/model3d/1.6.1/matcap.png +0 -0
  286. package/dist/lib/third-party/model3d/1.6.1/three.min.js +43300 -0
  287. package/dist/lib/third-party/model3d/1.6.1/webvr-polyfill.js +6341 -0
  288. package/dist/lib/third-party/model3d/1.9.1/WebVR/VRConfig.js +49 -0
  289. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  290. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  291. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  292. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  293. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  294. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/entities.json +439 -0
  295. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchLeft/entities.json +755 -0
  296. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchLeft/geometry.bin +0 -0
  297. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchRight/entities.json +746 -0
  298. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchRight/geometry.bin +0 -0
  299. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/entities.json +1869 -0
  300. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/geometry.bin +0 -0
  301. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/1024/1.png +0 -0
  302. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/1024/2.jpg +0 -0
  303. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/1024/3.jpg +0 -0
  304. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/1.png +0 -0
  305. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/2.jpg +0 -0
  306. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/3.jpg +0 -0
  307. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/4.png +0 -0
  308. package/dist/lib/third-party/model3d/1.9.1/box3d-player.json +1 -0
  309. package/dist/lib/third-party/model3d/1.9.1/box3d-runtime.min.js +2 -0
  310. package/dist/lib/third-party/model3d/1.9.1/boxsdk.min.js +2 -0
  311. package/dist/lib/third-party/model3d/1.9.1/matcap.png +0 -0
  312. package/dist/lib/third-party/model3d/1.9.1/three.min.js +882 -0
  313. package/dist/lib/third-party/model3d/1.9.1/webvr-polyfill.js +6341 -0
  314. package/dist/lib/third-party/swf/0.112.0/swfobject.js +6 -0
  315. package/dist/lib/third-party/text/0.112.0/github-markdown.css +681 -0
  316. package/dist/lib/third-party/text/0.112.0/github.css +123 -0
  317. package/dist/lib/third-party/text/0.112.0/highlight.min.js +3 -0
  318. package/dist/lib/third-party/text/0.112.0/papaparse.js +1457 -0
  319. package/dist/lib/third-party/text/0.112.0/papaparse.min.js +34 -0
  320. package/dist/lib/third-party/text/0.112.0/remarkable.min.js +4 -0
  321. package/dist/lib/third-party/text/0.114.0/github-markdown.css +681 -0
  322. package/dist/lib/third-party/text/0.114.0/github-markdown.min.css +1 -0
  323. package/dist/lib/third-party/text/0.114.0/github.css +123 -0
  324. package/dist/lib/third-party/text/0.114.0/github.min.css +1 -0
  325. package/dist/lib/third-party/text/0.114.0/highlight.min.js +3 -0
  326. package/dist/lib/third-party/text/0.114.0/manifest.json +10 -0
  327. package/dist/lib/third-party/text/0.114.0/papaparse.js +1457 -0
  328. package/dist/lib/third-party/text/0.114.0/papaparse.min.js +34 -0
  329. package/dist/lib/third-party/text/0.114.0/remarkable.min.js +4 -0
  330. package/dist/lib/third-party/text/2.65.0/github-markdown.css +681 -0
  331. package/dist/lib/third-party/text/2.65.0/github-markdown.min.css +1 -0
  332. package/dist/lib/third-party/text/2.65.0/github.css +99 -0
  333. package/dist/lib/third-party/text/2.65.0/github.min.css +1 -0
  334. package/dist/lib/third-party/text/2.65.0/highlight.min.js +2 -0
  335. package/dist/lib/third-party/text/2.65.0/manifest.json +10 -0
  336. package/dist/lib/third-party/text/2.65.0/papaparse.js +1897 -0
  337. package/dist/lib/third-party/text/2.65.0/papaparse.min.js +7 -0
  338. package/dist/lib/third-party/text/2.65.0/remarkable.min.js +1 -0
  339. package/package.json +198 -0
@@ -0,0 +1,1897 @@
1
+ /* @license
2
+ Papa Parse
3
+ v5.0.0
4
+ https://github.com/mholt/PapaParse
5
+ License: MIT
6
+ */
7
+
8
+ (function(root, factory)
9
+ {
10
+ /* globals define */
11
+ if (typeof define === 'function' && define.amd)
12
+ {
13
+ // AMD. Register as an anonymous module.
14
+ define([], factory);
15
+ }
16
+ else if (typeof module === 'object' && typeof exports !== 'undefined')
17
+ {
18
+ // Node. Does not work with strict CommonJS, but
19
+ // only CommonJS-like environments that support module.exports,
20
+ // like Node.
21
+ module.exports = factory();
22
+ }
23
+ else
24
+ {
25
+ // Browser globals (root is window)
26
+ root.Papa = factory();
27
+ }
28
+ // in strict mode we cannot access arguments.callee, so we need a named reference to
29
+ // stringify the factory method for the blob worker
30
+ // eslint-disable-next-line func-name
31
+ }(this, function moduleFactory()
32
+ {
33
+ 'use strict';
34
+
35
+ var global = (function() {
36
+ // alternative method, similar to `Function('return this')()`
37
+ // but without using `eval` (which is disabled when
38
+ // using Content Security Policy).
39
+
40
+ if (typeof self !== 'undefined') { return self; }
41
+ if (typeof window !== 'undefined') { return window; }
42
+ if (typeof global !== 'undefined') { return global; }
43
+
44
+ // When running tests none of the above have been defined
45
+ return {};
46
+ })();
47
+
48
+
49
+ function getWorkerBlob() {
50
+ var URL = global.URL || global.webkitURL || null;
51
+ var code = moduleFactory.toString();
52
+ return Papa.BLOB_URL || (Papa.BLOB_URL = URL.createObjectURL(new Blob(['(', code, ')();'], {type: 'text/javascript'})));
53
+ }
54
+
55
+ var IS_WORKER = !global.document && !!global.postMessage,
56
+ IS_PAPA_WORKER = IS_WORKER && /blob:/i.test((global.location || {}).protocol);
57
+ var workers = {}, workerIdCounter = 0;
58
+
59
+ var Papa = {};
60
+
61
+ Papa.parse = CsvToJson;
62
+ Papa.unparse = JsonToCsv;
63
+
64
+ Papa.RECORD_SEP = String.fromCharCode(30);
65
+ Papa.UNIT_SEP = String.fromCharCode(31);
66
+ Papa.BYTE_ORDER_MARK = '\ufeff';
67
+ Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
68
+ Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
69
+ Papa.NODE_STREAM_INPUT = 1;
70
+
71
+ // Configurable chunk sizes for local and remote files, respectively
72
+ Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
73
+ Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
74
+ Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
75
+
76
+ // Exposed for testing and development only
77
+ Papa.Parser = Parser;
78
+ Papa.ParserHandle = ParserHandle;
79
+ Papa.NetworkStreamer = NetworkStreamer;
80
+ Papa.FileStreamer = FileStreamer;
81
+ Papa.StringStreamer = StringStreamer;
82
+ Papa.ReadableStreamStreamer = ReadableStreamStreamer;
83
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
84
+ Papa.DuplexStreamStreamer = DuplexStreamStreamer;
85
+ }
86
+
87
+ if (global.jQuery)
88
+ {
89
+ var $ = global.jQuery;
90
+ $.fn.parse = function(options)
91
+ {
92
+ var config = options.config || {};
93
+ var queue = [];
94
+
95
+ this.each(function(idx)
96
+ {
97
+ var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
98
+ && $(this).attr('type').toLowerCase() === 'file'
99
+ && global.FileReader;
100
+
101
+ if (!supported || !this.files || this.files.length === 0)
102
+ return true; // continue to next input element
103
+
104
+ for (var i = 0; i < this.files.length; i++)
105
+ {
106
+ queue.push({
107
+ file: this.files[i],
108
+ inputElem: this,
109
+ instanceConfig: $.extend({}, config)
110
+ });
111
+ }
112
+ });
113
+
114
+ parseNextFile(); // begin parsing
115
+ return this; // maintains chainability
116
+
117
+
118
+ function parseNextFile()
119
+ {
120
+ if (queue.length === 0)
121
+ {
122
+ if (isFunction(options.complete))
123
+ options.complete();
124
+ return;
125
+ }
126
+
127
+ var f = queue[0];
128
+
129
+ if (isFunction(options.before))
130
+ {
131
+ var returned = options.before(f.file, f.inputElem);
132
+
133
+ if (typeof returned === 'object')
134
+ {
135
+ if (returned.action === 'abort')
136
+ {
137
+ error('AbortError', f.file, f.inputElem, returned.reason);
138
+ return; // Aborts all queued files immediately
139
+ }
140
+ else if (returned.action === 'skip')
141
+ {
142
+ fileComplete(); // parse the next file in the queue, if any
143
+ return;
144
+ }
145
+ else if (typeof returned.config === 'object')
146
+ f.instanceConfig = $.extend(f.instanceConfig, returned.config);
147
+ }
148
+ else if (returned === 'skip')
149
+ {
150
+ fileComplete(); // parse the next file in the queue, if any
151
+ return;
152
+ }
153
+ }
154
+
155
+ // Wrap up the user's complete callback, if any, so that ours also gets executed
156
+ var userCompleteFunc = f.instanceConfig.complete;
157
+ f.instanceConfig.complete = function(results)
158
+ {
159
+ if (isFunction(userCompleteFunc))
160
+ userCompleteFunc(results, f.file, f.inputElem);
161
+ fileComplete();
162
+ };
163
+
164
+ Papa.parse(f.file, f.instanceConfig);
165
+ }
166
+
167
+ function error(name, file, elem, reason)
168
+ {
169
+ if (isFunction(options.error))
170
+ options.error({name: name}, file, elem, reason);
171
+ }
172
+
173
+ function fileComplete()
174
+ {
175
+ queue.splice(0, 1);
176
+ parseNextFile();
177
+ }
178
+ };
179
+ }
180
+
181
+
182
+ if (IS_PAPA_WORKER)
183
+ {
184
+ global.onmessage = workerThreadReceivedMessage;
185
+ }
186
+
187
+
188
+
189
+
190
+ function CsvToJson(_input, _config)
191
+ {
192
+ _config = _config || {};
193
+ var dynamicTyping = _config.dynamicTyping || false;
194
+ if (isFunction(dynamicTyping)) {
195
+ _config.dynamicTypingFunction = dynamicTyping;
196
+ // Will be filled on first row call
197
+ dynamicTyping = {};
198
+ }
199
+ _config.dynamicTyping = dynamicTyping;
200
+
201
+ _config.transform = isFunction(_config.transform) ? _config.transform : false;
202
+
203
+ if (_config.worker && Papa.WORKERS_SUPPORTED)
204
+ {
205
+ var w = newWorker();
206
+
207
+ w.userStep = _config.step;
208
+ w.userChunk = _config.chunk;
209
+ w.userComplete = _config.complete;
210
+ w.userError = _config.error;
211
+
212
+ _config.step = isFunction(_config.step);
213
+ _config.chunk = isFunction(_config.chunk);
214
+ _config.complete = isFunction(_config.complete);
215
+ _config.error = isFunction(_config.error);
216
+ delete _config.worker; // prevent infinite loop
217
+
218
+ w.postMessage({
219
+ input: _input,
220
+ config: _config,
221
+ workerId: w.id
222
+ });
223
+
224
+ return;
225
+ }
226
+
227
+ var streamer = null;
228
+ if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
229
+ {
230
+ // create a node Duplex stream for use
231
+ // with .pipe
232
+ streamer = new DuplexStreamStreamer(_config);
233
+ return streamer.getStream();
234
+ }
235
+ else if (typeof _input === 'string')
236
+ {
237
+ if (_config.download)
238
+ streamer = new NetworkStreamer(_config);
239
+ else
240
+ streamer = new StringStreamer(_config);
241
+ }
242
+ else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on))
243
+ {
244
+ streamer = new ReadableStreamStreamer(_config);
245
+ }
246
+ else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
247
+ streamer = new FileStreamer(_config);
248
+
249
+ return streamer.stream(_input);
250
+ }
251
+
252
+
253
+
254
+
255
+
256
+
257
+ function JsonToCsv(_input, _config)
258
+ {
259
+ // Default configuration
260
+
261
+ /** whether to surround every datum with quotes */
262
+ var _quotes = false;
263
+
264
+ /** whether to write headers */
265
+ var _writeHeader = true;
266
+
267
+ /** delimiting character(s) */
268
+ var _delimiter = ',';
269
+
270
+ /** newline character(s) */
271
+ var _newline = '\r\n';
272
+
273
+ /** quote character */
274
+ var _quoteChar = '"';
275
+
276
+ /** escaped quote character, either "" or <config.escapeChar>" */
277
+ var _escapedQuote = _quoteChar + _quoteChar;
278
+
279
+ /** whether to skip empty lines */
280
+ var _skipEmptyLines = false;
281
+
282
+ /** the columns (keys) we expect when we unparse objects */
283
+ var _columns = null;
284
+
285
+ unpackConfig();
286
+
287
+ var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), 'g');
288
+
289
+ if (typeof _input === 'string')
290
+ _input = JSON.parse(_input);
291
+
292
+ if (Array.isArray(_input))
293
+ {
294
+ if (!_input.length || Array.isArray(_input[0]))
295
+ return serialize(null, _input, _skipEmptyLines);
296
+ else if (typeof _input[0] === 'object')
297
+ return serialize(_columns || objectKeys(_input[0]), _input, _skipEmptyLines);
298
+ }
299
+ else if (typeof _input === 'object')
300
+ {
301
+ if (typeof _input.data === 'string')
302
+ _input.data = JSON.parse(_input.data);
303
+
304
+ if (Array.isArray(_input.data))
305
+ {
306
+ if (!_input.fields)
307
+ _input.fields = _input.meta && _input.meta.fields;
308
+
309
+ if (!_input.fields)
310
+ _input.fields = Array.isArray(_input.data[0])
311
+ ? _input.fields
312
+ : objectKeys(_input.data[0]);
313
+
314
+ if (!(Array.isArray(_input.data[0])) && typeof _input.data[0] !== 'object')
315
+ _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
316
+ }
317
+
318
+ return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
319
+ }
320
+
321
+ // Default (any valid paths should return before this)
322
+ throw new Error('Unable to serialize unrecognized input');
323
+
324
+
325
+ function unpackConfig()
326
+ {
327
+ if (typeof _config !== 'object')
328
+ return;
329
+
330
+ if (typeof _config.delimiter === 'string'
331
+ && !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.indexOf(value) !== -1; }).length)
332
+ {
333
+ _delimiter = _config.delimiter;
334
+ }
335
+
336
+ if (typeof _config.quotes === 'boolean'
337
+ || Array.isArray(_config.quotes))
338
+ _quotes = _config.quotes;
339
+
340
+ if (typeof _config.skipEmptyLines === 'boolean'
341
+ || typeof _config.skipEmptyLines === 'string')
342
+ _skipEmptyLines = _config.skipEmptyLines;
343
+
344
+ if (typeof _config.newline === 'string')
345
+ _newline = _config.newline;
346
+
347
+ if (typeof _config.quoteChar === 'string')
348
+ _quoteChar = _config.quoteChar;
349
+
350
+ if (typeof _config.header === 'boolean')
351
+ _writeHeader = _config.header;
352
+
353
+ if (Array.isArray(_config.columns)) {
354
+
355
+ if (_config.columns.length === 0) throw new Error('Option columns is empty');
356
+
357
+ _columns = _config.columns;
358
+ }
359
+
360
+ if (_config.escapeChar !== undefined) {
361
+ _escapedQuote = _config.escapeChar + _quoteChar;
362
+ }
363
+ }
364
+
365
+
366
+ /** Turns an object's keys into an array */
367
+ function objectKeys(obj)
368
+ {
369
+ if (typeof obj !== 'object')
370
+ return [];
371
+ var keys = [];
372
+ for (var key in obj)
373
+ keys.push(key);
374
+ return keys;
375
+ }
376
+
377
+ /** The double for loop that iterates the data and writes out a CSV string including header row */
378
+ function serialize(fields, data, skipEmptyLines)
379
+ {
380
+ var csv = '';
381
+
382
+ if (typeof fields === 'string')
383
+ fields = JSON.parse(fields);
384
+ if (typeof data === 'string')
385
+ data = JSON.parse(data);
386
+
387
+ var hasHeader = Array.isArray(fields) && fields.length > 0;
388
+ var dataKeyedByField = !(Array.isArray(data[0]));
389
+
390
+ // If there a header row, write it first
391
+ if (hasHeader && _writeHeader)
392
+ {
393
+ for (var i = 0; i < fields.length; i++)
394
+ {
395
+ if (i > 0)
396
+ csv += _delimiter;
397
+ csv += safe(fields[i], i);
398
+ }
399
+ if (data.length > 0)
400
+ csv += _newline;
401
+ }
402
+
403
+ // Then write out the data
404
+ for (var row = 0; row < data.length; row++)
405
+ {
406
+ var maxCol = hasHeader ? fields.length : data[row].length;
407
+
408
+ var emptyLine = false;
409
+ var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
410
+ if (skipEmptyLines && !hasHeader)
411
+ {
412
+ emptyLine = skipEmptyLines === 'greedy' ? data[row].join('').trim() === '' : data[row].length === 1 && data[row][0].length === 0;
413
+ }
414
+ if (skipEmptyLines === 'greedy' && hasHeader) {
415
+ var line = [];
416
+ for (var c = 0; c < maxCol; c++) {
417
+ var cx = dataKeyedByField ? fields[c] : c;
418
+ line.push(data[row][cx]);
419
+ }
420
+ emptyLine = line.join('').trim() === '';
421
+ }
422
+ if (!emptyLine)
423
+ {
424
+ for (var col = 0; col < maxCol; col++)
425
+ {
426
+ if (col > 0 && !nullLine)
427
+ csv += _delimiter;
428
+ var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
429
+ csv += safe(data[row][colIdx], col);
430
+ }
431
+ if (row < data.length - 1 && (!skipEmptyLines || (maxCol > 0 && !nullLine)))
432
+ {
433
+ csv += _newline;
434
+ }
435
+ }
436
+ }
437
+ return csv;
438
+ }
439
+
440
+ /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
441
+ function safe(str, col)
442
+ {
443
+ if (typeof str === 'undefined' || str === null)
444
+ return '';
445
+
446
+ if (str.constructor === Date)
447
+ return JSON.stringify(str).slice(1, 25);
448
+
449
+ str = str.toString().replace(quoteCharRegex, _escapedQuote);
450
+
451
+ var needsQuotes = (typeof _quotes === 'boolean' && _quotes)
452
+ || (Array.isArray(_quotes) && _quotes[col])
453
+ || hasAny(str, Papa.BAD_DELIMITERS)
454
+ || str.indexOf(_delimiter) > -1
455
+ || str.charAt(0) === ' '
456
+ || str.charAt(str.length - 1) === ' ';
457
+
458
+ return needsQuotes ? _quoteChar + str + _quoteChar : str;
459
+ }
460
+
461
+ function hasAny(str, substrings)
462
+ {
463
+ for (var i = 0; i < substrings.length; i++)
464
+ if (str.indexOf(substrings[i]) > -1)
465
+ return true;
466
+ return false;
467
+ }
468
+ }
469
+
470
+ /** ChunkStreamer is the base prototype for various streamer implementations. */
471
+ function ChunkStreamer(config)
472
+ {
473
+ this._handle = null;
474
+ this._finished = false;
475
+ this._completed = false;
476
+ this._halted = false;
477
+ this._input = null;
478
+ this._baseIndex = 0;
479
+ this._partialLine = '';
480
+ this._rowCount = 0;
481
+ this._start = 0;
482
+ this._nextChunk = null;
483
+ this.isFirstChunk = true;
484
+ this._completeResults = {
485
+ data: [],
486
+ errors: [],
487
+ meta: {}
488
+ };
489
+ replaceConfig.call(this, config);
490
+
491
+ this.parseChunk = function(chunk, isFakeChunk)
492
+ {
493
+ // First chunk pre-processing
494
+ if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
495
+ {
496
+ var modifiedChunk = this._config.beforeFirstChunk(chunk);
497
+ if (modifiedChunk !== undefined)
498
+ chunk = modifiedChunk;
499
+ }
500
+ this.isFirstChunk = false;
501
+ this._halted = false;
502
+
503
+ // Rejoin the line we likely just split in two by chunking the file
504
+ var aggregate = this._partialLine + chunk;
505
+ this._partialLine = '';
506
+
507
+ var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
508
+
509
+ if (this._handle.paused() || this._handle.aborted()) {
510
+ this._halted = true;
511
+ return;
512
+ }
513
+
514
+ var lastIndex = results.meta.cursor;
515
+
516
+ if (!this._finished)
517
+ {
518
+ this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
519
+ this._baseIndex = lastIndex;
520
+ }
521
+
522
+ if (results && results.data)
523
+ this._rowCount += results.data.length;
524
+
525
+ var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
526
+
527
+ if (IS_PAPA_WORKER)
528
+ {
529
+ global.postMessage({
530
+ results: results,
531
+ workerId: Papa.WORKER_ID,
532
+ finished: finishedIncludingPreview
533
+ });
534
+ }
535
+ else if (isFunction(this._config.chunk) && !isFakeChunk)
536
+ {
537
+ this._config.chunk(results, this._handle);
538
+ if (this._handle.paused() || this._handle.aborted()) {
539
+ this._halted = true;
540
+ return;
541
+ }
542
+ results = undefined;
543
+ this._completeResults = undefined;
544
+ }
545
+
546
+ if (!this._config.step && !this._config.chunk) {
547
+ this._completeResults.data = this._completeResults.data.concat(results.data);
548
+ this._completeResults.errors = this._completeResults.errors.concat(results.errors);
549
+ this._completeResults.meta = results.meta;
550
+ }
551
+
552
+ if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
553
+ this._config.complete(this._completeResults, this._input);
554
+ this._completed = true;
555
+ }
556
+
557
+ if (!finishedIncludingPreview && (!results || !results.meta.paused))
558
+ this._nextChunk();
559
+
560
+ return results;
561
+ };
562
+
563
+ this._sendError = function(error)
564
+ {
565
+ if (isFunction(this._config.error))
566
+ this._config.error(error);
567
+ else if (IS_PAPA_WORKER && this._config.error)
568
+ {
569
+ global.postMessage({
570
+ workerId: Papa.WORKER_ID,
571
+ error: error,
572
+ finished: false
573
+ });
574
+ }
575
+ };
576
+
577
+ function replaceConfig(config)
578
+ {
579
+ // Deep-copy the config so we can edit it
580
+ var configCopy = copy(config);
581
+ configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
582
+ if (!config.step && !config.chunk)
583
+ configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
584
+ this._handle = new ParserHandle(configCopy);
585
+ this._handle.streamer = this;
586
+ this._config = configCopy; // persist the copy to the caller
587
+ }
588
+ }
589
+
590
+
591
+ function NetworkStreamer(config)
592
+ {
593
+ config = config || {};
594
+ if (!config.chunkSize)
595
+ config.chunkSize = Papa.RemoteChunkSize;
596
+ ChunkStreamer.call(this, config);
597
+
598
+ var xhr;
599
+
600
+ if (IS_WORKER)
601
+ {
602
+ this._nextChunk = function()
603
+ {
604
+ this._readChunk();
605
+ this._chunkLoaded();
606
+ };
607
+ }
608
+ else
609
+ {
610
+ this._nextChunk = function()
611
+ {
612
+ this._readChunk();
613
+ };
614
+ }
615
+
616
+ this.stream = function(url)
617
+ {
618
+ this._input = url;
619
+ this._nextChunk(); // Starts streaming
620
+ };
621
+
622
+ this._readChunk = function()
623
+ {
624
+ if (this._finished)
625
+ {
626
+ this._chunkLoaded();
627
+ return;
628
+ }
629
+
630
+ xhr = new XMLHttpRequest();
631
+
632
+ if (this._config.withCredentials)
633
+ {
634
+ xhr.withCredentials = this._config.withCredentials;
635
+ }
636
+
637
+ if (!IS_WORKER)
638
+ {
639
+ xhr.onload = bindFunction(this._chunkLoaded, this);
640
+ xhr.onerror = bindFunction(this._chunkError, this);
641
+ }
642
+
643
+ xhr.open('GET', this._input, !IS_WORKER);
644
+ // Headers can only be set when once the request state is OPENED
645
+ if (this._config.downloadRequestHeaders)
646
+ {
647
+ var headers = this._config.downloadRequestHeaders;
648
+
649
+ for (var headerName in headers)
650
+ {
651
+ xhr.setRequestHeader(headerName, headers[headerName]);
652
+ }
653
+ }
654
+
655
+ if (this._config.chunkSize)
656
+ {
657
+ var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
658
+ xhr.setRequestHeader('Range', 'bytes=' + this._start + '-' + end);
659
+ }
660
+
661
+ try {
662
+ xhr.send();
663
+ }
664
+ catch (err) {
665
+ this._chunkError(err.message);
666
+ }
667
+
668
+ if (IS_WORKER && xhr.status === 0)
669
+ this._chunkError();
670
+ else
671
+ this._start += this._config.chunkSize;
672
+ };
673
+
674
+ this._chunkLoaded = function()
675
+ {
676
+ if (xhr.readyState !== 4)
677
+ return;
678
+
679
+ if (xhr.status < 200 || xhr.status >= 400)
680
+ {
681
+ this._chunkError();
682
+ return;
683
+ }
684
+
685
+ this._finished = !this._config.chunkSize || this._start > getFileSize(xhr);
686
+ this.parseChunk(xhr.responseText);
687
+ };
688
+
689
+ this._chunkError = function(errorMessage)
690
+ {
691
+ var errorText = xhr.statusText || errorMessage;
692
+ this._sendError(new Error(errorText));
693
+ };
694
+
695
+ function getFileSize(xhr)
696
+ {
697
+ var contentRange = xhr.getResponseHeader('Content-Range');
698
+ if (contentRange === null) { // no content range, then finish!
699
+ return -1;
700
+ }
701
+ return parseInt(contentRange.substr(contentRange.lastIndexOf('/') + 1));
702
+ }
703
+ }
704
+ NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
705
+ NetworkStreamer.prototype.constructor = NetworkStreamer;
706
+
707
+
708
+ function FileStreamer(config)
709
+ {
710
+ config = config || {};
711
+ if (!config.chunkSize)
712
+ config.chunkSize = Papa.LocalChunkSize;
713
+ ChunkStreamer.call(this, config);
714
+
715
+ var reader, slice;
716
+
717
+ // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
718
+ // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
719
+ var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
720
+
721
+ this.stream = function(file)
722
+ {
723
+ this._input = file;
724
+ slice = file.slice || file.webkitSlice || file.mozSlice;
725
+
726
+ if (usingAsyncReader)
727
+ {
728
+ reader = new FileReader(); // Preferred method of reading files, even in workers
729
+ reader.onload = bindFunction(this._chunkLoaded, this);
730
+ reader.onerror = bindFunction(this._chunkError, this);
731
+ }
732
+ else
733
+ reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
734
+
735
+ this._nextChunk(); // Starts streaming
736
+ };
737
+
738
+ this._nextChunk = function()
739
+ {
740
+ if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
741
+ this._readChunk();
742
+ };
743
+
744
+ this._readChunk = function()
745
+ {
746
+ var input = this._input;
747
+ if (this._config.chunkSize)
748
+ {
749
+ var end = Math.min(this._start + this._config.chunkSize, this._input.size);
750
+ input = slice.call(input, this._start, end);
751
+ }
752
+ var txt = reader.readAsText(input, this._config.encoding);
753
+ if (!usingAsyncReader)
754
+ this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
755
+ };
756
+
757
+ this._chunkLoaded = function(event)
758
+ {
759
+ // Very important to increment start each time before handling results
760
+ this._start += this._config.chunkSize;
761
+ this._finished = !this._config.chunkSize || this._start >= this._input.size;
762
+ this.parseChunk(event.target.result);
763
+ };
764
+
765
+ this._chunkError = function()
766
+ {
767
+ this._sendError(reader.error);
768
+ };
769
+
770
+ }
771
+ FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
772
+ FileStreamer.prototype.constructor = FileStreamer;
773
+
774
+
775
+ function StringStreamer(config)
776
+ {
777
+ config = config || {};
778
+ ChunkStreamer.call(this, config);
779
+
780
+ var remaining;
781
+ this.stream = function(s)
782
+ {
783
+ remaining = s;
784
+ return this._nextChunk();
785
+ };
786
+ this._nextChunk = function()
787
+ {
788
+ if (this._finished) return;
789
+ var size = this._config.chunkSize;
790
+ var chunk = size ? remaining.substr(0, size) : remaining;
791
+ remaining = size ? remaining.substr(size) : '';
792
+ this._finished = !remaining;
793
+ return this.parseChunk(chunk);
794
+ };
795
+ }
796
+ StringStreamer.prototype = Object.create(StringStreamer.prototype);
797
+ StringStreamer.prototype.constructor = StringStreamer;
798
+
799
+
800
+ function ReadableStreamStreamer(config)
801
+ {
802
+ config = config || {};
803
+
804
+ ChunkStreamer.call(this, config);
805
+
806
+ var queue = [];
807
+ var parseOnData = true;
808
+ var streamHasEnded = false;
809
+
810
+ this.pause = function()
811
+ {
812
+ ChunkStreamer.prototype.pause.apply(this, arguments);
813
+ this._input.pause();
814
+ };
815
+
816
+ this.resume = function()
817
+ {
818
+ ChunkStreamer.prototype.resume.apply(this, arguments);
819
+ this._input.resume();
820
+ };
821
+
822
+ this.stream = function(stream)
823
+ {
824
+ this._input = stream;
825
+
826
+ this._input.on('data', this._streamData);
827
+ this._input.on('end', this._streamEnd);
828
+ this._input.on('error', this._streamError);
829
+ };
830
+
831
+ this._checkIsFinished = function()
832
+ {
833
+ if (streamHasEnded && queue.length === 1) {
834
+ this._finished = true;
835
+ }
836
+ };
837
+
838
+ this._nextChunk = function()
839
+ {
840
+ this._checkIsFinished();
841
+ if (queue.length)
842
+ {
843
+ this.parseChunk(queue.shift());
844
+ }
845
+ else
846
+ {
847
+ parseOnData = true;
848
+ }
849
+ };
850
+
851
+ this._streamData = bindFunction(function(chunk)
852
+ {
853
+ try
854
+ {
855
+ queue.push(typeof chunk === 'string' ? chunk : chunk.toString(this._config.encoding));
856
+
857
+ if (parseOnData)
858
+ {
859
+ parseOnData = false;
860
+ this._checkIsFinished();
861
+ this.parseChunk(queue.shift());
862
+ }
863
+ }
864
+ catch (error)
865
+ {
866
+ this._streamError(error);
867
+ }
868
+ }, this);
869
+
870
+ this._streamError = bindFunction(function(error)
871
+ {
872
+ this._streamCleanUp();
873
+ this._sendError(error);
874
+ }, this);
875
+
876
+ this._streamEnd = bindFunction(function()
877
+ {
878
+ this._streamCleanUp();
879
+ streamHasEnded = true;
880
+ this._streamData('');
881
+ }, this);
882
+
883
+ this._streamCleanUp = bindFunction(function()
884
+ {
885
+ this._input.removeListener('data', this._streamData);
886
+ this._input.removeListener('end', this._streamEnd);
887
+ this._input.removeListener('error', this._streamError);
888
+ }, this);
889
+ }
890
+ ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
891
+ ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
892
+
893
+
894
+ function DuplexStreamStreamer(_config) {
895
+ var Duplex = require('stream').Duplex;
896
+ var config = copy(_config);
897
+ var parseOnWrite = true;
898
+ var writeStreamHasFinished = false;
899
+ var parseCallbackQueue = [];
900
+ var stream = null;
901
+
902
+ this._onCsvData = function(results)
903
+ {
904
+ var data = results.data;
905
+ if (!stream.push(data) && !this._handle.paused()) {
906
+ // the writeable consumer buffer has filled up
907
+ // so we need to pause until more items
908
+ // can be processed
909
+ this._handle.pause();
910
+ }
911
+ };
912
+
913
+ this._onCsvComplete = function()
914
+ {
915
+ // node will finish the read stream when
916
+ // null is pushed
917
+ stream.push(null);
918
+ };
919
+
920
+ config.step = bindFunction(this._onCsvData, this);
921
+ config.complete = bindFunction(this._onCsvComplete, this);
922
+ ChunkStreamer.call(this, config);
923
+
924
+ this._nextChunk = function()
925
+ {
926
+ if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
927
+ this._finished = true;
928
+ }
929
+ if (parseCallbackQueue.length) {
930
+ parseCallbackQueue.shift()();
931
+ } else {
932
+ parseOnWrite = true;
933
+ }
934
+ };
935
+
936
+ this._addToParseQueue = function(chunk, callback)
937
+ {
938
+ // add to queue so that we can indicate
939
+ // completion via callback
940
+ // node will automatically pause the incoming stream
941
+ // when too many items have been added without their
942
+ // callback being invoked
943
+ parseCallbackQueue.push(bindFunction(function() {
944
+ this.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));
945
+ if (isFunction(callback)) {
946
+ return callback();
947
+ }
948
+ }, this));
949
+ if (parseOnWrite) {
950
+ parseOnWrite = false;
951
+ this._nextChunk();
952
+ }
953
+ };
954
+
955
+ this._onRead = function()
956
+ {
957
+ if (this._handle.paused()) {
958
+ // the writeable consumer can handle more data
959
+ // so resume the chunk parsing
960
+ this._handle.resume();
961
+ }
962
+ };
963
+
964
+ this._onWrite = function(chunk, encoding, callback)
965
+ {
966
+ this._addToParseQueue(chunk, callback);
967
+ };
968
+
969
+ this._onWriteComplete = function()
970
+ {
971
+ writeStreamHasFinished = true;
972
+ // have to write empty string
973
+ // so parser knows its done
974
+ this._addToParseQueue('');
975
+ };
976
+
977
+ this.getStream = function()
978
+ {
979
+ return stream;
980
+ };
981
+ stream = new Duplex({
982
+ readableObjectMode: true,
983
+ decodeStrings: false,
984
+ read: bindFunction(this._onRead, this),
985
+ write: bindFunction(this._onWrite, this)
986
+ });
987
+ stream.once('finish', bindFunction(this._onWriteComplete, this));
988
+ }
989
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
990
+ DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
991
+ DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
992
+ }
993
+
994
+
995
+ // Use one ParserHandle per entire CSV file or string
996
+ function ParserHandle(_config)
997
+ {
998
+ // One goal is to minimize the use of regular expressions...
999
+ var FLOAT = /^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i;
1000
+ var ISO_DATE = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/;
1001
+ var self = this;
1002
+ var _stepCounter = 0; // Number of times step was called (number of rows parsed)
1003
+ var _rowCounter = 0; // Number of rows that have been parsed so far
1004
+ var _input; // The input being parsed
1005
+ var _parser; // The core parser being used
1006
+ var _paused = false; // Whether we are paused or not
1007
+ var _aborted = false; // Whether the parser has aborted or not
1008
+ var _delimiterError; // Temporary state between delimiter detection and processing results
1009
+ var _fields = []; // Fields are from the header row of the input, if there is one
1010
+ var _results = { // The last results returned from the parser
1011
+ data: [],
1012
+ errors: [],
1013
+ meta: {}
1014
+ };
1015
+
1016
+ if (isFunction(_config.step))
1017
+ {
1018
+ var userStep = _config.step;
1019
+ _config.step = function(results)
1020
+ {
1021
+ _results = results;
1022
+
1023
+ if (needsHeaderRow())
1024
+ processResults();
1025
+ else // only call user's step function after header row
1026
+ {
1027
+ processResults();
1028
+
1029
+ // It's possbile that this line was empty and there's no row here after all
1030
+ if (_results.data.length === 0)
1031
+ return;
1032
+
1033
+ _stepCounter += results.data.length;
1034
+ if (_config.preview && _stepCounter > _config.preview)
1035
+ _parser.abort();
1036
+ else
1037
+ userStep(_results, self);
1038
+ }
1039
+ };
1040
+ }
1041
+
1042
+ /**
1043
+ * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
1044
+ * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
1045
+ * when an input comes in multiple chunks, like from a file.
1046
+ */
1047
+ this.parse = function(input, baseIndex, ignoreLastRow)
1048
+ {
1049
+ var quoteChar = _config.quoteChar || '"';
1050
+ if (!_config.newline)
1051
+ _config.newline = guessLineEndings(input, quoteChar);
1052
+
1053
+ _delimiterError = false;
1054
+ if (!_config.delimiter)
1055
+ {
1056
+ var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
1057
+ if (delimGuess.successful)
1058
+ _config.delimiter = delimGuess.bestDelimiter;
1059
+ else
1060
+ {
1061
+ _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
1062
+ _config.delimiter = Papa.DefaultDelimiter;
1063
+ }
1064
+ _results.meta.delimiter = _config.delimiter;
1065
+ }
1066
+ else if(isFunction(_config.delimiter))
1067
+ {
1068
+ _config.delimiter = _config.delimiter(input);
1069
+ _results.meta.delimiter = _config.delimiter;
1070
+ }
1071
+
1072
+ var parserConfig = copy(_config);
1073
+ if (_config.preview && _config.header)
1074
+ parserConfig.preview++; // to compensate for header row
1075
+
1076
+ _input = input;
1077
+ _parser = new Parser(parserConfig);
1078
+ _results = _parser.parse(_input, baseIndex, ignoreLastRow);
1079
+ processResults();
1080
+ return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
1081
+ };
1082
+
1083
+ this.paused = function()
1084
+ {
1085
+ return _paused;
1086
+ };
1087
+
1088
+ this.pause = function()
1089
+ {
1090
+ _paused = true;
1091
+ _parser.abort();
1092
+ _input = _input.substr(_parser.getCharIndex());
1093
+ };
1094
+
1095
+ this.resume = function()
1096
+ {
1097
+ if(self.streamer._halted) {
1098
+ _paused = false;
1099
+ self.streamer.parseChunk(_input, true);
1100
+ } else {
1101
+ // Bugfix: #636 In case the processing hasn't halted yet
1102
+ // wait for it to halt in order to resume
1103
+ setTimeout(this.resume, 3);
1104
+ }
1105
+ };
1106
+
1107
+ this.aborted = function()
1108
+ {
1109
+ return _aborted;
1110
+ };
1111
+
1112
+ this.abort = function()
1113
+ {
1114
+ _aborted = true;
1115
+ _parser.abort();
1116
+ _results.meta.aborted = true;
1117
+ if (isFunction(_config.complete))
1118
+ _config.complete(_results);
1119
+ _input = '';
1120
+ };
1121
+
1122
+ function testEmptyLine(s) {
1123
+ return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0;
1124
+ }
1125
+
1126
+ function processResults()
1127
+ {
1128
+ if (_results && _delimiterError)
1129
+ {
1130
+ addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \'' + Papa.DefaultDelimiter + '\'');
1131
+ _delimiterError = false;
1132
+ }
1133
+
1134
+ if (_config.skipEmptyLines)
1135
+ {
1136
+ for (var i = 0; i < _results.data.length; i++)
1137
+ if (testEmptyLine(_results.data[i]))
1138
+ _results.data.splice(i--, 1);
1139
+ }
1140
+
1141
+ if (needsHeaderRow())
1142
+ fillHeaderFields();
1143
+
1144
+ return applyHeaderAndDynamicTypingAndTransformation();
1145
+ }
1146
+
1147
+ function needsHeaderRow()
1148
+ {
1149
+ return _config.header && _fields.length === 0;
1150
+ }
1151
+
1152
+ function fillHeaderFields()
1153
+ {
1154
+ if (!_results)
1155
+ return;
1156
+
1157
+ function addHeder(header)
1158
+ {
1159
+ if (isFunction(_config.transformHeader))
1160
+ header = _config.transformHeader(header);
1161
+
1162
+ _fields.push(header);
1163
+ }
1164
+
1165
+ if (Array.isArray(_results.data[0]))
1166
+ {
1167
+ for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
1168
+ _results.data[i].forEach(addHeder);
1169
+
1170
+ _results.data.splice(0, 1);
1171
+ }
1172
+ // if _results.data[0] is not an array, we are in a step where _results.data is the row.
1173
+ else
1174
+ _results.data.forEach(addHeder);
1175
+ }
1176
+
1177
+ function shouldApplyDynamicTyping(field) {
1178
+ // Cache function values to avoid calling it for each row
1179
+ if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) {
1180
+ _config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
1181
+ }
1182
+ return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
1183
+ }
1184
+
1185
+ function parseDynamic(field, value)
1186
+ {
1187
+ if (shouldApplyDynamicTyping(field))
1188
+ {
1189
+ if (value === 'true' || value === 'TRUE')
1190
+ return true;
1191
+ else if (value === 'false' || value === 'FALSE')
1192
+ return false;
1193
+ else if (FLOAT.test(value))
1194
+ return parseFloat(value);
1195
+ else if (ISO_DATE.test(value))
1196
+ return new Date(value);
1197
+ else
1198
+ return (value === '' ? null : value);
1199
+ }
1200
+ return value;
1201
+ }
1202
+
1203
+ function applyHeaderAndDynamicTypingAndTransformation()
1204
+ {
1205
+ if (!_results || (!_config.header && !_config.dynamicTyping && !_config.transform))
1206
+ return _results;
1207
+
1208
+ function processRow(rowSource, i)
1209
+ {
1210
+ var row = _config.header ? {} : [];
1211
+
1212
+ var j;
1213
+ for (j = 0; j < rowSource.length; j++)
1214
+ {
1215
+ var field = j;
1216
+ var value = rowSource[j];
1217
+
1218
+ if (_config.header)
1219
+ field = j >= _fields.length ? '__parsed_extra' : _fields[j];
1220
+
1221
+ if (_config.transform)
1222
+ value = _config.transform(value,field);
1223
+
1224
+ value = parseDynamic(field, value);
1225
+
1226
+ if (field === '__parsed_extra')
1227
+ {
1228
+ row[field] = row[field] || [];
1229
+ row[field].push(value);
1230
+ }
1231
+ else
1232
+ row[field] = value;
1233
+ }
1234
+
1235
+
1236
+ if (_config.header)
1237
+ {
1238
+ if (j > _fields.length)
1239
+ addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1240
+ else if (j < _fields.length)
1241
+ addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1242
+ }
1243
+
1244
+ return row;
1245
+ }
1246
+
1247
+ var incrementBy = 1;
1248
+ if (!_results.data[0] || Array.isArray(_results.data[0]))
1249
+ {
1250
+ _results.data = _results.data.map(processRow);
1251
+ incrementBy = _results.data.length;
1252
+ }
1253
+ else
1254
+ _results.data = processRow(_results.data, 0);
1255
+
1256
+
1257
+ if (_config.header && _results.meta)
1258
+ _results.meta.fields = _fields;
1259
+
1260
+ _rowCounter += incrementBy;
1261
+ return _results;
1262
+ }
1263
+
1264
+ function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess)
1265
+ {
1266
+ var bestDelim, bestDelta, fieldCountPrevRow;
1267
+
1268
+ delimitersToGuess = delimitersToGuess || [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
1269
+
1270
+ for (var i = 0; i < delimitersToGuess.length; i++)
1271
+ {
1272
+ var delim = delimitersToGuess[i];
1273
+ var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
1274
+ fieldCountPrevRow = undefined;
1275
+
1276
+ var preview = new Parser({
1277
+ comments: comments,
1278
+ delimiter: delim,
1279
+ newline: newline,
1280
+ preview: 10
1281
+ }).parse(input);
1282
+
1283
+ for (var j = 0; j < preview.data.length; j++)
1284
+ {
1285
+ if (skipEmptyLines && testEmptyLine(preview.data[j]))
1286
+ {
1287
+ emptyLinesCount++;
1288
+ continue;
1289
+ }
1290
+ var fieldCount = preview.data[j].length;
1291
+ avgFieldCount += fieldCount;
1292
+
1293
+ if (typeof fieldCountPrevRow === 'undefined')
1294
+ {
1295
+ fieldCountPrevRow = 0;
1296
+ continue;
1297
+ }
1298
+ else if (fieldCount > 1)
1299
+ {
1300
+ delta += Math.abs(fieldCount - fieldCountPrevRow);
1301
+ fieldCountPrevRow = fieldCount;
1302
+ }
1303
+ }
1304
+
1305
+ if (preview.data.length > 0)
1306
+ avgFieldCount /= (preview.data.length - emptyLinesCount);
1307
+
1308
+ if ((typeof bestDelta === 'undefined' || delta > bestDelta)
1309
+ && avgFieldCount > 1.99)
1310
+ {
1311
+ bestDelta = delta;
1312
+ bestDelim = delim;
1313
+ }
1314
+ }
1315
+
1316
+ _config.delimiter = bestDelim;
1317
+
1318
+ return {
1319
+ successful: !!bestDelim,
1320
+ bestDelimiter: bestDelim
1321
+ };
1322
+ }
1323
+
1324
+ function guessLineEndings(input, quoteChar)
1325
+ {
1326
+ input = input.substr(0, 1024 * 1024); // max length 1 MB
1327
+ // Replace all the text inside quotes
1328
+ var re = new RegExp(escapeRegExp(quoteChar) + '([^]*?)' + escapeRegExp(quoteChar), 'gm');
1329
+ input = input.replace(re, '');
1330
+
1331
+ var r = input.split('\r');
1332
+
1333
+ var n = input.split('\n');
1334
+
1335
+ var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
1336
+
1337
+ if (r.length === 1 || nAppearsFirst)
1338
+ return '\n';
1339
+
1340
+ var numWithN = 0;
1341
+ for (var i = 0; i < r.length; i++)
1342
+ {
1343
+ if (r[i][0] === '\n')
1344
+ numWithN++;
1345
+ }
1346
+
1347
+ return numWithN >= r.length / 2 ? '\r\n' : '\r';
1348
+ }
1349
+
1350
+ function addError(type, code, msg, row)
1351
+ {
1352
+ _results.errors.push({
1353
+ type: type,
1354
+ code: code,
1355
+ message: msg,
1356
+ row: row
1357
+ });
1358
+ }
1359
+ }
1360
+
1361
+ /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions */
1362
+ function escapeRegExp(string)
1363
+ {
1364
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
1365
+ }
1366
+
1367
+ /** The core parser implements speedy and correct CSV parsing */
1368
+ function Parser(config)
1369
+ {
1370
+ // Unpack the config object
1371
+ config = config || {};
1372
+ var delim = config.delimiter;
1373
+ var newline = config.newline;
1374
+ var comments = config.comments;
1375
+ var step = config.step;
1376
+ var preview = config.preview;
1377
+ var fastMode = config.fastMode;
1378
+ var quoteChar;
1379
+ /** Allows for no quoteChar by setting quoteChar to undefined in config */
1380
+ if (config.quoteChar === undefined) {
1381
+ quoteChar = '"';
1382
+ } else {
1383
+ quoteChar = config.quoteChar;
1384
+ }
1385
+ var escapeChar = quoteChar;
1386
+ if (config.escapeChar !== undefined) {
1387
+ escapeChar = config.escapeChar;
1388
+ }
1389
+
1390
+ // Delimiter must be valid
1391
+ if (typeof delim !== 'string'
1392
+ || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
1393
+ delim = ',';
1394
+
1395
+ // Comment character must be valid
1396
+ if (comments === delim)
1397
+ throw new Error('Comment character same as delimiter');
1398
+ else if (comments === true)
1399
+ comments = '#';
1400
+ else if (typeof comments !== 'string'
1401
+ || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
1402
+ comments = false;
1403
+
1404
+ // Newline must be valid: \r, \n, or \r\n
1405
+ if (newline !== '\n' && newline !== '\r' && newline !== '\r\n')
1406
+ newline = '\n';
1407
+
1408
+ // We're gonna need these at the Parser scope
1409
+ var cursor = 0;
1410
+ var aborted = false;
1411
+
1412
+ this.parse = function(input, baseIndex, ignoreLastRow)
1413
+ {
1414
+ // For some reason, in Chrome, this speeds things up (!?)
1415
+ if (typeof input !== 'string')
1416
+ throw new Error('Input must be a string');
1417
+
1418
+ // We don't need to compute some of these every time parse() is called,
1419
+ // but having them in a more local scope seems to perform better
1420
+ var inputLen = input.length,
1421
+ delimLen = delim.length,
1422
+ newlineLen = newline.length,
1423
+ commentsLen = comments.length;
1424
+ var stepIsFunction = isFunction(step);
1425
+
1426
+ // Establish starting state
1427
+ cursor = 0;
1428
+ var data = [], errors = [], row = [], lastCursor = 0;
1429
+
1430
+ if (!input)
1431
+ return returnable();
1432
+
1433
+ if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
1434
+ {
1435
+ var rows = input.split(newline);
1436
+ for (var i = 0; i < rows.length; i++)
1437
+ {
1438
+ row = rows[i];
1439
+ cursor += row.length;
1440
+ if (i !== rows.length - 1)
1441
+ cursor += newline.length;
1442
+ else if (ignoreLastRow)
1443
+ return returnable();
1444
+ if (comments && row.substr(0, commentsLen) === comments)
1445
+ continue;
1446
+ if (stepIsFunction)
1447
+ {
1448
+ data = [];
1449
+ pushRow(row.split(delim));
1450
+ doStep();
1451
+ if (aborted)
1452
+ return returnable();
1453
+ }
1454
+ else
1455
+ pushRow(row.split(delim));
1456
+ if (preview && i >= preview)
1457
+ {
1458
+ data = data.slice(0, preview);
1459
+ return returnable(true);
1460
+ }
1461
+ }
1462
+ return returnable();
1463
+ }
1464
+
1465
+ var nextDelim = input.indexOf(delim, cursor);
1466
+ var nextNewline = input.indexOf(newline, cursor);
1467
+ var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), 'g');
1468
+ var quoteSearch = input.indexOf(quoteChar, cursor);
1469
+
1470
+ // Parser loop
1471
+ for (;;)
1472
+ {
1473
+ // Field has opening quote
1474
+ if (input[cursor] === quoteChar)
1475
+ {
1476
+ // Start our search for the closing quote where the cursor is
1477
+ quoteSearch = cursor;
1478
+
1479
+ // Skip the opening quote
1480
+ cursor++;
1481
+
1482
+ for (;;)
1483
+ {
1484
+ // Find closing quote
1485
+ quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
1486
+
1487
+ //No other quotes are found - no other delimiters
1488
+ if (quoteSearch === -1)
1489
+ {
1490
+ if (!ignoreLastRow) {
1491
+ // No closing quote... what a pity
1492
+ errors.push({
1493
+ type: 'Quotes',
1494
+ code: 'MissingQuotes',
1495
+ message: 'Quoted field unterminated',
1496
+ row: data.length, // row has yet to be inserted
1497
+ index: cursor
1498
+ });
1499
+ }
1500
+ return finish();
1501
+ }
1502
+
1503
+ // Closing quote at EOF
1504
+ if (quoteSearch === inputLen - 1)
1505
+ {
1506
+ var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
1507
+ return finish(value);
1508
+ }
1509
+
1510
+ // If this quote is escaped, it's part of the data; skip it
1511
+ // If the quote character is the escape character, then check if the next character is the escape character
1512
+ if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar)
1513
+ {
1514
+ quoteSearch++;
1515
+ continue;
1516
+ }
1517
+
1518
+ // If the quote character is not the escape character, then check if the previous character was the escape character
1519
+ if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar)
1520
+ {
1521
+ continue;
1522
+ }
1523
+
1524
+ // Check up to nextDelim or nextNewline, whichever is closest
1525
+ var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
1526
+ var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
1527
+
1528
+ // Closing quote followed by delimiter or 'unnecessary spaces + delimiter'
1529
+ if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter] === delim)
1530
+ {
1531
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1532
+ cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
1533
+
1534
+ // If char after following delimiter is not quoteChar, we find next quote char position
1535
+ if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar)
1536
+ {
1537
+ quoteSearch = input.indexOf(quoteChar, cursor);
1538
+ }
1539
+ nextDelim = input.indexOf(delim, cursor);
1540
+ nextNewline = input.indexOf(newline, cursor);
1541
+ break;
1542
+ }
1543
+
1544
+ var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
1545
+
1546
+ // Closing quote followed by newline or 'unnecessary spaces + newLine'
1547
+ if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, newlineLen) === newline)
1548
+ {
1549
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1550
+ saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
1551
+ nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
1552
+ quoteSearch = input.indexOf(quoteChar, cursor); // we search for first quote in next line
1553
+
1554
+ if (stepIsFunction)
1555
+ {
1556
+ doStep();
1557
+ if (aborted)
1558
+ return returnable();
1559
+ }
1560
+
1561
+ if (preview && data.length >= preview)
1562
+ return returnable(true);
1563
+
1564
+ break;
1565
+ }
1566
+
1567
+
1568
+ // Checks for valid closing quotes are complete (escaped quotes or quote followed by EOF/delimiter/newline) -- assume these quotes are part of an invalid text string
1569
+ errors.push({
1570
+ type: 'Quotes',
1571
+ code: 'InvalidQuotes',
1572
+ message: 'Trailing quote on quoted field is malformed',
1573
+ row: data.length, // row has yet to be inserted
1574
+ index: cursor
1575
+ });
1576
+
1577
+ quoteSearch++;
1578
+ continue;
1579
+
1580
+ }
1581
+
1582
+ continue;
1583
+ }
1584
+
1585
+ // Comment found at start of new line
1586
+ if (comments && row.length === 0 && input.substr(cursor, commentsLen) === comments)
1587
+ {
1588
+ if (nextNewline === -1) // Comment ends at EOF
1589
+ return returnable();
1590
+ cursor = nextNewline + newlineLen;
1591
+ nextNewline = input.indexOf(newline, cursor);
1592
+ nextDelim = input.indexOf(delim, cursor);
1593
+ continue;
1594
+ }
1595
+
1596
+ // Next delimiter comes before next newline, so we've reached end of field
1597
+ if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
1598
+ {
1599
+ // we check, if we have quotes, because delimiter char may be part of field enclosed in quotes
1600
+ if (quoteSearch !== -1) {
1601
+ // we have quotes, so we try to find the next delimiter not enclosed in quotes and also next starting quote char
1602
+ var nextDelimObj = getNextUnqotedDelimiter(nextDelim, quoteSearch, nextNewline);
1603
+
1604
+ // if we have next delimiter char which is not enclosed in quotes
1605
+ if (nextDelimObj && nextDelimObj.nextDelim) {
1606
+ nextDelim = nextDelimObj.nextDelim;
1607
+ quoteSearch = nextDelimObj.quoteSearch;
1608
+ row.push(input.substring(cursor, nextDelim));
1609
+ cursor = nextDelim + delimLen;
1610
+ // we look for next delimiter char
1611
+ nextDelim = input.indexOf(delim, cursor);
1612
+ continue;
1613
+ }
1614
+ } else {
1615
+ row.push(input.substring(cursor, nextDelim));
1616
+ cursor = nextDelim + delimLen;
1617
+ nextDelim = input.indexOf(delim, cursor);
1618
+ continue;
1619
+ }
1620
+ }
1621
+
1622
+ // End of row
1623
+ if (nextNewline !== -1)
1624
+ {
1625
+ row.push(input.substring(cursor, nextNewline));
1626
+ saveRow(nextNewline + newlineLen);
1627
+
1628
+ if (stepIsFunction)
1629
+ {
1630
+ doStep();
1631
+ if (aborted)
1632
+ return returnable();
1633
+ }
1634
+
1635
+ if (preview && data.length >= preview)
1636
+ return returnable(true);
1637
+
1638
+ continue;
1639
+ }
1640
+
1641
+ break;
1642
+ }
1643
+
1644
+
1645
+ return finish();
1646
+
1647
+
1648
+ function pushRow(row)
1649
+ {
1650
+ data.push(row);
1651
+ lastCursor = cursor;
1652
+ }
1653
+
1654
+ /**
1655
+ * checks if there are extra spaces after closing quote and given index without any text
1656
+ * if Yes, returns the number of spaces
1657
+ */
1658
+ function extraSpaces(index) {
1659
+ var spaceLength = 0;
1660
+ if (index !== -1) {
1661
+ var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
1662
+ if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') {
1663
+ spaceLength = textBetweenClosingQuoteAndIndex.length;
1664
+ }
1665
+ }
1666
+ return spaceLength;
1667
+ }
1668
+
1669
+ /**
1670
+ * Appends the remaining input from cursor to the end into
1671
+ * row, saves the row, calls step, and returns the results.
1672
+ */
1673
+ function finish(value)
1674
+ {
1675
+ if (ignoreLastRow)
1676
+ return returnable();
1677
+ if (typeof value === 'undefined')
1678
+ value = input.substr(cursor);
1679
+ row.push(value);
1680
+ cursor = inputLen; // important in case parsing is paused
1681
+ pushRow(row);
1682
+ if (stepIsFunction)
1683
+ doStep();
1684
+ return returnable();
1685
+ }
1686
+
1687
+ /**
1688
+ * Appends the current row to the results. It sets the cursor
1689
+ * to newCursor and finds the nextNewline. The caller should
1690
+ * take care to execute user's step function and check for
1691
+ * preview and end parsing if necessary.
1692
+ */
1693
+ function saveRow(newCursor)
1694
+ {
1695
+ cursor = newCursor;
1696
+ pushRow(row);
1697
+ row = [];
1698
+ nextNewline = input.indexOf(newline, cursor);
1699
+ }
1700
+
1701
+ /** Returns an object with the results, errors, and meta. */
1702
+ function returnable(stopped, step)
1703
+ {
1704
+ var isStep = step || false;
1705
+ return {
1706
+ data: isStep ? data[0] : data,
1707
+ errors: errors,
1708
+ meta: {
1709
+ delimiter: delim,
1710
+ linebreak: newline,
1711
+ aborted: aborted,
1712
+ truncated: !!stopped,
1713
+ cursor: lastCursor + (baseIndex || 0)
1714
+ }
1715
+ };
1716
+ }
1717
+
1718
+ /** Executes the user's step function and resets data & errors. */
1719
+ function doStep()
1720
+ {
1721
+ step(returnable(undefined, true));
1722
+ data = [];
1723
+ errors = [];
1724
+ }
1725
+
1726
+ /** Gets the delimiter character, which is not inside the quoted field */
1727
+ function getNextUnqotedDelimiter(nextDelim, quoteSearch, newLine) {
1728
+ var result = {
1729
+ nextDelim: undefined,
1730
+ quoteSearch: undefined
1731
+ };
1732
+ // get the next closing quote character
1733
+ var nextQuoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
1734
+
1735
+ // if next delimiter is part of a field enclosed in quotes
1736
+ if (nextDelim > quoteSearch && nextDelim < nextQuoteSearch && (nextQuoteSearch < newLine || newLine === -1)) {
1737
+ // get the next delimiter character after this one
1738
+ var nextNextDelim = input.indexOf(delim, nextQuoteSearch);
1739
+
1740
+ // if there is no next delimiter, return default result
1741
+ if (nextNextDelim === -1) {
1742
+ return result;
1743
+ }
1744
+ // find the next opening quote char position
1745
+ if (nextNextDelim > nextQuoteSearch) {
1746
+ nextQuoteSearch = input.indexOf(quoteChar, nextQuoteSearch + 1);
1747
+ }
1748
+ // try to get the next delimiter position
1749
+ result = getNextUnqotedDelimiter(nextNextDelim, nextQuoteSearch, newLine);
1750
+ } else {
1751
+ result = {
1752
+ nextDelim: nextDelim,
1753
+ quoteSearch: quoteSearch
1754
+ };
1755
+ }
1756
+
1757
+ return result;
1758
+ }
1759
+ };
1760
+
1761
+ /** Sets the abort flag */
1762
+ this.abort = function()
1763
+ {
1764
+ aborted = true;
1765
+ };
1766
+
1767
+ /** Gets the cursor position */
1768
+ this.getCharIndex = function()
1769
+ {
1770
+ return cursor;
1771
+ };
1772
+ }
1773
+
1774
+
1775
+ function newWorker()
1776
+ {
1777
+ if (!Papa.WORKERS_SUPPORTED)
1778
+ return false;
1779
+
1780
+ var workerUrl = getWorkerBlob();
1781
+ var w = new global.Worker(workerUrl);
1782
+ w.onmessage = mainThreadReceivedMessage;
1783
+ w.id = workerIdCounter++;
1784
+ workers[w.id] = w;
1785
+ return w;
1786
+ }
1787
+
1788
+ /** Callback when main thread receives a message */
1789
+ function mainThreadReceivedMessage(e)
1790
+ {
1791
+ var msg = e.data;
1792
+ var worker = workers[msg.workerId];
1793
+ var aborted = false;
1794
+
1795
+ if (msg.error)
1796
+ worker.userError(msg.error, msg.file);
1797
+ else if (msg.results && msg.results.data)
1798
+ {
1799
+ var abort = function() {
1800
+ aborted = true;
1801
+ completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
1802
+ };
1803
+
1804
+ var handle = {
1805
+ abort: abort,
1806
+ pause: notImplemented,
1807
+ resume: notImplemented
1808
+ };
1809
+
1810
+ if (isFunction(worker.userStep))
1811
+ {
1812
+ for (var i = 0; i < msg.results.data.length; i++)
1813
+ {
1814
+ worker.userStep({
1815
+ data: msg.results.data[i],
1816
+ errors: msg.results.errors,
1817
+ meta: msg.results.meta
1818
+ }, handle);
1819
+ if (aborted)
1820
+ break;
1821
+ }
1822
+ delete msg.results; // free memory ASAP
1823
+ }
1824
+ else if (isFunction(worker.userChunk))
1825
+ {
1826
+ worker.userChunk(msg.results, handle, msg.file);
1827
+ delete msg.results;
1828
+ }
1829
+ }
1830
+
1831
+ if (msg.finished && !aborted)
1832
+ completeWorker(msg.workerId, msg.results);
1833
+ }
1834
+
1835
+ function completeWorker(workerId, results) {
1836
+ var worker = workers[workerId];
1837
+ if (isFunction(worker.userComplete))
1838
+ worker.userComplete(results);
1839
+ worker.terminate();
1840
+ delete workers[workerId];
1841
+ }
1842
+
1843
+ function notImplemented() {
1844
+ throw new Error('Not implemented.');
1845
+ }
1846
+
1847
+ /** Callback when worker thread receives a message */
1848
+ function workerThreadReceivedMessage(e)
1849
+ {
1850
+ var msg = e.data;
1851
+
1852
+ if (typeof Papa.WORKER_ID === 'undefined' && msg)
1853
+ Papa.WORKER_ID = msg.workerId;
1854
+
1855
+ if (typeof msg.input === 'string')
1856
+ {
1857
+ global.postMessage({
1858
+ workerId: Papa.WORKER_ID,
1859
+ results: Papa.parse(msg.input, msg.config),
1860
+ finished: true
1861
+ });
1862
+ }
1863
+ else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
1864
+ {
1865
+ var results = Papa.parse(msg.input, msg.config);
1866
+ if (results)
1867
+ global.postMessage({
1868
+ workerId: Papa.WORKER_ID,
1869
+ results: results,
1870
+ finished: true
1871
+ });
1872
+ }
1873
+ }
1874
+
1875
+ /** Makes a deep copy of an array or object (mostly) */
1876
+ function copy(obj)
1877
+ {
1878
+ if (typeof obj !== 'object' || obj === null)
1879
+ return obj;
1880
+ var cpy = Array.isArray(obj) ? [] : {};
1881
+ for (var key in obj)
1882
+ cpy[key] = copy(obj[key]);
1883
+ return cpy;
1884
+ }
1885
+
1886
+ function bindFunction(f, self)
1887
+ {
1888
+ return function() { f.apply(self, arguments); };
1889
+ }
1890
+
1891
+ function isFunction(func)
1892
+ {
1893
+ return typeof func === 'function';
1894
+ }
1895
+
1896
+ return Papa;
1897
+ }));