@gsknnft/bigint-buffer 1.4.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (453) hide show
  1. package/README.md +150 -107
  2. package/build/Release/bigint_buffer.node +0 -0
  3. package/dist/build/Release/bigint_buffer.node +0 -0
  4. package/dist/conversion/bundle.iife.js +421 -0
  5. package/dist/conversion/bundle.umd.js +423 -0
  6. package/dist/conversion/cjs/converter.d.ts +14 -0
  7. package/dist/conversion/cjs/index.d.ts +33 -0
  8. package/dist/conversion/cjs/index.js +418 -0
  9. package/dist/conversion/cjs/index.node.js +4 -0
  10. package/dist/conversion/cjs/package.json +1 -0
  11. package/dist/conversion/converter.d.ts +14 -0
  12. package/dist/conversion/esm/bundle.js +416 -0
  13. package/dist/conversion/esm/bundle.min.js +1 -0
  14. package/dist/conversion/esm/converter.d.ts +14 -0
  15. package/dist/conversion/esm/index.browser.js +416 -0
  16. package/dist/conversion/esm/index.d.ts +33 -0
  17. package/dist/conversion/esm/index.js +416 -0
  18. package/dist/conversion/esm/index.node.js +2 -0
  19. package/dist/conversion/esm/package.json +1 -0
  20. package/dist/conversion/index.d.ts +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/{types/dist/dist/index.d.ts → index.d.ts} +5 -5
  23. package/dist/index.js +301 -419
  24. package/dist/index.umd.js +1 -1
  25. package/dist/types/conversion/index.d.ts +1 -2
  26. package/dist/types/conversion/src/index.d.ts +2 -0
  27. package/dist/types/conversion/src/ts/converter.d.ts +7 -3
  28. package/dist/types/conversion/src/ts/index.d.ts +23 -10
  29. package/dist/types/index.d.ts +5 -5
  30. package/package.json +50 -33
  31. package/prebuilds/win32-x64/@gsknnft+bigint-buffer.node +0 -0
  32. package/scripts/postinstall.cjs +40 -0
  33. package/build/Release/bigint_buffer.exp +0 -0
  34. package/build/Release/bigint_buffer.iobj +0 -0
  35. package/build/Release/bigint_buffer.ipdb +0 -0
  36. package/build/Release/bigint_buffer.lib +0 -0
  37. package/build/Release/bigint_buffer.pdb +0 -0
  38. package/build/Release/obj/bigint_buffer/bigint_buffer.node.recipe +0 -11
  39. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/CL.command.1.tlog +0 -0
  40. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/CL.read.1.tlog +0 -0
  41. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/CL.write.1.tlog +0 -0
  42. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/Cl.items.tlog +0 -2
  43. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/bigint_buffer.lastbuildstate +0 -2
  44. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.command.1.tlog +0 -0
  45. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.read.1.tlog +0 -0
  46. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.secondary.1.tlog +0 -5
  47. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.write.1.tlog +0 -0
  48. package/build/Release/obj/bigint_buffer/src/bigint-buffer.obj +0 -0
  49. package/build/Release/obj/bigint_buffer/win_delay_load_hook.obj +0 -0
  50. package/build/bigint_buffer.vcxproj +0 -148
  51. package/build/bigint_buffer.vcxproj.filters +0 -64
  52. package/build/binding.sln +0 -19
  53. package/build/config.gypi +0 -525
  54. package/dist/tsconfig.tsbuildinfo +0 -1
  55. package/dist/types/bigint-buffer.test.d.ts +0 -1
  56. package/dist/types/conversion/src/ts/fixedPoint/index.d.ts +0 -12
  57. package/dist/types/conversion/test/bigintToBase64.test.d.ts +0 -1
  58. package/dist/types/conversion/test/bigintToBuf.test.d.ts +0 -1
  59. package/dist/types/conversion/test/bigintToHex.test.d.ts +0 -1
  60. package/dist/types/conversion/test/bigintToText.test.d.ts +0 -1
  61. package/dist/types/conversion/test/bufToBigint.test.d.ts +0 -1
  62. package/dist/types/conversion/test/hexToBigint.test.d.ts +0 -1
  63. package/dist/types/conversion/test/hexToBuf.test.d.ts +0 -1
  64. package/dist/types/conversion/test/parseHex.test.d.ts +0 -1
  65. package/dist/types/conversion/test/setup.test.d.ts +0 -1
  66. package/dist/types/conversion/test/textToBuf.test.d.ts +0 -1
  67. package/dist/types/conversion/vite.config.d.ts +0 -2
  68. package/dist/types/conversion/vitest.config.d.ts +0 -2
  69. package/dist/types/dist/dist/conversion/conversion/index.d.ts +0 -2
  70. package/dist/types/index.bench.d.ts +0 -1
  71. package/dist/types/index.spec.d.ts +0 -1
  72. package/src/bigint-buffer.test.ts +0 -11
  73. package/src/conversion/.github/workflows/build-and-test.yml +0 -116
  74. package/src/conversion/.rollup.cache/C/Users/G/AppData/Local/Temp/rollup-plugin-typescript-allowjs-PYrzNv/src/ts/index.js +0 -178
  75. package/src/conversion/.rollup.cache/C/Users/G/AppData/Local/Temp/rollup-plugin-typescript-allowjs-PYrzNv/src/ts/index.js.map +0 -1
  76. package/src/conversion/.rollup.cache/C/Users/G/AppData/Local/Temp/rollup-plugin-typescript-allowjs-h16OVM/src/ts/index.js +0 -178
  77. package/src/conversion/.rollup.cache/C/Users/G/AppData/Local/Temp/rollup-plugin-typescript-allowjs-h16OVM/src/ts/index.js.map +0 -1
  78. package/src/conversion/.rollup.cache/C/Users/G/AppData/Local/Temp/rollup-plugin-typescript-allowjs-uUCFYt/src/ts/index.js +0 -178
  79. package/src/conversion/.rollup.cache/C/Users/G/AppData/Local/Temp/rollup-plugin-typescript-allowjs-uUCFYt/src/ts/index.js.map +0 -1
  80. package/src/conversion/CODE_OF_CONDUCT.md +0 -134
  81. package/src/conversion/LICENSE +0 -21
  82. package/src/conversion/README.md +0 -48
  83. package/src/conversion/coverage/base.css +0 -224
  84. package/src/conversion/coverage/block-navigation.js +0 -87
  85. package/src/conversion/coverage/clover.xml +0 -131
  86. package/src/conversion/coverage/coverage-final.json +0 -2
  87. package/src/conversion/coverage/favicon.png +0 -0
  88. package/src/conversion/coverage/index.html +0 -116
  89. package/src/conversion/coverage/index.ts.html +0 -1225
  90. package/src/conversion/coverage/prettify.css +0 -1
  91. package/src/conversion/coverage/prettify.js +0 -2
  92. package/src/conversion/coverage/sort-arrow-sprite.png +0 -0
  93. package/src/conversion/coverage/sorter.js +0 -210
  94. package/src/conversion/docs/README.md +0 -42
  95. package/src/conversion/docs/functions/base64ToBigint.md +0 -27
  96. package/src/conversion/docs/functions/bigintToBase64.md +0 -43
  97. package/src/conversion/docs/functions/bigintToBuf.md +0 -35
  98. package/src/conversion/docs/functions/bigintToHex.md +0 -43
  99. package/src/conversion/docs/functions/bigintToText.md +0 -31
  100. package/src/conversion/docs/functions/bufToBigint.md +0 -25
  101. package/src/conversion/docs/functions/bufToHex.md +0 -37
  102. package/src/conversion/docs/functions/bufToText.md +0 -27
  103. package/src/conversion/docs/functions/hexToBigint.md +0 -29
  104. package/src/conversion/docs/functions/hexToBuf.md +0 -37
  105. package/src/conversion/docs/functions/parseHex.md +0 -45
  106. package/src/conversion/docs/functions/textToBigint.md +0 -27
  107. package/src/conversion/docs/functions/textToBuf.md +0 -33
  108. package/src/conversion/docs/functions/toBigIntBE.md +0 -27
  109. package/src/conversion/docs/functions/toBigIntLE.md +0 -27
  110. package/src/conversion/docs/functions/toBufferBE.md +0 -33
  111. package/src/conversion/docs/functions/toBufferLE.md +0 -33
  112. package/src/conversion/docs/functions/validateBigIntBuffer.md +0 -15
  113. package/src/conversion/docs/type-aliases/TypedArray.md +0 -11
  114. package/src/conversion/docs/variables/isNative.md +0 -11
  115. package/src/conversion/example.cjs +0 -9
  116. package/src/conversion/example.esm.js +0 -11
  117. package/src/conversion/index.ts +0 -2
  118. package/src/conversion/node_modules/.bin/_mocha +0 -21
  119. package/src/conversion/node_modules/.bin/_mocha.CMD +0 -12
  120. package/src/conversion/node_modules/.bin/_mocha.ps1 +0 -41
  121. package/src/conversion/node_modules/.bin/c8 +0 -21
  122. package/src/conversion/node_modules/.bin/c8.CMD +0 -12
  123. package/src/conversion/node_modules/.bin/c8.ps1 +0 -41
  124. package/src/conversion/node_modules/.bin/esbuild +0 -21
  125. package/src/conversion/node_modules/.bin/esbuild.CMD +0 -12
  126. package/src/conversion/node_modules/.bin/esbuild.ps1 +0 -41
  127. package/src/conversion/node_modules/.bin/eslint +0 -21
  128. package/src/conversion/node_modules/.bin/eslint.CMD +0 -12
  129. package/src/conversion/node_modules/.bin/eslint.ps1 +0 -41
  130. package/src/conversion/node_modules/.bin/jiti +0 -21
  131. package/src/conversion/node_modules/.bin/jiti.CMD +0 -12
  132. package/src/conversion/node_modules/.bin/jiti.ps1 +0 -41
  133. package/src/conversion/node_modules/.bin/json5 +0 -21
  134. package/src/conversion/node_modules/.bin/json5.CMD +0 -12
  135. package/src/conversion/node_modules/.bin/json5.ps1 +0 -41
  136. package/src/conversion/node_modules/.bin/mocha +0 -21
  137. package/src/conversion/node_modules/.bin/mocha.CMD +0 -12
  138. package/src/conversion/node_modules/.bin/mocha.ps1 +0 -41
  139. package/src/conversion/node_modules/.bin/npm-run-all +0 -21
  140. package/src/conversion/node_modules/.bin/npm-run-all.CMD +0 -12
  141. package/src/conversion/node_modules/.bin/npm-run-all.ps1 +0 -41
  142. package/src/conversion/node_modules/.bin/puppeteer +0 -21
  143. package/src/conversion/node_modules/.bin/puppeteer.CMD +0 -12
  144. package/src/conversion/node_modules/.bin/puppeteer.ps1 +0 -41
  145. package/src/conversion/node_modules/.bin/rimraf +0 -16
  146. package/src/conversion/node_modules/.bin/rimraf.cmd +0 -17
  147. package/src/conversion/node_modules/.bin/rimraf.ps1 +0 -28
  148. package/src/conversion/node_modules/.bin/rollup +0 -21
  149. package/src/conversion/node_modules/.bin/rollup.CMD +0 -12
  150. package/src/conversion/node_modules/.bin/rollup.ps1 +0 -41
  151. package/src/conversion/node_modules/.bin/run-p +0 -21
  152. package/src/conversion/node_modules/.bin/run-p.CMD +0 -12
  153. package/src/conversion/node_modules/.bin/run-p.ps1 +0 -41
  154. package/src/conversion/node_modules/.bin/run-s +0 -21
  155. package/src/conversion/node_modules/.bin/run-s.CMD +0 -12
  156. package/src/conversion/node_modules/.bin/run-s.ps1 +0 -41
  157. package/src/conversion/node_modules/.bin/terser +0 -21
  158. package/src/conversion/node_modules/.bin/terser.CMD +0 -12
  159. package/src/conversion/node_modules/.bin/terser.ps1 +0 -41
  160. package/src/conversion/node_modules/.bin/ts-standard +0 -21
  161. package/src/conversion/node_modules/.bin/ts-standard.CMD +0 -12
  162. package/src/conversion/node_modules/.bin/ts-standard.ps1 +0 -41
  163. package/src/conversion/node_modules/.bin/tsc +0 -21
  164. package/src/conversion/node_modules/.bin/tsc.CMD +0 -12
  165. package/src/conversion/node_modules/.bin/tsc.ps1 +0 -41
  166. package/src/conversion/node_modules/.bin/tsserver +0 -21
  167. package/src/conversion/node_modules/.bin/tsserver.CMD +0 -12
  168. package/src/conversion/node_modules/.bin/tsserver.ps1 +0 -41
  169. package/src/conversion/node_modules/.bin/typedoc +0 -21
  170. package/src/conversion/node_modules/.bin/typedoc.CMD +0 -12
  171. package/src/conversion/node_modules/.bin/typedoc.ps1 +0 -41
  172. package/src/conversion/node_modules/.bin/vite +0 -21
  173. package/src/conversion/node_modules/.bin/vite.CMD +0 -12
  174. package/src/conversion/node_modules/.bin/vite.ps1 +0 -41
  175. package/src/conversion/node_modules/.bin/vitest +0 -21
  176. package/src/conversion/node_modules/.bin/vitest.CMD +0 -12
  177. package/src/conversion/node_modules/.bin/vitest.ps1 +0 -41
  178. package/src/conversion/node_modules/.bin/yaml +0 -21
  179. package/src/conversion/node_modules/.bin/yaml.CMD +0 -12
  180. package/src/conversion/node_modules/.bin/yaml.ps1 +0 -41
  181. package/src/conversion/node_modules/glob/LICENSE.md +0 -63
  182. package/src/conversion/node_modules/glob/README.md +0 -1177
  183. package/src/conversion/node_modules/glob/dist/commonjs/glob.d.ts +0 -388
  184. package/src/conversion/node_modules/glob/dist/commonjs/glob.d.ts.map +0 -1
  185. package/src/conversion/node_modules/glob/dist/commonjs/glob.js +0 -247
  186. package/src/conversion/node_modules/glob/dist/commonjs/glob.js.map +0 -1
  187. package/src/conversion/node_modules/glob/dist/commonjs/has-magic.d.ts +0 -14
  188. package/src/conversion/node_modules/glob/dist/commonjs/has-magic.d.ts.map +0 -1
  189. package/src/conversion/node_modules/glob/dist/commonjs/has-magic.js +0 -27
  190. package/src/conversion/node_modules/glob/dist/commonjs/has-magic.js.map +0 -1
  191. package/src/conversion/node_modules/glob/dist/commonjs/ignore.d.ts +0 -24
  192. package/src/conversion/node_modules/glob/dist/commonjs/ignore.d.ts.map +0 -1
  193. package/src/conversion/node_modules/glob/dist/commonjs/ignore.js +0 -119
  194. package/src/conversion/node_modules/glob/dist/commonjs/ignore.js.map +0 -1
  195. package/src/conversion/node_modules/glob/dist/commonjs/index.d.ts +0 -97
  196. package/src/conversion/node_modules/glob/dist/commonjs/index.d.ts.map +0 -1
  197. package/src/conversion/node_modules/glob/dist/commonjs/index.js +0 -68
  198. package/src/conversion/node_modules/glob/dist/commonjs/index.js.map +0 -1
  199. package/src/conversion/node_modules/glob/dist/commonjs/package.json +0 -3
  200. package/src/conversion/node_modules/glob/dist/commonjs/pattern.d.ts +0 -76
  201. package/src/conversion/node_modules/glob/dist/commonjs/pattern.d.ts.map +0 -1
  202. package/src/conversion/node_modules/glob/dist/commonjs/pattern.js +0 -219
  203. package/src/conversion/node_modules/glob/dist/commonjs/pattern.js.map +0 -1
  204. package/src/conversion/node_modules/glob/dist/commonjs/processor.d.ts +0 -59
  205. package/src/conversion/node_modules/glob/dist/commonjs/processor.d.ts.map +0 -1
  206. package/src/conversion/node_modules/glob/dist/commonjs/processor.js +0 -301
  207. package/src/conversion/node_modules/glob/dist/commonjs/processor.js.map +0 -1
  208. package/src/conversion/node_modules/glob/dist/commonjs/walker.d.ts +0 -97
  209. package/src/conversion/node_modules/glob/dist/commonjs/walker.d.ts.map +0 -1
  210. package/src/conversion/node_modules/glob/dist/commonjs/walker.js +0 -387
  211. package/src/conversion/node_modules/glob/dist/commonjs/walker.js.map +0 -1
  212. package/src/conversion/node_modules/glob/dist/esm/glob.d.ts +0 -388
  213. package/src/conversion/node_modules/glob/dist/esm/glob.d.ts.map +0 -1
  214. package/src/conversion/node_modules/glob/dist/esm/glob.js +0 -243
  215. package/src/conversion/node_modules/glob/dist/esm/glob.js.map +0 -1
  216. package/src/conversion/node_modules/glob/dist/esm/has-magic.d.ts +0 -14
  217. package/src/conversion/node_modules/glob/dist/esm/has-magic.d.ts.map +0 -1
  218. package/src/conversion/node_modules/glob/dist/esm/has-magic.js +0 -23
  219. package/src/conversion/node_modules/glob/dist/esm/has-magic.js.map +0 -1
  220. package/src/conversion/node_modules/glob/dist/esm/ignore.d.ts +0 -24
  221. package/src/conversion/node_modules/glob/dist/esm/ignore.d.ts.map +0 -1
  222. package/src/conversion/node_modules/glob/dist/esm/ignore.js +0 -115
  223. package/src/conversion/node_modules/glob/dist/esm/ignore.js.map +0 -1
  224. package/src/conversion/node_modules/glob/dist/esm/index.d.ts +0 -97
  225. package/src/conversion/node_modules/glob/dist/esm/index.d.ts.map +0 -1
  226. package/src/conversion/node_modules/glob/dist/esm/index.js +0 -55
  227. package/src/conversion/node_modules/glob/dist/esm/index.js.map +0 -1
  228. package/src/conversion/node_modules/glob/dist/esm/package.json +0 -3
  229. package/src/conversion/node_modules/glob/dist/esm/pattern.d.ts +0 -76
  230. package/src/conversion/node_modules/glob/dist/esm/pattern.d.ts.map +0 -1
  231. package/src/conversion/node_modules/glob/dist/esm/pattern.js +0 -215
  232. package/src/conversion/node_modules/glob/dist/esm/pattern.js.map +0 -1
  233. package/src/conversion/node_modules/glob/dist/esm/processor.d.ts +0 -59
  234. package/src/conversion/node_modules/glob/dist/esm/processor.d.ts.map +0 -1
  235. package/src/conversion/node_modules/glob/dist/esm/processor.js +0 -294
  236. package/src/conversion/node_modules/glob/dist/esm/processor.js.map +0 -1
  237. package/src/conversion/node_modules/glob/dist/esm/walker.d.ts +0 -97
  238. package/src/conversion/node_modules/glob/dist/esm/walker.d.ts.map +0 -1
  239. package/src/conversion/node_modules/glob/dist/esm/walker.js +0 -381
  240. package/src/conversion/node_modules/glob/dist/esm/walker.js.map +0 -1
  241. package/src/conversion/node_modules/glob/package.json +0 -93
  242. package/src/conversion/node_modules/minimatch/LICENSE.md +0 -55
  243. package/src/conversion/node_modules/minimatch/README.md +0 -453
  244. package/src/conversion/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +0 -2
  245. package/src/conversion/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +0 -1
  246. package/src/conversion/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +0 -14
  247. package/src/conversion/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +0 -1
  248. package/src/conversion/node_modules/minimatch/dist/commonjs/ast.d.ts +0 -20
  249. package/src/conversion/node_modules/minimatch/dist/commonjs/ast.d.ts.map +0 -1
  250. package/src/conversion/node_modules/minimatch/dist/commonjs/ast.js +0 -591
  251. package/src/conversion/node_modules/minimatch/dist/commonjs/ast.js.map +0 -1
  252. package/src/conversion/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +0 -8
  253. package/src/conversion/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +0 -1
  254. package/src/conversion/node_modules/minimatch/dist/commonjs/brace-expressions.js +0 -152
  255. package/src/conversion/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +0 -1
  256. package/src/conversion/node_modules/minimatch/dist/commonjs/escape.d.ts +0 -15
  257. package/src/conversion/node_modules/minimatch/dist/commonjs/escape.d.ts.map +0 -1
  258. package/src/conversion/node_modules/minimatch/dist/commonjs/escape.js +0 -30
  259. package/src/conversion/node_modules/minimatch/dist/commonjs/escape.js.map +0 -1
  260. package/src/conversion/node_modules/minimatch/dist/commonjs/index.d.ts +0 -94
  261. package/src/conversion/node_modules/minimatch/dist/commonjs/index.d.ts.map +0 -1
  262. package/src/conversion/node_modules/minimatch/dist/commonjs/index.js +0 -1029
  263. package/src/conversion/node_modules/minimatch/dist/commonjs/index.js.map +0 -1
  264. package/src/conversion/node_modules/minimatch/dist/commonjs/package.json +0 -3
  265. package/src/conversion/node_modules/minimatch/dist/commonjs/unescape.d.ts +0 -22
  266. package/src/conversion/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +0 -1
  267. package/src/conversion/node_modules/minimatch/dist/commonjs/unescape.js +0 -38
  268. package/src/conversion/node_modules/minimatch/dist/commonjs/unescape.js.map +0 -1
  269. package/src/conversion/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +0 -2
  270. package/src/conversion/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +0 -1
  271. package/src/conversion/node_modules/minimatch/dist/esm/assert-valid-pattern.js +0 -10
  272. package/src/conversion/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +0 -1
  273. package/src/conversion/node_modules/minimatch/dist/esm/ast.d.ts +0 -20
  274. package/src/conversion/node_modules/minimatch/dist/esm/ast.d.ts.map +0 -1
  275. package/src/conversion/node_modules/minimatch/dist/esm/ast.js +0 -587
  276. package/src/conversion/node_modules/minimatch/dist/esm/ast.js.map +0 -1
  277. package/src/conversion/node_modules/minimatch/dist/esm/brace-expressions.d.ts +0 -8
  278. package/src/conversion/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +0 -1
  279. package/src/conversion/node_modules/minimatch/dist/esm/brace-expressions.js +0 -148
  280. package/src/conversion/node_modules/minimatch/dist/esm/brace-expressions.js.map +0 -1
  281. package/src/conversion/node_modules/minimatch/dist/esm/escape.d.ts +0 -15
  282. package/src/conversion/node_modules/minimatch/dist/esm/escape.d.ts.map +0 -1
  283. package/src/conversion/node_modules/minimatch/dist/esm/escape.js +0 -26
  284. package/src/conversion/node_modules/minimatch/dist/esm/escape.js.map +0 -1
  285. package/src/conversion/node_modules/minimatch/dist/esm/index.d.ts +0 -94
  286. package/src/conversion/node_modules/minimatch/dist/esm/index.d.ts.map +0 -1
  287. package/src/conversion/node_modules/minimatch/dist/esm/index.js +0 -1016
  288. package/src/conversion/node_modules/minimatch/dist/esm/index.js.map +0 -1
  289. package/src/conversion/node_modules/minimatch/dist/esm/package.json +0 -3
  290. package/src/conversion/node_modules/minimatch/dist/esm/unescape.d.ts +0 -22
  291. package/src/conversion/node_modules/minimatch/dist/esm/unescape.d.ts.map +0 -1
  292. package/src/conversion/node_modules/minimatch/dist/esm/unescape.js +0 -34
  293. package/src/conversion/node_modules/minimatch/dist/esm/unescape.js.map +0 -1
  294. package/src/conversion/node_modules/minimatch/package.json +0 -78
  295. package/src/conversion/node_modules/rimraf/LICENSE.md +0 -55
  296. package/src/conversion/node_modules/rimraf/README.md +0 -226
  297. package/src/conversion/node_modules/rimraf/dist/commonjs/default-tmp.d.ts +0 -3
  298. package/src/conversion/node_modules/rimraf/dist/commonjs/default-tmp.d.ts.map +0 -1
  299. package/src/conversion/node_modules/rimraf/dist/commonjs/default-tmp.js +0 -58
  300. package/src/conversion/node_modules/rimraf/dist/commonjs/default-tmp.js.map +0 -1
  301. package/src/conversion/node_modules/rimraf/dist/commonjs/error.d.ts +0 -6
  302. package/src/conversion/node_modules/rimraf/dist/commonjs/error.d.ts.map +0 -1
  303. package/src/conversion/node_modules/rimraf/dist/commonjs/error.js +0 -10
  304. package/src/conversion/node_modules/rimraf/dist/commonjs/error.js.map +0 -1
  305. package/src/conversion/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts +0 -3
  306. package/src/conversion/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts.map +0 -1
  307. package/src/conversion/node_modules/rimraf/dist/commonjs/fix-eperm.js +0 -38
  308. package/src/conversion/node_modules/rimraf/dist/commonjs/fix-eperm.js.map +0 -1
  309. package/src/conversion/node_modules/rimraf/dist/commonjs/fs.d.ts +0 -15
  310. package/src/conversion/node_modules/rimraf/dist/commonjs/fs.d.ts.map +0 -1
  311. package/src/conversion/node_modules/rimraf/dist/commonjs/fs.js +0 -33
  312. package/src/conversion/node_modules/rimraf/dist/commonjs/fs.js.map +0 -1
  313. package/src/conversion/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts +0 -3
  314. package/src/conversion/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts.map +0 -1
  315. package/src/conversion/node_modules/rimraf/dist/commonjs/ignore-enoent.js +0 -24
  316. package/src/conversion/node_modules/rimraf/dist/commonjs/ignore-enoent.js.map +0 -1
  317. package/src/conversion/node_modules/rimraf/dist/commonjs/index.d.ts +0 -50
  318. package/src/conversion/node_modules/rimraf/dist/commonjs/index.d.ts.map +0 -1
  319. package/src/conversion/node_modules/rimraf/dist/commonjs/index.js +0 -78
  320. package/src/conversion/node_modules/rimraf/dist/commonjs/index.js.map +0 -1
  321. package/src/conversion/node_modules/rimraf/dist/commonjs/opt-arg.d.ts +0 -34
  322. package/src/conversion/node_modules/rimraf/dist/commonjs/opt-arg.d.ts.map +0 -1
  323. package/src/conversion/node_modules/rimraf/dist/commonjs/opt-arg.js +0 -53
  324. package/src/conversion/node_modules/rimraf/dist/commonjs/opt-arg.js.map +0 -1
  325. package/src/conversion/node_modules/rimraf/dist/commonjs/package.json +0 -3
  326. package/src/conversion/node_modules/rimraf/dist/commonjs/path-arg.d.ts +0 -4
  327. package/src/conversion/node_modules/rimraf/dist/commonjs/path-arg.d.ts.map +0 -1
  328. package/src/conversion/node_modules/rimraf/dist/commonjs/path-arg.js +0 -48
  329. package/src/conversion/node_modules/rimraf/dist/commonjs/path-arg.js.map +0 -1
  330. package/src/conversion/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts +0 -3
  331. package/src/conversion/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts.map +0 -1
  332. package/src/conversion/node_modules/rimraf/dist/commonjs/readdir-or-error.js +0 -19
  333. package/src/conversion/node_modules/rimraf/dist/commonjs/readdir-or-error.js.map +0 -1
  334. package/src/conversion/node_modules/rimraf/dist/commonjs/retry-busy.d.ts +0 -8
  335. package/src/conversion/node_modules/rimraf/dist/commonjs/retry-busy.d.ts.map +0 -1
  336. package/src/conversion/node_modules/rimraf/dist/commonjs/retry-busy.js +0 -65
  337. package/src/conversion/node_modules/rimraf/dist/commonjs/retry-busy.js.map +0 -1
  338. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts +0 -3
  339. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts.map +0 -1
  340. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-manual.js +0 -8
  341. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-manual.js.map +0 -1
  342. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts +0 -4
  343. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts.map +0 -1
  344. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js +0 -138
  345. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js.map +0 -1
  346. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts +0 -4
  347. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts.map +0 -1
  348. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-native.js +0 -24
  349. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-native.js.map +0 -1
  350. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts +0 -4
  351. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts.map +0 -1
  352. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-posix.js +0 -103
  353. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-posix.js.map +0 -1
  354. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts +0 -4
  355. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts.map +0 -1
  356. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-windows.js +0 -159
  357. package/src/conversion/node_modules/rimraf/dist/commonjs/rimraf-windows.js.map +0 -1
  358. package/src/conversion/node_modules/rimraf/dist/commonjs/use-native.d.ts +0 -4
  359. package/src/conversion/node_modules/rimraf/dist/commonjs/use-native.d.ts.map +0 -1
  360. package/src/conversion/node_modules/rimraf/dist/commonjs/use-native.js +0 -18
  361. package/src/conversion/node_modules/rimraf/dist/commonjs/use-native.js.map +0 -1
  362. package/src/conversion/node_modules/rimraf/dist/esm/bin.d.mts +0 -3
  363. package/src/conversion/node_modules/rimraf/dist/esm/bin.d.mts.map +0 -1
  364. package/src/conversion/node_modules/rimraf/dist/esm/bin.mjs +0 -250
  365. package/src/conversion/node_modules/rimraf/dist/esm/bin.mjs.map +0 -1
  366. package/src/conversion/node_modules/rimraf/dist/esm/default-tmp.d.ts +0 -3
  367. package/src/conversion/node_modules/rimraf/dist/esm/default-tmp.d.ts.map +0 -1
  368. package/src/conversion/node_modules/rimraf/dist/esm/default-tmp.js +0 -55
  369. package/src/conversion/node_modules/rimraf/dist/esm/default-tmp.js.map +0 -1
  370. package/src/conversion/node_modules/rimraf/dist/esm/error.d.ts +0 -6
  371. package/src/conversion/node_modules/rimraf/dist/esm/error.d.ts.map +0 -1
  372. package/src/conversion/node_modules/rimraf/dist/esm/error.js +0 -5
  373. package/src/conversion/node_modules/rimraf/dist/esm/error.js.map +0 -1
  374. package/src/conversion/node_modules/rimraf/dist/esm/fix-eperm.d.ts +0 -3
  375. package/src/conversion/node_modules/rimraf/dist/esm/fix-eperm.d.ts.map +0 -1
  376. package/src/conversion/node_modules/rimraf/dist/esm/fix-eperm.js +0 -33
  377. package/src/conversion/node_modules/rimraf/dist/esm/fix-eperm.js.map +0 -1
  378. package/src/conversion/node_modules/rimraf/dist/esm/fs.d.ts +0 -15
  379. package/src/conversion/node_modules/rimraf/dist/esm/fs.d.ts.map +0 -1
  380. package/src/conversion/node_modules/rimraf/dist/esm/fs.js +0 -18
  381. package/src/conversion/node_modules/rimraf/dist/esm/fs.js.map +0 -1
  382. package/src/conversion/node_modules/rimraf/dist/esm/ignore-enoent.d.ts +0 -3
  383. package/src/conversion/node_modules/rimraf/dist/esm/ignore-enoent.d.ts.map +0 -1
  384. package/src/conversion/node_modules/rimraf/dist/esm/ignore-enoent.js +0 -19
  385. package/src/conversion/node_modules/rimraf/dist/esm/ignore-enoent.js.map +0 -1
  386. package/src/conversion/node_modules/rimraf/dist/esm/index.d.ts +0 -50
  387. package/src/conversion/node_modules/rimraf/dist/esm/index.d.ts.map +0 -1
  388. package/src/conversion/node_modules/rimraf/dist/esm/index.js +0 -70
  389. package/src/conversion/node_modules/rimraf/dist/esm/index.js.map +0 -1
  390. package/src/conversion/node_modules/rimraf/dist/esm/opt-arg.d.ts +0 -34
  391. package/src/conversion/node_modules/rimraf/dist/esm/opt-arg.d.ts.map +0 -1
  392. package/src/conversion/node_modules/rimraf/dist/esm/opt-arg.js +0 -46
  393. package/src/conversion/node_modules/rimraf/dist/esm/opt-arg.js.map +0 -1
  394. package/src/conversion/node_modules/rimraf/dist/esm/package.json +0 -3
  395. package/src/conversion/node_modules/rimraf/dist/esm/path-arg.d.ts +0 -4
  396. package/src/conversion/node_modules/rimraf/dist/esm/path-arg.d.ts.map +0 -1
  397. package/src/conversion/node_modules/rimraf/dist/esm/path-arg.js +0 -46
  398. package/src/conversion/node_modules/rimraf/dist/esm/path-arg.js.map +0 -1
  399. package/src/conversion/node_modules/rimraf/dist/esm/readdir-or-error.d.ts +0 -3
  400. package/src/conversion/node_modules/rimraf/dist/esm/readdir-or-error.d.ts.map +0 -1
  401. package/src/conversion/node_modules/rimraf/dist/esm/readdir-or-error.js +0 -14
  402. package/src/conversion/node_modules/rimraf/dist/esm/readdir-or-error.js.map +0 -1
  403. package/src/conversion/node_modules/rimraf/dist/esm/retry-busy.d.ts +0 -8
  404. package/src/conversion/node_modules/rimraf/dist/esm/retry-busy.d.ts.map +0 -1
  405. package/src/conversion/node_modules/rimraf/dist/esm/retry-busy.js +0 -60
  406. package/src/conversion/node_modules/rimraf/dist/esm/retry-busy.js.map +0 -1
  407. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-manual.d.ts +0 -3
  408. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-manual.d.ts.map +0 -1
  409. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-manual.js +0 -5
  410. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-manual.js.map +0 -1
  411. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts +0 -4
  412. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts.map +0 -1
  413. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-move-remove.js +0 -133
  414. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-move-remove.js.map +0 -1
  415. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-native.d.ts +0 -4
  416. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-native.d.ts.map +0 -1
  417. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-native.js +0 -19
  418. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-native.js.map +0 -1
  419. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-posix.d.ts +0 -4
  420. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-posix.d.ts.map +0 -1
  421. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-posix.js +0 -98
  422. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-posix.js.map +0 -1
  423. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-windows.d.ts +0 -4
  424. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-windows.d.ts.map +0 -1
  425. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-windows.js +0 -154
  426. package/src/conversion/node_modules/rimraf/dist/esm/rimraf-windows.js.map +0 -1
  427. package/src/conversion/node_modules/rimraf/dist/esm/use-native.d.ts +0 -4
  428. package/src/conversion/node_modules/rimraf/dist/esm/use-native.d.ts.map +0 -1
  429. package/src/conversion/node_modules/rimraf/dist/esm/use-native.js +0 -15
  430. package/src/conversion/node_modules/rimraf/dist/esm/use-native.js.map +0 -1
  431. package/src/conversion/node_modules/rimraf/package.json +0 -92
  432. package/src/conversion/package.json +0 -154
  433. package/src/conversion/src/docs/index.md +0 -52
  434. package/src/conversion/src/ts/converter.ts +0 -85
  435. package/src/conversion/src/ts/fixedPoint/index.ts +0 -87
  436. package/src/conversion/src/ts/index.ts +0 -500
  437. package/src/conversion/test/bigintToBase64.test.ts +0 -37
  438. package/src/conversion/test/bigintToBuf.test.ts +0 -43
  439. package/src/conversion/test/bigintToHex.test.ts +0 -52
  440. package/src/conversion/test/bigintToText.test.ts +0 -30
  441. package/src/conversion/test/bufToBigint.test.ts +0 -20
  442. package/src/conversion/test/hexToBigint.test.ts +0 -22
  443. package/src/conversion/test/hexToBuf.test.ts +0 -39
  444. package/src/conversion/test/parseHex.test.ts +0 -35
  445. package/src/conversion/test/setup.test.ts +0 -9
  446. package/src/conversion/test/textToBuf.test.ts +0 -26
  447. package/src/conversion/tsconfig.json +0 -57
  448. package/src/conversion/typedoc.json +0 -5
  449. package/src/conversion/vite.config.ts +0 -47
  450. package/src/conversion/vitest.config.ts +0 -15
  451. package/src/index.bench.ts +0 -206
  452. package/src/index.spec.ts +0 -318
  453. package/src/index.ts +0 -343
@@ -1,178 +0,0 @@
1
- import * as b64 from '@juanelas/base64';
2
- export let isNative = false;
3
- let converter;
4
- const IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
5
- if (!process.browser) {
6
- try {
7
- converter = require('bindings')('bigint_buffer');
8
- isNative = converter !== undefined;
9
- }
10
- catch (e) {
11
- console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
12
- }
13
- }
14
- else {
15
- converter = {
16
- toBigInt: (buf) => BigInt('0x' + Buffer.from(buf).toString('hex')),
17
- fromBigInt: (num) => Buffer.from(num.toString(16), 'hex')
18
- };
19
- }
20
- export function toBigIntLE(buf) {
21
- if (process.browser || converter === undefined) {
22
- const reversed = Buffer.from(buf);
23
- reversed.reverse();
24
- const hex = reversed.toString('hex');
25
- if (hex.length === 0) {
26
- return BigInt(0);
27
- }
28
- return BigInt(`0x${hex}`);
29
- }
30
- return converter.toBigInt(buf, false);
31
- }
32
- export function validateBigIntBuffer() {
33
- try {
34
- const test = toBigIntLE(Buffer.from([0x01, 0x00]));
35
- return test === BigInt(1);
36
- }
37
- catch {
38
- return false;
39
- }
40
- }
41
- export function toBigIntBE(buf) {
42
- if (process.browser || converter === undefined) {
43
- const hex = buf.toString('hex');
44
- if (hex.length === 0) {
45
- return BigInt(0);
46
- }
47
- return BigInt(`0x${hex}`);
48
- }
49
- return converter.toBigInt(buf, true);
50
- }
51
- export function toBufferLE(num, width) {
52
- if (process.browser || converter === undefined) {
53
- const hex = num.toString(16);
54
- const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
55
- buffer.reverse();
56
- return buffer;
57
- }
58
- return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
59
- }
60
- export function toBufferBE(num, width) {
61
- if (process.browser || converter === undefined) {
62
- const hex = num.toString(16);
63
- return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
64
- }
65
- return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
66
- }
67
- export function parseHex(a, prefix0x = false, byteLength) {
68
- const hexMatch = a.match(/^(0x)?([\da-fA-F]+)$/);
69
- if (hexMatch == null) {
70
- throw new RangeError('input must be a hexadecimal string, e.g. \'0x124fe3a\' or \'0214f1b2\'');
71
- }
72
- let hex = hexMatch[2];
73
- if (byteLength !== undefined) {
74
- if (byteLength < hex.length / 2) {
75
- throw new RangeError(`expected byte length ${byteLength} < input hex byte length ${Math.ceil(hex.length / 2)}`);
76
- }
77
- hex = hex.padStart(byteLength * 2, '0');
78
- }
79
- return (prefix0x) ? '0x' + hex : hex;
80
- }
81
- export function bigintToBuf(a, returnArrayBuffer = false) {
82
- if (a < 0)
83
- throw RangeError('a should be a non-negative integer. Negative values are not supported');
84
- return hexToBuf(bigintToHex(a), returnArrayBuffer);
85
- }
86
- export function bufToBigint(buf) {
87
- let bits = 8n;
88
- if (ArrayBuffer.isView(buf))
89
- bits = BigInt(buf.BYTES_PER_ELEMENT * 8);
90
- else
91
- buf = new Uint8Array(buf);
92
- let ret = 0n;
93
- for (const i of (buf).values()) {
94
- const bi = BigInt(i);
95
- ret = (ret << bits) + bi;
96
- }
97
- return ret;
98
- }
99
- export function bigintToHex(a, prefix0x = false, byteLength) {
100
- if (a < 0)
101
- throw RangeError('a should be a non-negative integer. Negative values are not supported');
102
- return parseHex(a.toString(16), prefix0x, byteLength);
103
- }
104
- export function hexToBigint(hexStr) {
105
- return BigInt(parseHex(hexStr, true));
106
- }
107
- export function bigintToText(a) {
108
- if (a < 0)
109
- throw RangeError('a should be a non-negative integer. Negative values are not supported');
110
- return bufToText(hexToBuf(a.toString(16)));
111
- }
112
- export function textToBigint(text) {
113
- return hexToBigint(bufToHex(textToBuf(text)));
114
- }
115
- function toBuffer(input) {
116
- if (Buffer.isBuffer(input))
117
- return input;
118
- if (ArrayBuffer.isView(input)) {
119
- return Buffer.from(input.buffer, input.byteOffset, input.byteLength);
120
- }
121
- if (input instanceof ArrayBuffer) {
122
- return Buffer.from(new Uint8Array(input));
123
- }
124
- throw new TypeError('Unsupported input type for Buffer.from');
125
- }
126
- export function bufToText(buf) {
127
- const input = toBuffer(buf);
128
- if (IS_BROWSER)
129
- return new TextDecoder().decode(new Uint8Array(input));
130
- else
131
- return Buffer.from(input).toString();
132
- }
133
- export function textToBuf(str, returnArrayBuffer = false) {
134
- if (!IS_BROWSER && !returnArrayBuffer) {
135
- return Buffer.from(new TextEncoder().encode(str).buffer);
136
- }
137
- return new TextEncoder().encode(str).buffer;
138
- }
139
- export function bufToHex(buf, prefix0x = false, byteLength) {
140
- if (IS_BROWSER) {
141
- let s = '';
142
- const h = '0123456789abcdef';
143
- if (ArrayBuffer.isView(buf))
144
- buf = new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
145
- else
146
- buf = new Uint8Array(buf);
147
- buf.forEach((v) => {
148
- s += h[v >> 4] + h[v & 15];
149
- });
150
- return parseHex(s, prefix0x, byteLength);
151
- }
152
- else {
153
- const input = toBuffer(buf);
154
- if (ArrayBuffer.isView(input))
155
- buf = new Uint8Array(input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength));
156
- return parseHex(Buffer.from(input).toString('hex'), prefix0x, byteLength);
157
- }
158
- }
159
- export function hexToBuf(hexStr, returnArrayBuffer = false) {
160
- let hex = parseHex(hexStr);
161
- hex = parseHex(hexStr, false, Math.ceil(hex.length / 2));
162
- if (IS_BROWSER) {
163
- return Uint8Array.from(hex.match(/[\da-fA-F]{2}/g).map((h) => {
164
- return parseInt(h, 16);
165
- })).buffer;
166
- }
167
- else {
168
- const b = Buffer.from(hex, 'hex');
169
- return returnArrayBuffer ? b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) : b;
170
- }
171
- }
172
- export function bigintToBase64(a, urlsafe = false, padding = true) {
173
- return b64.encode(bigintToBuf(a), urlsafe, padding);
174
- }
175
- export function base64ToBigint(a) {
176
- return bufToBigint(b64.decode(a));
177
- }
178
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../OneDrive/Documents/tests/bigint-buffer/src/conversion/src/ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAA;AASvC,MAAM,CAAC,IAAI,QAAQ,GAAG,KAAK,CAAA;AAC3B,IAAI,SAA6B,CAAA;AAEjC,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAA;AAE1F,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC;QAEH,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,CAAA;QAChD,QAAQ,GAAG,SAAS,KAAK,SAAS,CAAA;IACpC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC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AAA;IACxD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5D,OAAO,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IACZ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACjC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1F,CAAC;AACH,CAAC;AAYD,MAAM,UAAU,cAAc,CAAE,CAAS,EAAE,UAAmB,KAAK,EAAE,UAAmB,IAAI;IAC1F,OAAO,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC;AAOD,MAAM,UAAU,cAAc,CAAE,CAAS;IACvC,OAAO,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC","sourcesContent":["import * as b64 from '@juanelas/base64'\n\ninterface ConverterInterface {\n toBigInt: (buf: Buffer, bigEndian?: boolean) => bigint\n fromBigInt: (num: bigint, buf: Buffer, bigEndian?: boolean) => Buffer\n}\n\ndeclare let process: { browser: boolean }\n\nexport let isNative = false\nlet converter: ConverterInterface\n\nconst IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined'\n\nif (!process.browser) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n converter = require('bindings')('bigint_buffer')\n isNative = converter !== undefined\n } catch (e) {\n console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)')\n }\n} else {\n // fallback to pure JS if needed\n converter = {\n toBigInt: (buf: Buffer) => BigInt('0x' + Buffer.from(buf).toString('hex')),\n fromBigInt: (num: bigint) => Buffer.from(num.toString(16), 'hex')\n }\n}\n\n/**\n * Convert a little-endian buffer into a BigInt.\n * @param buf The little-endian buffer to convert\n * @returns A BigInt with the little-endian representation of buf.\n */\nexport function toBigIntLE (buf: Buffer): bigint {\n if (process.browser || converter === undefined) {\n const reversed = Buffer.from(buf)\n reversed.reverse()\n const hex = reversed.toString('hex')\n if (hex.length === 0) {\n return BigInt(0)\n }\n return BigInt(`0x${hex}`)\n }\n return converter.toBigInt(buf, false)\n}\n\nexport function validateBigIntBuffer (): boolean {\n try {\n const test = toBigIntLE(Buffer.from([0x01, 0x00]))\n return test === BigInt(1)\n } catch {\n return false\n }\n}\n\n/**\n * Convert a big-endian buffer into a BigInt\n * @param buf The big-endian buffer to convert.\n * @returns A BigInt with the big-endian representation of buf.\n */\nexport function toBigIntBE (buf: Buffer): bigint {\n if (process.browser || converter === undefined) {\n const hex = buf.toString('hex')\n if (hex.length === 0) {\n return BigInt(0)\n }\n return BigInt(`0x${hex}`)\n }\n return converter.toBigInt(buf, true)\n}\n\n/**\n * Convert a BigInt to a little-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A little-endian buffer representation of num.\n */\nexport function toBufferLE (num: bigint, width: number): Buffer {\n if (process.browser || converter === undefined) {\n const hex = num.toString(16)\n const buffer =\n Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex')\n buffer.reverse()\n return buffer\n }\n // Allocation is done here, since it is slower using napi in C\n return converter.fromBigInt(num, Buffer.allocUnsafe(width), false)\n}\n\n/**\n * Convert a BigInt to a big-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A big-endian buffer representation of num.\n */\nexport function toBufferBE (num: bigint, width: number): Buffer {\n if (process.browser || converter === undefined) {\n const hex = num.toString(16)\n return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex')\n }\n return converter.fromBigInt(num, Buffer.allocUnsafe(width), true)\n}\n\nexport type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array\n\n/**\n * Parses a hexadecimal string for correctness and returns it with or without '0x' prefix, and/or with the specified byte length\n * @param a - the string with an hexadecimal number to be parsed\n * @param prefix0x - set to true to prefix the output with '0x'\n * @param byteLength - pad the output to have the desired byte length. Notice that the hex length is double the byte length.\n *\n * @returns\n *\n * @throws {@link RangeError} if input string does not hold an hexadecimal number\n * @throws {@link RangeError} if requested byte length is less than the input byte length\n */\nexport function parseHex (a: string, prefix0x: boolean = false, byteLength?: number): string {\n const hexMatch = a.match(/^(0x)?([\\da-fA-F]+)$/)\n if (hexMatch == null) {\n throw new RangeError('input must be a hexadecimal string, e.g. \\'0x124fe3a\\' or \\'0214f1b2\\'')\n }\n let hex = hexMatch[2]\n if (byteLength !== undefined) {\n if (byteLength < hex.length / 2) {\n throw new RangeError(`expected byte length ${byteLength} < input hex byte length ${Math.ceil(hex.length / 2)}`)\n }\n hex = hex.padStart(byteLength * 2, '0')\n }\n return (prefix0x) ? '0x' + hex : hex\n}\n\n/**\n * Converts an arbitrary-size non-negative bigint to an ArrayBuffer or a Buffer (default for Node.js)\n *\n * @param a\n * @param returnArrayBuffer - In Node.js, it forces the output to be an ArrayBuffer instead of a Buffer.\n *\n * @returns an ArrayBuffer or a Buffer with a binary representation of the input bigint\n *\n * @throws {@link RangeError} if a < 0.\n */\nexport function bigintToBuf (a: bigint, returnArrayBuffer: boolean = false): ArrayBuffer | Buffer {\n if (a < 0) throw RangeError('a should be a non-negative integer. Negative values are not supported')\n return hexToBuf(bigintToHex(a), returnArrayBuffer)\n}\n\n/**\n * Converts an ArrayBuffer, TypedArray or Buffer (node.js) to a bigint\n * @param buf\n * @returns a bigint\n */\nexport function bufToBigint (buf: ArrayBuffer | TypedArray | Buffer): bigint {\n let bits = 8n\n if (ArrayBuffer.isView(buf)) bits = BigInt(buf.BYTES_PER_ELEMENT * 8)\n else buf = new Uint8Array(buf)\n\n let ret = 0n\n for (const i of (buf).values()) {\n const bi = BigInt(i)\n ret = (ret << bits) + bi\n }\n return ret\n}\n\n/**\n * Converts a non-negative bigint to a hexadecimal string\n * @param a - a non negative bigint\n * @param prefix0x - set to true to prefix the output with '0x'\n * @param byteLength - pad the output to have the desired byte length. Notice that the hex length is double the byte length.\n *\n * @returns hexadecimal representation of the input bigint\n *\n * @throws {@link RangeError} if a < 0\n */\nexport function bigintToHex (a: bigint, prefix0x: boolean = false, byteLength?: number): string {\n if (a < 0) throw RangeError('a should be a non-negative integer. Negative values are not supported')\n return parseHex(a.toString(16), prefix0x, byteLength)\n}\n\n/**\n * Converts a hexadecimal string to a bigint\n *\n * @param hexStr\n *\n * @returns a bigint\n *\n * @throws {@link RangeError} if input string does not hold an hexadecimal number\n */\nexport function hexToBigint (hexStr: string): bigint {\n return BigInt(parseHex(hexStr, true))\n}\n\n/**\n * Converts a non-negative bigint representing a binary array of utf-8 encoded text to a string of utf-8 text\n *\n * @param a - A non-negative bigint representing a binary array of utf-8 encoded text.\n *\n * @returns a string text with utf-8 encoding\n *\n * @throws {@link RangeError} if a < 0.\n */\nexport function bigintToText (a: bigint): string {\n if (a < 0) throw RangeError('a should be a non-negative integer. Negative values are not supported')\n return bufToText(hexToBuf(a.toString(16)))\n}\n\n/**\n * Converts a utf-8 string to a bigint (from its binary representaion)\n *\n * @param text - A string text with utf-8 encoding\n *\n * @returns a bigint representing a binary array of the input utf-8 encoded text\n */\nexport function textToBigint (text: string): bigint {\n return hexToBigint(bufToHex(textToBuf(text)))\n}\nfunction toBuffer (input: ArrayBuffer | TypedArray | Buffer): Buffer {\n if (Buffer.isBuffer(input)) return input\n\n if (ArrayBuffer.isView(input)) {\n return Buffer.from(input.buffer, input.byteOffset, input.byteLength)\n }\n\n if (input instanceof ArrayBuffer) {\n return Buffer.from(new Uint8Array(input))\n }\n\n throw new TypeError('Unsupported input type for Buffer.from')\n}\n/**\n * Converts an ArrayBuffer, TypedArray or Buffer (in Node.js) containing utf-8 encoded text to a string of utf-8 text\n *\n * @param buf - A buffer containing utf-8 encoded text\n *\n * @returns a string text with utf-8 encoding\n */\nexport function bufToText (buf: ArrayBuffer | TypedArray | Buffer): string {\n const input = toBuffer(buf)\n if (IS_BROWSER) return new TextDecoder().decode(new Uint8Array(input))\n else return Buffer.from(input).toString()\n}\n\n/**\n * Converts a string of utf-8 encoded text to an ArrayBuffer or a Buffer (default in Node.js)\n *\n * @param str - A string of text (with utf-8 encoding)\n * @param returnArrayBuffer - When invoked in Node.js, it can force the output to be an ArrayBuffer instead of a Buffer.\n *\n * @returns an ArrayBuffer or a Buffer containing the utf-8 encoded text\n */\nexport function textToBuf (str: string, returnArrayBuffer: boolean = false): ArrayBuffer | Buffer {\n if (!IS_BROWSER && !returnArrayBuffer) {\n return Buffer.from(new TextEncoder().encode(str).buffer)\n }\n return new TextEncoder().encode(str).buffer\n}\n\n/**\n * Returns the hexadecimal representation of a buffer.\n *\n * @param buf\n * @param prefix0x - set to true to prefix the output with '0x'\n * @param byteLength - pad the output to have the desired byte length. Notice that the hex length is double the byte length.\n *\n * @returns a string with a hexadecimal representation of the input buffer\n */\nexport function bufToHex (buf: ArrayBuffer | TypedArray | Buffer, prefix0x: boolean = false, byteLength?: number): string {\n if (IS_BROWSER) {\n let s = ''\n const h = '0123456789abcdef'\n if (ArrayBuffer.isView(buf)) buf = new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength))\n else buf = new Uint8Array(buf);\n\n (buf as Uint8Array).forEach((v) => {\n s += h[v >> 4] + h[v & 15]\n })\n\n return parseHex(s, prefix0x, byteLength)\n } else {\n const input = toBuffer(buf)\n if (ArrayBuffer.isView(input)) buf = new Uint8Array(input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength))\n return parseHex(Buffer.from(input).toString('hex'), prefix0x, byteLength)\n }\n}\n\n/**\n * Converts a hexadecimal string to a buffer\n *\n * @param hexStr - A string representing a number with hexadecimal notation\n * @param returnArrayBuffer - In Node.js, it forces the output to be an ArrayBuffer instead of a Buffer.\n *\n * @returns An ArrayBuffer or a Buffer\n *\n * @throws {@link RangeError} if input string does not hold an hexadecimal number\n */\nexport function hexToBuf (hexStr: string, returnArrayBuffer: boolean = false): ArrayBuffer | Buffer {\n let hex = parseHex(hexStr)\n hex = parseHex(hexStr, false, Math.ceil(hex.length / 2)) // pad to have a length in bytes\n if (IS_BROWSER) {\n return Uint8Array.from(hex.match(/[\\da-fA-F]{2}/g)!.map((h) => { // eslint-disable-line\n return parseInt(h, 16)\n })).buffer\n } else {\n const b = Buffer.from(hex, 'hex')\n return returnArrayBuffer ? b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) : b\n }\n}\n\n/**\n * Converts an arbitrary-size non-negative bigint to a base64 string\n * @param a - a non negative bigint\n * @param urlsafe - if true Base64 URL encoding is used ('+' and '/' are replaced by '-', '_')\n * @param padding - if false, padding (trailing '=') is removed\n * @returns a base64 representation of the input bigint\n *\n * @throws {RangeError}\n * Thrown if a < 0\n */\nexport function bigintToBase64 (a: bigint, urlsafe: boolean = false, padding: boolean = true): string {\n return b64.encode(bigintToBuf(a), urlsafe, padding)\n}\n\n/**\n * Converts a base64 string to bigint.\n * @param a base64 string. It accepts standard and URL-safe base64 with and without padding\n * @returns a bigint\n */\nexport function base64ToBigint (a: string): bigint {\n return bufToBigint(b64.decode(a))\n}\n"]}
@@ -1,178 +0,0 @@
1
- import * as b64 from '@juanelas/base64';
2
- export let isNative = false;
3
- let converter;
4
- const IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
5
- if (!process.browser) {
6
- try {
7
- converter = require('bindings')('bigint_buffer');
8
- isNative = converter !== undefined;
9
- }
10
- catch (e) {
11
- console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
12
- }
13
- }
14
- else {
15
- converter = {
16
- toBigInt: (buf) => BigInt('0x' + Buffer.from(buf).toString('hex')),
17
- fromBigInt: (num) => Buffer.from(num.toString(16), 'hex')
18
- };
19
- }
20
- export function toBigIntLE(buf) {
21
- if (process.browser || converter === undefined) {
22
- const reversed = Buffer.from(buf);
23
- reversed.reverse();
24
- const hex = reversed.toString('hex');
25
- if (hex.length === 0) {
26
- return BigInt(0);
27
- }
28
- return BigInt(`0x${hex}`);
29
- }
30
- return converter.toBigInt(buf, false);
31
- }
32
- export function validateBigIntBuffer() {
33
- try {
34
- const test = toBigIntLE(Buffer.from([0x01, 0x00]));
35
- return test === BigInt(1);
36
- }
37
- catch {
38
- return false;
39
- }
40
- }
41
- export function toBigIntBE(buf) {
42
- if (process.browser || converter === undefined) {
43
- const hex = buf.toString('hex');
44
- if (hex.length === 0) {
45
- return BigInt(0);
46
- }
47
- return BigInt(`0x${hex}`);
48
- }
49
- return converter.toBigInt(buf, true);
50
- }
51
- export function toBufferLE(num, width) {
52
- if (process.browser || converter === undefined) {
53
- const hex = num.toString(16);
54
- const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
55
- buffer.reverse();
56
- return buffer;
57
- }
58
- return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
59
- }
60
- export function toBufferBE(num, width) {
61
- if (process.browser || converter === undefined) {
62
- const hex = num.toString(16);
63
- return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
64
- }
65
- return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
66
- }
67
- export function parseHex(a, prefix0x = false, byteLength) {
68
- const hexMatch = a.match(/^(0x)?([\da-fA-F]+)$/);
69
- if (hexMatch == null) {
70
- throw new RangeError('input must be a hexadecimal string, e.g. \'0x124fe3a\' or \'0214f1b2\'');
71
- }
72
- let hex = hexMatch[2];
73
- if (byteLength !== undefined) {
74
- if (byteLength < hex.length / 2) {
75
- throw new RangeError(`expected byte length ${byteLength} < input hex byte length ${Math.ceil(hex.length / 2)}`);
76
- }
77
- hex = hex.padStart(byteLength * 2, '0');
78
- }
79
- return (prefix0x) ? '0x' + hex : hex;
80
- }
81
- export function bigintToBuf(a, returnArrayBuffer = false) {
82
- if (a < 0)
83
- throw RangeError('a should be a non-negative integer. Negative values are not supported');
84
- return hexToBuf(bigintToHex(a), returnArrayBuffer);
85
- }
86
- export function bufToBigint(buf) {
87
- let bits = 8n;
88
- if (ArrayBuffer.isView(buf))
89
- bits = BigInt(buf.BYTES_PER_ELEMENT * 8);
90
- else
91
- buf = new Uint8Array(buf);
92
- let ret = 0n;
93
- for (const i of (buf).values()) {
94
- const bi = BigInt(i);
95
- ret = (ret << bits) + bi;
96
- }
97
- return ret;
98
- }
99
- export function bigintToHex(a, prefix0x = false, byteLength) {
100
- if (a < 0)
101
- throw RangeError('a should be a non-negative integer. Negative values are not supported');
102
- return parseHex(a.toString(16), prefix0x, byteLength);
103
- }
104
- export function hexToBigint(hexStr) {
105
- return BigInt(parseHex(hexStr, true));
106
- }
107
- export function bigintToText(a) {
108
- if (a < 0)
109
- throw RangeError('a should be a non-negative integer. Negative values are not supported');
110
- return bufToText(hexToBuf(a.toString(16)));
111
- }
112
- export function textToBigint(text) {
113
- return hexToBigint(bufToHex(textToBuf(text)));
114
- }
115
- function toBuffer(input) {
116
- if (Buffer.isBuffer(input))
117
- return input;
118
- if (ArrayBuffer.isView(input)) {
119
- return Buffer.from(input.buffer, input.byteOffset, input.byteLength);
120
- }
121
- if (input instanceof ArrayBuffer) {
122
- return Buffer.from(new Uint8Array(input));
123
- }
124
- throw new TypeError('Unsupported input type for Buffer.from');
125
- }
126
- export function bufToText(buf) {
127
- const input = toBuffer(buf);
128
- if (IS_BROWSER)
129
- return new TextDecoder().decode(new Uint8Array(input));
130
- else
131
- return Buffer.from(input).toString();
132
- }
133
- export function textToBuf(str, returnArrayBuffer = false) {
134
- if (!IS_BROWSER && !returnArrayBuffer) {
135
- return Buffer.from(new TextEncoder().encode(str).buffer);
136
- }
137
- return new TextEncoder().encode(str).buffer;
138
- }
139
- export function bufToHex(buf, prefix0x = false, byteLength) {
140
- if (IS_BROWSER) {
141
- let s = '';
142
- const h = '0123456789abcdef';
143
- if (ArrayBuffer.isView(buf))
144
- buf = new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
145
- else
146
- buf = new Uint8Array(buf);
147
- buf.forEach((v) => {
148
- s += h[v >> 4] + h[v & 15];
149
- });
150
- return parseHex(s, prefix0x, byteLength);
151
- }
152
- else {
153
- const input = toBuffer(buf);
154
- if (ArrayBuffer.isView(input))
155
- buf = new Uint8Array(input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength));
156
- return parseHex(Buffer.from(input).toString('hex'), prefix0x, byteLength);
157
- }
158
- }
159
- export function hexToBuf(hexStr, returnArrayBuffer = false) {
160
- let hex = parseHex(hexStr);
161
- hex = parseHex(hexStr, false, Math.ceil(hex.length / 2));
162
- if (IS_BROWSER) {
163
- return Uint8Array.from(hex.match(/[\da-fA-F]{2}/g).map((h) => {
164
- return parseInt(h, 16);
165
- })).buffer;
166
- }
167
- else {
168
- const b = Buffer.from(hex, 'hex');
169
- return returnArrayBuffer ? b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) : b;
170
- }
171
- }
172
- export function bigintToBase64(a, urlsafe = false, padding = true) {
173
- return b64.encode(bigintToBuf(a), urlsafe, padding);
174
- }
175
- export function base64ToBigint(a) {
176
- return bufToBigint(b64.decode(a));
177
- }
178
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../OneDrive/Documents/tests/bigint-buffer/src/conversion/src/ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAA;AASvC,MAAM,CAAC,IAAI,QAAQ,GAAG,KAAK,CAAA;AAC3B,IAAI,SAA6B,CAAA;AAEjC,MAAM,U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?: boolean) => bigint\n fromBigInt: (num: bigint, buf: Buffer, bigEndian?: boolean) => Buffer\n}\n\ndeclare let process: { browser: boolean }\n\nexport let isNative = false\nlet converter: ConverterInterface\n\nconst IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined'\n\nif (!process.browser) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n converter = require('bindings')('bigint_buffer')\n isNative = converter !== undefined\n } catch (e) {\n console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)')\n }\n} else {\n // fallback to pure JS if needed\n converter = {\n toBigInt: (buf: Buffer) => BigInt('0x' + Buffer.from(buf).toString('hex')),\n fromBigInt: (num: bigint) => Buffer.from(num.toString(16), 'hex')\n }\n}\n\n/**\n * Convert a little-endian buffer into a BigInt.\n * @param buf The little-endian buffer to convert\n * @returns A BigInt with the little-endian representation of buf.\n */\nexport function toBigIntLE (buf: Buffer): bigint {\n if (process.browser || converter === undefined) {\n const reversed = Buffer.from(buf)\n reversed.reverse()\n const hex = reversed.toString('hex')\n if (hex.length === 0) {\n return BigInt(0)\n }\n return BigInt(`0x${hex}`)\n }\n return converter.toBigInt(buf, false)\n}\n\nexport function validateBigIntBuffer (): boolean {\n try {\n const test = toBigIntLE(Buffer.from([0x01, 0x00]))\n return test === BigInt(1)\n } catch {\n return false\n }\n}\n\n/**\n * Convert a big-endian buffer into a BigInt\n * @param buf The big-endian buffer to convert.\n * @returns A BigInt with the big-endian representation of buf.\n */\nexport function toBigIntBE (buf: Buffer): bigint {\n if (process.browser || converter === undefined) {\n const hex = buf.toString('hex')\n if (hex.length === 0) {\n return BigInt(0)\n }\n return BigInt(`0x${hex}`)\n }\n return converter.toBigInt(buf, true)\n}\n\n/**\n * Convert a BigInt to a little-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A little-endian buffer representation of num.\n */\nexport function toBufferLE (num: bigint, width: number): Buffer {\n if (process.browser || converter === undefined) {\n const hex = num.toString(16)\n const buffer =\n Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex')\n buffer.reverse()\n return buffer\n }\n // Allocation is done here, since it is slower using napi in C\n return converter.fromBigInt(num, Buffer.allocUnsafe(width), false)\n}\n\n/**\n * Convert a BigInt to a big-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A big-endian buffer representation of num.\n */\nexport function toBufferBE (num: bigint, width: number): Buffer {\n if (process.browser || converter === undefined) {\n const hex = num.toString(16)\n return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex')\n }\n return converter.fromBigInt(num, Buffer.allocUnsafe(width), true)\n}\n\nexport type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array\n\n/**\n * Parses a hexadecimal string for correctness and returns it with or without '0x' prefix, and/or with the specified byte length\n * @param a - the string with an hexadecimal number to be parsed\n * @param prefix0x - set to true to prefix the output with '0x'\n * @param byteLength - pad the output to have the desired byte length. Notice that the hex length is double the byte length.\n *\n * @returns\n *\n * @throws {@link RangeError} if input string does not hold an hexadecimal number\n * @throws {@link RangeError} if requested byte length is less than the input byte length\n */\nexport function parseHex (a: string, prefix0x: boolean = false, byteLength?: number): string {\n const hexMatch = a.match(/^(0x)?([\\da-fA-F]+)$/)\n if (hexMatch == null) {\n throw new RangeError('input must be a hexadecimal string, e.g. \\'0x124fe3a\\' or \\'0214f1b2\\'')\n }\n let hex = hexMatch[2]\n if (byteLength !== undefined) {\n if (byteLength < hex.length / 2) {\n throw new RangeError(`expected byte length ${byteLength} < input hex byte length ${Math.ceil(hex.length / 2)}`)\n }\n hex = hex.padStart(byteLength * 2, '0')\n }\n return (prefix0x) ? '0x' + hex : hex\n}\n\n/**\n * Converts an arbitrary-size non-negative bigint to an ArrayBuffer or a Buffer (default for Node.js)\n *\n * @param a\n * @param returnArrayBuffer - In Node.js, it forces the output to be an ArrayBuffer instead of a Buffer.\n *\n * @returns an ArrayBuffer or a Buffer with a binary representation of the input bigint\n *\n * @throws {@link RangeError} if a < 0.\n */\nexport function bigintToBuf (a: bigint, returnArrayBuffer: boolean = false): ArrayBuffer | Buffer {\n if (a < 0) throw RangeError('a should be a non-negative integer. Negative values are not supported')\n return hexToBuf(bigintToHex(a), returnArrayBuffer)\n}\n\n/**\n * Converts an ArrayBuffer, TypedArray or Buffer (node.js) to a bigint\n * @param buf\n * @returns a bigint\n */\nexport function bufToBigint (buf: ArrayBuffer | TypedArray | Buffer): bigint {\n let bits = 8n\n if (ArrayBuffer.isView(buf)) bits = BigInt(buf.BYTES_PER_ELEMENT * 8)\n else buf = new Uint8Array(buf)\n\n let ret = 0n\n for (const i of (buf).values()) {\n const bi = BigInt(i)\n ret = (ret << bits) + bi\n }\n return ret\n}\n\n/**\n * Converts a non-negative bigint to a hexadecimal string\n * @param a - a non negative bigint\n * @param prefix0x - set to true to prefix the output with '0x'\n * @param byteLength - pad the output to have the desired byte length. Notice that the hex length is double the byte length.\n *\n * @returns hexadecimal representation of the input bigint\n *\n * @throws {@link RangeError} if a < 0\n */\nexport function bigintToHex (a: bigint, prefix0x: boolean = false, byteLength?: number): string {\n if (a < 0) throw RangeError('a should be a non-negative integer. Negative values are not supported')\n return parseHex(a.toString(16), prefix0x, byteLength)\n}\n\n/**\n * Converts a hexadecimal string to a bigint\n *\n * @param hexStr\n *\n * @returns a bigint\n *\n * @throws {@link RangeError} if input string does not hold an hexadecimal number\n */\nexport function hexToBigint (hexStr: string): bigint {\n return BigInt(parseHex(hexStr, true))\n}\n\n/**\n * Converts a non-negative bigint representing a binary array of utf-8 encoded text to a string of utf-8 text\n *\n * @param a - A non-negative bigint representing a binary array of utf-8 encoded text.\n *\n * @returns a string text with utf-8 encoding\n *\n * @throws {@link RangeError} if a < 0.\n */\nexport function bigintToText (a: bigint): string {\n if (a < 0) throw RangeError('a should be a non-negative integer. Negative values are not supported')\n return bufToText(hexToBuf(a.toString(16)))\n}\n\n/**\n * Converts a utf-8 string to a bigint (from its binary representaion)\n *\n * @param text - A string text with utf-8 encoding\n *\n * @returns a bigint representing a binary array of the input utf-8 encoded text\n */\nexport function textToBigint (text: string): bigint {\n return hexToBigint(bufToHex(textToBuf(text)))\n}\nfunction toBuffer (input: ArrayBuffer | TypedArray | Buffer): Buffer {\n if (Buffer.isBuffer(input)) return input\n\n if (ArrayBuffer.isView(input)) {\n return Buffer.from(input.buffer, input.byteOffset, input.byteLength)\n }\n\n if (input instanceof ArrayBuffer) {\n return Buffer.from(new Uint8Array(input))\n }\n\n throw new TypeError('Unsupported input type for Buffer.from')\n}\n/**\n * Converts an ArrayBuffer, TypedArray or Buffer (in Node.js) containing utf-8 encoded text to a string of utf-8 text\n *\n * @param buf - A buffer containing utf-8 encoded text\n *\n * @returns a string text with utf-8 encoding\n */\nexport function bufToText (buf: ArrayBuffer | TypedArray | Buffer): string {\n const input = toBuffer(buf)\n if (IS_BROWSER) return new TextDecoder().decode(new Uint8Array(input))\n else return Buffer.from(input).toString()\n}\n\n/**\n * Converts a string of utf-8 encoded text to an ArrayBuffer or a Buffer (default in Node.js)\n *\n * @param str - A string of text (with utf-8 encoding)\n * @param returnArrayBuffer - When invoked in Node.js, it can force the output to be an ArrayBuffer instead of a Buffer.\n *\n * @returns an ArrayBuffer or a Buffer containing the utf-8 encoded text\n */\nexport function textToBuf (str: string, returnArrayBuffer: boolean = false): ArrayBuffer | Buffer {\n if (!IS_BROWSER && !returnArrayBuffer) {\n return Buffer.from(new TextEncoder().encode(str).buffer)\n }\n return new TextEncoder().encode(str).buffer\n}\n\n/**\n * Returns the hexadecimal representation of a buffer.\n *\n * @param buf\n * @param prefix0x - set to true to prefix the output with '0x'\n * @param byteLength - pad the output to have the desired byte length. Notice that the hex length is double the byte length.\n *\n * @returns a string with a hexadecimal representation of the input buffer\n */\nexport function bufToHex (buf: ArrayBuffer | TypedArray | Buffer, prefix0x: boolean = false, byteLength?: number): string {\n if (IS_BROWSER) {\n let s = ''\n const h = '0123456789abcdef'\n if (ArrayBuffer.isView(buf)) buf = new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength))\n else buf = new Uint8Array(buf);\n\n (buf as Uint8Array).forEach((v) => {\n s += h[v >> 4] + h[v & 15]\n })\n\n return parseHex(s, prefix0x, byteLength)\n } else {\n const input = toBuffer(buf)\n if (ArrayBuffer.isView(input)) buf = new Uint8Array(input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength))\n return parseHex(Buffer.from(input).toString('hex'), prefix0x, byteLength)\n }\n}\n\n/**\n * Converts a hexadecimal string to a buffer\n *\n * @param hexStr - A string representing a number with hexadecimal notation\n * @param returnArrayBuffer - In Node.js, it forces the output to be an ArrayBuffer instead of a Buffer.\n *\n * @returns An ArrayBuffer or a Buffer\n *\n * @throws {@link RangeError} if input string does not hold an hexadecimal number\n */\nexport function hexToBuf (hexStr: string, returnArrayBuffer: boolean = false): ArrayBuffer | Buffer {\n let hex = parseHex(hexStr)\n hex = parseHex(hexStr, false, Math.ceil(hex.length / 2)) // pad to have a length in bytes\n if (IS_BROWSER) {\n return Uint8Array.from(hex.match(/[\\da-fA-F]{2}/g)!.map((h) => { // eslint-disable-line\n return parseInt(h, 16)\n })).buffer\n } else {\n const b = Buffer.from(hex, 'hex')\n return returnArrayBuffer ? b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) : b\n }\n}\n\n/**\n * Converts an arbitrary-size non-negative bigint to a base64 string\n * @param a - a non negative bigint\n * @param urlsafe - if true Base64 URL encoding is used ('+' and '/' are replaced by '-', '_')\n * @param padding - if false, padding (trailing '=') is removed\n * @returns a base64 representation of the input bigint\n *\n * @throws {RangeError}\n * Thrown if a < 0\n */\nexport function bigintToBase64 (a: bigint, urlsafe: boolean = false, padding: boolean = true): string {\n return b64.encode(bigintToBuf(a), urlsafe, padding)\n}\n\n/**\n * Converts a base64 string to bigint.\n * @param a base64 string. It accepts standard and URL-safe base64 with and without padding\n * @returns a bigint\n */\nexport function base64ToBigint (a: string): bigint {\n return bufToBigint(b64.decode(a))\n}\n"]}
@@ -1,134 +0,0 @@
1
-
2
- # Contributor Covenant Code of Conduct
3
-
4
- ## Our Pledge
5
-
6
- We as members, contributors, and leaders pledge to make participation in our
7
- community a harassment-free experience for everyone, regardless of age, body
8
- size, visible or invisible disability, ethnicity, sex characteristics, gender
9
- identity and expression, level of experience, education, socio-economic status,
10
- nationality, personal appearance, race, caste, color, religion, or sexual
11
- identity and orientation.
12
-
13
- We pledge to act and interact in ways that contribute to an open, welcoming,
14
- diverse, inclusive, and healthy community.
15
-
16
- ## Our Standards
17
-
18
- Examples of behavior that contributes to a positive environment for our
19
- community include:
20
-
21
- * Demonstrating empathy and kindness toward other people
22
- * Being respectful of differing opinions, viewpoints, and experiences
23
- * Giving and gracefully accepting constructive feedback
24
- * Accepting responsibility and apologizing to those affected by our mistakes,
25
- and learning from the experience
26
- * Focusing on what is best not just for us as individuals, but for the overall
27
- community
28
-
29
- Examples of unacceptable behavior include:
30
-
31
- * The use of sexualized language or imagery, and sexual attention or advances of
32
- any kind
33
- * Trolling, insulting or derogatory comments, and personal or political attacks
34
- * Public or private harassment
35
- * Publishing others' private information, such as a physical or email address,
36
- without their explicit permission
37
- * Other conduct which could reasonably be considered inappropriate in a
38
- professional setting
39
-
40
- ## Enforcement Responsibilities
41
-
42
- Community leaders are responsible for clarifying and enforcing our standards of
43
- acceptable behavior and will take appropriate and fair corrective action in
44
- response to any behavior that they deem inappropriate, threatening, offensive,
45
- or harmful.
46
-
47
- Community leaders have the right and responsibility to remove, edit, or reject
48
- comments, commits, code, wiki edits, issues, and other contributions that are
49
- not aligned to this Code of Conduct, and will communicate reasons for moderation
50
- decisions when appropriate.
51
-
52
- ## Scope
53
-
54
- This Code of Conduct applies within all community spaces, and also applies when
55
- an individual is officially representing the community in public spaces.
56
- Examples of representing our community include using an official e-mail address,
57
- posting via an official social media account, or acting as an appointed
58
- representative at an online or offline event.
59
-
60
- ## Enforcement
61
-
62
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
- reported to the community leaders responsible for enforcement at
64
- [INSERT CONTACT METHOD].
65
- All complaints will be reviewed and investigated promptly and fairly.
66
-
67
- All community leaders are obligated to respect the privacy and security of the
68
- reporter of any incident.
69
-
70
- ## Enforcement Guidelines
71
-
72
- Community leaders will follow these Community Impact Guidelines in determining
73
- the consequences for any action they deem in violation of this Code of Conduct:
74
-
75
- ### 1. Correction
76
-
77
- **Community Impact**: Use of inappropriate language or other behavior deemed
78
- unprofessional or unwelcome in the community.
79
-
80
- **Consequence**: A private, written warning from community leaders, providing
81
- clarity around the nature of the violation and an explanation of why the
82
- behavior was inappropriate. A public apology may be requested.
83
-
84
- ### 2. Warning
85
-
86
- **Community Impact**: A violation through a single incident or series of
87
- actions.
88
-
89
- **Consequence**: A warning with consequences for continued behavior. No
90
- interaction with the people involved, including unsolicited interaction with
91
- those enforcing the Code of Conduct, for a specified period of time. This
92
- includes avoiding interactions in community spaces as well as external channels
93
- like social media. Violating these terms may lead to a temporary or permanent
94
- ban.
95
-
96
- ### 3. Temporary Ban
97
-
98
- **Community Impact**: A serious violation of community standards, including
99
- sustained inappropriate behavior.
100
-
101
- **Consequence**: A temporary ban from any sort of interaction or public
102
- communication with the community for a specified period of time. No public or
103
- private interaction with the people involved, including unsolicited interaction
104
- with those enforcing the Code of Conduct, is allowed during this period.
105
- Violating these terms may lead to a permanent ban.
106
-
107
- ### 4. Permanent Ban
108
-
109
- **Community Impact**: Demonstrating a pattern of violation of community
110
- standards, including sustained inappropriate behavior, harassment of an
111
- individual, or aggression toward or disparagement of classes of individuals.
112
-
113
- **Consequence**: A permanent ban from any sort of public interaction within the
114
- community.
115
-
116
- ## Attribution
117
-
118
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
- version 2.1, available at
120
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121
-
122
- Community Impact Guidelines were inspired by
123
- [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124
-
125
- For answers to common questions about this code of conduct, see the FAQ at
126
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
127
- [https://www.contributor-covenant.org/translations][translations].
128
-
129
- [homepage]: https://www.contributor-covenant.org
130
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131
- [Mozilla CoC]: https://github.com/mozilla/diversity
132
- [FAQ]: https://www.contributor-covenant.org/faq
133
- [translations]: https://www.contributor-covenant.org/translations
134
-
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Juan Hernández Serrano
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,48 +0,0 @@
1
- [![Licence: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
- [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
3
- [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
4
- [![Node.js CI](https://github.com/juanelas/bigint-conversion/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/juanelas/bigint-conversion/actions/workflows/build-and-test.yml)
5
- [![Coverage Status](https://coveralls.io/repos/github/juanelas/bigint-conversion/badge.svg?branch=main)](https://coveralls.io/github/juanelas/bigint-conversion?branch=main)
6
-
7
- # bigint-conversion
8
-
9
- Convert to/from non-negative integers represented with [ES-2020 native JS implementation of BigInt](https://tc39.es/ecma262/#sec-bigint-objects) from/to:
10
-
11
- - `Buffer` (node.js) or `ArrayBuffer|TypedArray` (native js),
12
- - hex `string`,
13
- - utf8-encoded text `string`,
14
- - standard and url-safe base64 with and without padding.
15
-
16
- It provides a common interface for the conversions that works for both **node.js** and **native javascript**.
17
-
18
- > Note that there is not a directly visible `TypedArray()` constructor, but a set of typed array ones: `Int8Array()`, `Uint8Array()`, `Uint8ClampedArray()`, `Int16Array()`, `Uint16Array()`, `Int32Array()`, `Uint32Array()`, `Float32Array()`, `Float64Array()`, `BigInt64Array()`, `BigUint64Array()`.
19
-
20
- ## Usage
21
-
22
- `bigint-conversion` can be imported to your project with `npm`:
23
-
24
- ```console
25
- npm install bigint-conversion
26
- ```
27
-
28
- Then either require (Node.js CJS):
29
-
30
- ```javascript
31
- const bigintConversion = require('bigint-conversion')
32
- ```
33
-
34
- or import (JavaScript ES module):
35
-
36
- ```javascript
37
- import * as bigintConversion from 'bigint-conversion'
38
- ```
39
-
40
- The appropriate version for browser or node is automatically exported.
41
-
42
- > BigInt is [ES-2020](https://tc39.es/ecma262/#sec-bigint-objects). In order to use it with TypeScript you should set `target` (and probably also `lib`) to at least `es2020` in `tsconfig.json`.
43
-
44
- You can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/bigint-conversion/main/dist\bundle.iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-conversion/main/dist\esm\bundle.min.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/bigint-conversion/main/dist\bundle.umd.js) and manually add it to your project, or, if you have already installed `bigint-conversion` in your project, just get the bundles from `node_modules/bigint-conversion/dist/bundles/`.
45
-
46
- ## API reference documentation
47
-
48
- [Check the API](./docs/API.md)