@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,27 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / toBigIntBE
6
+
7
+ # Function: toBigIntBE()
8
+
9
+ > **toBigIntBE**(`buf`): `bigint`
10
+
11
+ Defined in: index.ts:63
12
+
13
+ Convert a big-endian buffer into a BigInt
14
+
15
+ ## Parameters
16
+
17
+ ### buf
18
+
19
+ `Buffer`
20
+
21
+ The big-endian buffer to convert.
22
+
23
+ ## Returns
24
+
25
+ `bigint`
26
+
27
+ A BigInt with the big-endian representation of buf.
@@ -0,0 +1,27 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / toBigIntLE
6
+
7
+ # Function: toBigIntLE()
8
+
9
+ > **toBigIntLE**(`buf`): `bigint`
10
+
11
+ Defined in: index.ts:36
12
+
13
+ Convert a little-endian buffer into a BigInt.
14
+
15
+ ## Parameters
16
+
17
+ ### buf
18
+
19
+ `Buffer`
20
+
21
+ The little-endian buffer to convert
22
+
23
+ ## Returns
24
+
25
+ `bigint`
26
+
27
+ A BigInt with the little-endian representation of buf.
@@ -0,0 +1,33 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / toBufferBE
6
+
7
+ # Function: toBufferBE()
8
+
9
+ > **toBufferBE**(`num`, `width`): `Buffer`
10
+
11
+ Defined in: index.ts:98
12
+
13
+ Convert a BigInt to a big-endian buffer.
14
+
15
+ ## Parameters
16
+
17
+ ### num
18
+
19
+ `bigint`
20
+
21
+ The BigInt to convert.
22
+
23
+ ### width
24
+
25
+ `number`
26
+
27
+ The number of bytes that the resulting buffer should be.
28
+
29
+ ## Returns
30
+
31
+ `Buffer`
32
+
33
+ A big-endian buffer representation of num.
@@ -0,0 +1,33 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / toBufferLE
6
+
7
+ # Function: toBufferLE()
8
+
9
+ > **toBufferLE**(`num`, `width`): `Buffer`
10
+
11
+ Defined in: index.ts:80
12
+
13
+ Convert a BigInt to a little-endian buffer.
14
+
15
+ ## Parameters
16
+
17
+ ### num
18
+
19
+ `bigint`
20
+
21
+ The BigInt to convert.
22
+
23
+ ### width
24
+
25
+ `number`
26
+
27
+ The number of bytes that the resulting buffer should be.
28
+
29
+ ## Returns
30
+
31
+ `Buffer`
32
+
33
+ A little-endian buffer representation of num.
@@ -0,0 +1,15 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / validateBigIntBuffer
6
+
7
+ # Function: validateBigIntBuffer()
8
+
9
+ > **validateBigIntBuffer**(): `boolean`
10
+
11
+ Defined in: index.ts:49
12
+
13
+ ## Returns
14
+
15
+ `boolean`
@@ -0,0 +1,11 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / TypedArray
6
+
7
+ # Type Alias: TypedArray
8
+
9
+ > **TypedArray** = `Int8Array` \| `Uint8Array` \| `Uint8ClampedArray` \| `Int16Array` \| `Uint16Array` \| `Int32Array` \| `Uint32Array` \| `Float32Array` \| `Float64Array` \| `BigInt64Array` \| `BigUint64Array`
10
+
11
+ Defined in: index.ts:106
@@ -0,0 +1,11 @@
1
+ [**bigint-conversion**](../README.md)
2
+
3
+ ***
4
+
5
+ [bigint-conversion](../README.md) / isNative
6
+
7
+ # Variable: isNative
8
+
9
+ > **isNative**: `boolean` = `false`
10
+
11
+ Defined in: index.ts:10
@@ -0,0 +1,9 @@
1
+ const bcu = require('.')
2
+
3
+ const bi = 87213425n
4
+ console.log(bi)
5
+
6
+ const b64 = bcu.bigintToBase64(bi)
7
+ console.log(b64)
8
+
9
+ console.log(bcu.base64ToBigint(b64))
@@ -0,0 +1,11 @@
1
+ import { bigintToBase64, base64ToBigint } from './dist/esm/index.node.js'
2
+
3
+ const bi = 87213425n
4
+ console.log(bi)
5
+
6
+ const b64 = bigintToBase64(bi)
7
+ console.log(b64)
8
+
9
+ console.log(base64ToBigint(b64))
10
+
11
+ export {}
@@ -0,0 +1 @@
1
+ export * from './src/ts/index';
@@ -0,0 +1,163 @@
1
+ {
2
+ "name": "bigint-conversion",
3
+ "version": "2.4.3",
4
+ "description": "Convert to/from BigInt from/to Buffer, ArrayBuffer, hex string, utf8-encoded text string.",
5
+ "keywords": [
6
+ "BigInt",
7
+ "bignum",
8
+ "big integer",
9
+ "text",
10
+ "utf8",
11
+ "hex",
12
+ "Buffer",
13
+ "ArrayBuffer",
14
+ "TypedArray"
15
+ ],
16
+ "license": "MIT",
17
+ "author": {
18
+ "name": "Juan Hernández Serrano",
19
+ "email": "j.hernandez@upc.edu",
20
+ "url": "https://github.com/juanelas"
21
+ },
22
+ "repository": "github:juanelas/bigint-conversion",
23
+ "main": "./dist/cjs/index.node.js",
24
+ "browser": "./dist/esm/index.browser.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "node": {
29
+ "import": {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/esm/index.node.js"
32
+ },
33
+ "require": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/node.js"
36
+ }
37
+ },
38
+ "script": "./dist/bundle.iife.js",
39
+ "default": {
40
+ "types": "./dist/index.d.ts",
41
+ "default": "./dist/esm/index.browser.js"
42
+ }
43
+ },
44
+ "./esm-browser-bundle": "./dist/esm/bundle.min.js",
45
+ "./dist/esm/bundle.min.js": "./dist/esm/bundle.min.js",
46
+ "./esm-browser-bundle-nomin": "./dist/esm/bundle.js",
47
+ "./dist/esm/bundle.js": "./dist/esm/bundle.js",
48
+ "./iife-browser-bundle": "./dist/bundle.iife.js",
49
+ "./dist/bundle.iife.js": "./dist/bundle.iife.js",
50
+ "./umd-browser-bundle": "./dist/bundle.umd.js",
51
+ "./dist/bundle.umd.js": "./dist/bundle.umd.js",
52
+ "./dist/cjs/index.node": {
53
+ "types": "./dist/index.d.ts",
54
+ "default": "./dist/cjs/index.node.js"
55
+ },
56
+ "./dist/esm/index.node": {
57
+ "types": "./dist/index.d.ts",
58
+ "default": "./dist/esm/index.node.js"
59
+ },
60
+ "./dist/esm/index.browser": {
61
+ "types": "./dist/index.d.ts",
62
+ "default": "./dist/esm/index.browser.js"
63
+ },
64
+ "./package.json": "./package.json"
65
+ },
66
+ "imports": {
67
+ "#pkg": {
68
+ "require": {
69
+ "types": "./dist/index.d.ts",
70
+ "default": "./dist/cjs/index.node.js"
71
+ },
72
+ "import": {
73
+ "types": "./dist/index.d.ts",
74
+ "default": "./dist/esm/index.node.js"
75
+ },
76
+ "default": {
77
+ "types": "./dist/index.d.ts",
78
+ "default": "./dist/esm/index.browser.js"
79
+ }
80
+ }
81
+ },
82
+ "directories": {
83
+ "build": "./build",
84
+ "dist": "./dist",
85
+ "docs": "./docs",
86
+ "src": "./src",
87
+ "test": "./test"
88
+ },
89
+ "scripts": {
90
+ "_build:cleantypes": "rimraf .types",
91
+ "_build:cjsAndesmPkgJsons": "node ./build/bin/post-build.ts",
92
+ "build": "run-s build:js docs copy:types",
93
+ "build:js": "rollup -c build/rollup.config.ts",
94
+ "typecheck": "tsc --noEmit",
95
+ "postbuild:js": "run-s _build:cleantypes _build:cjsAndesmPkgJsons",
96
+ "test:node": "vitest run",
97
+ "clean": "rimraf coverage dist .types docs",
98
+ "coverage": "vitest run --coverage",
99
+ "docs": "typedoc --plugin typedoc-plugin-markdown --entryModule API.md --readme none --excludePrivate --out docs src/ts/index.ts",
100
+ "test": "vitest run",
101
+ "test:watch": "vitest watch",
102
+ "test:browser": "vitest run --browser"
103
+ },
104
+ "copy:types": "cpy ./build/index.d.ts ./dist/ --flat",
105
+ "ts-standard": {
106
+ "project": "tsconfig.json",
107
+ "env": [
108
+ "mocha"
109
+ ],
110
+ "globals": [
111
+ "IS_BROWSER",
112
+ "browser",
113
+ "page",
114
+ "chai"
115
+ ],
116
+ "ignore": [
117
+ "dist/**/*",
118
+ "examples/**/*",
119
+ "types/**/*",
120
+ "benchmark/**/*"
121
+ ]
122
+ },
123
+ "nodeBrowserSkel": {
124
+ "badges": {
125
+ "workflow": true,
126
+ "coveralls": true
127
+ },
128
+ "git": {
129
+ "branch": "main"
130
+ }
131
+ },
132
+ "devDependencies": {
133
+ "@rollup/plugin-commonjs": "^29.0.0",
134
+ "@rollup/plugin-inject": "^5.0.5",
135
+ "@rollup/plugin-json": "^6.1.0",
136
+ "@rollup/plugin-multi-entry": "^7.0.1",
137
+ "@rollup/plugin-node-resolve": "^16.0.3",
138
+ "@rollup/plugin-replace": "^6.0.2",
139
+ "@rollup/plugin-terser": "^0.4.4",
140
+ "@rollup/plugin-typescript": "^12.3.0",
141
+ "@types/node": "^24.10.1",
142
+ "c8": "^10.1.3",
143
+ "chai": "^6.2.0",
144
+ "esbuild-register": "^3.6.0",
145
+ "glob": "^13.0.0",
146
+ "json5": "^2.2.3",
147
+ "minimatch": "^10.0.3",
148
+ "mocha": "^11.7.4",
149
+ "npm-run-all": "^4.1.5",
150
+ "pirates": "^4.0.7",
151
+ "puppeteer": "^24.26.1",
152
+ "rimraf": "^6.0.1",
153
+ "rollup": "^4.53.3",
154
+ "rollup-plugin-dts": "^6.2.3",
155
+ "ts-standard": "^12.0.2",
156
+ "tslib": "^2.8.1",
157
+ "typedoc": "^0.28.14",
158
+ "typedoc-plugin-markdown": "^4.9.0",
159
+ "typescript": "^5.9.3",
160
+ "vite": "7.2.4",
161
+ "vitest": "^4.0.3"
162
+ }
163
+ }
@@ -0,0 +1,47 @@
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
+ {{GITHUB_ACTIONS_BADGES}}
5
+
6
+ # {{PKG_NAME}}
7
+
8
+ Convert to/from non-negative integers represented with [ES-2020 native JS implementation of BigInt](https://tc39.es/ecma262/#sec-bigint-objects) from/to:
9
+
10
+ - `Buffer` (node.js) or `ArrayBuffer|TypedArray` (native js),
11
+ - hex `string`,
12
+ - utf8-encoded text `string`,
13
+ - standard and url-safe base64 with and without padding.
14
+
15
+ It provides a common interface for the conversions that works for both **node.js** and **native javascript**.
16
+
17
+ > 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()`.
18
+
19
+ ## Usage
20
+
21
+ `{{PKG_NAME}}` can be imported to your project with `npm`:
22
+
23
+ ```console
24
+ npm install {{PKG_NAME}}
25
+ ```
26
+
27
+ Then either require (Node.js CJS):
28
+
29
+ ```javascript
30
+ const {{PKG_CAMELCASE}} = require('{{PKG_NAME}}')
31
+ ```
32
+
33
+ or import (JavaScript ES module):
34
+
35
+ ```javascript
36
+ import * as {{PKG_CAMELCASE}} from '{{PKG_NAME}}'
37
+ ```
38
+
39
+ The appropriate version for browser or node is automatically exported.
40
+
41
+ > 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`.
42
+
43
+ You can also download the {{IIFE_BUNDLE}}, the {{ESM_BUNDLE}} or the {{UMD_BUNDLE}} and manually add it to your project, or, if you have already installed `{{PKG_NAME}}` in your project, just get the bundles from `node_modules/{{PKG_NAME}}/dist/bundles/`.
44
+
45
+ ## API reference documentation
46
+
47
+ [Check the API](./docs/API.md)