locutus 2.0.31 → 2.0.34

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 (879) hide show
  1. package/README.md +84 -0
  2. package/_data/rosetta.yml +325 -0
  3. package/awk/builtin/index.js +3 -0
  4. package/awk/builtin/int.js +13 -0
  5. package/awk/builtin/length.js +16 -0
  6. package/awk/builtin/substr.js +23 -0
  7. package/c/ctype/index.js +8 -0
  8. package/c/ctype/isalnum.js +15 -0
  9. package/c/ctype/isalpha.js +17 -0
  10. package/c/ctype/isdigit.js +15 -0
  11. package/c/ctype/islower.js +15 -0
  12. package/c/ctype/isspace.js +15 -0
  13. package/c/ctype/isupper.js +15 -0
  14. package/c/ctype/tolower.js +15 -0
  15. package/c/ctype/toupper.js +15 -0
  16. package/c/index.js +2 -5
  17. package/c/math/abs.js +14 -18
  18. package/c/math/frexp.js +19 -20
  19. package/c/math/index.js +2 -5
  20. package/c/stdio/index.js +1 -4
  21. package/c/stdio/sprintf.js +71 -81
  22. package/c/stdlib/atof.js +15 -0
  23. package/c/stdlib/atoi.js +17 -0
  24. package/c/stdlib/index.js +2 -0
  25. package/c/string/index.js +5 -0
  26. package/c/string/strcat.js +12 -0
  27. package/c/string/strchr.js +15 -0
  28. package/c/string/strcmp.js +21 -0
  29. package/c/string/strlen.js +12 -0
  30. package/c/string/strstr.js +15 -0
  31. package/clojure/Math/abs.js +13 -0
  32. package/clojure/Math/ceil.js +15 -0
  33. package/clojure/Math/floor.js +14 -0
  34. package/clojure/Math/index.js +3 -0
  35. package/elixir/Float/ceil.js +16 -0
  36. package/elixir/Float/floor.js +14 -0
  37. package/elixir/Float/index.js +2 -0
  38. package/elixir/Kernel/abs.js +13 -0
  39. package/elixir/Kernel/index.js +1 -0
  40. package/golang/index.js +1 -4
  41. package/golang/strconv/Atoi.js +26 -0
  42. package/golang/strconv/FormatBool.js +12 -0
  43. package/golang/strconv/FormatInt.js +21 -0
  44. package/golang/strconv/Itoa.js +14 -0
  45. package/golang/strconv/ParseBool.js +35 -0
  46. package/golang/strconv/ParseInt.js +27 -0
  47. package/golang/strconv/index.js +6 -0
  48. package/golang/strings/Compare.js +19 -0
  49. package/golang/strings/Contains.js +7 -9
  50. package/golang/strings/ContainsAny.js +18 -0
  51. package/golang/strings/Count.js +20 -22
  52. package/golang/strings/EqualFold.js +13 -0
  53. package/golang/strings/Fields.js +12 -0
  54. package/golang/strings/HasPrefix.js +15 -0
  55. package/golang/strings/HasSuffix.js +20 -0
  56. package/golang/strings/Index.js +11 -0
  57. package/golang/strings/Index2.js +9 -11
  58. package/golang/strings/IndexAny.js +18 -0
  59. package/golang/strings/Join.js +16 -0
  60. package/golang/strings/LastIndex.js +10 -12
  61. package/golang/strings/LastIndexAny.js +18 -0
  62. package/golang/strings/Repeat.js +19 -0
  63. package/golang/strings/Replace.js +44 -0
  64. package/golang/strings/Split.js +24 -0
  65. package/golang/strings/ToLower.js +9 -0
  66. package/golang/strings/ToUpper.js +9 -0
  67. package/golang/strings/Trim.js +19 -0
  68. package/golang/strings/TrimLeft.js +15 -0
  69. package/golang/strings/TrimPrefix.js +14 -0
  70. package/golang/strings/TrimRight.js +15 -0
  71. package/golang/strings/TrimSpace.js +10 -0
  72. package/golang/strings/TrimSuffix.js +14 -0
  73. package/golang/strings/index.js +25 -7
  74. package/index.js +5 -8
  75. package/julia/Base/abs.js +13 -0
  76. package/julia/Base/ceil.js +16 -0
  77. package/julia/Base/floor.js +14 -0
  78. package/julia/Base/index.js +3 -0
  79. package/lua/math/abs.js +13 -0
  80. package/lua/math/ceil.js +16 -0
  81. package/lua/math/floor.js +14 -0
  82. package/lua/math/index.js +3 -0
  83. package/package.json +37 -51
  84. package/perl/POSIX/ceil.js +16 -0
  85. package/perl/POSIX/floor.js +14 -0
  86. package/perl/POSIX/index.js +2 -0
  87. package/perl/core/index.js +1 -0
  88. package/perl/core/length.js +16 -0
  89. package/php/_helpers/_bc.js +524 -515
  90. package/php/_helpers/_phpCastString.js +20 -25
  91. package/php/_helpers/_php_cast_float.js +5 -10
  92. package/php/_helpers/_php_cast_int.js +6 -11
  93. package/php/_helpers/index.js +4 -7
  94. package/php/array/array_change_key_case.js +11 -16
  95. package/php/array/array_chunk.js +20 -23
  96. package/php/array/array_column.js +22 -72
  97. package/php/array/array_combine.js +13 -18
  98. package/php/array/array_count_values.js +35 -39
  99. package/php/array/array_diff.js +11 -14
  100. package/php/array/array_diff_assoc.js +11 -14
  101. package/php/array/array_diff_key.js +11 -14
  102. package/php/array/array_diff_uassoc.js +15 -19
  103. package/php/array/array_diff_ukey.js +14 -17
  104. package/php/array/array_fill.js +11 -13
  105. package/php/array/array_fill_keys.js +5 -8
  106. package/php/array/array_filter.js +12 -13
  107. package/php/array/array_flip.js +13 -15
  108. package/php/array/array_intersect.js +13 -16
  109. package/php/array/array_intersect_assoc.js +13 -16
  110. package/php/array/array_intersect_key.js +15 -18
  111. package/php/array/array_intersect_uassoc.js +17 -20
  112. package/php/array/array_intersect_ukey.js +17 -20
  113. package/php/array/array_key_exists.js +4 -7
  114. package/php/array/array_keys.js +22 -24
  115. package/php/array/array_map.js +24 -29
  116. package/php/array/array_merge.js +22 -25
  117. package/php/array/array_merge_recursive.js +51 -27
  118. package/php/array/array_multisort.js +138 -130
  119. package/php/array/array_pad.js +24 -26
  120. package/php/array/array_pop.js +10 -13
  121. package/php/array/array_product.js +15 -17
  122. package/php/array/array_push.js +16 -19
  123. package/php/array/array_rand.js +11 -14
  124. package/php/array/array_reduce.js +11 -14
  125. package/php/array/array_replace.js +9 -12
  126. package/php/array/array_replace_recursive.js +20 -24
  127. package/php/array/array_reverse.js +12 -15
  128. package/php/array/array_search.js +27 -29
  129. package/php/array/array_shift.js +3 -6
  130. package/php/array/array_slice.js +37 -39
  131. package/php/array/array_splice.js +64 -69
  132. package/php/array/array_sum.js +7 -12
  133. package/php/array/array_udiff.js +14 -17
  134. package/php/array/array_udiff_assoc.js +14 -17
  135. package/php/array/array_udiff_uassoc.js +17 -20
  136. package/php/array/array_uintersect.js +16 -19
  137. package/php/array/array_uintersect_uassoc.js +18 -21
  138. package/php/array/array_unique.js +12 -15
  139. package/php/array/array_unshift.js +4 -7
  140. package/php/array/array_values.js +11 -13
  141. package/php/array/array_walk.js +10 -15
  142. package/php/array/array_walk_recursive.js +15 -20
  143. package/php/array/arsort.js +50 -52
  144. package/php/array/asort.js +50 -51
  145. package/php/array/count.js +15 -14
  146. package/php/array/current.js +30 -32
  147. package/php/array/each.js +32 -35
  148. package/php/array/end.js +27 -30
  149. package/php/array/in_array.js +7 -10
  150. package/php/array/index.js +73 -76
  151. package/php/array/key.js +32 -34
  152. package/php/array/krsort.js +50 -51
  153. package/php/array/ksort.js +50 -51
  154. package/php/array/natcasesort.js +37 -38
  155. package/php/array/natsort.js +35 -36
  156. package/php/array/next.js +34 -36
  157. package/php/array/pos.js +10 -12
  158. package/php/array/prev.js +32 -34
  159. package/php/array/range.js +30 -33
  160. package/php/array/reset.js +24 -27
  161. package/php/array/rsort.js +47 -49
  162. package/php/array/shuffle.js +16 -18
  163. package/php/array/sizeof.js +3 -6
  164. package/php/array/sort.js +43 -45
  165. package/php/array/uasort.js +19 -21
  166. package/php/array/uksort.js +22 -24
  167. package/php/array/usort.js +20 -22
  168. package/php/bc/bcadd.js +16 -19
  169. package/php/bc/bccomp.js +12 -15
  170. package/php/bc/bcdiv.js +17 -20
  171. package/php/bc/bcmul.js +16 -19
  172. package/php/bc/bcround.js +21 -24
  173. package/php/bc/bcscale.js +8 -11
  174. package/php/bc/bcsub.js +16 -19
  175. package/php/bc/index.js +7 -10
  176. package/php/ctype/ctype_alnum.js +14 -16
  177. package/php/ctype/ctype_alpha.js +14 -16
  178. package/php/ctype/ctype_cntrl.js +9 -12
  179. package/php/ctype/ctype_digit.js +14 -16
  180. package/php/ctype/ctype_graph.js +14 -16
  181. package/php/ctype/ctype_lower.js +14 -16
  182. package/php/ctype/ctype_print.js +14 -16
  183. package/php/ctype/ctype_punct.js +14 -16
  184. package/php/ctype/ctype_space.js +9 -12
  185. package/php/ctype/ctype_upper.js +14 -16
  186. package/php/ctype/ctype_xdigit.js +14 -16
  187. package/php/ctype/index.js +11 -14
  188. package/php/datetime/checkdate.js +15 -17
  189. package/php/datetime/date.js +142 -123
  190. package/php/datetime/date_parse.js +18 -21
  191. package/php/datetime/getdate.js +38 -24
  192. package/php/datetime/gettimeofday.js +7 -10
  193. package/php/datetime/gmdate.js +17 -16
  194. package/php/datetime/gmmktime.js +23 -25
  195. package/php/datetime/gmstrftime.js +17 -14
  196. package/php/datetime/idate.js +44 -38
  197. package/php/datetime/index.js +15 -18
  198. package/php/datetime/microtime.js +11 -14
  199. package/php/datetime/mktime.js +14 -17
  200. package/php/datetime/strftime.js +122 -113
  201. package/php/datetime/strptime.js +210 -191
  202. package/php/datetime/strtotime.js +615 -496
  203. package/php/datetime/time.js +11 -13
  204. package/php/exec/escapeshellarg.js +16 -18
  205. package/php/exec/index.js +1 -4
  206. package/php/filesystem/basename.js +22 -24
  207. package/php/filesystem/dirname.js +12 -14
  208. package/php/filesystem/file_exists.js +12 -0
  209. package/php/filesystem/file_get_contents.js +3 -6
  210. package/php/filesystem/index.js +6 -8
  211. package/php/filesystem/pathinfo.js +47 -46
  212. package/php/filesystem/realpath.js +16 -19
  213. package/php/funchand/call_user_func.js +4 -7
  214. package/php/funchand/call_user_func_array.js +19 -22
  215. package/php/funchand/create_function.js +4 -7
  216. package/php/funchand/function_exists.js +4 -8
  217. package/php/funchand/get_defined_functions.js +25 -32
  218. package/php/funchand/index.js +5 -8
  219. package/php/i18n/i18n_loc_get_default.js +7 -10
  220. package/php/i18n/i18n_loc_set_default.js +12 -15
  221. package/php/i18n/index.js +2 -5
  222. package/php/index.js +20 -23
  223. package/php/info/assert_options.js +25 -27
  224. package/php/info/getenv.js +8 -10
  225. package/php/info/index.js +6 -9
  226. package/php/info/ini_get.js +9 -12
  227. package/php/info/ini_set.js +32 -34
  228. package/php/info/set_time_limit.js +8 -11
  229. package/php/info/version_compare.js +43 -44
  230. package/php/json/index.js +3 -6
  231. package/php/json/json_decode.js +42 -28
  232. package/php/json/json_encode.js +89 -66
  233. package/php/json/json_last_error.js +11 -13
  234. package/php/math/abs.js +2 -5
  235. package/php/math/acos.js +2 -5
  236. package/php/math/acosh.js +7 -9
  237. package/php/math/asin.js +2 -5
  238. package/php/math/asinh.js +7 -9
  239. package/php/math/atan.js +7 -9
  240. package/php/math/atan2.js +7 -9
  241. package/php/math/atanh.js +2 -5
  242. package/php/math/base_convert.js +8 -10
  243. package/php/math/bindec.js +12 -14
  244. package/php/math/ceil.js +7 -9
  245. package/php/math/cos.js +7 -9
  246. package/php/math/cosh.js +7 -9
  247. package/php/math/decbin.js +16 -18
  248. package/php/math/dechex.js +3 -6
  249. package/php/math/decoct.js +13 -15
  250. package/php/math/deg2rad.js +8 -10
  251. package/php/math/exp.js +7 -9
  252. package/php/math/expm1.js +9 -11
  253. package/php/math/floor.js +7 -9
  254. package/php/math/fmod.js +27 -29
  255. package/php/math/getrandmax.js +7 -9
  256. package/php/math/hexdec.js +10 -12
  257. package/php/math/hypot.js +8 -11
  258. package/php/math/index.js +46 -49
  259. package/php/math/is_finite.js +9 -14
  260. package/php/math/is_infinite.js +9 -14
  261. package/php/math/is_nan.js +8 -13
  262. package/php/math/lcg_value.js +8 -10
  263. package/php/math/log.js +8 -10
  264. package/php/math/log10.js +12 -14
  265. package/php/math/log1p.js +15 -17
  266. package/php/math/max.js +54 -59
  267. package/php/math/min.js +54 -59
  268. package/php/math/mt_getrandmax.js +7 -9
  269. package/php/math/mt_rand.js +15 -17
  270. package/php/math/octdec.js +8 -10
  271. package/php/math/pi.js +2 -5
  272. package/php/math/pow.js +2 -5
  273. package/php/math/rad2deg.js +8 -10
  274. package/php/math/rand.js +15 -17
  275. package/php/math/round.js +48 -49
  276. package/php/math/sin.js +7 -9
  277. package/php/math/sinh.js +7 -9
  278. package/php/math/sqrt.js +7 -9
  279. package/php/math/tan.js +7 -9
  280. package/php/math/tanh.js +8 -10
  281. package/php/misc/index.js +2 -5
  282. package/php/misc/pack.js +173 -165
  283. package/php/misc/uniqid.js +20 -23
  284. package/php/net-gopher/gopher_parsedir.js +27 -29
  285. package/php/net-gopher/index.js +1 -4
  286. package/php/network/index.js +6 -9
  287. package/php/network/inet_ntop.js +15 -15
  288. package/php/network/inet_pton.js +30 -34
  289. package/php/network/ip2long.js +25 -15
  290. package/php/network/long2ip.js +8 -10
  291. package/php/network/setcookie.js +11 -13
  292. package/php/network/setrawcookie.js +16 -19
  293. package/php/pcre/index.js +4 -7
  294. package/php/pcre/preg_match.js +3 -6
  295. package/php/pcre/preg_quote.js +2 -5
  296. package/php/pcre/preg_replace.js +8 -11
  297. package/php/pcre/sql_regcase.js +17 -20
  298. package/php/strings/addcslashes.js +86 -88
  299. package/php/strings/addslashes.js +15 -16
  300. package/php/strings/bin2hex.js +19 -43
  301. package/php/strings/chop.js +8 -10
  302. package/php/strings/chr.js +12 -14
  303. package/php/strings/chunk_split.js +15 -17
  304. package/php/strings/convert_cyr_string.js +137 -50
  305. package/php/strings/convert_uuencode.js +35 -38
  306. package/php/strings/count_chars.js +29 -27
  307. package/php/strings/crc32.js +276 -21
  308. package/php/strings/echo.js +28 -30
  309. package/php/strings/explode.js +31 -26
  310. package/php/strings/get_html_translation_table.js +123 -122
  311. package/php/strings/hex2bin.js +21 -21
  312. package/php/strings/html_entity_decode.js +31 -33
  313. package/php/strings/htmlentities.js +38 -34
  314. package/php/strings/htmlspecialchars.js +20 -23
  315. package/php/strings/htmlspecialchars_decode.js +19 -21
  316. package/php/strings/implode.js +23 -27
  317. package/php/strings/index.js +91 -94
  318. package/php/strings/join.js +8 -10
  319. package/php/strings/lcfirst.js +9 -11
  320. package/php/strings/levenshtein.js +37 -39
  321. package/php/strings/localeconv.js +12 -15
  322. package/php/strings/ltrim.js +12 -14
  323. package/php/strings/md5.js +216 -223
  324. package/php/strings/md5_file.js +17 -19
  325. package/php/strings/metaphone.js +112 -117
  326. package/php/strings/money_format.js +139 -126
  327. package/php/strings/nl2br.js +24 -26
  328. package/php/strings/nl_langinfo.js +32 -35
  329. package/php/strings/number_format.js +19 -22
  330. package/php/strings/ord.js +19 -21
  331. package/php/strings/parse_str.js +53 -56
  332. package/php/strings/printf.js +6 -9
  333. package/php/strings/quoted_printable_decode.js +7 -10
  334. package/php/strings/quoted_printable_encode.js +19 -20
  335. package/php/strings/quotemeta.js +7 -9
  336. package/php/strings/rtrim.js +14 -16
  337. package/php/strings/setlocale.js +148 -104
  338. package/php/strings/sha1.js +108 -106
  339. package/php/strings/sha1_file.js +15 -17
  340. package/php/strings/similar_text.js +34 -33
  341. package/php/strings/soundex.js +34 -36
  342. package/php/strings/split.js +8 -10
  343. package/php/strings/sprintf.js +112 -114
  344. package/php/strings/sscanf.js +99 -96
  345. package/php/strings/str_getcsv.js +37 -32
  346. package/php/strings/str_ireplace.js +50 -55
  347. package/php/strings/str_pad.js +18 -21
  348. package/php/strings/str_repeat.js +14 -16
  349. package/php/strings/str_replace.js +32 -37
  350. package/php/strings/str_rot13.js +15 -17
  351. package/php/strings/str_shuffle.js +12 -15
  352. package/php/strings/str_split.js +19 -21
  353. package/php/strings/str_word_count.js +51 -50
  354. package/php/strings/strcasecmp.js +12 -14
  355. package/php/strings/strchr.js +10 -12
  356. package/php/strings/strcmp.js +12 -14
  357. package/php/strings/strcoll.js +9 -12
  358. package/php/strings/strcspn.js +30 -25
  359. package/php/strings/strip_tags.js +50 -52
  360. package/php/strings/stripos.js +12 -14
  361. package/php/strings/stripslashes.js +8 -10
  362. package/php/strings/stristr.js +15 -17
  363. package/php/strings/strlen.js +23 -26
  364. package/php/strings/strnatcasecmp.js +6 -8
  365. package/php/strings/strnatcmp.js +47 -46
  366. package/php/strings/strncasecmp.js +30 -32
  367. package/php/strings/strncmp.js +5 -7
  368. package/php/strings/strpbrk.js +12 -14
  369. package/php/strings/strpos.js +11 -13
  370. package/php/strings/strrchr.js +7 -10
  371. package/php/strings/strrev.js +188 -10
  372. package/php/strings/strripos.js +16 -18
  373. package/php/strings/strrpos.js +20 -22
  374. package/php/strings/strspn.js +24 -26
  375. package/php/strings/strstr.js +20 -22
  376. package/php/strings/strtok.js +14 -16
  377. package/php/strings/strtolower.js +8 -10
  378. package/php/strings/strtoupper.js +8 -10
  379. package/php/strings/strtr.js +38 -43
  380. package/php/strings/substr.js +14 -18
  381. package/php/strings/substr_compare.js +18 -20
  382. package/php/strings/substr_count.js +11 -14
  383. package/php/strings/substr_replace.js +5 -8
  384. package/php/strings/trim.js +53 -32
  385. package/php/strings/ucfirst.js +11 -13
  386. package/php/strings/ucwords.js +3 -6
  387. package/php/strings/vprintf.js +6 -9
  388. package/php/strings/vsprintf.js +8 -10
  389. package/php/strings/wordwrap.js +32 -35
  390. package/php/url/base64_decode.js +42 -40
  391. package/php/url/base64_encode.js +51 -53
  392. package/php/url/http_build_query.js +27 -32
  393. package/php/url/index.js +8 -11
  394. package/php/url/parse_url.js +61 -25
  395. package/php/url/rawurldecode.js +8 -8
  396. package/php/url/rawurlencode.js +9 -6
  397. package/php/url/urldecode.js +9 -8
  398. package/php/url/urlencode.js +11 -6
  399. package/php/var/boolval.js +31 -33
  400. package/php/var/doubleval.js +10 -12
  401. package/php/var/empty.js +11 -16
  402. package/php/var/floatval.js +13 -15
  403. package/php/var/gettype.js +22 -23
  404. package/php/var/index.js +30 -33
  405. package/php/var/intval.js +35 -39
  406. package/php/var/is_array.js +27 -31
  407. package/php/var/is_binary.js +2 -5
  408. package/php/var/is_bool.js +10 -12
  409. package/php/var/is_buffer.js +2 -5
  410. package/php/var/is_callable.js +34 -35
  411. package/php/var/is_double.js +10 -12
  412. package/php/var/is_float.js +12 -14
  413. package/php/var/is_int.js +20 -22
  414. package/php/var/is_integer.js +12 -14
  415. package/php/var/is_long.js +3 -6
  416. package/php/var/is_null.js +9 -11
  417. package/php/var/is_numeric.js +30 -6
  418. package/php/var/is_object.js +4 -9
  419. package/php/var/is_real.js +3 -6
  420. package/php/var/is_scalar.js +2 -8
  421. package/php/var/is_string.js +9 -11
  422. package/php/var/is_unicode.js +12 -15
  423. package/php/var/isset.js +9 -12
  424. package/php/var/print_r.js +49 -53
  425. package/php/var/serialize.js +47 -52
  426. package/php/var/serialize.vitest.ts +10 -0
  427. package/php/var/strval.js +10 -13
  428. package/php/var/unserialize.js +168 -202
  429. package/php/var/var_dump.js +105 -104
  430. package/php/var/var_export.js +64 -66
  431. package/php/xdiff/index.js +2 -5
  432. package/php/xdiff/xdiff_string_diff.js +240 -226
  433. package/php/xdiff/xdiff_string_patch.js +98 -93
  434. package/php/xml/index.js +2 -5
  435. package/php/xml/utf8_decode.js +40 -42
  436. package/php/xml/utf8_encode.js +40 -42
  437. package/python/index.js +1 -4
  438. package/python/math/ceil.js +17 -0
  439. package/python/math/exp.js +12 -0
  440. package/python/math/fabs.js +14 -0
  441. package/python/math/factorial.js +29 -0
  442. package/python/math/floor.js +14 -0
  443. package/python/math/gcd.js +23 -0
  444. package/python/math/index.js +15 -0
  445. package/python/math/isfinite.js +14 -0
  446. package/python/math/isinf.js +14 -0
  447. package/python/math/isnan.js +14 -0
  448. package/python/math/log.js +16 -0
  449. package/python/math/log10.js +14 -0
  450. package/python/math/log2.js +14 -0
  451. package/python/math/pow.js +14 -0
  452. package/python/math/sqrt.js +14 -0
  453. package/python/math/trunc.js +14 -0
  454. package/python/string/ascii_letters.js +14 -14
  455. package/python/string/ascii_lowercase.js +12 -16
  456. package/python/string/ascii_uppercase.js +12 -16
  457. package/python/string/capwords.js +4 -7
  458. package/python/string/digits.js +10 -0
  459. package/python/string/hexdigits.js +10 -0
  460. package/python/string/index.js +10 -8
  461. package/python/string/octdigits.js +10 -0
  462. package/python/string/printable.js +15 -0
  463. package/python/string/punctuation.js +5 -7
  464. package/python/string/whitespace.js +10 -0
  465. package/r/base/abs.js +13 -0
  466. package/r/base/ceiling.js +16 -0
  467. package/r/base/floor.js +14 -0
  468. package/r/base/index.js +3 -0
  469. package/ruby/Array/compact.js +18 -0
  470. package/ruby/Array/first.js +22 -0
  471. package/ruby/Array/flatten.js +22 -0
  472. package/ruby/Array/index.js +6 -0
  473. package/ruby/Array/last.js +22 -0
  474. package/ruby/Array/sample.js +31 -0
  475. package/ruby/Array/uniq.js +16 -0
  476. package/ruby/Math/acos.js +2 -5
  477. package/ruby/Math/asin.js +11 -0
  478. package/ruby/Math/atan.js +11 -0
  479. package/ruby/Math/cbrt.js +13 -0
  480. package/ruby/Math/cos.js +12 -0
  481. package/ruby/Math/cosh.js +11 -0
  482. package/ruby/Math/exp.js +11 -0
  483. package/ruby/Math/index.js +15 -4
  484. package/ruby/Math/log.js +11 -0
  485. package/ruby/Math/log10.js +13 -0
  486. package/ruby/Math/log2.js +13 -0
  487. package/ruby/Math/sin.js +12 -0
  488. package/ruby/Math/sinh.js +11 -0
  489. package/ruby/Math/sqrt.js +13 -0
  490. package/ruby/Math/tan.js +11 -0
  491. package/ruby/Math/tanh.js +11 -0
  492. package/ruby/String/capitalize.js +19 -0
  493. package/ruby/String/chomp.js +27 -0
  494. package/ruby/String/chop.js +25 -0
  495. package/ruby/String/downcase.js +10 -0
  496. package/ruby/String/end_with.js +17 -0
  497. package/ruby/String/include.js +12 -0
  498. package/ruby/String/index.js +11 -0
  499. package/ruby/String/length.js +12 -0
  500. package/ruby/String/reverse.js +12 -0
  501. package/ruby/String/start_with.js +14 -0
  502. package/ruby/String/strip.js +12 -0
  503. package/ruby/String/upcase.js +10 -0
  504. package/ruby/index.js +1 -4
  505. package/_util/cli.js +0 -14
  506. package/_util/cli.js.map +0 -1
  507. package/_util/util.js +0 -620
  508. package/_util/util.js.map +0 -1
  509. package/c/index.js.map +0 -1
  510. package/c/math/abs.js.map +0 -1
  511. package/c/math/frexp.js.map +0 -1
  512. package/c/math/index.js.map +0 -1
  513. package/c/stdio/index.js.map +0 -1
  514. package/c/stdio/sprintf.js.map +0 -1
  515. package/golang/index.js.map +0 -1
  516. package/golang/strings/Contains.js.map +0 -1
  517. package/golang/strings/Count.js.map +0 -1
  518. package/golang/strings/Index2.js.map +0 -1
  519. package/golang/strings/LastIndex.js.map +0 -1
  520. package/golang/strings/index.js.map +0 -1
  521. package/index.js.map +0 -1
  522. package/php/_helpers/_bc.js.map +0 -1
  523. package/php/_helpers/_phpCastString.js.map +0 -1
  524. package/php/_helpers/_php_cast_float.js.map +0 -1
  525. package/php/_helpers/_php_cast_int.js.map +0 -1
  526. package/php/_helpers/index.js.map +0 -1
  527. package/php/array/array_change_key_case.js.map +0 -1
  528. package/php/array/array_chunk.js.map +0 -1
  529. package/php/array/array_column.js.map +0 -1
  530. package/php/array/array_combine.js.map +0 -1
  531. package/php/array/array_count_values.js.map +0 -1
  532. package/php/array/array_diff.js.map +0 -1
  533. package/php/array/array_diff_assoc.js.map +0 -1
  534. package/php/array/array_diff_key.js.map +0 -1
  535. package/php/array/array_diff_uassoc.js.map +0 -1
  536. package/php/array/array_diff_ukey.js.map +0 -1
  537. package/php/array/array_fill.js.map +0 -1
  538. package/php/array/array_fill_keys.js.map +0 -1
  539. package/php/array/array_filter.js.map +0 -1
  540. package/php/array/array_flip.js.map +0 -1
  541. package/php/array/array_intersect.js.map +0 -1
  542. package/php/array/array_intersect_assoc.js.map +0 -1
  543. package/php/array/array_intersect_key.js.map +0 -1
  544. package/php/array/array_intersect_uassoc.js.map +0 -1
  545. package/php/array/array_intersect_ukey.js.map +0 -1
  546. package/php/array/array_key_exists.js.map +0 -1
  547. package/php/array/array_keys.js.map +0 -1
  548. package/php/array/array_map.js.map +0 -1
  549. package/php/array/array_merge.js.map +0 -1
  550. package/php/array/array_merge_recursive.js.map +0 -1
  551. package/php/array/array_multisort.js.map +0 -1
  552. package/php/array/array_pad.js.map +0 -1
  553. package/php/array/array_pop.js.map +0 -1
  554. package/php/array/array_product.js.map +0 -1
  555. package/php/array/array_push.js.map +0 -1
  556. package/php/array/array_rand.js.map +0 -1
  557. package/php/array/array_reduce.js.map +0 -1
  558. package/php/array/array_replace.js.map +0 -1
  559. package/php/array/array_replace_recursive.js.map +0 -1
  560. package/php/array/array_reverse.js.map +0 -1
  561. package/php/array/array_search.js.map +0 -1
  562. package/php/array/array_shift.js.map +0 -1
  563. package/php/array/array_slice.js.map +0 -1
  564. package/php/array/array_splice.js.map +0 -1
  565. package/php/array/array_sum.js.map +0 -1
  566. package/php/array/array_udiff.js.map +0 -1
  567. package/php/array/array_udiff_assoc.js.map +0 -1
  568. package/php/array/array_udiff_uassoc.js.map +0 -1
  569. package/php/array/array_uintersect.js.map +0 -1
  570. package/php/array/array_uintersect_uassoc.js.map +0 -1
  571. package/php/array/array_unique.js.map +0 -1
  572. package/php/array/array_unshift.js.map +0 -1
  573. package/php/array/array_values.js.map +0 -1
  574. package/php/array/array_walk.js.map +0 -1
  575. package/php/array/array_walk_recursive.js.map +0 -1
  576. package/php/array/arsort.js.map +0 -1
  577. package/php/array/asort.js.map +0 -1
  578. package/php/array/count.js.map +0 -1
  579. package/php/array/current.js.map +0 -1
  580. package/php/array/each.js.map +0 -1
  581. package/php/array/end.js.map +0 -1
  582. package/php/array/in_array.js.map +0 -1
  583. package/php/array/index.js.map +0 -1
  584. package/php/array/key.js.map +0 -1
  585. package/php/array/krsort.js.map +0 -1
  586. package/php/array/ksort.js.map +0 -1
  587. package/php/array/natcasesort.js.map +0 -1
  588. package/php/array/natsort.js.map +0 -1
  589. package/php/array/next.js.map +0 -1
  590. package/php/array/pos.js.map +0 -1
  591. package/php/array/prev.js.map +0 -1
  592. package/php/array/range.js.map +0 -1
  593. package/php/array/reset.js.map +0 -1
  594. package/php/array/rsort.js.map +0 -1
  595. package/php/array/shuffle.js.map +0 -1
  596. package/php/array/sizeof.js.map +0 -1
  597. package/php/array/sort.js.map +0 -1
  598. package/php/array/uasort.js.map +0 -1
  599. package/php/array/uksort.js.map +0 -1
  600. package/php/array/usort.js.map +0 -1
  601. package/php/bc/bcadd.js.map +0 -1
  602. package/php/bc/bccomp.js.map +0 -1
  603. package/php/bc/bcdiv.js.map +0 -1
  604. package/php/bc/bcmul.js.map +0 -1
  605. package/php/bc/bcround.js.map +0 -1
  606. package/php/bc/bcscale.js.map +0 -1
  607. package/php/bc/bcsub.js.map +0 -1
  608. package/php/bc/index.js.map +0 -1
  609. package/php/ctype/ctype_alnum.js.map +0 -1
  610. package/php/ctype/ctype_alpha.js.map +0 -1
  611. package/php/ctype/ctype_cntrl.js.map +0 -1
  612. package/php/ctype/ctype_digit.js.map +0 -1
  613. package/php/ctype/ctype_graph.js.map +0 -1
  614. package/php/ctype/ctype_lower.js.map +0 -1
  615. package/php/ctype/ctype_print.js.map +0 -1
  616. package/php/ctype/ctype_punct.js.map +0 -1
  617. package/php/ctype/ctype_space.js.map +0 -1
  618. package/php/ctype/ctype_upper.js.map +0 -1
  619. package/php/ctype/ctype_xdigit.js.map +0 -1
  620. package/php/ctype/index.js.map +0 -1
  621. package/php/datetime/checkdate.js.map +0 -1
  622. package/php/datetime/date.js.map +0 -1
  623. package/php/datetime/date_parse.js.map +0 -1
  624. package/php/datetime/getdate.js.map +0 -1
  625. package/php/datetime/gettimeofday.js.map +0 -1
  626. package/php/datetime/gmdate.js.map +0 -1
  627. package/php/datetime/gmmktime.js.map +0 -1
  628. package/php/datetime/gmstrftime.js.map +0 -1
  629. package/php/datetime/idate.js.map +0 -1
  630. package/php/datetime/index.js.map +0 -1
  631. package/php/datetime/microtime.js.map +0 -1
  632. package/php/datetime/mktime.js.map +0 -1
  633. package/php/datetime/strftime.js.map +0 -1
  634. package/php/datetime/strptime.js.map +0 -1
  635. package/php/datetime/strtotime.js.map +0 -1
  636. package/php/datetime/time.js.map +0 -1
  637. package/php/exec/escapeshellarg.js.map +0 -1
  638. package/php/exec/index.js.map +0 -1
  639. package/php/filesystem/basename.js.map +0 -1
  640. package/php/filesystem/dirname.js.map +0 -1
  641. package/php/filesystem/file_get_contents.js.map +0 -1
  642. package/php/filesystem/index.js.map +0 -1
  643. package/php/filesystem/pathinfo.js.map +0 -1
  644. package/php/filesystem/realpath.js.map +0 -1
  645. package/php/funchand/call_user_func.js.map +0 -1
  646. package/php/funchand/call_user_func_array.js.map +0 -1
  647. package/php/funchand/create_function.js.map +0 -1
  648. package/php/funchand/function_exists.js.map +0 -1
  649. package/php/funchand/get_defined_functions.js.map +0 -1
  650. package/php/funchand/index.js.map +0 -1
  651. package/php/i18n/i18n_loc_get_default.js.map +0 -1
  652. package/php/i18n/i18n_loc_set_default.js.map +0 -1
  653. package/php/i18n/index.js.map +0 -1
  654. package/php/index.js.map +0 -1
  655. package/php/info/assert_options.js.map +0 -1
  656. package/php/info/getenv.js.map +0 -1
  657. package/php/info/index.js.map +0 -1
  658. package/php/info/ini_get.js.map +0 -1
  659. package/php/info/ini_set.js.map +0 -1
  660. package/php/info/set_time_limit.js.map +0 -1
  661. package/php/info/version_compare.js.map +0 -1
  662. package/php/json/index.js.map +0 -1
  663. package/php/json/json_decode.js.map +0 -1
  664. package/php/json/json_encode.js.map +0 -1
  665. package/php/json/json_last_error.js.map +0 -1
  666. package/php/math/abs.js.map +0 -1
  667. package/php/math/acos.js.map +0 -1
  668. package/php/math/acosh.js.map +0 -1
  669. package/php/math/asin.js.map +0 -1
  670. package/php/math/asinh.js.map +0 -1
  671. package/php/math/atan.js.map +0 -1
  672. package/php/math/atan2.js.map +0 -1
  673. package/php/math/atanh.js.map +0 -1
  674. package/php/math/base_convert.js.map +0 -1
  675. package/php/math/bindec.js.map +0 -1
  676. package/php/math/ceil.js.map +0 -1
  677. package/php/math/cos.js.map +0 -1
  678. package/php/math/cosh.js.map +0 -1
  679. package/php/math/decbin.js.map +0 -1
  680. package/php/math/dechex.js.map +0 -1
  681. package/php/math/decoct.js.map +0 -1
  682. package/php/math/deg2rad.js.map +0 -1
  683. package/php/math/exp.js.map +0 -1
  684. package/php/math/expm1.js.map +0 -1
  685. package/php/math/floor.js.map +0 -1
  686. package/php/math/fmod.js.map +0 -1
  687. package/php/math/getrandmax.js.map +0 -1
  688. package/php/math/hexdec.js.map +0 -1
  689. package/php/math/hypot.js.map +0 -1
  690. package/php/math/index.js.map +0 -1
  691. package/php/math/is_finite.js.map +0 -1
  692. package/php/math/is_infinite.js.map +0 -1
  693. package/php/math/is_nan.js.map +0 -1
  694. package/php/math/lcg_value.js.map +0 -1
  695. package/php/math/log.js.map +0 -1
  696. package/php/math/log10.js.map +0 -1
  697. package/php/math/log1p.js.map +0 -1
  698. package/php/math/max.js.map +0 -1
  699. package/php/math/min.js.map +0 -1
  700. package/php/math/mt_getrandmax.js.map +0 -1
  701. package/php/math/mt_rand.js.map +0 -1
  702. package/php/math/octdec.js.map +0 -1
  703. package/php/math/pi.js.map +0 -1
  704. package/php/math/pow.js.map +0 -1
  705. package/php/math/rad2deg.js.map +0 -1
  706. package/php/math/rand.js.map +0 -1
  707. package/php/math/round.js.map +0 -1
  708. package/php/math/sin.js.map +0 -1
  709. package/php/math/sinh.js.map +0 -1
  710. package/php/math/sqrt.js.map +0 -1
  711. package/php/math/tan.js.map +0 -1
  712. package/php/math/tanh.js.map +0 -1
  713. package/php/misc/index.js.map +0 -1
  714. package/php/misc/pack.js.map +0 -1
  715. package/php/misc/uniqid.js.map +0 -1
  716. package/php/net-gopher/gopher_parsedir.js.map +0 -1
  717. package/php/net-gopher/index.js.map +0 -1
  718. package/php/network/index.js.map +0 -1
  719. package/php/network/inet_ntop.js.map +0 -1
  720. package/php/network/inet_pton.js.map +0 -1
  721. package/php/network/ip2long.js.map +0 -1
  722. package/php/network/long2ip.js.map +0 -1
  723. package/php/network/setcookie.js.map +0 -1
  724. package/php/network/setrawcookie.js.map +0 -1
  725. package/php/pcre/index.js.map +0 -1
  726. package/php/pcre/preg_match.js.map +0 -1
  727. package/php/pcre/preg_quote.js.map +0 -1
  728. package/php/pcre/preg_replace.js.map +0 -1
  729. package/php/pcre/sql_regcase.js.map +0 -1
  730. package/php/strings/addcslashes.js.map +0 -1
  731. package/php/strings/addslashes.js.map +0 -1
  732. package/php/strings/bin2hex.js.map +0 -1
  733. package/php/strings/chop.js.map +0 -1
  734. package/php/strings/chr.js.map +0 -1
  735. package/php/strings/chunk_split.js.map +0 -1
  736. package/php/strings/convert_cyr_string.js.map +0 -1
  737. package/php/strings/convert_uuencode.js.map +0 -1
  738. package/php/strings/count_chars.js.map +0 -1
  739. package/php/strings/crc32.js.map +0 -1
  740. package/php/strings/echo.js.map +0 -1
  741. package/php/strings/explode.js.map +0 -1
  742. package/php/strings/get_html_translation_table.js.map +0 -1
  743. package/php/strings/hex2bin.js.map +0 -1
  744. package/php/strings/html_entity_decode.js.map +0 -1
  745. package/php/strings/htmlentities.js.map +0 -1
  746. package/php/strings/htmlspecialchars.js.map +0 -1
  747. package/php/strings/htmlspecialchars_decode.js.map +0 -1
  748. package/php/strings/implode.js.map +0 -1
  749. package/php/strings/index.js.map +0 -1
  750. package/php/strings/join.js.map +0 -1
  751. package/php/strings/lcfirst.js.map +0 -1
  752. package/php/strings/levenshtein.js.map +0 -1
  753. package/php/strings/localeconv.js.map +0 -1
  754. package/php/strings/ltrim.js.map +0 -1
  755. package/php/strings/md5.js.map +0 -1
  756. package/php/strings/md5_file.js.map +0 -1
  757. package/php/strings/metaphone.js.map +0 -1
  758. package/php/strings/money_format.js.map +0 -1
  759. package/php/strings/nl2br.js.map +0 -1
  760. package/php/strings/nl_langinfo.js.map +0 -1
  761. package/php/strings/number_format.js.map +0 -1
  762. package/php/strings/ord.js.map +0 -1
  763. package/php/strings/parse_str.js.map +0 -1
  764. package/php/strings/printf.js.map +0 -1
  765. package/php/strings/quoted_printable_decode.js.map +0 -1
  766. package/php/strings/quoted_printable_encode.js.map +0 -1
  767. package/php/strings/quotemeta.js.map +0 -1
  768. package/php/strings/rtrim.js.map +0 -1
  769. package/php/strings/setlocale.js.map +0 -1
  770. package/php/strings/sha1.js.map +0 -1
  771. package/php/strings/sha1_file.js.map +0 -1
  772. package/php/strings/similar_text.js.map +0 -1
  773. package/php/strings/soundex.js.map +0 -1
  774. package/php/strings/split.js.map +0 -1
  775. package/php/strings/sprintf.js.map +0 -1
  776. package/php/strings/sscanf.js.map +0 -1
  777. package/php/strings/str_getcsv.js.map +0 -1
  778. package/php/strings/str_ireplace.js.map +0 -1
  779. package/php/strings/str_pad.js.map +0 -1
  780. package/php/strings/str_repeat.js.map +0 -1
  781. package/php/strings/str_replace.js.map +0 -1
  782. package/php/strings/str_rot13.js.map +0 -1
  783. package/php/strings/str_shuffle.js.map +0 -1
  784. package/php/strings/str_split.js.map +0 -1
  785. package/php/strings/str_word_count.js.map +0 -1
  786. package/php/strings/strcasecmp.js.map +0 -1
  787. package/php/strings/strchr.js.map +0 -1
  788. package/php/strings/strcmp.js.map +0 -1
  789. package/php/strings/strcoll.js.map +0 -1
  790. package/php/strings/strcspn.js.map +0 -1
  791. package/php/strings/strip_tags.js.map +0 -1
  792. package/php/strings/stripos.js.map +0 -1
  793. package/php/strings/stripslashes.js.map +0 -1
  794. package/php/strings/stristr.js.map +0 -1
  795. package/php/strings/strlen.js.map +0 -1
  796. package/php/strings/strnatcasecmp.js.map +0 -1
  797. package/php/strings/strnatcmp.js.map +0 -1
  798. package/php/strings/strncasecmp.js.map +0 -1
  799. package/php/strings/strncmp.js.map +0 -1
  800. package/php/strings/strpbrk.js.map +0 -1
  801. package/php/strings/strpos.js.map +0 -1
  802. package/php/strings/strrchr.js.map +0 -1
  803. package/php/strings/strrev.js.map +0 -1
  804. package/php/strings/strripos.js.map +0 -1
  805. package/php/strings/strrpos.js.map +0 -1
  806. package/php/strings/strspn.js.map +0 -1
  807. package/php/strings/strstr.js.map +0 -1
  808. package/php/strings/strtok.js.map +0 -1
  809. package/php/strings/strtolower.js.map +0 -1
  810. package/php/strings/strtoupper.js.map +0 -1
  811. package/php/strings/strtr.js.map +0 -1
  812. package/php/strings/substr.js.map +0 -1
  813. package/php/strings/substr_compare.js.map +0 -1
  814. package/php/strings/substr_count.js.map +0 -1
  815. package/php/strings/substr_replace.js.map +0 -1
  816. package/php/strings/trim.js.map +0 -1
  817. package/php/strings/ucfirst.js.map +0 -1
  818. package/php/strings/ucwords.js.map +0 -1
  819. package/php/strings/vprintf.js.map +0 -1
  820. package/php/strings/vsprintf.js.map +0 -1
  821. package/php/strings/wordwrap.js.map +0 -1
  822. package/php/url/base64_decode.js.map +0 -1
  823. package/php/url/base64_encode.js.map +0 -1
  824. package/php/url/http_build_query.js.map +0 -1
  825. package/php/url/index.js.map +0 -1
  826. package/php/url/parse_url.js.map +0 -1
  827. package/php/url/rawurldecode.js.map +0 -1
  828. package/php/url/rawurlencode.js.map +0 -1
  829. package/php/url/urldecode.js.map +0 -1
  830. package/php/url/urlencode.js.map +0 -1
  831. package/php/var/boolval.js.map +0 -1
  832. package/php/var/doubleval.js.map +0 -1
  833. package/php/var/empty.js.map +0 -1
  834. package/php/var/floatval.js.map +0 -1
  835. package/php/var/gettype.js.map +0 -1
  836. package/php/var/index.js.map +0 -1
  837. package/php/var/intval.js.map +0 -1
  838. package/php/var/is_array.js.map +0 -1
  839. package/php/var/is_binary.js.map +0 -1
  840. package/php/var/is_bool.js.map +0 -1
  841. package/php/var/is_buffer.js.map +0 -1
  842. package/php/var/is_callable.js.map +0 -1
  843. package/php/var/is_double.js.map +0 -1
  844. package/php/var/is_float.js.map +0 -1
  845. package/php/var/is_int.js.map +0 -1
  846. package/php/var/is_integer.js.map +0 -1
  847. package/php/var/is_long.js.map +0 -1
  848. package/php/var/is_null.js.map +0 -1
  849. package/php/var/is_numeric.js.map +0 -1
  850. package/php/var/is_object.js.map +0 -1
  851. package/php/var/is_real.js.map +0 -1
  852. package/php/var/is_scalar.js.map +0 -1
  853. package/php/var/is_string.js.map +0 -1
  854. package/php/var/is_unicode.js.map +0 -1
  855. package/php/var/isset.js.map +0 -1
  856. package/php/var/print_r.js.map +0 -1
  857. package/php/var/serialize.js.map +0 -1
  858. package/php/var/serialize.mocha.js +0 -14
  859. package/php/var/serialize.mocha.js.map +0 -1
  860. package/php/var/strval.js.map +0 -1
  861. package/php/var/unserialize.js.map +0 -1
  862. package/php/var/var_dump.js.map +0 -1
  863. package/php/var/var_export.js.map +0 -1
  864. package/php/xdiff/index.js.map +0 -1
  865. package/php/xdiff/xdiff_string_diff.js.map +0 -1
  866. package/php/xdiff/xdiff_string_patch.js.map +0 -1
  867. package/php/xml/index.js.map +0 -1
  868. package/php/xml/utf8_decode.js.map +0 -1
  869. package/php/xml/utf8_encode.js.map +0 -1
  870. package/python/index.js.map +0 -1
  871. package/python/string/ascii_letters.js.map +0 -1
  872. package/python/string/ascii_lowercase.js.map +0 -1
  873. package/python/string/ascii_uppercase.js.map +0 -1
  874. package/python/string/capwords.js.map +0 -1
  875. package/python/string/index.js.map +0 -1
  876. package/python/string/punctuation.js.map +0 -1
  877. package/ruby/Math/acos.js.map +0 -1
  878. package/ruby/Math/index.js.map +0 -1
  879. package/ruby/index.js.map +0 -1
@@ -1,4 +1,6 @@
1
- 'use strict';
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // NOTE: This file is LGPL licensed, not MIT like the rest of locutus.
3
+ // See LICENSE file for details.
2
4
 
3
5
  module.exports = function _bc() {
4
6
  // discuss at: https://locutus.io/php/_helpers/_bc
@@ -9,7 +11,7 @@ module.exports = function _bc() {
9
11
  // returns 1: '+'
10
12
 
11
13
  /**
12
- * BC Math Library for Javascript
14
+ * BC Math Library for Javascript (LGPL-2.1)
13
15
  * Ported from the PHP5 bcmath extension source code,
14
16
  * which uses the Libbcmath package...
15
17
  * Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
@@ -23,10 +25,9 @@ module.exports = function _bc() {
23
25
  * Western Washington University
24
26
  * Bellingham, WA 98226-9062
25
27
  *
26
- * bcmath-js homepage:
28
+ * bcmath-js homepage: https://sourceforge.net/projects/bcmath-js/
27
29
  *
28
- * This code is covered under the LGPL licence, and can be used however you want :)
29
- * Be kind and share any decent code changes.
30
+ * This code is covered under the LGPL-2.1 license.
30
31
  */
31
32
 
32
33
  /**
@@ -54,7 +55,7 @@ module.exports = function _bc() {
54
55
  * Bellingham, WA 98226-9062
55
56
  */
56
57
 
57
- var Libbcmath = {
58
+ const Libbcmath = {
58
59
  PLUS: '+',
59
60
  MINUS: '-',
60
61
  BASE: 10,
@@ -64,27 +65,27 @@ module.exports = function _bc() {
64
65
  /**
65
66
  * Basic number structure
66
67
  */
67
- bc_num: function bc_num() {
68
- this.n_sign = null; // sign
69
- this.n_len = null; // (int) The number of digits before the decimal point.
70
- this.n_scale = null; // (int) The number of digits after the decimal point.
68
+ bc_num: function () {
69
+ this.n_sign = null // sign
70
+ this.n_len = null // (int) The number of digits before the decimal point.
71
+ this.n_scale = null // (int) The number of digits after the decimal point.
71
72
  // this.n_refs = null; // (int) The number of pointers to this number.
72
73
  // this.n_text = null; // ?? Linked list for available list.
73
- this.n_value = null; // array as value, where 1.23 = [1,2,3]
74
+ this.n_value = null // array as value, where 1.23 = [1,2,3]
74
75
  this.toString = function () {
75
- var r = void 0,
76
- tmp = void 0;
77
- tmp = this.n_value.join('');
76
+ let r
77
+ let tmp
78
+ tmp = this.n_value.join('')
78
79
 
79
80
  // add minus sign (if applicable) then add the integer part
80
- r = (this.n_sign === Libbcmath.PLUS ? '' : this.n_sign) + tmp.substr(0, this.n_len);
81
+ r = (this.n_sign === Libbcmath.PLUS ? '' : this.n_sign) + tmp.substr(0, this.n_len)
81
82
 
82
83
  // if decimal places, add a . and the decimal part
83
84
  if (this.n_scale > 0) {
84
- r += '.' + tmp.substr(this.n_len, this.n_scale);
85
+ r += '.' + tmp.substr(this.n_len, this.n_scale)
85
86
  }
86
- return r;
87
- };
87
+ return r
88
+ }
88
89
  },
89
90
 
90
91
  /**
@@ -99,38 +100,38 @@ module.exports = function _bc() {
99
100
  * @param {int} scaleMin
100
101
  * @return bc_num
101
102
  */
102
- bc_add: function bc_add(n1, n2, scaleMin) {
103
- var sum = void 0,
104
- cmpRes = void 0,
105
- resScale = void 0;
103
+ bc_add: function (n1, n2, scaleMin) {
104
+ let sum
105
+ let cmpRes
106
+ let resScale
106
107
 
107
108
  if (n1.n_sign === n2.n_sign) {
108
- sum = Libbcmath._bc_do_add(n1, n2, scaleMin);
109
- sum.n_sign = n1.n_sign;
109
+ sum = Libbcmath._bc_do_add(n1, n2, scaleMin)
110
+ sum.n_sign = n1.n_sign
110
111
  } else {
111
112
  // subtraction must be done.
112
- cmpRes = Libbcmath._bc_do_compare(n1, n2, false, false); // Compare magnitudes.
113
+ cmpRes = Libbcmath._bc_do_compare(n1, n2, false, false) // Compare magnitudes.
113
114
  switch (cmpRes) {
114
115
  case -1:
115
116
  // n1 is less than n2, subtract n1 from n2.
116
- sum = Libbcmath._bc_do_sub(n2, n1, scaleMin);
117
- sum.n_sign = n2.n_sign;
118
- break;
117
+ sum = Libbcmath._bc_do_sub(n2, n1, scaleMin)
118
+ sum.n_sign = n2.n_sign
119
+ break
119
120
 
120
121
  case 0:
121
122
  // They are equal! return zero with the correct scale!
122
- resScale = Libbcmath.MAX(scaleMin, Libbcmath.MAX(n1.n_scale, n2.n_scale));
123
- sum = Libbcmath.bc_new_num(1, resScale);
124
- Libbcmath.memset(sum.n_value, 0, 0, resScale + 1);
125
- break;
123
+ resScale = Libbcmath.MAX(scaleMin, Libbcmath.MAX(n1.n_scale, n2.n_scale))
124
+ sum = Libbcmath.bc_new_num(1, resScale)
125
+ Libbcmath.memset(sum.n_value, 0, 0, resScale + 1)
126
+ break
126
127
 
127
128
  case 1:
128
129
  // n2 is less than n1, subtract n2 from n1.
129
- sum = Libbcmath._bc_do_sub(n1, n2, scaleMin);
130
- sum.n_sign = n1.n_sign;
130
+ sum = Libbcmath._bc_do_sub(n1, n2, scaleMin)
131
+ sum.n_sign = n1.n_sign
131
132
  }
132
133
  }
133
- return sum;
134
+ return sum
134
135
  },
135
136
 
136
137
  /**
@@ -139,72 +140,72 @@ module.exports = function _bc() {
139
140
  * @param {bc_num} n2
140
141
  * @return int -1, 0, 1 (n1 < n2, ===, n1 > n2)
141
142
  */
142
- bc_compare: function bc_compare(n1, n2) {
143
- return Libbcmath._bc_do_compare(n1, n2, true, false);
143
+ bc_compare: function (n1, n2) {
144
+ return Libbcmath._bc_do_compare(n1, n2, true, false)
144
145
  },
145
146
 
146
- _one_mult: function _one_mult(num, nPtr, size, digit, result, rPtr) {
147
- var carry = void 0,
148
- value = void 0; // int
149
- var nptr = void 0,
150
- rptr = void 0; // int pointers
147
+ _one_mult: function (num, nPtr, size, digit, result, rPtr) {
148
+ let carry
149
+ let value // int
150
+ let nptr
151
+ let rptr // int pointers
151
152
  if (digit === 0) {
152
- Libbcmath.memset(result, 0, 0, size); // memset (result, 0, size);
153
+ Libbcmath.memset(result, 0, 0, size) // memset (result, 0, size);
153
154
  } else {
154
155
  if (digit === 1) {
155
- Libbcmath.memcpy(result, rPtr, num, nPtr, size); // memcpy (result, num, size);
156
+ Libbcmath.memcpy(result, rPtr, num, nPtr, size) // memcpy (result, num, size);
156
157
  } else {
157
158
  // Initialize
158
- nptr = nPtr + size - 1; // nptr = (unsigned char *) (num+size-1);
159
- rptr = rPtr + size - 1; // rptr = (unsigned char *) (result+size-1);
160
- carry = 0;
159
+ nptr = nPtr + size - 1 // nptr = (unsigned char *) (num+size-1);
160
+ rptr = rPtr + size - 1 // rptr = (unsigned char *) (result+size-1);
161
+ carry = 0
161
162
 
162
163
  while (size-- > 0) {
163
- value = num[nptr--] * digit + carry; // value = *nptr-- * digit + carry;
164
- result[rptr--] = value % Libbcmath.BASE; // @CHECK cint //*rptr-- = value % BASE;
165
- carry = Math.floor(value / Libbcmath.BASE); // @CHECK cint //carry = value / BASE;
164
+ value = num[nptr--] * digit + carry // value = *nptr-- * digit + carry;
165
+ result[rptr--] = value % Libbcmath.BASE // @CHECK cint //*rptr-- = value % BASE;
166
+ carry = Math.floor(value / Libbcmath.BASE) // @CHECK cint //carry = value / BASE;
166
167
  }
167
168
 
168
169
  if (carry !== 0) {
169
- result[rptr] = carry;
170
+ result[rptr] = carry
170
171
  }
171
172
  }
172
173
  }
173
174
  },
174
175
 
175
- bc_divide: function bc_divide(n1, n2, scale) {
176
+ bc_divide: function (n1, n2, scale) {
176
177
  // var quot // bc_num return
177
- var qval = void 0; // bc_num
178
- var num1 = void 0,
179
- num2 = void 0; // string
180
- var ptr1 = void 0,
181
- ptr2 = void 0,
182
- n2ptr = void 0,
183
- qptr = void 0; // int pointers
184
- var scale1 = void 0,
185
- val = void 0; // int
186
- var len1 = void 0,
187
- len2 = void 0,
188
- scale2 = void 0,
189
- qdigits = void 0,
190
- extra = void 0,
191
- count = void 0; // int
192
- var qdig = void 0,
193
- qguess = void 0,
194
- borrow = void 0,
195
- carry = void 0; // int
196
- var mval = void 0; // string
197
- var zero = void 0; // char
198
- var norm = void 0; // int
178
+ let qval // bc_num
179
+ let num1
180
+ let num2 // string
181
+ let ptr1
182
+ let ptr2
183
+ let n2ptr
184
+ let qptr // int pointers
185
+ let scale1
186
+ let val // int
187
+ let len1
188
+ let len2
189
+ let scale2
190
+ let qdigits
191
+ let extra
192
+ let count // int
193
+ let qdig
194
+ let qguess
195
+ let borrow
196
+ let carry // int
197
+ let mval // string
198
+ let zero // char
199
+ let norm // int
199
200
  // var ptrs // return object from one_mul
200
201
  // Test for divide by zero. (return failure)
201
202
  if (Libbcmath.bc_is_zero(n2)) {
202
- return -1;
203
+ return -1
203
204
  }
204
205
 
205
206
  // Test for zero divide by anything (return zero)
206
207
  if (Libbcmath.bc_is_zero(n1)) {
207
- return Libbcmath.bc_new_num(1, scale);
208
+ return Libbcmath.bc_new_num(1, scale)
208
209
  }
209
210
 
210
211
  /* Test for n1 equals n2 (return 1 as n1 nor n2 are zero)
@@ -220,12 +221,12 @@ module.exports = function _bc() {
220
221
  // (ie bc_is_zero - add bc_is_one function)
221
222
  if (n2.n_scale === 0) {
222
223
  if (n2.n_len === 1 && n2.n_value[0] === 1) {
223
- qval = Libbcmath.bc_new_num(n1.n_len, scale); // qval = bc_new_num (n1->n_len, scale);
224
- qval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS;
224
+ qval = Libbcmath.bc_new_num(n1.n_len, scale) // qval = bc_new_num (n1->n_len, scale);
225
+ qval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS
225
226
  // memset (&qval->n_value[n1->n_len],0,scale):
226
- Libbcmath.memset(qval.n_value, n1.n_len, 0, scale);
227
+ Libbcmath.memset(qval.n_value, n1.n_len, 0, scale)
227
228
  // memcpy (qval->n_value, n1->n_value, n1->n_len + MIN(n1->n_scale,scale)):
228
- Libbcmath.memcpy(qval.n_value, 0, n1.n_value, 0, n1.n_len + Libbcmath.MIN(n1.n_scale, scale));
229
+ Libbcmath.memcpy(qval.n_value, 0, n1.n_value, 0, n1.n_len + Libbcmath.MIN(n1.n_scale, scale))
229
230
  // can we return here? not in c src, but can't see why-not.
230
231
  // return qval;
231
232
  }
@@ -233,71 +234,71 @@ module.exports = function _bc() {
233
234
 
234
235
  /* Set up the divide. Move the decimal point on n1 by n2's scale.
235
236
  Remember, zeros on the end of num2 are wasted effort for dividing. */
236
- scale2 = n2.n_scale; // scale2 = n2->n_scale;
237
- n2ptr = n2.n_len + scale2 - 1; // n2ptr = (unsigned char *) n2.n_value+n2.n_len+scale2-1;
237
+ scale2 = n2.n_scale // scale2 = n2->n_scale;
238
+ n2ptr = n2.n_len + scale2 - 1 // n2ptr = (unsigned char *) n2.n_value+n2.n_len+scale2-1;
238
239
  while (scale2 > 0 && n2.n_value[n2ptr--] === 0) {
239
- scale2--;
240
+ scale2--
240
241
  }
241
242
 
242
- len1 = n1.n_len + scale2;
243
- scale1 = n1.n_scale - scale2;
243
+ len1 = n1.n_len + scale2
244
+ scale1 = n1.n_scale - scale2
244
245
  if (scale1 < scale) {
245
- extra = scale - scale1;
246
+ extra = scale - scale1
246
247
  } else {
247
- extra = 0;
248
+ extra = 0
248
249
  }
249
250
 
250
251
  // num1 = (unsigned char *) safe_emalloc (1, n1.n_len+n1.n_scale, extra+2):
251
- num1 = Libbcmath.safe_emalloc(1, n1.n_len + n1.n_scale, extra + 2);
252
+ num1 = Libbcmath.safe_emalloc(1, n1.n_len + n1.n_scale, extra + 2)
252
253
  if (num1 === null) {
253
- Libbcmath.bc_out_of_memory();
254
+ Libbcmath.bc_out_of_memory()
254
255
  }
255
256
  // memset (num1, 0, n1->n_len+n1->n_scale+extra+2):
256
- Libbcmath.memset(num1, 0, 0, n1.n_len + n1.n_scale + extra + 2);
257
+ Libbcmath.memset(num1, 0, 0, n1.n_len + n1.n_scale + extra + 2)
257
258
  // memcpy (num1+1, n1.n_value, n1.n_len+n1.n_scale):
258
- Libbcmath.memcpy(num1, 1, n1.n_value, 0, n1.n_len + n1.n_scale);
259
+ Libbcmath.memcpy(num1, 1, n1.n_value, 0, n1.n_len + n1.n_scale)
259
260
  // len2 = n2->n_len + scale2:
260
- len2 = n2.n_len + scale2;
261
+ len2 = n2.n_len + scale2
261
262
  // num2 = (unsigned char *) safe_emalloc (1, len2, 1):
262
- num2 = Libbcmath.safe_emalloc(1, len2, 1);
263
+ num2 = Libbcmath.safe_emalloc(1, len2, 1)
263
264
  if (num2 === null) {
264
- Libbcmath.bc_out_of_memory();
265
+ Libbcmath.bc_out_of_memory()
265
266
  }
266
267
  // memcpy (num2, n2.n_value, len2):
267
- Libbcmath.memcpy(num2, 0, n2.n_value, 0, len2);
268
+ Libbcmath.memcpy(num2, 0, n2.n_value, 0, len2)
268
269
  // *(num2+len2) = 0:
269
- num2[len2] = 0;
270
+ num2[len2] = 0
270
271
  // n2ptr = num2:
271
- n2ptr = 0;
272
+ n2ptr = 0
272
273
  // while (*n2ptr === 0):
273
274
  while (num2[n2ptr] === 0) {
274
- n2ptr++;
275
- len2--;
275
+ n2ptr++
276
+ len2--
276
277
  }
277
278
 
278
279
  // Calculate the number of quotient digits.
279
280
  if (len2 > len1 + scale) {
280
- qdigits = scale + 1;
281
- zero = true;
281
+ qdigits = scale + 1
282
+ zero = true
282
283
  } else {
283
- zero = false;
284
+ zero = false
284
285
  if (len2 > len1) {
285
- qdigits = scale + 1; // One for the zero integer part.
286
+ qdigits = scale + 1 // One for the zero integer part.
286
287
  } else {
287
- qdigits = len1 - len2 + scale + 1;
288
+ qdigits = len1 - len2 + scale + 1
288
289
  }
289
290
  }
290
291
 
291
292
  // Allocate and zero the storage for the quotient.
292
293
  // qval = bc_new_num (qdigits-scale,scale);
293
- qval = Libbcmath.bc_new_num(qdigits - scale, scale);
294
+ qval = Libbcmath.bc_new_num(qdigits - scale, scale)
294
295
  // memset (qval->n_value, 0, qdigits);
295
- Libbcmath.memset(qval.n_value, 0, 0, qdigits);
296
+ Libbcmath.memset(qval.n_value, 0, 0, qdigits)
296
297
  // Allocate storage for the temporary storage mval.
297
298
  // mval = (unsigned char *) safe_emalloc (1, len2, 1);
298
- mval = Libbcmath.safe_emalloc(1, len2, 1);
299
+ mval = Libbcmath.safe_emalloc(1, len2, 1)
299
300
  if (mval === null) {
300
- Libbcmath.bc_out_of_memory();
301
+ Libbcmath.bc_out_of_memory()
301
302
  }
302
303
 
303
304
  // Now for the full divide algorithm.
@@ -305,121 +306,127 @@ module.exports = function _bc() {
305
306
  // Normalize
306
307
  // norm = Libbcmath.cint(10 / (Libbcmath.cint(n2.n_value[n2ptr]) + 1));
307
308
  // norm = 10 / ((int)*n2ptr + 1)
308
- norm = Math.floor(10 / (n2.n_value[n2ptr] + 1)); // norm = 10 / ((int)*n2ptr + 1);
309
+ norm = Math.floor(10 / (n2.n_value[n2ptr] + 1)) // norm = 10 / ((int)*n2ptr + 1);
309
310
  if (norm !== 1) {
310
311
  // Libbcmath._one_mult(num1, len1+scale1+extra+1, norm, num1);
311
- Libbcmath._one_mult(num1, 0, len1 + scale1 + extra + 1, norm, num1, 0);
312
+ Libbcmath._one_mult(num1, 0, len1 + scale1 + extra + 1, norm, num1, 0)
312
313
  // Libbcmath._one_mult(n2ptr, len2, norm, n2ptr);
313
- Libbcmath._one_mult(n2.n_value, n2ptr, len2, norm, n2.n_value, n2ptr);
314
+ Libbcmath._one_mult(n2.n_value, n2ptr, len2, norm, n2.n_value, n2ptr)
314
315
  // @todo: Check: Is the pointer affected by the call? if so,
315
316
  // maybe need to adjust points on return?
316
317
  }
317
318
 
318
319
  // Initialize divide loop.
319
- qdig = 0;
320
+ qdig = 0
320
321
  if (len2 > len1) {
321
- qptr = len2 - len1; // qptr = (unsigned char *) qval.n_value+len2-len1;
322
+ qptr = len2 - len1 // qptr = (unsigned char *) qval.n_value+len2-len1;
322
323
  } else {
323
- qptr = 0; // qptr = (unsigned char *) qval.n_value;
324
+ qptr = 0 // qptr = (unsigned char *) qval.n_value;
324
325
  }
325
326
 
326
327
  // Loop
327
328
  while (qdig <= len1 + scale - len2) {
328
329
  // Calculate the quotient digit guess.
329
330
  if (n2.n_value[n2ptr] === num1[qdig]) {
330
- qguess = 9;
331
+ qguess = 9
331
332
  } else {
332
- qguess = Math.floor((num1[qdig] * 10 + num1[qdig + 1]) / n2.n_value[n2ptr]);
333
+ qguess = Math.floor((num1[qdig] * 10 + num1[qdig + 1]) / n2.n_value[n2ptr])
333
334
  }
334
335
  // Test qguess.
335
336
 
336
- if (n2.n_value[n2ptr + 1] * qguess > (num1[qdig] * 10 + num1[qdig + 1] - n2.n_value[n2ptr] * qguess) * 10 + num1[qdig + 2]) {
337
- qguess--;
337
+ if (
338
+ n2.n_value[n2ptr + 1] * qguess >
339
+ (num1[qdig] * 10 + num1[qdig + 1] - n2.n_value[n2ptr] * qguess) * 10 + num1[qdig + 2]
340
+ ) {
341
+ qguess--
338
342
  // And again.
339
- if (n2.n_value[n2ptr + 1] * qguess > (num1[qdig] * 10 + num1[qdig + 1] - n2.n_value[n2ptr] * qguess) * 10 + num1[qdig + 2]) {
340
- qguess--;
343
+ if (
344
+ n2.n_value[n2ptr + 1] * qguess >
345
+ (num1[qdig] * 10 + num1[qdig + 1] - n2.n_value[n2ptr] * qguess) * 10 + num1[qdig + 2]
346
+ ) {
347
+ qguess--
341
348
  }
342
349
  }
343
350
 
344
351
  // Multiply and subtract.
345
- borrow = 0;
352
+ borrow = 0
346
353
  if (qguess !== 0) {
347
- mval[0] = 0; //* mval = 0; // @CHECK is this to fix ptr2 < 0?
354
+ mval[0] = 0 //* mval = 0; // @CHECK is this to fix ptr2 < 0?
348
355
  // _one_mult (n2ptr, len2, qguess, mval+1); // @CHECK
349
- Libbcmath._one_mult(n2.n_value, n2ptr, len2, qguess, mval, 1);
350
- ptr1 = qdig + len2; // (unsigned char *) num1+qdig+len2;
351
- ptr2 = len2; // (unsigned char *) mval+len2;
356
+ Libbcmath._one_mult(n2.n_value, n2ptr, len2, qguess, mval, 1)
357
+ ptr1 = qdig + len2 // (unsigned char *) num1+qdig+len2;
358
+ ptr2 = len2 // (unsigned char *) mval+len2;
352
359
  // @todo: CHECK: Does a negative pointer return null?
353
360
  // ptr2 can be < 0 here as ptr1 = len2, thus count < len2+1 will always fail ?
354
361
  for (count = 0; count < len2 + 1; count++) {
355
362
  if (ptr2 < 0) {
356
363
  // val = Libbcmath.cint(num1[ptr1]) - 0 - borrow;
357
364
  // val = (int) *ptr1 - (int) *ptr2-- - borrow;
358
- val = num1[ptr1] - 0 - borrow; // val = (int) *ptr1 - (int) *ptr2-- - borrow;
365
+ val = num1[ptr1] - 0 - borrow // val = (int) *ptr1 - (int) *ptr2-- - borrow;
359
366
  } else {
360
367
  // val = Libbcmath.cint(num1[ptr1]) - Libbcmath.cint(mval[ptr2--]) - borrow;
361
368
  // val = (int) *ptr1 - (int) *ptr2-- - borrow;
362
369
  // val = (int) *ptr1 - (int) *ptr2-- - borrow;
363
- val = num1[ptr1] - mval[ptr2--] - borrow;
370
+ val = num1[ptr1] - mval[ptr2--] - borrow
364
371
  }
365
372
  if (val < 0) {
366
- val += 10;
367
- borrow = 1;
373
+ val += 10
374
+ borrow = 1
368
375
  } else {
369
- borrow = 0;
376
+ borrow = 0
370
377
  }
371
- num1[ptr1--] = val;
378
+ num1[ptr1--] = val
372
379
  }
373
380
  }
374
381
 
375
382
  // Test for negative result.
376
383
  if (borrow === 1) {
377
- qguess--;
378
- ptr1 = qdig + len2; // (unsigned char *) num1+qdig+len2;
379
- ptr2 = len2 - 1; // (unsigned char *) n2ptr+len2-1;
380
- carry = 0;
384
+ qguess--
385
+ ptr1 = qdig + len2 // (unsigned char *) num1+qdig+len2;
386
+ ptr2 = len2 - 1 // (unsigned char *) n2ptr+len2-1;
387
+ carry = 0
381
388
  for (count = 0; count < len2; count++) {
382
389
  if (ptr2 < 0) {
383
390
  // val = Libbcmath.cint(num1[ptr1]) + 0 + carry;
384
391
  // val = (int) *ptr1 + (int) *ptr2-- + carry;
385
392
  // val = (int) *ptr1 + (int) *ptr2-- + carry;
386
- val = num1[ptr1] + 0 + carry;
393
+ val = num1[ptr1] + 0 + carry
387
394
  } else {
388
395
  // val = Libbcmath.cint(num1[ptr1]) + Libbcmath.cint(n2.n_value[ptr2--]) + carry;
389
396
  // val = (int) *ptr1 + (int) *ptr2-- + carry;
390
397
  // val = (int) *ptr1 + (int) *ptr2-- + carry;
391
- val = num1[ptr1] + n2.n_value[ptr2--] + carry;
398
+ val = num1[ptr1] + n2.n_value[ptr2--] + carry
392
399
  }
393
400
  if (val > 9) {
394
- val -= 10;
395
- carry = 1;
401
+ val -= 10
402
+ carry = 1
396
403
  } else {
397
- carry = 0;
404
+ carry = 0
398
405
  }
399
- num1[ptr1--] = val; //* ptr1-- = val;
406
+ num1[ptr1--] = val //* ptr1-- = val;
400
407
  }
401
408
  if (carry === 1) {
402
409
  // num1[ptr1] = Libbcmath.cint((num1[ptr1] + 1) % 10);
403
410
  // *ptr1 = (*ptr1 + 1) % 10; // @CHECK
404
411
  // *ptr1 = (*ptr1 + 1) % 10; // @CHECK
405
- num1[ptr1] = (num1[ptr1] + 1) % 10;
412
+ num1[ptr1] = (num1[ptr1] + 1) % 10
406
413
  }
407
414
  }
408
415
 
409
416
  // We now know the quotient digit.
410
- qval.n_value[qptr++] = qguess; //* qptr++ = qguess;
411
- qdig++;
417
+ qval.n_value[qptr++] = qguess //* qptr++ = qguess;
418
+ qdig++
412
419
  }
413
420
  }
414
421
 
415
422
  // Clean up and return the number.
416
- qval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS;
423
+ qval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS
417
424
  if (Libbcmath.bc_is_zero(qval)) {
418
- qval.n_sign = Libbcmath.PLUS;
425
+ qval.n_sign = Libbcmath.PLUS
419
426
  }
420
- Libbcmath._bc_rm_leading_zeros(qval);
427
+ Libbcmath._bc_rm_leading_zeros(qval)
421
428
 
422
- return qval;
429
+ return qval
423
430
 
424
431
  // return 0; // Everything is OK.
425
432
  },
@@ -429,161 +436,159 @@ module.exports = function _bc() {
429
436
  // #define MUL_SMALL_DIGITS mul_base_digits/4
430
437
 
431
438
  /* The multiply routine. N2 times N1 is put int PROD with the scale of
432
- the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)).
433
- */
439
+ the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)).
440
+ */
434
441
  /**
435
442
  * @param n1 bc_num
436
443
  * @param n2 bc_num
437
444
  * @param scale [int] optional
438
445
  */
439
- bc_multiply: function bc_multiply(n1, n2, scale) {
440
- var pval = void 0; // bc_num
441
- var len1 = void 0,
442
- len2 = void 0; // int
443
- var fullScale = void 0,
444
- prodScale = void 0; // int
446
+ bc_multiply: function (n1, n2, scale) {
447
+ let pval // bc_num
448
+ let len1
449
+ let len2 // int
450
+ let fullScale
451
+ let prodScale // int
445
452
  // Initialize things.
446
- len1 = n1.n_len + n1.n_scale;
447
- len2 = n2.n_len + n2.n_scale;
448
- fullScale = n1.n_scale + n2.n_scale;
449
- prodScale = Libbcmath.MIN(fullScale, Libbcmath.MAX(scale, Libbcmath.MAX(n1.n_scale, n2.n_scale)));
453
+ len1 = n1.n_len + n1.n_scale
454
+ len2 = n2.n_len + n2.n_scale
455
+ fullScale = n1.n_scale + n2.n_scale
456
+ prodScale = Libbcmath.MIN(fullScale, Libbcmath.MAX(scale, Libbcmath.MAX(n1.n_scale, n2.n_scale)))
450
457
 
451
458
  // pval = Libbcmath.bc_init_num(); // allow pass by ref
452
459
  // Do the multiply
453
- pval = Libbcmath._bc_rec_mul(n1, len1, n2, len2, fullScale);
460
+ pval = Libbcmath._bc_rec_mul(n1, len1, n2, len2, fullScale)
454
461
 
455
462
  // Assign to prod and clean up the number.
456
- pval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS;
463
+ pval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS
457
464
  // pval.n_value = pval.nPtr;
458
- pval.n_len = len2 + len1 + 1 - fullScale;
459
- pval.n_scale = prodScale;
460
- Libbcmath._bc_rm_leading_zeros(pval);
465
+ pval.n_len = len2 + len1 + 1 - fullScale
466
+ pval.n_scale = prodScale
467
+ Libbcmath._bc_rm_leading_zeros(pval)
461
468
  if (Libbcmath.bc_is_zero(pval)) {
462
- pval.n_sign = Libbcmath.PLUS;
469
+ pval.n_sign = Libbcmath.PLUS
463
470
  }
464
471
  // bc_free_num (prod);
465
- return pval;
472
+ return pval
466
473
  },
467
474
 
468
- new_sub_num: function new_sub_num(length, scale, value) {
469
- var ptr = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
470
-
471
- var temp = new Libbcmath.bc_num(); // eslint-disable-line new-cap
472
- temp.n_sign = Libbcmath.PLUS;
473
- temp.n_len = length;
474
- temp.n_scale = scale;
475
- temp.n_value = Libbcmath.safe_emalloc(1, length + scale, 0);
476
- Libbcmath.memcpy(temp.n_value, 0, value, ptr, length + scale);
477
- return temp;
475
+ new_sub_num: function (length, scale, value, ptr = 0) {
476
+ const temp = new Libbcmath.bc_num()
477
+ temp.n_sign = Libbcmath.PLUS
478
+ temp.n_len = length
479
+ temp.n_scale = scale
480
+ temp.n_value = Libbcmath.safe_emalloc(1, length + scale, 0)
481
+ Libbcmath.memcpy(temp.n_value, 0, value, ptr, length + scale)
482
+ return temp
478
483
  },
479
484
 
480
- _bc_simp_mul: function _bc_simp_mul(n1, n1len, n2, n2len, fullScale) {
481
- var prod = void 0; // bc_num
482
- var n1ptr = void 0,
483
- n2ptr = void 0,
484
- pvptr = void 0; // char *n1ptr, *n2ptr, *pvptr;
485
- var n1end = void 0,
486
- n2end = void 0; // char *n1end, *n2end; // To the end of n1 and n2.
487
- var indx = void 0,
488
- sum = void 0,
489
- prodlen = void 0; // int indx, sum, prodlen;
490
- prodlen = n1len + n2len + 1;
491
-
492
- prod = Libbcmath.bc_new_num(prodlen, 0);
493
-
494
- n1end = n1len - 1; // (char *) (n1->n_value + n1len - 1);
495
- n2end = n2len - 1; // (char *) (n2->n_value + n2len - 1);
496
- pvptr = prodlen - 1; // (char *) ((*prod)->n_value + prodlen - 1);
497
- sum = 0;
485
+ _bc_simp_mul: function (n1, n1len, n2, n2len, fullScale) {
486
+ let prod // bc_num
487
+ let n1ptr
488
+ let n2ptr
489
+ let pvptr // char *n1ptr, *n2ptr, *pvptr;
490
+ let n1end
491
+ let n2end // char *n1end, *n2end; // To the end of n1 and n2.
492
+ let indx
493
+ let sum
494
+ let prodlen // int indx, sum, prodlen;
495
+ prodlen = n1len + n2len + 1
496
+
497
+ prod = Libbcmath.bc_new_num(prodlen, 0)
498
+
499
+ n1end = n1len - 1 // (char *) (n1->n_value + n1len - 1);
500
+ n2end = n2len - 1 // (char *) (n2->n_value + n2len - 1);
501
+ pvptr = prodlen - 1 // (char *) ((*prod)->n_value + prodlen - 1);
502
+ sum = 0
498
503
 
499
504
  // Here is the loop...
500
505
  for (indx = 0; indx < prodlen - 1; indx++) {
501
506
  // (char *) (n1end - MAX(0, indx-n2len+1));
502
- n1ptr = n1end - Libbcmath.MAX(0, indx - n2len + 1);
507
+ n1ptr = n1end - Libbcmath.MAX(0, indx - n2len + 1)
503
508
  // (char *) (n2end - MIN(indx, n2len-1));
504
- n2ptr = n2end - Libbcmath.MIN(indx, n2len - 1);
509
+ n2ptr = n2end - Libbcmath.MIN(indx, n2len - 1)
505
510
  while (n1ptr >= 0 && n2ptr <= n2end) {
506
511
  // sum += *n1ptr-- * *n2ptr++;
507
- sum += n1.n_value[n1ptr--] * n2.n_value[n2ptr++];
512
+ sum += n1.n_value[n1ptr--] * n2.n_value[n2ptr++]
508
513
  }
509
514
  //* pvptr-- = sum % BASE;
510
- prod.n_value[pvptr--] = Math.floor(sum % Libbcmath.BASE);
511
- sum = Math.floor(sum / Libbcmath.BASE); // sum = sum / BASE;
515
+ prod.n_value[pvptr--] = Math.floor(sum % Libbcmath.BASE)
516
+ sum = Math.floor(sum / Libbcmath.BASE) // sum = sum / BASE;
512
517
  }
513
- prod.n_value[pvptr] = sum; //* pvptr = sum;
514
- return prod;
518
+ prod.n_value[pvptr] = sum //* pvptr = sum;
519
+ return prod
515
520
  },
516
521
 
517
522
  /* A special adder/subtractor for the recursive divide and conquer
518
523
  multiply algorithm. Note: if sub is called, accum must
519
524
  be larger that what is being subtracted. Also, accum and val
520
525
  must have n_scale = 0. (e.g. they must look like integers. *) */
521
- _bc_shift_addsub: function _bc_shift_addsub(accum, val, shift, sub) {
522
- var accp = void 0,
523
- valp = void 0; // signed char *accp, *valp;
524
- var count = void 0,
525
- carry = void 0; // int count, carry;
526
- count = val.n_len;
526
+ _bc_shift_addsub: function (accum, val, shift, sub) {
527
+ let accp
528
+ let valp // signed char *accp, *valp;
529
+ let count
530
+ let carry // int count, carry;
531
+ count = val.n_len
527
532
  if (val.n_value[0] === 0) {
528
- count--;
533
+ count--
529
534
  }
530
535
 
531
536
  // assert (accum->n_len+accum->n_scale >= shift+count);
532
537
  if (accum.n_len + accum.n_scale < shift + count) {
533
- throw new Error('len + scale < shift + count'); // ?? I think that's what assert does :)
538
+ throw new Error('len + scale < shift + count') // ?? I think that's what assert does :)
534
539
  }
535
540
 
536
541
  // Set up pointers and others
537
542
  // (signed char *)(accum->n_value + accum->n_len + accum->n_scale - shift - 1);
538
- accp = accum.n_len + accum.n_scale - shift - 1;
539
- valp = val.n_len - 1; // (signed char *)(val->n_value + val->n_len - 1);
540
- carry = 0;
543
+ accp = accum.n_len + accum.n_scale - shift - 1
544
+ valp = val.n_len - 1 // (signed char *)(val->n_value + val->n_len - 1);
545
+ carry = 0
541
546
  if (sub) {
542
547
  // Subtraction, carry is really borrow.
543
548
  while (count--) {
544
- accum.n_value[accp] -= val.n_value[valp--] + carry; //* accp -= *valp-- + carry;
549
+ accum.n_value[accp] -= val.n_value[valp--] + carry //* accp -= *valp-- + carry;
545
550
  if (accum.n_value[accp] < 0) {
546
551
  // if (*accp < 0)
547
- carry = 1;
548
- accum.n_value[accp--] += Libbcmath.BASE; //* accp-- += BASE;
552
+ carry = 1
553
+ accum.n_value[accp--] += Libbcmath.BASE //* accp-- += BASE;
549
554
  } else {
550
- carry = 0;
551
- accp--;
555
+ carry = 0
556
+ accp--
552
557
  }
553
558
  }
554
559
  while (carry) {
555
- accum.n_value[accp] -= carry; //* accp -= carry;
560
+ accum.n_value[accp] -= carry //* accp -= carry;
556
561
  if (accum.n_value[accp] < 0) {
557
562
  // if (*accp < 0)
558
- accum.n_value[accp--] += Libbcmath.BASE; // *accp-- += BASE;
563
+ accum.n_value[accp--] += Libbcmath.BASE // *accp-- += BASE;
559
564
  } else {
560
- carry = 0;
565
+ carry = 0
561
566
  }
562
567
  }
563
568
  } else {
564
569
  // Addition
565
570
  while (count--) {
566
- accum.n_value[accp] += val.n_value[valp--] + carry; //* accp += *valp-- + carry;
571
+ accum.n_value[accp] += val.n_value[valp--] + carry //* accp += *valp-- + carry;
567
572
  if (accum.n_value[accp] > Libbcmath.BASE - 1) {
568
573
  // if (*accp > (BASE-1))
569
- carry = 1;
570
- accum.n_value[accp--] -= Libbcmath.BASE; //* accp-- -= BASE;
574
+ carry = 1
575
+ accum.n_value[accp--] -= Libbcmath.BASE //* accp-- -= BASE;
571
576
  } else {
572
- carry = 0;
573
- accp--;
577
+ carry = 0
578
+ accp--
574
579
  }
575
580
  }
576
581
  while (carry) {
577
- accum.n_value[accp] += carry; //* accp += carry;
582
+ accum.n_value[accp] += carry //* accp += carry;
578
583
  if (accum.n_value[accp] > Libbcmath.BASE - 1) {
579
584
  // if (*accp > (BASE-1))
580
- accum.n_value[accp--] -= Libbcmath.BASE; //* accp-- -= BASE;
585
+ accum.n_value[accp--] -= Libbcmath.BASE //* accp-- -= BASE;
581
586
  } else {
582
- carry = 0;
587
+ carry = 0
583
588
  }
584
589
  }
585
590
  }
586
- return true; // accum is the pass-by-reference return
591
+ return true // accum is the pass-by-reference return
587
592
  },
588
593
 
589
594
  /* Recursive divide and conquer multiply algorithm.
@@ -591,101 +596,106 @@ module.exports = function _bc() {
591
596
  Let u = u0 + u1*(b^n)
592
597
  Let v = v0 + v1*(b^n)
593
598
  Then uv = (B^2n+B^n)*u1*v1 + B^n*(u1-u0)*(v0-v1) + (B^n+1)*u0*v0
594
- B is the base of storage, number of digits in u1,u0 close to equal.
599
+
600
+ B is the base of storage, number of digits in u1,u0 close to equal.
595
601
  */
596
- _bc_rec_mul: function _bc_rec_mul(u, ulen, v, vlen, fullScale) {
597
- var prod = void 0; // @return
598
- var u0 = void 0,
599
- u1 = void 0,
600
- v0 = void 0,
601
- v1 = void 0; // bc_num
602
+ _bc_rec_mul: function (u, ulen, v, vlen, fullScale) {
603
+ let prod // @return
604
+ let u0
605
+ let u1
606
+ let v0
607
+ let v1 // bc_num
602
608
  // var u0len,
603
609
  // var v0len // int
604
- var m1 = void 0,
605
- m2 = void 0,
606
- m3 = void 0,
607
- d1 = void 0,
608
- d2 = void 0; // bc_num
609
- var n = void 0,
610
- prodlen = void 0,
611
- m1zero = void 0; // int
612
- var d1len = void 0,
613
- d2len = void 0; // int
610
+ let m1
611
+ let m2
612
+ let m3
613
+ let d1
614
+ let d2 // bc_num
615
+ let n
616
+ let prodlen
617
+ let m1zero // int
618
+ let d1len
619
+ let d2len // int
614
620
  // Base case?
615
- if (ulen + vlen < Libbcmath.MUL_BASE_DIGITS || ulen < Libbcmath.MUL_SMALL_DIGITS || vlen < Libbcmath.MUL_SMALL_DIGITS) {
616
- return Libbcmath._bc_simp_mul(u, ulen, v, vlen, fullScale);
621
+ if (
622
+ ulen + vlen < Libbcmath.MUL_BASE_DIGITS ||
623
+ ulen < Libbcmath.MUL_SMALL_DIGITS ||
624
+ vlen < Libbcmath.MUL_SMALL_DIGITS
625
+ ) {
626
+ return Libbcmath._bc_simp_mul(u, ulen, v, vlen, fullScale)
617
627
  }
618
628
 
619
629
  // Calculate n -- the u and v split point in digits.
620
- n = Math.floor((Libbcmath.MAX(ulen, vlen) + 1) / 2);
630
+ n = Math.floor((Libbcmath.MAX(ulen, vlen) + 1) / 2)
621
631
 
622
632
  // Split u and v.
623
633
  if (ulen < n) {
624
- u1 = Libbcmath.bc_init_num(); // u1 = bc_copy_num (BCG(_zero_));
625
- u0 = Libbcmath.new_sub_num(ulen, 0, u.n_value);
634
+ u1 = Libbcmath.bc_init_num() // u1 = bc_copy_num (BCG(_zero_));
635
+ u0 = Libbcmath.new_sub_num(ulen, 0, u.n_value)
626
636
  } else {
627
- u1 = Libbcmath.new_sub_num(ulen - n, 0, u.n_value);
628
- u0 = Libbcmath.new_sub_num(n, 0, u.n_value, ulen - n);
637
+ u1 = Libbcmath.new_sub_num(ulen - n, 0, u.n_value)
638
+ u0 = Libbcmath.new_sub_num(n, 0, u.n_value, ulen - n)
629
639
  }
630
640
  if (vlen < n) {
631
- v1 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
632
- v0 = Libbcmath.new_sub_num(vlen, 0, v.n_value);
641
+ v1 = Libbcmath.bc_init_num() // bc_copy_num (BCG(_zero_));
642
+ v0 = Libbcmath.new_sub_num(vlen, 0, v.n_value)
633
643
  } else {
634
- v1 = Libbcmath.new_sub_num(vlen - n, 0, v.n_value);
635
- v0 = Libbcmath.new_sub_num(n, 0, v.n_value, vlen - n);
644
+ v1 = Libbcmath.new_sub_num(vlen - n, 0, v.n_value)
645
+ v0 = Libbcmath.new_sub_num(n, 0, v.n_value, vlen - n)
636
646
  }
637
- Libbcmath._bc_rm_leading_zeros(u1);
638
- Libbcmath._bc_rm_leading_zeros(u0);
647
+ Libbcmath._bc_rm_leading_zeros(u1)
648
+ Libbcmath._bc_rm_leading_zeros(u0)
639
649
  // var u0len = u0.n_len
640
- Libbcmath._bc_rm_leading_zeros(v1);
641
- Libbcmath._bc_rm_leading_zeros(v0);
650
+ Libbcmath._bc_rm_leading_zeros(v1)
651
+ Libbcmath._bc_rm_leading_zeros(v0)
642
652
  // var v0len = v0.n_len
643
653
 
644
- m1zero = Libbcmath.bc_is_zero(u1) || Libbcmath.bc_is_zero(v1);
654
+ m1zero = Libbcmath.bc_is_zero(u1) || Libbcmath.bc_is_zero(v1)
645
655
 
646
656
  // Calculate sub results ...
647
- d1 = Libbcmath.bc_init_num(); // needed?
648
- d2 = Libbcmath.bc_init_num(); // needed?
649
- d1 = Libbcmath.bc_sub(u1, u0, 0);
650
- d1len = d1.n_len;
657
+ d1 = Libbcmath.bc_init_num() // needed?
658
+ d2 = Libbcmath.bc_init_num() // needed?
659
+ d1 = Libbcmath.bc_sub(u1, u0, 0)
660
+ d1len = d1.n_len
651
661
 
652
- d2 = Libbcmath.bc_sub(v0, v1, 0);
653
- d2len = d2.n_len;
662
+ d2 = Libbcmath.bc_sub(v0, v1, 0)
663
+ d2len = d2.n_len
654
664
 
655
665
  // Do recursive multiplies and shifted adds.
656
666
  if (m1zero) {
657
- m1 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
667
+ m1 = Libbcmath.bc_init_num() // bc_copy_num (BCG(_zero_));
658
668
  } else {
659
669
  // m1 = Libbcmath.bc_init_num(); //allow pass-by-ref
660
- m1 = Libbcmath._bc_rec_mul(u1, u1.n_len, v1, v1.n_len, 0);
670
+ m1 = Libbcmath._bc_rec_mul(u1, u1.n_len, v1, v1.n_len, 0)
661
671
  }
662
672
  if (Libbcmath.bc_is_zero(d1) || Libbcmath.bc_is_zero(d2)) {
663
- m2 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
673
+ m2 = Libbcmath.bc_init_num() // bc_copy_num (BCG(_zero_));
664
674
  } else {
665
675
  // m2 = Libbcmath.bc_init_num(); //allow pass-by-ref
666
- m2 = Libbcmath._bc_rec_mul(d1, d1len, d2, d2len, 0);
676
+ m2 = Libbcmath._bc_rec_mul(d1, d1len, d2, d2len, 0)
667
677
  }
668
678
 
669
679
  if (Libbcmath.bc_is_zero(u0) || Libbcmath.bc_is_zero(v0)) {
670
- m3 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
680
+ m3 = Libbcmath.bc_init_num() // bc_copy_num (BCG(_zero_));
671
681
  } else {
672
682
  // m3 = Libbcmath.bc_init_num(); //allow pass-by-ref
673
- m3 = Libbcmath._bc_rec_mul(u0, u0.n_len, v0, v0.n_len, 0);
683
+ m3 = Libbcmath._bc_rec_mul(u0, u0.n_len, v0, v0.n_len, 0)
674
684
  }
675
685
 
676
686
  // Initialize product
677
- prodlen = ulen + vlen + 1;
678
- prod = Libbcmath.bc_new_num(prodlen, 0);
687
+ prodlen = ulen + vlen + 1
688
+ prod = Libbcmath.bc_new_num(prodlen, 0)
679
689
 
680
690
  if (!m1zero) {
681
- Libbcmath._bc_shift_addsub(prod, m1, 2 * n, 0);
682
- Libbcmath._bc_shift_addsub(prod, m1, n, 0);
691
+ Libbcmath._bc_shift_addsub(prod, m1, 2 * n, 0)
692
+ Libbcmath._bc_shift_addsub(prod, m1, n, 0)
683
693
  }
684
- Libbcmath._bc_shift_addsub(prod, m3, n, 0);
685
- Libbcmath._bc_shift_addsub(prod, m3, 0, 0);
686
- Libbcmath._bc_shift_addsub(prod, m2, n, d1.n_sign !== d2.n_sign);
694
+ Libbcmath._bc_shift_addsub(prod, m3, n, 0)
695
+ Libbcmath._bc_shift_addsub(prod, m3, 0, 0)
696
+ Libbcmath._bc_shift_addsub(prod, m2, n, d1.n_sign !== d2.n_sign)
687
697
 
688
- return prod;
698
+ return prod
689
699
  // Now clean up!
690
700
  // bc_free_num (&u1);
691
701
  // bc_free_num (&u0);
@@ -706,17 +716,17 @@ module.exports = function _bc() {
706
716
  * @param {boolean} ignoreLast
707
717
  * @return -1, 0, 1 (see bc_compare)
708
718
  */
709
- _bc_do_compare: function _bc_do_compare(n1, n2, useSign, ignoreLast) {
710
- var n1ptr = void 0,
711
- n2ptr = void 0; // int
712
- var count = void 0; // int
719
+ _bc_do_compare: function (n1, n2, useSign, ignoreLast) {
720
+ let n1ptr
721
+ let n2ptr // int
722
+ let count // int
713
723
  // First, compare signs.
714
724
  if (useSign && n1.n_sign !== n2.n_sign) {
715
725
  if (n1.n_sign === Libbcmath.PLUS) {
716
- return 1; // Positive N1 > Negative N2
726
+ return 1 // Positive N1 > Negative N2
717
727
  } else {
718
- return -1; // Negative N1 < Positive N1
719
- }
728
+ return -1 // Negative N1 < Positive N1
729
+ }
720
730
  }
721
731
 
722
732
  // Now compare the magnitude.
@@ -724,50 +734,50 @@ module.exports = function _bc() {
724
734
  if (n1.n_len > n2.n_len) {
725
735
  // Magnitude of n1 > n2.
726
736
  if (!useSign || n1.n_sign === Libbcmath.PLUS) {
727
- return 1;
737
+ return 1
728
738
  } else {
729
- return -1;
739
+ return -1
730
740
  }
731
741
  } else {
732
742
  // Magnitude of n1 < n2.
733
743
  if (!useSign || n1.n_sign === Libbcmath.PLUS) {
734
- return -1;
744
+ return -1
735
745
  } else {
736
- return 1;
746
+ return 1
737
747
  }
738
748
  }
739
749
  }
740
750
 
741
751
  /* If we get here, they have the same number of integer digits.
742
- check the integer part and the equal length part of the fraction. */
743
- count = n1.n_len + Math.min(n1.n_scale, n2.n_scale);
744
- n1ptr = 0;
745
- n2ptr = 0;
752
+ check the integer part and the equal length part of the fraction. */
753
+ count = n1.n_len + Math.min(n1.n_scale, n2.n_scale)
754
+ n1ptr = 0
755
+ n2ptr = 0
746
756
 
747
757
  while (count > 0 && n1.n_value[n1ptr] === n2.n_value[n2ptr]) {
748
- n1ptr++;
749
- n2ptr++;
750
- count--;
758
+ n1ptr++
759
+ n2ptr++
760
+ count--
751
761
  }
752
762
 
753
763
  if (ignoreLast && count === 1 && n1.n_scale === n2.n_scale) {
754
- return 0;
764
+ return 0
755
765
  }
756
766
 
757
767
  if (count !== 0) {
758
768
  if (n1.n_value[n1ptr] > n2.n_value[n2ptr]) {
759
769
  // Magnitude of n1 > n2.
760
770
  if (!useSign || n1.n_sign === Libbcmath.PLUS) {
761
- return 1;
771
+ return 1
762
772
  } else {
763
- return -1;
773
+ return -1
764
774
  }
765
775
  } else {
766
776
  // Magnitude of n1 < n2.
767
777
  if (!useSign || n1.n_sign === Libbcmath.PLUS) {
768
- return -1;
778
+ return -1
769
779
  } else {
770
- return 1;
780
+ return 1
771
781
  }
772
782
  }
773
783
  }
@@ -779,9 +789,9 @@ module.exports = function _bc() {
779
789
  if (n1.n_value[n1ptr++] !== 0) {
780
790
  // Magnitude of n1 > n2.
781
791
  if (!useSign || n1.n_sign === Libbcmath.PLUS) {
782
- return 1;
792
+ return 1
783
793
  } else {
784
- return -1;
794
+ return -1
785
795
  }
786
796
  }
787
797
  }
@@ -790,9 +800,9 @@ module.exports = function _bc() {
790
800
  if (n2.n_value[n2ptr++] !== 0) {
791
801
  // Magnitude of n1 < n2.
792
802
  if (!useSign || n1.n_sign === Libbcmath.PLUS) {
793
- return -1;
803
+ return -1
794
804
  } else {
795
- return 1;
805
+ return 1
796
806
  }
797
807
  }
798
808
  }
@@ -800,72 +810,72 @@ module.exports = function _bc() {
800
810
  }
801
811
 
802
812
  // They must be equal!
803
- return 0;
813
+ return 0
804
814
  },
805
815
 
806
816
  /* Here is the full subtract routine that takes care of negative numbers.
807
- N2 is subtracted from N1 and the result placed in RESULT. SCALE_MIN
808
- is the minimum scale for the result. */
809
- bc_sub: function bc_sub(n1, n2, scaleMin) {
810
- var diff = void 0; // bc_num
811
- var cmpRes = void 0,
812
- resScale = void 0; // int
817
+ N2 is subtracted from N1 and the result placed in RESULT. SCALE_MIN
818
+ is the minimum scale for the result. */
819
+ bc_sub: function (n1, n2, scaleMin) {
820
+ let diff // bc_num
821
+ let cmpRes
822
+ let resScale // int
813
823
  if (n1.n_sign !== n2.n_sign) {
814
- diff = Libbcmath._bc_do_add(n1, n2, scaleMin);
815
- diff.n_sign = n1.n_sign;
824
+ diff = Libbcmath._bc_do_add(n1, n2, scaleMin)
825
+ diff.n_sign = n1.n_sign
816
826
  } else {
817
827
  // subtraction must be done.
818
828
  // Compare magnitudes.
819
- cmpRes = Libbcmath._bc_do_compare(n1, n2, false, false);
829
+ cmpRes = Libbcmath._bc_do_compare(n1, n2, false, false)
820
830
  switch (cmpRes) {
821
831
  case -1:
822
832
  // n1 is less than n2, subtract n1 from n2.
823
- diff = Libbcmath._bc_do_sub(n2, n1, scaleMin);
824
- diff.n_sign = n2.n_sign === Libbcmath.PLUS ? Libbcmath.MINUS : Libbcmath.PLUS;
825
- break;
833
+ diff = Libbcmath._bc_do_sub(n2, n1, scaleMin)
834
+ diff.n_sign = n2.n_sign === Libbcmath.PLUS ? Libbcmath.MINUS : Libbcmath.PLUS
835
+ break
826
836
  case 0:
827
837
  // They are equal! return zero!
828
- resScale = Libbcmath.MAX(scaleMin, Libbcmath.MAX(n1.n_scale, n2.n_scale));
829
- diff = Libbcmath.bc_new_num(1, resScale);
830
- Libbcmath.memset(diff.n_value, 0, 0, resScale + 1);
831
- break;
838
+ resScale = Libbcmath.MAX(scaleMin, Libbcmath.MAX(n1.n_scale, n2.n_scale))
839
+ diff = Libbcmath.bc_new_num(1, resScale)
840
+ Libbcmath.memset(diff.n_value, 0, 0, resScale + 1)
841
+ break
832
842
  case 1:
833
843
  // n2 is less than n1, subtract n2 from n1.
834
- diff = Libbcmath._bc_do_sub(n1, n2, scaleMin);
835
- diff.n_sign = n1.n_sign;
836
- break;
844
+ diff = Libbcmath._bc_do_sub(n1, n2, scaleMin)
845
+ diff.n_sign = n1.n_sign
846
+ break
837
847
  }
838
848
  }
839
849
 
840
850
  // Clean up and return.
841
851
  // bc_free_num (result);
842
852
  //* result = diff;
843
- return diff;
853
+ return diff
844
854
  },
845
855
 
846
- _bc_do_add: function _bc_do_add(n1, n2, scaleMin) {
847
- var sum = void 0; // bc_num
848
- var sumScale = void 0,
849
- sumDigits = void 0; // int
850
- var n1ptr = void 0,
851
- n2ptr = void 0,
852
- sumptr = void 0; // int
853
- var carry = void 0,
854
- n1bytes = void 0,
855
- n2bytes = void 0; // int
856
- var tmp = void 0; // int
856
+ _bc_do_add: function (n1, n2, scaleMin) {
857
+ let sum // bc_num
858
+ let sumScale
859
+ let sumDigits // int
860
+ let n1ptr
861
+ let n2ptr
862
+ let sumptr // int
863
+ let carry
864
+ let n1bytes
865
+ let n2bytes // int
866
+ let tmp // int
857
867
 
858
868
  // Prepare sum.
859
- sumScale = Libbcmath.MAX(n1.n_scale, n2.n_scale);
860
- sumDigits = Libbcmath.MAX(n1.n_len, n2.n_len) + 1;
861
- sum = Libbcmath.bc_new_num(sumDigits, Libbcmath.MAX(sumScale, scaleMin));
869
+ sumScale = Libbcmath.MAX(n1.n_scale, n2.n_scale)
870
+ sumDigits = Libbcmath.MAX(n1.n_len, n2.n_len) + 1
871
+ sum = Libbcmath.bc_new_num(sumDigits, Libbcmath.MAX(sumScale, scaleMin))
862
872
 
863
873
  // Start with the fraction part. Initialize the pointers.
864
- n1bytes = n1.n_scale;
865
- n2bytes = n2.n_scale;
866
- n1ptr = n1.n_len + n1bytes - 1;
867
- n2ptr = n2.n_len + n2bytes - 1;
868
- sumptr = sumScale + sumDigits - 1;
874
+ n1bytes = n1.n_scale
875
+ n2bytes = n2.n_scale
876
+ n1ptr = n1.n_len + n1bytes - 1
877
+ n2ptr = n2.n_len + n2bytes - 1
878
+ sumptr = sumScale + sumDigits - 1
869
879
 
870
880
  // Add the fraction part. First copy the longer fraction
871
881
  // (ie when adding 1.2345 to 1 we know .2345 is correct already) .
@@ -873,79 +883,79 @@ module.exports = function _bc() {
873
883
  if (n1bytes > n2bytes) {
874
884
  // n1 has more dp then n2
875
885
  while (n1bytes > n2bytes) {
876
- sum.n_value[sumptr--] = n1.n_value[n1ptr--];
886
+ sum.n_value[sumptr--] = n1.n_value[n1ptr--]
877
887
  // *sumptr-- = *n1ptr--;
878
- n1bytes--;
888
+ n1bytes--
879
889
  }
880
890
  } else {
881
891
  // n2 has more dp then n1
882
892
  while (n2bytes > n1bytes) {
883
- sum.n_value[sumptr--] = n2.n_value[n2ptr--];
893
+ sum.n_value[sumptr--] = n2.n_value[n2ptr--]
884
894
  // *sumptr-- = *n2ptr--;
885
- n2bytes--;
895
+ n2bytes--
886
896
  }
887
897
  }
888
898
  }
889
899
 
890
900
  // Now add the remaining fraction part and equal size integer parts.
891
- n1bytes += n1.n_len;
892
- n2bytes += n2.n_len;
893
- carry = 0;
901
+ n1bytes += n1.n_len
902
+ n2bytes += n2.n_len
903
+ carry = 0
894
904
  while (n1bytes > 0 && n2bytes > 0) {
895
905
  // add the two numbers together
896
- tmp = n1.n_value[n1ptr--] + n2.n_value[n2ptr--] + carry;
906
+ tmp = n1.n_value[n1ptr--] + n2.n_value[n2ptr--] + carry
897
907
  // *sumptr = *n1ptr-- + *n2ptr-- + carry;
898
908
  // check if they are >= 10 (impossible to be more then 18)
899
909
  if (tmp >= Libbcmath.BASE) {
900
- carry = 1;
901
- tmp -= Libbcmath.BASE; // yep, subtract 10, add a carry
910
+ carry = 1
911
+ tmp -= Libbcmath.BASE // yep, subtract 10, add a carry
902
912
  } else {
903
- carry = 0;
913
+ carry = 0
904
914
  }
905
- sum.n_value[sumptr] = tmp;
906
- sumptr--;
907
- n1bytes--;
908
- n2bytes--;
915
+ sum.n_value[sumptr] = tmp
916
+ sumptr--
917
+ n1bytes--
918
+ n2bytes--
909
919
  }
910
920
 
911
921
  // Now add carry the [rest of the] longer integer part.
912
922
  if (n1bytes === 0) {
913
923
  // n2 is a bigger number then n1
914
924
  while (n2bytes-- > 0) {
915
- tmp = n2.n_value[n2ptr--] + carry;
925
+ tmp = n2.n_value[n2ptr--] + carry
916
926
  // *sumptr = *n2ptr-- + carry;
917
927
  if (tmp >= Libbcmath.BASE) {
918
- carry = 1;
919
- tmp -= Libbcmath.BASE;
928
+ carry = 1
929
+ tmp -= Libbcmath.BASE
920
930
  } else {
921
- carry = 0;
931
+ carry = 0
922
932
  }
923
- sum.n_value[sumptr--] = tmp;
933
+ sum.n_value[sumptr--] = tmp
924
934
  }
925
935
  } else {
926
936
  // n1 is bigger then n2..
927
937
  while (n1bytes-- > 0) {
928
- tmp = n1.n_value[n1ptr--] + carry;
938
+ tmp = n1.n_value[n1ptr--] + carry
929
939
  // *sumptr = *n1ptr-- + carry;
930
940
  if (tmp >= Libbcmath.BASE) {
931
- carry = 1;
932
- tmp -= Libbcmath.BASE;
941
+ carry = 1
942
+ tmp -= Libbcmath.BASE
933
943
  } else {
934
- carry = 0;
944
+ carry = 0
935
945
  }
936
- sum.n_value[sumptr--] = tmp;
946
+ sum.n_value[sumptr--] = tmp
937
947
  }
938
948
  }
939
949
 
940
950
  // Set final carry.
941
951
  if (carry === 1) {
942
- sum.n_value[sumptr] += 1;
952
+ sum.n_value[sumptr] += 1
943
953
  // *sumptr += 1;
944
954
  }
945
955
 
946
956
  // Adjust sum and return.
947
- Libbcmath._bc_rm_leading_zeros(sum);
948
- return sum;
957
+ Libbcmath._bc_rm_leading_zeros(sum)
958
+ return sum
949
959
  },
950
960
 
951
961
  /**
@@ -967,24 +977,24 @@ module.exports = function _bc() {
967
977
  * @param {int} scaleMin
968
978
  * @return bc_num
969
979
  */
970
- _bc_do_sub: function _bc_do_sub(n1, n2, scaleMin) {
971
- var diff = void 0; // bc_num
972
- var diffScale = void 0,
973
- diffLen = void 0; // int
974
- var minScale = void 0,
975
- minLen = void 0; // int
976
- var n1ptr = void 0,
977
- n2ptr = void 0,
978
- diffptr = void 0; // int
979
- var borrow = void 0,
980
- count = void 0,
981
- val = void 0; // int
980
+ _bc_do_sub: function (n1, n2, scaleMin) {
981
+ let diff // bc_num
982
+ let diffScale
983
+ let diffLen // int
984
+ let minScale
985
+ let minLen // int
986
+ let n1ptr
987
+ let n2ptr
988
+ let diffptr // int
989
+ let borrow
990
+ let count
991
+ let val // int
982
992
  // Allocate temporary storage.
983
- diffLen = Libbcmath.MAX(n1.n_len, n2.n_len);
984
- diffScale = Libbcmath.MAX(n1.n_scale, n2.n_scale);
985
- minLen = Libbcmath.MIN(n1.n_len, n2.n_len);
986
- minScale = Libbcmath.MIN(n1.n_scale, n2.n_scale);
987
- diff = Libbcmath.bc_new_num(diffLen, Libbcmath.MAX(diffScale, scaleMin));
993
+ diffLen = Libbcmath.MAX(n1.n_len, n2.n_len)
994
+ diffScale = Libbcmath.MAX(n1.n_scale, n2.n_scale)
995
+ minLen = Libbcmath.MIN(n1.n_len, n2.n_len)
996
+ minScale = Libbcmath.MIN(n1.n_scale, n2.n_scale)
997
+ diff = Libbcmath.bc_new_num(diffLen, Libbcmath.MAX(diffScale, scaleMin))
988
998
 
989
999
  /* Not needed?
990
1000
  // Zero extra digits made by scaleMin.
@@ -997,68 +1007,68 @@ module.exports = function _bc() {
997
1007
  */
998
1008
 
999
1009
  // Initialize the subtract.
1000
- n1ptr = n1.n_len + n1.n_scale - 1;
1001
- n2ptr = n2.n_len + n2.n_scale - 1;
1002
- diffptr = diffLen + diffScale - 1;
1010
+ n1ptr = n1.n_len + n1.n_scale - 1
1011
+ n2ptr = n2.n_len + n2.n_scale - 1
1012
+ diffptr = diffLen + diffScale - 1
1003
1013
 
1004
1014
  // Subtract the numbers.
1005
- borrow = 0;
1015
+ borrow = 0
1006
1016
 
1007
1017
  // Take care of the longer scaled number.
1008
1018
  if (n1.n_scale !== minScale) {
1009
1019
  // n1 has the longer scale
1010
1020
  for (count = n1.n_scale - minScale; count > 0; count--) {
1011
- diff.n_value[diffptr--] = n1.n_value[n1ptr--];
1021
+ diff.n_value[diffptr--] = n1.n_value[n1ptr--]
1012
1022
  // *diffptr-- = *n1ptr--;
1013
1023
  }
1014
1024
  } else {
1015
1025
  // n2 has the longer scale
1016
1026
  for (count = n2.n_scale - minScale; count > 0; count--) {
1017
- val = 0 - n2.n_value[n2ptr--] - borrow;
1027
+ val = 0 - n2.n_value[n2ptr--] - borrow
1018
1028
  // val = - *n2ptr-- - borrow;
1019
1029
  if (val < 0) {
1020
- val += Libbcmath.BASE;
1021
- borrow = 1;
1030
+ val += Libbcmath.BASE
1031
+ borrow = 1
1022
1032
  } else {
1023
- borrow = 0;
1033
+ borrow = 0
1024
1034
  }
1025
- diff.n_value[diffptr--] = val;
1035
+ diff.n_value[diffptr--] = val
1026
1036
  //* diffptr-- = val;
1027
1037
  }
1028
1038
  }
1029
1039
 
1030
1040
  // Now do the equal length scale and integer parts.
1031
1041
  for (count = 0; count < minLen + minScale; count++) {
1032
- val = n1.n_value[n1ptr--] - n2.n_value[n2ptr--] - borrow;
1042
+ val = n1.n_value[n1ptr--] - n2.n_value[n2ptr--] - borrow
1033
1043
  // val = *n1ptr-- - *n2ptr-- - borrow;
1034
1044
  if (val < 0) {
1035
- val += Libbcmath.BASE;
1036
- borrow = 1;
1045
+ val += Libbcmath.BASE
1046
+ borrow = 1
1037
1047
  } else {
1038
- borrow = 0;
1048
+ borrow = 0
1039
1049
  }
1040
- diff.n_value[diffptr--] = val;
1050
+ diff.n_value[diffptr--] = val
1041
1051
  //* diffptr-- = val;
1042
1052
  }
1043
1053
 
1044
1054
  // If n1 has more digits then n2, we now do that subtract.
1045
1055
  if (diffLen !== minLen) {
1046
1056
  for (count = diffLen - minLen; count > 0; count--) {
1047
- val = n1.n_value[n1ptr--] - borrow;
1057
+ val = n1.n_value[n1ptr--] - borrow
1048
1058
  // val = *n1ptr-- - borrow;
1049
1059
  if (val < 0) {
1050
- val += Libbcmath.BASE;
1051
- borrow = 1;
1060
+ val += Libbcmath.BASE
1061
+ borrow = 1
1052
1062
  } else {
1053
- borrow = 0;
1063
+ borrow = 0
1054
1064
  }
1055
- diff.n_value[diffptr--] = val;
1065
+ diff.n_value[diffptr--] = val
1056
1066
  }
1057
1067
  }
1058
1068
 
1059
1069
  // Clean up and return.
1060
- Libbcmath._bc_rm_leading_zeros(diff);
1061
- return diff;
1070
+ Libbcmath._bc_rm_leading_zeros(diff)
1071
+ return diff
1062
1072
  },
1063
1073
 
1064
1074
  /**
@@ -1067,162 +1077,162 @@ module.exports = function _bc() {
1067
1077
  * @param {int} scale
1068
1078
  * @return bc_num
1069
1079
  */
1070
- bc_new_num: function bc_new_num(length, scale) {
1071
- var temp = void 0; // bc_num
1072
- temp = new Libbcmath.bc_num(); // eslint-disable-line new-cap
1073
- temp.n_sign = Libbcmath.PLUS;
1074
- temp.n_len = length;
1075
- temp.n_scale = scale;
1076
- temp.n_value = Libbcmath.safe_emalloc(1, length + scale, 0);
1077
- Libbcmath.memset(temp.n_value, 0, 0, length + scale);
1078
- return temp;
1080
+ bc_new_num: function (length, scale) {
1081
+ let temp // bc_num
1082
+ temp = new Libbcmath.bc_num()
1083
+ temp.n_sign = Libbcmath.PLUS
1084
+ temp.n_len = length
1085
+ temp.n_scale = scale
1086
+ temp.n_value = Libbcmath.safe_emalloc(1, length + scale, 0)
1087
+ Libbcmath.memset(temp.n_value, 0, 0, length + scale)
1088
+ return temp
1079
1089
  },
1080
1090
 
1081
- safe_emalloc: function safe_emalloc(size, len, extra) {
1082
- return Array(size * len + extra);
1091
+ safe_emalloc: function (size, len, extra) {
1092
+ return new Array(size * len + extra)
1083
1093
  },
1084
1094
 
1085
1095
  /**
1086
1096
  * Create a new number
1087
1097
  */
1088
- bc_init_num: function bc_init_num() {
1089
- return new Libbcmath.bc_new_num(1, 0); // eslint-disable-line new-cap
1098
+ bc_init_num: function () {
1099
+ return new Libbcmath.bc_new_num(1, 0)
1090
1100
  },
1091
1101
 
1092
- _bc_rm_leading_zeros: function _bc_rm_leading_zeros(num) {
1102
+ _bc_rm_leading_zeros: function (num) {
1093
1103
  // We can move n_value to point to the first non zero digit!
1094
1104
  while (num.n_value[0] === 0 && num.n_len > 1) {
1095
- num.n_value.shift();
1096
- num.n_len--;
1105
+ num.n_value.shift()
1106
+ num.n_len--
1097
1107
  }
1098
1108
  },
1099
1109
 
1100
1110
  /**
1101
1111
  * Convert to bc_num detecting scale
1102
1112
  */
1103
- php_str2num: function php_str2num(str) {
1104
- var p = void 0;
1105
- p = str.indexOf('.');
1113
+ php_str2num: function (str) {
1114
+ let p
1115
+ p = str.indexOf('.')
1106
1116
  if (p === -1) {
1107
- return Libbcmath.bc_str2num(str, 0);
1117
+ return Libbcmath.bc_str2num(str, 0)
1108
1118
  } else {
1109
- return Libbcmath.bc_str2num(str, str.length - p);
1119
+ return Libbcmath.bc_str2num(str, str.length - p)
1110
1120
  }
1111
1121
  },
1112
1122
 
1113
- CH_VAL: function CH_VAL(c) {
1114
- return c - '0'; // ??
1123
+ CH_VAL: function (c) {
1124
+ return c - '0' // ??
1115
1125
  },
1116
1126
 
1117
- BCD_CHAR: function BCD_CHAR(d) {
1118
- return d + '0'; // ??
1127
+ BCD_CHAR: function (d) {
1128
+ return d + '0' // ??
1119
1129
  },
1120
1130
 
1121
- isdigit: function isdigit(c) {
1122
- return isNaN(parseInt(c, 10));
1131
+ isdigit: function (c) {
1132
+ return isNaN(parseInt(c, 10))
1123
1133
  },
1124
1134
 
1125
- bc_str2num: function bc_str2num(strIn, scale) {
1126
- var str = void 0,
1127
- num = void 0,
1128
- ptr = void 0,
1129
- digits = void 0,
1130
- strscale = void 0,
1131
- zeroInt = void 0,
1132
- nptr = void 0;
1135
+ bc_str2num: function (strIn, scale) {
1136
+ let str
1137
+ let num
1138
+ let ptr
1139
+ let digits
1140
+ let strscale
1141
+ let zeroInt
1142
+ let nptr
1133
1143
  // remove any non-expected characters
1134
1144
  // Check for valid number and count digits.
1135
1145
 
1136
- str = strIn.split(''); // convert to array
1137
- ptr = 0; // str
1138
- digits = 0;
1139
- strscale = 0;
1140
- zeroInt = false;
1146
+ str = strIn.split('') // convert to array
1147
+ ptr = 0 // str
1148
+ digits = 0
1149
+ strscale = 0
1150
+ zeroInt = false
1141
1151
  if (str[ptr] === '+' || str[ptr] === '-') {
1142
- ptr++; // Sign
1152
+ ptr++ // Sign
1143
1153
  }
1144
1154
  while (str[ptr] === '0') {
1145
- ptr++; // Skip leading zeros.
1155
+ ptr++ // Skip leading zeros.
1146
1156
  }
1147
1157
  // while (Libbcmath.isdigit(str[ptr])) {
1148
1158
  while (str[ptr] % 1 === 0) {
1149
1159
  // Libbcmath.isdigit(str[ptr])) {
1150
- ptr++;
1151
- digits++; // digits
1160
+ ptr++
1161
+ digits++ // digits
1152
1162
  }
1153
1163
 
1154
1164
  if (str[ptr] === '.') {
1155
- ptr++; // decimal point
1165
+ ptr++ // decimal point
1156
1166
  }
1157
1167
  // while (Libbcmath.isdigit(str[ptr])) {
1158
1168
  while (str[ptr] % 1 === 0) {
1159
1169
  // Libbcmath.isdigit(str[ptr])) {
1160
- ptr++;
1161
- strscale++; // digits
1170
+ ptr++
1171
+ strscale++ // digits
1162
1172
  }
1163
1173
 
1164
1174
  if (str[ptr] || digits + strscale === 0) {
1165
1175
  // invalid number, return 0
1166
- return Libbcmath.bc_init_num();
1176
+ return Libbcmath.bc_init_num()
1167
1177
  //* num = bc_copy_num (BCG(_zero_));
1168
1178
  }
1169
1179
 
1170
1180
  // Adjust numbers and allocate storage and initialize fields.
1171
- strscale = Libbcmath.MIN(strscale, scale);
1181
+ strscale = Libbcmath.MIN(strscale, scale)
1172
1182
  if (digits === 0) {
1173
- zeroInt = true;
1174
- digits = 1;
1183
+ zeroInt = true
1184
+ digits = 1
1175
1185
  }
1176
1186
 
1177
- num = Libbcmath.bc_new_num(digits, strscale);
1187
+ num = Libbcmath.bc_new_num(digits, strscale)
1178
1188
 
1179
1189
  // Build the whole number.
1180
- ptr = 0; // str
1190
+ ptr = 0 // str
1181
1191
  if (str[ptr] === '-') {
1182
- num.n_sign = Libbcmath.MINUS;
1192
+ num.n_sign = Libbcmath.MINUS
1183
1193
  // (*num)->n_sign = MINUS;
1184
- ptr++;
1194
+ ptr++
1185
1195
  } else {
1186
- num.n_sign = Libbcmath.PLUS;
1196
+ num.n_sign = Libbcmath.PLUS
1187
1197
  // (*num)->n_sign = PLUS;
1188
1198
  if (str[ptr] === '+') {
1189
- ptr++;
1199
+ ptr++
1190
1200
  }
1191
1201
  }
1192
1202
  while (str[ptr] === '0') {
1193
- ptr++; // Skip leading zeros.
1203
+ ptr++ // Skip leading zeros.
1194
1204
  }
1195
1205
 
1196
- nptr = 0; // (*num)->n_value;
1206
+ nptr = 0 // (*num)->n_value;
1197
1207
  if (zeroInt) {
1198
- num.n_value[nptr++] = 0;
1199
- digits = 0;
1208
+ num.n_value[nptr++] = 0
1209
+ digits = 0
1200
1210
  }
1201
1211
  for (; digits > 0; digits--) {
1202
- num.n_value[nptr++] = Libbcmath.CH_VAL(str[ptr++]);
1212
+ num.n_value[nptr++] = Libbcmath.CH_VAL(str[ptr++])
1203
1213
  //* nptr++ = CH_VAL(*ptr++);
1204
1214
  }
1205
1215
 
1206
1216
  // Build the fractional part.
1207
1217
  if (strscale > 0) {
1208
- ptr++; // skip the decimal point!
1218
+ ptr++ // skip the decimal point!
1209
1219
  for (; strscale > 0; strscale--) {
1210
- num.n_value[nptr++] = Libbcmath.CH_VAL(str[ptr++]);
1220
+ num.n_value[nptr++] = Libbcmath.CH_VAL(str[ptr++])
1211
1221
  }
1212
1222
  }
1213
1223
 
1214
- return num;
1224
+ return num
1215
1225
  },
1216
1226
 
1217
- cint: function cint(v) {
1227
+ cint: function (v) {
1218
1228
  if (typeof v === 'undefined') {
1219
- v = 0;
1229
+ v = 0
1220
1230
  }
1221
- var x = parseInt(v, 10);
1231
+ let x = parseInt(v, 10)
1222
1232
  if (isNaN(x)) {
1223
- x = 0;
1233
+ x = 0
1224
1234
  }
1225
- return x;
1235
+ return x
1226
1236
  },
1227
1237
 
1228
1238
  /**
@@ -1230,8 +1240,8 @@ module.exports = function _bc() {
1230
1240
  * @param {int} a
1231
1241
  * @param {int} b
1232
1242
  */
1233
- MIN: function MIN(a, b) {
1234
- return a > b ? b : a;
1243
+ MIN: function (a, b) {
1244
+ return a > b ? b : a
1235
1245
  },
1236
1246
 
1237
1247
  /**
@@ -1239,16 +1249,16 @@ module.exports = function _bc() {
1239
1249
  * @param {int} a
1240
1250
  * @param {int} b
1241
1251
  */
1242
- MAX: function MAX(a, b) {
1243
- return a > b ? a : b;
1252
+ MAX: function (a, b) {
1253
+ return a > b ? a : b
1244
1254
  },
1245
1255
 
1246
1256
  /**
1247
1257
  * Basic odd function
1248
1258
  * @param {int} a
1249
1259
  */
1250
- ODD: function ODD(a) {
1251
- return a & 1;
1260
+ ODD: function (a) {
1261
+ return a & 1
1252
1262
  },
1253
1263
 
1254
1264
  /**
@@ -1258,10 +1268,10 @@ module.exports = function _bc() {
1258
1268
  * @param {string} chr char to fill
1259
1269
  * @param {int} len length to fill
1260
1270
  */
1261
- memset: function memset(r, ptr, chr, len) {
1262
- var i = void 0;
1271
+ memset: function (r, ptr, chr, len) {
1272
+ let i
1263
1273
  for (i = 0; i < len; i++) {
1264
- r[ptr + i] = chr;
1274
+ r[ptr + i] = chr
1265
1275
  }
1266
1276
  },
1267
1277
 
@@ -1271,12 +1281,12 @@ module.exports = function _bc() {
1271
1281
  * param so you could do memcpy(dest+1, src, len) as memcpy(dest, 1, src, len)
1272
1282
  * Also only works on arrays
1273
1283
  */
1274
- memcpy: function memcpy(dest, ptr, src, srcptr, len) {
1275
- var i = void 0;
1284
+ memcpy: function (dest, ptr, src, srcptr, len) {
1285
+ let i
1276
1286
  for (i = 0; i < len; i++) {
1277
- dest[ptr + i] = src[srcptr + i];
1287
+ dest[ptr + i] = src[srcptr + i]
1278
1288
  }
1279
- return true;
1289
+ return true
1280
1290
  },
1281
1291
 
1282
1292
  /**
@@ -1284,30 +1294,29 @@ module.exports = function _bc() {
1284
1294
  * @param {bc_num} num number to check
1285
1295
  * @return boolean true when zero, false when not zero.
1286
1296
  */
1287
- bc_is_zero: function bc_is_zero(num) {
1288
- var count = void 0; // int
1289
- var nptr = void 0; // int
1297
+ bc_is_zero: function (num) {
1298
+ let count // int
1299
+ let nptr // int
1290
1300
  // Quick check.
1291
1301
  // if (num === BCG(_zero_)) return TRUE;
1292
1302
  // Initialize
1293
- count = num.n_len + num.n_scale;
1294
- nptr = 0; // num->n_value;
1303
+ count = num.n_len + num.n_scale
1304
+ nptr = 0 // num->n_value;
1295
1305
  // The check
1296
1306
  while (count > 0 && num.n_value[nptr++] === 0) {
1297
- count--;
1307
+ count--
1298
1308
  }
1299
1309
 
1300
1310
  if (count !== 0) {
1301
- return false;
1311
+ return false
1302
1312
  } else {
1303
- return true;
1313
+ return true
1304
1314
  }
1305
1315
  },
1306
1316
 
1307
- bc_out_of_memory: function bc_out_of_memory() {
1308
- throw new Error('(BC) Out of memory');
1309
- }
1310
- };
1311
- return Libbcmath;
1312
- };
1313
- //# sourceMappingURL=_bc.js.map
1317
+ bc_out_of_memory: function () {
1318
+ throw new Error('(BC) Out of memory')
1319
+ },
1320
+ }
1321
+ return Libbcmath
1322
+ }