@gsknnft/bigint-buffer 1.3.0 → 1.3.1

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 (47) hide show
  1. package/README.md +16 -8
  2. package/dist/browser.js +75 -0
  3. package/dist/index.cjs +90 -0
  4. package/dist/node.js +21 -10
  5. package/helper/bigint.d.ts +2 -2
  6. package/package.json +100 -163
  7. package/rollup.cjs.config.js +8 -0
  8. package/rollup.esm.config.js +13 -0
  9. package/src/index.bench.ts +119 -116
  10. package/src/index.spec.ts +78 -44
  11. package/src/index.ts +35 -40
  12. package/tsconfig.json +2 -5
  13. package/.eslintrc +0 -5
  14. package/okg.md +0 -180
  15. package/rollup.config.js +0 -16
  16. package/src/conversion/LICENSE +0 -21
  17. package/src/conversion/README.md +0 -48
  18. package/src/conversion/docs/README.md +0 -34
  19. package/src/conversion/docs/functions/base64ToBigint.md +0 -27
  20. package/src/conversion/docs/functions/bigintToBase64.md +0 -43
  21. package/src/conversion/docs/functions/bigintToBuf.md +0 -35
  22. package/src/conversion/docs/functions/bigintToHex.md +0 -43
  23. package/src/conversion/docs/functions/bigintToText.md +0 -31
  24. package/src/conversion/docs/functions/bufToBigint.md +0 -25
  25. package/src/conversion/docs/functions/bufToHex.md +0 -37
  26. package/src/conversion/docs/functions/bufToText.md +0 -27
  27. package/src/conversion/docs/functions/hexToBigint.md +0 -29
  28. package/src/conversion/docs/functions/hexToBuf.md +0 -37
  29. package/src/conversion/docs/functions/parseHex.md +0 -45
  30. package/src/conversion/docs/functions/textToBigint.md +0 -27
  31. package/src/conversion/docs/functions/textToBuf.md +0 -33
  32. package/src/conversion/docs/functions/toBigIntBE.md +0 -27
  33. package/src/conversion/docs/functions/toBigIntLE.md +0 -27
  34. package/src/conversion/docs/functions/toBufferBE.md +0 -33
  35. package/src/conversion/docs/functions/toBufferLE.md +0 -33
  36. package/src/conversion/docs/functions/validateBigIntBuffer.md +0 -15
  37. package/src/conversion/docs/type-aliases/TypedArray.md +0 -11
  38. package/src/conversion/docs/variables/isNative.md +0 -11
  39. package/src/conversion/example.cjs +0 -9
  40. package/src/conversion/example.esm.js +0 -11
  41. package/src/conversion/package.json +0 -182
  42. package/src/conversion/pnpm-lock.yaml +0 -5571
  43. package/src/conversion/tsconfig.rollup.json +0 -9
  44. package/src/conversion/typedoc.json +0 -5
  45. package/src/types/bindings.d.t.s +0 -4
  46. package/tsconfig.lint.json +0 -5
  47. package/vitest.config.ts +0 -10
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  As of October 2025, `bigint-buffer@1.1.5` is **compromised and flagged by multiple audit tools** due to unresolved vulnerabilities in its native bindings and transitive dependencies. No upstream patch has been published.
12
12
 
13
- This fork — `@gsknnft/bigint-buffer@1.3.0` — is a **sovereign override**:
13
+ This fork — `@gsknnft/bigint-buffer@1.2.0` — is a **sovereign override**:
14
14
  - ✅ Rebuilt with modern TypeScript and Rollup
15
15
  - ✅ Native bindings patched and rebuilt via `node-gyp`
16
16
  - ✅ Browser fallback formalized via `"browser"` field
@@ -22,7 +22,7 @@ If you're using `bigint-buffer` in a secure or reproducible system, **migrate to
22
22
  ```json
23
23
  "pnpm": {
24
24
  "overrides": {
25
- "bigint-buffer": "@gsknnft/bigint-buffer@1.3.0"
25
+ "bigint-buffer": "@gsknnft/bigint-buffer@1.2.0"
26
26
  }
27
27
  }
28
28
  ```
@@ -85,6 +85,12 @@ const base64 = bigintToBase64(123456789n); // → "B1vNFQ=="
85
85
 
86
86
  ---
87
87
 
88
+ The original introduced utilities for converting TC39 BigInts to and from buffers. This fork builds on that foundation with modern tooling, patched bindings, and reproducible builds.
89
+
90
+ This utility is necessary because BigInts, as proposed, do not support direct conversion between Buffers (or UInt8Arrays), but rather require conversion from buffers to hexadecimal strings then to BigInts, which is suboptimal. This utility includes N-API bindings, so under node, conversion is performed without generating a hexadecimal string. In the browser, normal string conversion is used.
91
+
92
+ ---
93
+
88
94
  # Why use BigInts?
89
95
 
90
96
  BigInts are currently a stage 3 proposal, supported in Node 10 and V8 v6.7. BigInts are primitive arbitrary precision integers, overcoming the limitations of the number type in javascript, which only supports up to 53 bits of precision.
@@ -140,7 +146,7 @@ bigint from hex string from buffer (huge): 1230607±1.02% ops/s 812.61±40.013 n
140
146
 
141
147
  bigint-buffer introduces four functions for conversion between buffers and bigints. A small example follows:
142
148
  ```typescript
143
- import {toBigIntBE, toBigIntLE, toBufferBE, toBufferLE} from 'bigint-buffer';
149
+ import {toBigIntBE, toBigIntLE, toBufferBE, toBufferLE} from '@gsknnft/bigint-buffer';
144
150
 
145
151
  // Get a big endian buffer of the given width
146
152
  toBufferBE(0xdeadbeefn, 8);
@@ -176,8 +182,6 @@ BE bigint to hex string to buffer (large): 1714292±1.35% ops/s 583.33±37.995 n
176
182
  BE bigint-buffer to buffer (large, truncated): 5977218±4.68% ops/s 167.30±37.284 ns/op (87 runs)
177
183
  ```
178
184
 
179
- You can run the benchmarks by running `npm run benchmark`.
180
-
181
185
  # Typescript Support
182
186
 
183
187
  bigint-buffer supplies typescript bindings, but BigInts are still not supported in typescript, though
@@ -188,13 +192,17 @@ a pull request has been opened, so support should be coming soon. If you are usi
188
192
 
189
193
  Add bigint-buffer to your project with:
190
194
 
191
- > `npm install bigint-buffer`
195
+ > `pnpm add @gsknnft/bigint-buffer`
196
+
197
+ or
198
+
199
+ > `npm install @gsknnft/bigint-buffer`
192
200
 
193
201
  # Documentation
194
202
 
195
- Basic API documentation can be found [here](https://no2chem.github.io/bigint-buffer/). Note that v1.0.0 changes
203
+ Basic API documentation can be found [here](https://gsknnft.github.io/bigint-buffer/). Note that v1.0.0 changes
196
204
  the name of the original functions to meet style guidelines.
197
205
 
198
206
  # Benchmarks
199
207
 
200
- Benchmarks can be run by executing `npm run benchmark` from the package directory.
208
+ Benchmarks can be run by executing `pnpm run benchmark` from the package directory.
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isNative = void 0;
5
+ exports.toBigIntLE = toBigIntLE;
6
+ exports.validateBigIntBuffer = validateBigIntBuffer;
7
+ exports.toBigIntBE = toBigIntBE;
8
+ exports.toBufferLE = toBufferLE;
9
+ exports.toBufferBE = toBufferBE;
10
+ exports.isNative = false;
11
+ /**
12
+ * Convert a little-endian buffer into a BigInt.
13
+ * @param buf The little-endian buffer to convert
14
+ * @returns A BigInt with the little-endian representation of buf.
15
+ */
16
+ function toBigIntLE(buf) {
17
+ {
18
+ const reversed = Buffer.from(buf);
19
+ reversed.reverse();
20
+ const hex = reversed.toString('hex');
21
+ if (hex.length === 0) {
22
+ return BigInt(0);
23
+ }
24
+ return BigInt(`0x${hex}`);
25
+ }
26
+ }
27
+ function validateBigIntBuffer() {
28
+ try {
29
+ const test = toBigIntLE(Buffer.from([0x01, 0x00]));
30
+ return test === BigInt(1);
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ /**
37
+ * Convert a big-endian buffer into a BigInt
38
+ * @param buf The big-endian buffer to convert.
39
+ * @returns A BigInt with the big-endian representation of buf.
40
+ */
41
+ function toBigIntBE(buf) {
42
+ {
43
+ const hex = buf.toString('hex');
44
+ if (hex.length === 0) {
45
+ return BigInt(0);
46
+ }
47
+ return BigInt(`0x${hex}`);
48
+ }
49
+ }
50
+ /**
51
+ * Convert a BigInt to a little-endian buffer.
52
+ * @param num The BigInt to convert.
53
+ * @param width The number of bytes that the resulting buffer should be.
54
+ * @returns A little-endian buffer representation of num.
55
+ */
56
+ function toBufferLE(num, width) {
57
+ {
58
+ const hex = num.toString(16);
59
+ const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
60
+ buffer.reverse();
61
+ return buffer;
62
+ }
63
+ }
64
+ /**
65
+ * Convert a BigInt to a big-endian buffer.
66
+ * @param num The BigInt to convert.
67
+ * @param width The number of bytes that the resulting buffer should be.
68
+ * @returns A big-endian buffer representation of num.
69
+ */
70
+ function toBufferBE(num, width) {
71
+ {
72
+ const hex = num.toString(16);
73
+ return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
74
+ }
75
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isNative = void 0;
5
+ exports.toBigIntLE = toBigIntLE;
6
+ exports.validateBigIntBuffer = validateBigIntBuffer;
7
+ exports.toBigIntBE = toBigIntBE;
8
+ exports.toBufferLE = toBufferLE;
9
+ exports.toBufferBE = toBufferBE;
10
+ let converter;
11
+ exports.isNative = false;
12
+ if (!process.browser) {
13
+ try {
14
+ converter = require('bindings')('bigint_buffer');
15
+ exports.isNative = !process.browser && converter !== undefined;
16
+ }
17
+ catch (e) {
18
+ console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
19
+ }
20
+ }
21
+ /**
22
+ * Convert a little-endian buffer into a BigInt.
23
+ * @param buf The little-endian buffer to convert
24
+ * @returns A BigInt with the little-endian representation of buf.
25
+ */
26
+ function toBigIntLE(buf) {
27
+ if (process.browser || converter === undefined) {
28
+ const reversed = Buffer.from(buf);
29
+ reversed.reverse();
30
+ const hex = reversed.toString('hex');
31
+ if (hex.length === 0) {
32
+ return BigInt(0);
33
+ }
34
+ return BigInt(`0x${hex}`);
35
+ }
36
+ return converter.toBigInt(buf, false);
37
+ }
38
+ function validateBigIntBuffer() {
39
+ try {
40
+ const test = toBigIntLE(Buffer.from([0x01, 0x00]));
41
+ return test === BigInt(1);
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ /**
48
+ * Convert a big-endian buffer into a BigInt
49
+ * @param buf The big-endian buffer to convert.
50
+ * @returns A BigInt with the big-endian representation of buf.
51
+ */
52
+ function toBigIntBE(buf) {
53
+ if (process.browser || converter === undefined) {
54
+ const hex = buf.toString('hex');
55
+ if (hex.length === 0) {
56
+ return BigInt(0);
57
+ }
58
+ return BigInt(`0x${hex}`);
59
+ }
60
+ return converter.toBigInt(buf, true);
61
+ }
62
+ /**
63
+ * Convert a BigInt to a little-endian buffer.
64
+ * @param num The BigInt to convert.
65
+ * @param width The number of bytes that the resulting buffer should be.
66
+ * @returns A little-endian buffer representation of num.
67
+ */
68
+ function toBufferLE(num, width) {
69
+ if (process.browser || converter === undefined) {
70
+ const hex = num.toString(16);
71
+ const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
72
+ buffer.reverse();
73
+ return buffer;
74
+ }
75
+ // Allocation is done here, since it is slower using napi in C
76
+ return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
77
+ }
78
+ /**
79
+ * Convert a BigInt to a big-endian buffer.
80
+ * @param num The BigInt to convert.
81
+ * @param width The number of bytes that the resulting buffer should be.
82
+ * @returns A big-endian buffer representation of num.
83
+ */
84
+ function toBufferBE(num, width) {
85
+ if (process.browser || converter === undefined) {
86
+ const hex = num.toString(16);
87
+ return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
88
+ }
89
+ return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
90
+ }
package/dist/node.js CHANGED
@@ -1,6 +1,5 @@
1
- var __importDefault = (undefined && undefined.__importDefault) || function (mod) {
2
- return (mod && mod.__esModule) ? mod : { "default": mod };
3
- };
1
+ 'use strict';
2
+
4
3
  Object.defineProperty(exports, "__esModule", { value: true });
5
4
  exports.isNative = void 0;
6
5
  exports.toBigIntLE = toBigIntLE;
@@ -8,17 +7,24 @@ exports.validateBigIntBuffer = validateBigIntBuffer;
8
7
  exports.toBigIntBE = toBigIntBE;
9
8
  exports.toBufferLE = toBufferLE;
10
9
  exports.toBufferBE = toBufferBE;
11
- // etc.
12
- const bindings_1 = __importDefault(require("bindings"));
13
- (0, bindings_1.default)('bigint_buffer');
10
+ let converter;
14
11
  exports.isNative = false;
12
+ {
13
+ try {
14
+ converter = require('bindings')('bigint_buffer');
15
+ exports.isNative = !false && converter !== undefined;
16
+ }
17
+ catch (e) {
18
+ console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
19
+ }
20
+ }
15
21
  /**
16
22
  * Convert a little-endian buffer into a BigInt.
17
23
  * @param buf The little-endian buffer to convert
18
24
  * @returns A BigInt with the little-endian representation of buf.
19
25
  */
20
26
  function toBigIntLE(buf) {
21
- {
27
+ if (converter === undefined) {
22
28
  const reversed = Buffer.from(buf);
23
29
  reversed.reverse();
24
30
  const hex = reversed.toString('hex');
@@ -27,6 +33,7 @@ function toBigIntLE(buf) {
27
33
  }
28
34
  return BigInt(`0x${hex}`);
29
35
  }
36
+ return converter.toBigInt(buf, false);
30
37
  }
31
38
  function validateBigIntBuffer() {
32
39
  try {
@@ -43,13 +50,14 @@ function validateBigIntBuffer() {
43
50
  * @returns A BigInt with the big-endian representation of buf.
44
51
  */
45
52
  function toBigIntBE(buf) {
46
- {
53
+ if (converter === undefined) {
47
54
  const hex = buf.toString('hex');
48
55
  if (hex.length === 0) {
49
56
  return BigInt(0);
50
57
  }
51
58
  return BigInt(`0x${hex}`);
52
59
  }
60
+ return converter.toBigInt(buf, true);
53
61
  }
54
62
  /**
55
63
  * Convert a BigInt to a little-endian buffer.
@@ -58,12 +66,14 @@ function toBigIntBE(buf) {
58
66
  * @returns A little-endian buffer representation of num.
59
67
  */
60
68
  function toBufferLE(num, width) {
61
- {
69
+ if (converter === undefined) {
62
70
  const hex = num.toString(16);
63
71
  const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
64
72
  buffer.reverse();
65
73
  return buffer;
66
74
  }
75
+ // Allocation is done here, since it is slower using napi in C
76
+ return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
67
77
  }
68
78
  /**
69
79
  * Convert a BigInt to a big-endian buffer.
@@ -72,8 +82,9 @@ function toBufferLE(num, width) {
72
82
  * @returns A big-endian buffer representation of num.
73
83
  */
74
84
  function toBufferBE(num, width) {
75
- {
85
+ if (converter === undefined) {
76
86
  const hex = num.toString(16);
77
87
  return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
78
88
  }
89
+ return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
79
90
  }
@@ -1,3 +1,3 @@
1
1
  // not used by code, only for documentation generation (since typedoc can't handle BigInt yet)
2
- type BigIntDoc = number
3
- declare const BigIntDoc: typeof Number
2
+ type BigInt = number
3
+ declare const BigInt: typeof Number
package/package.json CHANGED
@@ -1,163 +1,100 @@
1
- {
2
- "name": "@gsknnft/bigint-buffer",
3
- "version": "1.3.0",
4
- "description": "bigint to buffer conversion with native support",
5
- "main": "dist/index.js",
6
- "browser": {
7
- "./dist/node.js": "./dist/browser.js"
8
- },
9
- "directories": {
10
- "build": "./build",
11
- "dist": "./dist",
12
- "docs": "./docs",
13
- "src": "./src",
14
- "test": "./test",
15
- "benchmark": "./benchmark",
16
- "mocha-ts": "./.mocha-ts"
17
- },
18
- "types": "dist/index.d.ts",
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/gsknnft/bigint-buffer.git"
22
- },
23
- "bugs": {
24
- "url": "https://github.com/gsknnft/bigint-buffer/issues"
25
- },
26
- "homepage": "https://github.com/gsknnft/bigintbuffer",
27
- "keywords": [
28
- "bigint",
29
- "bignum",
30
- "tc39-bigint",
31
- "napi"
32
- ],
33
- "license": "Apache-2.0",
34
- "dependencies": {
35
- "@juanelas/base64": "^1.1.5",
36
- "bindings": "^1.5.0"
37
- },
38
- "devDependencies": {
39
- "@rollup/plugin-commonjs": "^28.0.9",
40
- "@rollup/plugin-inject": "^5.0.5",
41
- "@rollup/plugin-json": "^6.1.0",
42
- "@rollup/plugin-multi-entry": "^7.0.1",
43
- "@rollup/plugin-node-resolve": "^16.0.3",
44
- "@rollup/plugin-replace": "^6.0.2",
45
- "@rollup/plugin-terser": "^0.4.4",
46
- "@rollup/plugin-typescript": "^12.3.0",
47
- "@types/benchmark": "^2.1.5",
48
- "@types/bindings": "^1.5.5",
49
- "@types/bn.js": "^5.2.0",
50
- "@types/chai": "^5.2.3",
51
- "@types/mocha": "^10.0.10",
52
- "@types/node": "^24.9.1",
53
- "benchmark": "^2.1.4",
54
- "bn.js": "^5.2.2",
55
- "c8": "^10.1.3",
56
- "chai": "^6.2.0",
57
- "coveralls": "^3.1.1",
58
- "cpy-cli": "^6.0.0",
59
- "cross-env": "^6.0.3",
60
- "glob": "^11.0.3",
61
- "gts": "^0.8.0",
62
- "istanbul": "^0.4.1",
63
- "jsdom": "^27.0.1",
64
- "json5": "^2.2.3",
65
- "karma": "^3.0.0",
66
- "karma-chrome-launcher": "^2.2.0",
67
- "karma-env-preprocessor": "^0.1.1",
68
- "karma-mocha": "^1.3.0",
69
- "karma-mocha-reporter": "^2.2.5",
70
- "karma-webpack": "^3.0.0",
71
- "microtime": "^3.0.0",
72
- "minimatch": "^10.0.3",
73
- "mkdirp": "^0.5.1",
74
- "mocha": "^11.7.4",
75
- "npm-run-all": "^4.1.5",
76
- "pirates": "^4.0.7",
77
- "pre-commit": "^1.2.2",
78
- "puppeteer": "^24.26.1",
79
- "rimraf": "^6.0.1",
80
- "rollup": "^4.52.5",
81
- "rollup-plugin-dts": "^6.2.3",
82
- "rollup-plugin-esbuild": "^6.2.1",
83
- "ts-loader": "^9.5.4",
84
- "ts-node": "^10.9.2",
85
- "ts-standard": "^12.0.2",
86
- "tslib": "^2.8.1",
87
- "typedoc": "^0.28.14",
88
- "typedoc-plugin-markdown": "^4.9.0",
89
- "typescript": "5.9.3",
90
- "vite": "^7.1.12",
91
- "vitest": "^4.0.3",
92
- "webpack": "5.102.1",
93
- "webpack-cli": "6.0.1"
94
- },
95
- "exports": {
96
- ".": {
97
- "types": "./dist/index.d.ts",
98
- "import": "./dist/index.js",
99
- "require": "./dist/index.cjs"
100
- },
101
- "./conversion": {
102
- "types": "./dist/conversion/index.d.ts",
103
- "import": "./dist/conversion/index.js",
104
- "require": "./dist/conversion/index.cjs"
105
- }
106
- },
107
- "engines": {
108
- "node": ">=24.0.0"
109
- },
110
- "publishConfig": {
111
- "access": "public"
112
- },
113
- "contributors": [
114
- "Gordon Skinner <gsknnft@gmail.com> (https://github.com/gsknnft)",
115
- "Michael Wei <mwei@vmware.com> (https://github.com/no2chem)"
116
- ],
117
- "scripts": {
118
- "_build:cleantypes": "rimraf .types",
119
- "_build:cjsAndesmPkgJsons": "node ./build/bin/post-build.js",
120
- "build": "run-s lint:src build:js lint:test docs",
121
- "build:js": "rollup -c build/rollup.config.mjs",
122
- "postbuild:js": "run-s _build:cleantypes _build:cjsAndesmPkgJsons",
123
- "clean": "rimraf .mocha-ts coverage dist .types docs",
124
- "coverage": "c8 --clean --check-coverage --exclude \"{src/ts/**/*.spec.ts,src/ts/**/*.test.ts,test,test-vectors,build}\" --exclude-after-remap --reporter=text --reporter=lcov node ./build/bin/mocha-ts.js --commonjs ",
125
- "docs": "node build/build.docs.js",
126
- "git:add": "git add -A",
127
- "lint": "ts-standard --fix",
128
- "lint:src": "ts-standard --fix \"src/**/!(*.spec|*.test).ts\"",
129
- "lint:test": "ts-standard --fix \"{test/**/*.ts,src/**/*.spec.ts,src/**/*.test.ts}\"",
130
- "mocha-ts": "node --experimental-modules --experimental-json-modules --es-module-specifier-resolution=node ./build/bin/mocha-ts.js ",
131
- "mocha-ts:cjs": "node ./build/bin/mocha-ts.js --commonjs ",
132
- "mocha-ts:watch": "npm run mocha-ts:cjs -- --watch --timeout 0",
133
- "mocha-ts:browser": "node build/testing/browser/index.js ",
134
- "mocha-ts:browser-headless": "node build/testing/browser/index.js headless ",
135
- "preversion": "run-s clean lint:src build:js lint:test coverage test:browser-headless",
136
- "version": "run-s docs git:add",
137
- "postversion": "git push --follow-tags",
138
- "test:conv": "run-s test:node test:browser-headless",
139
- "test:browser:conv": "npm run mocha-ts:browser",
140
- "test:browser-headless": "npm run mocha-ts:browser-headless",
141
- "test:node:conv": "run-s test:node-cjs test:node-esm",
142
- "test:node-cjs": "npm run mocha-ts:cjs ",
143
- "test:node-esm": "npm run mocha-ts ",
144
- "watch": "npm run mocha-ts:watch ",
145
- "test": "npm run test:node && npm run test:browser",
146
- "coverage:istan": "istanbul cover ./test/index.js",
147
- "coveralls": "npm run coverage && coveralls <coverage/lcov.info",
148
- "lint:gts": "gts check",
149
- "install": "npm run rebuild || echo \"Couldn't build bindings. Non-native version used.\"",
150
- "test:browser": "karma start karma.conf.js",
151
- "test:node": "mocha -r ts-node/register src/**/*.spec.ts --timeout 40000",
152
- "benchmark": "node -r ts-node/register src/index.bench.ts",
153
- "typedoc": "typedoc --out docs $(pwd)/src $(pwd)/helper --target es6 --mode file --tsconfig ./tsconfig.json --excludePrivate --excludeProtected --excludeNotExported --exclude '**/*+(spec|bench).ts'",
154
- "rebuild": "node-gyp rebuild",
155
- "check": "gts check",
156
- "clean:gts": "gts clean",
157
- "compile": "tsc -p . && rollup -c && cross-env BROWSER=true rollup -c && cpy \"build/src/*.d.ts\" dist || echo \"No .d.ts files to copy\"",
158
- "compileOG": "mkdirp dist && tsc -p . && rollup -c > dist/node.js && cross-env BROWSER=true rollup -c > dist/browser.js && cpx \"build/src/*.d.ts\" dist",
159
- "fix": "gts fix",
160
- "pretest": "npm run compile",
161
- "posttest": "npm run check"
162
- }
163
- }
1
+ {
2
+ "name": "@gsknnft/bigint-buffer",
3
+ "version": "1.3.1",
4
+ "description": "bigint to buffer conversion with native support",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "browser": {
8
+ "./dist/node.js": "./dist/browser.js"
9
+ },
10
+ "types": "dist/index.d.ts",
11
+ "scripts": {
12
+ "test": "npm run test:node && npm run test:browser",
13
+ "coverage": "istanbul cover ./test/index.js",
14
+ "coveralls": "npm run coverage && coveralls <coverage/lcov.info",
15
+ "lint": "gts check",
16
+ "install": "npm run rebuild || echo \"Couldn't build bindings. Non-native version used.\"",
17
+ "prepare": "npm run compile",
18
+ "prepublishOnly": "rm -rf build/Release; rm build/Makefile; rm build/gyp-*; rm build/*.mk; rm build/*.Makefile; rm *.tgz",
19
+ "test:browser": "karma start karma.conf.js",
20
+ "test:node": "mocha -r ts-node/register src/**/*.spec.ts --timeout 40000",
21
+ "benchmark": "node -r ts-node/register src/index.bench.ts",
22
+ "typedoc": "typedoc --out docs $(pwd)/src $(pwd)/helper --target es6 --mode file --tsconfig ./tsconfig.json --excludePrivate --excludeProtected --excludeNotExported --exclude '**/*+(spec|bench).ts'",
23
+ "rebuild": "node-gyp rebuild",
24
+ "check": "gts check",
25
+ "clean": "gts clean",
26
+ "compile": "tsc -p . && rollup -c rollup.cjs.config.js && rollup -c rollup.esm.config.js && cpy build/src/*.d.ts dist",
27
+ "compileOG": "mkdirp dist && tsc -p . && rollup -c > dist/node.js && cross-env BROWSER=true rollup -c > dist/browser.js && cpx \"build/src/*.d.ts\" dist",
28
+ "fix": "gts fix",
29
+ "pretest": "npm run compile",
30
+ "posttest": "npm run check"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/gsknnft/bigint-buffer.git"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/gsknnft/bigint-buffer/issues"
38
+ },
39
+ "homepage": "https://github.com/gsknnft/bigintbuffer",
40
+ "keywords": [
41
+ "bigint",
42
+ "bignum",
43
+ "tc39-bigint",
44
+ "napi"
45
+ ],
46
+ "license": "Apache-2.0",
47
+ "dependencies": {
48
+ "bindings": "^1.5.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/benchmark": "^2.1.5",
52
+ "@types/bn.js": "^5.2.0",
53
+ "@types/chai": "^5.2.3",
54
+ "@types/mocha": "^10.0.10",
55
+ "@types/node": "^24.9.1",
56
+ "benchmark": "^2.1.4",
57
+ "bn.js": "^5.2.2",
58
+ "chai": "^4.1.2",
59
+ "coveralls": "^3.1.1",
60
+ "cpy-cli": "^6.0.0",
61
+ "cross-env": "^6.0.3",
62
+ "gts": "^0.8.0",
63
+ "istanbul": "^0.4.1",
64
+ "karma": "^3.0.0",
65
+ "karma-chrome-launcher": "^2.2.0",
66
+ "karma-env-preprocessor": "^0.1.1",
67
+ "karma-mocha": "^1.3.0",
68
+ "karma-mocha-reporter": "^2.2.5",
69
+ "karma-webpack": "^3.0.0",
70
+ "microtime": "^3.0.0",
71
+ "mkdirp": "^0.5.1",
72
+ "mocha": "^5.2.0",
73
+ "pre-commit": "^1.2.2",
74
+ "rollup": "^4.52.5",
75
+ "rollup-plugin-replace": "^2.2.0",
76
+ "ts-loader": "^9.5.4",
77
+ "ts-node": "^10.9.2",
78
+ "typedoc": "^0.28.14",
79
+ "typescript": "5.9.3",
80
+ "webpack": "5.102.1",
81
+ "webpack-cli": "6.0.1"
82
+ },
83
+ "exports": {
84
+ ".": {
85
+ "import": "./dist/index.js",
86
+ "require": "./dist/index.cjs",
87
+ "types": "./dist/index.d.ts"
88
+ }
89
+ },
90
+ "engines": {
91
+ "node": ">=24.0.0"
92
+ },
93
+ "publishConfig": {
94
+ "access": "public"
95
+ },
96
+ "contributors": [
97
+ "Gordon Skinner <gsknnft@gmail.com> (https://github.com/gsknnft)",
98
+ "Michael Wei <mwei@vmware.com> (https://github.com/no2chem)"
99
+ ]
100
+ }
@@ -0,0 +1,8 @@
1
+ export default {
2
+ input: 'build/src/index.js',
3
+ output: {
4
+ file: 'dist/index.cjs',
5
+ format: 'cjs',
6
+ },
7
+ external: ['bindings'],
8
+ };
@@ -0,0 +1,13 @@
1
+ import replace from 'rollup-plugin-replace';
2
+
3
+ export default {
4
+ input: 'build/src/index.js',
5
+ output: {
6
+ format: 'cjs'
7
+ },
8
+ plugins: [
9
+ replace({
10
+ 'process.browser': process.env.BROWSER === "true"
11
+ })
12
+ ]
13
+ };