@gsknnft/bigint-buffer 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +3 -3
  2. package/build/Release/bigint_buffer.exp +0 -0
  3. package/build/Release/bigint_buffer.iobj +0 -0
  4. package/build/Release/bigint_buffer.ipdb +0 -0
  5. package/build/Release/bigint_buffer.lib +0 -0
  6. package/build/Release/bigint_buffer.node +0 -0
  7. package/build/Release/bigint_buffer.pdb +0 -0
  8. package/build/Release/obj/bigint_buffer/bigint_buffer.node.recipe +11 -0
  9. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/CL.command.1.tlog +0 -0
  10. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/CL.read.1.tlog +0 -0
  11. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/CL.write.1.tlog +0 -0
  12. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/Cl.items.tlog +2 -0
  13. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/bigint_buffer.lastbuildstate +2 -0
  14. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.command.1.tlog +0 -0
  15. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.read.1.tlog +0 -0
  16. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.secondary.1.tlog +5 -0
  17. package/build/Release/obj/bigint_buffer/bigint_buffer.tlog/link.write.1.tlog +0 -0
  18. package/build/Release/obj/bigint_buffer/src/bigint-buffer.obj +0 -0
  19. package/build/Release/obj/bigint_buffer/win_delay_load_hook.obj +0 -0
  20. package/build/bigint_buffer.vcxproj +148 -0
  21. package/build/bigint_buffer.vcxproj.filters +67 -0
  22. package/build/binding.sln +19 -0
  23. package/build/config.gypi +522 -0
  24. package/dist/types/conversion/src/ts/index.d.ts +168 -0
  25. package/dist/types/conversion/test/bigintToBase64.test.d.ts +1 -0
  26. package/dist/types/conversion/test/bigintToBuf.test.d.ts +1 -0
  27. package/dist/types/conversion/test/bigintToHex.test.d.ts +1 -0
  28. package/dist/types/conversion/test/bigintToText.test.d.ts +1 -0
  29. package/dist/types/conversion/test/bufToBigint.test.d.ts +1 -0
  30. package/dist/types/conversion/test/hexToBigint.test.d.ts +1 -0
  31. package/dist/types/conversion/test/hexToBuf.test.d.ts +1 -0
  32. package/dist/types/conversion/test/parseHex.test.d.ts +1 -0
  33. package/dist/types/conversion/test/setup.test.d.ts +1 -0
  34. package/dist/types/conversion/test/textToBuf.test.d.ts +1 -0
  35. package/package.json +42 -27
  36. package/src/bigint-buffer.c +203 -0
  37. package/src/bigint-buffer.test.ts +11 -0
  38. package/src/conversion/.github/workflows/build-and-test.yml +116 -0
  39. package/src/conversion/CODE_OF_CONDUCT.md +134 -0
  40. package/src/conversion/LICENSE +21 -0
  41. package/src/conversion/README.md +48 -0
  42. package/src/conversion/docs/README.md +34 -0
  43. package/src/conversion/docs/functions/base64ToBigint.md +27 -0
  44. package/src/conversion/docs/functions/bigintToBase64.md +43 -0
  45. package/src/conversion/docs/functions/bigintToBuf.md +35 -0
  46. package/src/conversion/docs/functions/bigintToHex.md +43 -0
  47. package/src/conversion/docs/functions/bigintToText.md +31 -0
  48. package/src/conversion/docs/functions/bufToBigint.md +25 -0
  49. package/src/conversion/docs/functions/bufToHex.md +37 -0
  50. package/src/conversion/docs/functions/bufToText.md +27 -0
  51. package/src/conversion/docs/functions/hexToBigint.md +29 -0
  52. package/src/conversion/docs/functions/hexToBuf.md +37 -0
  53. package/src/conversion/docs/functions/parseHex.md +45 -0
  54. package/src/conversion/docs/functions/textToBigint.md +27 -0
  55. package/src/conversion/docs/functions/textToBuf.md +33 -0
  56. package/src/conversion/docs/functions/toBigIntBE.md +27 -0
  57. package/src/conversion/docs/functions/toBigIntLE.md +27 -0
  58. package/src/conversion/docs/functions/toBufferBE.md +33 -0
  59. package/src/conversion/docs/functions/toBufferLE.md +33 -0
  60. package/src/conversion/docs/functions/validateBigIntBuffer.md +15 -0
  61. package/src/conversion/docs/type-aliases/TypedArray.md +11 -0
  62. package/src/conversion/docs/variables/isNative.md +11 -0
  63. package/src/conversion/example.cjs +9 -0
  64. package/src/conversion/example.esm.js +11 -0
  65. package/src/conversion/index.ts +1 -0
  66. package/src/conversion/package.json +163 -0
  67. package/src/conversion/src/docs/index.md +47 -0
  68. package/src/conversion/src/ts/index.ts +514 -0
  69. package/src/conversion/test/bigintToBase64.test.ts +37 -0
  70. package/src/conversion/test/bigintToBuf.test.ts +43 -0
  71. package/src/conversion/test/bigintToHex.test.ts +52 -0
  72. package/src/conversion/test/bigintToText.test.ts +30 -0
  73. package/src/conversion/test/bufToBigint.test.ts +20 -0
  74. package/src/conversion/test/hexToBigint.test.ts +22 -0
  75. package/src/conversion/test/hexToBuf.test.ts +39 -0
  76. package/src/conversion/test/parseHex.test.ts +35 -0
  77. package/src/conversion/test/setup.test.ts +9 -0
  78. package/src/conversion/test/textToBuf.test.ts +26 -0
  79. package/src/conversion/tsconfig.json +57 -0
  80. package/src/conversion/tsconfig.rollup.json +9 -0
  81. package/src/conversion/typedoc.json +5 -0
  82. package/src/conversion/types/bindings.d.t.s +4 -0
  83. package/src/conversion/vite.config.ts +10 -0
  84. package/src/conversion/vitest.config.ts +15 -0
  85. package/src/index.bench.ts +206 -0
  86. package/src/index.spec.ts +318 -0
  87. package/src/index.ts +215 -0
  88. package/.travis.yml +0 -51
  89. package/PR_TEMPLATE.md +0 -53
  90. package/WHY_BIGINT.md +0 -127
  91. package/benchmark.md +0 -38
  92. package/eslint.config.ts +0 -12
  93. package/karma.conf.js +0 -62
  94. package/pnpm-workspace.yaml +0 -14
  95. package/rollup.cjs.config.js +0 -13
  96. package/rollup.conversion.cjs.config.js +0 -13
  97. package/rollup.conversion.esm.config.js +0 -24
  98. package/rollup.esm.config.js +0 -24
  99. package/tsconfig.tsbuildinfo +0 -1
  100. package/vite.config.ts +0 -44
  101. package/vitest.config.ts +0 -20
@@ -0,0 +1,134 @@
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
+
@@ -0,0 +1,21 @@
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.
@@ -0,0 +1,48 @@
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)
@@ -0,0 +1,34 @@
1
+ **bigint-conversion**
2
+
3
+ ***
4
+
5
+ # bigint-conversion
6
+
7
+ ## Type Aliases
8
+
9
+ - [TypedArray](type-aliases/TypedArray.md)
10
+
11
+ ## Variables
12
+
13
+ - [isNative](variables/isNative.md)
14
+
15
+ ## Functions
16
+
17
+ - [base64ToBigint](functions/base64ToBigint.md)
18
+ - [bigintToBase64](functions/bigintToBase64.md)
19
+ - [bigintToBuf](functions/bigintToBuf.md)
20
+ - [bigintToHex](functions/bigintToHex.md)
21
+ - [bigintToText](functions/bigintToText.md)
22
+ - [bufToBigint](functions/bufToBigint.md)
23
+ - [bufToHex](functions/bufToHex.md)
24
+ - [bufToText](functions/bufToText.md)
25
+ - [hexToBigint](functions/hexToBigint.md)
26
+ - [hexToBuf](functions/hexToBuf.md)
27
+ - [parseHex](functions/parseHex.md)
28
+ - [textToBigint](functions/textToBigint.md)
29
+ - [textToBuf](functions/textToBuf.md)
30
+ - [toBigIntBE](functions/toBigIntBE.md)
31
+ - [toBigIntLE](functions/toBigIntLE.md)
32
+ - [toBufferBE](functions/toBufferBE.md)
33
+ - [toBufferLE](functions/toBufferLE.md)
34
+ - [validateBigIntBuffer](functions/validateBigIntBuffer.md)
@@ -0,0 +1,27 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / base64ToBigint
6
+
7
+ # Function: base64ToBigint()
8
+
9
+ > **base64ToBigint**(`a`): `bigint`
10
+
11
+ Defined in: index.ts:330
12
+
13
+ Converts a base64 string to bigint.
14
+
15
+ ## Parameters
16
+
17
+ ### a
18
+
19
+ `string`
20
+
21
+ base64 string. It accepts standard and URL-safe base64 with and without padding
22
+
23
+ ## Returns
24
+
25
+ `bigint`
26
+
27
+ a bigint
@@ -0,0 +1,43 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / bigintToBase64
6
+
7
+ # Function: bigintToBase64()
8
+
9
+ > **bigintToBase64**(`a`, `urlsafe`, `padding`): `string`
10
+
11
+ Defined in: index.ts:321
12
+
13
+ Converts an arbitrary-size non-negative bigint to a base64 string
14
+
15
+ ## Parameters
16
+
17
+ ### a
18
+
19
+ `bigint`
20
+
21
+ a non negative bigint
22
+
23
+ ### urlsafe
24
+
25
+ `boolean` = `false`
26
+
27
+ if true Base64 URL encoding is used ('+' and '/' are replaced by '-', '_')
28
+
29
+ ### padding
30
+
31
+ `boolean` = `true`
32
+
33
+ if false, padding (trailing '=') is removed
34
+
35
+ ## Returns
36
+
37
+ `string`
38
+
39
+ a base64 representation of the input bigint
40
+
41
+ ## Throws
42
+
43
+ Thrown if a < 0
@@ -0,0 +1,35 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / bigintToBuf
6
+
7
+ # Function: bigintToBuf()
8
+
9
+ > **bigintToBuf**(`a`, `returnArrayBuffer`): `ArrayBuffer` \| `Buffer`\<`ArrayBufferLike`\>
10
+
11
+ Defined in: index.ts:144
12
+
13
+ Converts an arbitrary-size non-negative bigint to an ArrayBuffer or a Buffer (default for Node.js)
14
+
15
+ ## Parameters
16
+
17
+ ### a
18
+
19
+ `bigint`
20
+
21
+ ### returnArrayBuffer
22
+
23
+ `boolean` = `false`
24
+
25
+ In Node.js, it forces the output to be an ArrayBuffer instead of a Buffer.
26
+
27
+ ## Returns
28
+
29
+ `ArrayBuffer` \| `Buffer`\<`ArrayBufferLike`\>
30
+
31
+ an ArrayBuffer or a Buffer with a binary representation of the input bigint
32
+
33
+ ## Throws
34
+
35
+ RangeError if a < 0.
@@ -0,0 +1,43 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / bigintToHex
6
+
7
+ # Function: bigintToHex()
8
+
9
+ > **bigintToHex**(`a`, `prefix0x`, `byteLength?`): `string`
10
+
11
+ Defined in: index.ts:177
12
+
13
+ Converts a non-negative bigint to a hexadecimal string
14
+
15
+ ## Parameters
16
+
17
+ ### a
18
+
19
+ `bigint`
20
+
21
+ a non negative bigint
22
+
23
+ ### prefix0x
24
+
25
+ `boolean` = `false`
26
+
27
+ set to true to prefix the output with '0x'
28
+
29
+ ### byteLength?
30
+
31
+ `number`
32
+
33
+ pad the output to have the desired byte length. Notice that the hex length is double the byte length.
34
+
35
+ ## Returns
36
+
37
+ `string`
38
+
39
+ hexadecimal representation of the input bigint
40
+
41
+ ## Throws
42
+
43
+ RangeError if a < 0
@@ -0,0 +1,31 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / bigintToText
6
+
7
+ # Function: bigintToText()
8
+
9
+ > **bigintToText**(`a`): `string`
10
+
11
+ Defined in: index.ts:204
12
+
13
+ Converts a non-negative bigint representing a binary array of utf-8 encoded text to a string of utf-8 text
14
+
15
+ ## Parameters
16
+
17
+ ### a
18
+
19
+ `bigint`
20
+
21
+ A non-negative bigint representing a binary array of utf-8 encoded text.
22
+
23
+ ## Returns
24
+
25
+ `string`
26
+
27
+ a string text with utf-8 encoding
28
+
29
+ ## Throws
30
+
31
+ RangeError if a < 0.
@@ -0,0 +1,25 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / bufToBigint
6
+
7
+ # Function: bufToBigint()
8
+
9
+ > **bufToBigint**(`buf`): `bigint`
10
+
11
+ Defined in: index.ts:154
12
+
13
+ Converts an ArrayBuffer, TypedArray or Buffer (node.js) to a bigint
14
+
15
+ ## Parameters
16
+
17
+ ### buf
18
+
19
+ `ArrayBuffer` | `Buffer`\<`ArrayBufferLike`\> | [`TypedArray`](../type-aliases/TypedArray.md)
20
+
21
+ ## Returns
22
+
23
+ `bigint`
24
+
25
+ a bigint
@@ -0,0 +1,37 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / bufToHex
6
+
7
+ # Function: bufToHex()
8
+
9
+ > **bufToHex**(`buf`, `prefix0x`, `byteLength?`): `string`
10
+
11
+ Defined in: index.ts:269
12
+
13
+ Returns the hexadecimal representation of a buffer.
14
+
15
+ ## Parameters
16
+
17
+ ### buf
18
+
19
+ `ArrayBuffer` | `Buffer`\<`ArrayBufferLike`\> | [`TypedArray`](../type-aliases/TypedArray.md)
20
+
21
+ ### prefix0x
22
+
23
+ `boolean` = `false`
24
+
25
+ set to true to prefix the output with '0x'
26
+
27
+ ### byteLength?
28
+
29
+ `number`
30
+
31
+ pad the output to have the desired byte length. Notice that the hex length is double the byte length.
32
+
33
+ ## Returns
34
+
35
+ `string`
36
+
37
+ a string with a hexadecimal representation of the input buffer
@@ -0,0 +1,27 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / bufToText
6
+
7
+ # Function: bufToText()
8
+
9
+ > **bufToText**(`buf`): `string`
10
+
11
+ Defined in: index.ts:239
12
+
13
+ Converts an ArrayBuffer, TypedArray or Buffer (in Node.js) containing utf-8 encoded text to a string of utf-8 text
14
+
15
+ ## Parameters
16
+
17
+ ### buf
18
+
19
+ A buffer containing utf-8 encoded text
20
+
21
+ `ArrayBuffer` | `Buffer`\<`ArrayBufferLike`\> | [`TypedArray`](../type-aliases/TypedArray.md)
22
+
23
+ ## Returns
24
+
25
+ `string`
26
+
27
+ a string text with utf-8 encoding
@@ -0,0 +1,29 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / hexToBigint
6
+
7
+ # Function: hexToBigint()
8
+
9
+ > **hexToBigint**(`hexStr`): `bigint`
10
+
11
+ Defined in: index.ts:191
12
+
13
+ Converts a hexadecimal string to a bigint
14
+
15
+ ## Parameters
16
+
17
+ ### hexStr
18
+
19
+ `string`
20
+
21
+ ## Returns
22
+
23
+ `bigint`
24
+
25
+ a bigint
26
+
27
+ ## Throws
28
+
29
+ RangeError if input string does not hold an hexadecimal number
@@ -0,0 +1,37 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / hexToBuf
6
+
7
+ # Function: hexToBuf()
8
+
9
+ > **hexToBuf**(`hexStr`, `returnArrayBuffer`): `ArrayBuffer` \| `Buffer`\<`ArrayBufferLike`\>
10
+
11
+ Defined in: index.ts:298
12
+
13
+ Converts a hexadecimal string to a buffer
14
+
15
+ ## Parameters
16
+
17
+ ### hexStr
18
+
19
+ `string`
20
+
21
+ A string representing a number with hexadecimal notation
22
+
23
+ ### returnArrayBuffer
24
+
25
+ `boolean` = `false`
26
+
27
+ In Node.js, it forces the output to be an ArrayBuffer instead of a Buffer.
28
+
29
+ ## Returns
30
+
31
+ `ArrayBuffer` \| `Buffer`\<`ArrayBufferLike`\>
32
+
33
+ An ArrayBuffer or a Buffer
34
+
35
+ ## Throws
36
+
37
+ RangeError if input string does not hold an hexadecimal number
@@ -0,0 +1,45 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / parseHex
6
+
7
+ # Function: parseHex()
8
+
9
+ > **parseHex**(`a`, `prefix0x`, `byteLength?`): `string`
10
+
11
+ Defined in: index.ts:119
12
+
13
+ Parses a hexadecimal string for correctness and returns it with or without '0x' prefix, and/or with the specified byte length
14
+
15
+ ## Parameters
16
+
17
+ ### a
18
+
19
+ `string`
20
+
21
+ the string with an hexadecimal number to be parsed
22
+
23
+ ### prefix0x
24
+
25
+ `boolean` = `false`
26
+
27
+ set to true to prefix the output with '0x'
28
+
29
+ ### byteLength?
30
+
31
+ `number`
32
+
33
+ pad the output to have the desired byte length. Notice that the hex length is double the byte length.
34
+
35
+ ## Returns
36
+
37
+ `string`
38
+
39
+ ## Throws
40
+
41
+ RangeError if input string does not hold an hexadecimal number
42
+
43
+ ## Throws
44
+
45
+ RangeError if requested byte length is less than the input byte length
@@ -0,0 +1,27 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / textToBigint
6
+
7
+ # Function: textToBigint()
8
+
9
+ > **textToBigint**(`text`): `bigint`
10
+
11
+ Defined in: index.ts:216
12
+
13
+ Converts a utf-8 string to a bigint (from its binary representaion)
14
+
15
+ ## Parameters
16
+
17
+ ### text
18
+
19
+ `string`
20
+
21
+ A string text with utf-8 encoding
22
+
23
+ ## Returns
24
+
25
+ `bigint`
26
+
27
+ a bigint representing a binary array of the input utf-8 encoded text
@@ -0,0 +1,33 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / textToBuf
6
+
7
+ # Function: textToBuf()
8
+
9
+ > **textToBuf**(`str`, `returnArrayBuffer`): `ArrayBuffer` \| `Buffer`\<`ArrayBufferLike`\>
10
+
11
+ Defined in: index.ts:253
12
+
13
+ Converts a string of utf-8 encoded text to an ArrayBuffer or a Buffer (default in Node.js)
14
+
15
+ ## Parameters
16
+
17
+ ### str
18
+
19
+ `string`
20
+
21
+ A string of text (with utf-8 encoding)
22
+
23
+ ### returnArrayBuffer
24
+
25
+ `boolean` = `false`
26
+
27
+ When invoked in Node.js, it can force the output to be an ArrayBuffer instead of a Buffer.
28
+
29
+ ## Returns
30
+
31
+ `ArrayBuffer` \| `Buffer`\<`ArrayBufferLike`\>
32
+
33
+ an ArrayBuffer or a Buffer containing the utf-8 encoded text