@gsknnft/bigint-buffer 1.3.2 → 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 (106) hide show
  1. package/README.md +123 -126
  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/index.cjs +1 -205
  25. package/dist/index.js +347 -202
  26. package/dist/index.umd.js +1 -0
  27. package/dist/tsconfig.tsbuildinfo +1 -0
  28. package/dist/types/bigint-buffer.test.d.ts +1 -0
  29. package/dist/types/conversion/index.d.ts +1 -0
  30. package/dist/types/conversion/src/ts/index.d.ts +168 -0
  31. package/dist/types/conversion/test/bigintToBase64.test.d.ts +1 -0
  32. package/dist/types/conversion/test/bigintToBuf.test.d.ts +1 -0
  33. package/dist/types/conversion/test/bigintToHex.test.d.ts +1 -0
  34. package/dist/types/conversion/test/bigintToText.test.d.ts +1 -0
  35. package/dist/types/conversion/test/bufToBigint.test.d.ts +1 -0
  36. package/dist/types/conversion/test/hexToBigint.test.d.ts +1 -0
  37. package/dist/types/conversion/test/hexToBuf.test.d.ts +1 -0
  38. package/dist/types/conversion/test/parseHex.test.d.ts +1 -0
  39. package/dist/types/conversion/test/setup.test.d.ts +1 -0
  40. package/dist/types/conversion/test/textToBuf.test.d.ts +1 -0
  41. package/dist/types/conversion/vite.config.d.ts +2 -0
  42. package/dist/types/conversion/vitest.config.d.ts +2 -0
  43. package/dist/types/dist/dist/conversion/conversion/index.d.ts +1 -0
  44. package/dist/{index.d.ts → types/dist/dist/index.d.ts} +2 -0
  45. package/dist/types/index.bench.d.ts +1 -0
  46. package/dist/types/index.d.ts +80 -0
  47. package/dist/types/index.spec.d.ts +1 -0
  48. package/package.json +83 -49
  49. package/src/bigint-buffer.test.ts +11 -0
  50. package/src/conversion/.github/workflows/build-and-test.yml +116 -0
  51. package/src/conversion/CODE_OF_CONDUCT.md +134 -0
  52. package/src/conversion/LICENSE +21 -0
  53. package/src/conversion/README.md +48 -0
  54. package/src/conversion/docs/README.md +34 -0
  55. package/src/conversion/docs/functions/base64ToBigint.md +27 -0
  56. package/src/conversion/docs/functions/bigintToBase64.md +43 -0
  57. package/src/conversion/docs/functions/bigintToBuf.md +35 -0
  58. package/src/conversion/docs/functions/bigintToHex.md +43 -0
  59. package/src/conversion/docs/functions/bigintToText.md +31 -0
  60. package/src/conversion/docs/functions/bufToBigint.md +25 -0
  61. package/src/conversion/docs/functions/bufToHex.md +37 -0
  62. package/src/conversion/docs/functions/bufToText.md +27 -0
  63. package/src/conversion/docs/functions/hexToBigint.md +29 -0
  64. package/src/conversion/docs/functions/hexToBuf.md +37 -0
  65. package/src/conversion/docs/functions/parseHex.md +45 -0
  66. package/src/conversion/docs/functions/textToBigint.md +27 -0
  67. package/src/conversion/docs/functions/textToBuf.md +33 -0
  68. package/src/conversion/docs/functions/toBigIntBE.md +27 -0
  69. package/src/conversion/docs/functions/toBigIntLE.md +27 -0
  70. package/src/conversion/docs/functions/toBufferBE.md +33 -0
  71. package/src/conversion/docs/functions/toBufferLE.md +33 -0
  72. package/src/conversion/docs/functions/validateBigIntBuffer.md +15 -0
  73. package/src/conversion/docs/type-aliases/TypedArray.md +11 -0
  74. package/src/conversion/docs/variables/isNative.md +11 -0
  75. package/src/conversion/example.cjs +9 -0
  76. package/src/conversion/example.esm.js +11 -0
  77. package/src/conversion/index.ts +1 -0
  78. package/src/conversion/package.json +163 -0
  79. package/src/conversion/src/docs/index.md +47 -0
  80. package/src/conversion/src/ts/index.ts +514 -0
  81. package/src/conversion/test/bigintToBase64.test.ts +37 -0
  82. package/src/conversion/test/bigintToBuf.test.ts +43 -0
  83. package/src/conversion/test/bigintToHex.test.ts +52 -0
  84. package/src/conversion/test/bigintToText.test.ts +30 -0
  85. package/src/conversion/test/bufToBigint.test.ts +20 -0
  86. package/src/conversion/test/hexToBigint.test.ts +22 -0
  87. package/src/conversion/test/hexToBuf.test.ts +39 -0
  88. package/src/conversion/test/parseHex.test.ts +35 -0
  89. package/src/conversion/test/setup.test.ts +9 -0
  90. package/src/conversion/test/textToBuf.test.ts +26 -0
  91. package/src/conversion/tsconfig.json +57 -0
  92. package/src/conversion/tsconfig.rollup.json +9 -0
  93. package/src/conversion/typedoc.json +5 -0
  94. package/src/conversion/types/bindings.d.t.s +4 -0
  95. package/src/conversion/vite.config.ts +10 -0
  96. package/src/conversion/vitest.config.ts +15 -0
  97. package/src/index.bench.ts +5 -6
  98. package/src/index.spec.ts +232 -358
  99. package/src/index.ts +33 -28
  100. package/.travis.yml +0 -51
  101. package/PR_TEMPLATE.md +0 -53
  102. package/dist/node.js +0 -94
  103. package/karma.conf.js +0 -62
  104. package/rollup.cjs.config.js +0 -8
  105. package/rollup.esm.config.js +0 -15
  106. package/tsconfig.json +0 -20
package/package.json CHANGED
@@ -1,12 +1,56 @@
1
1
  {
2
2
  "name": "@gsknnft/bigint-buffer",
3
- "version": "1.3.2",
4
- "description": "bigint to buffer conversion with native support",
3
+ "version": "1.4.2",
4
+ "description": "bigint to buffer conversion with native support and built-in conversion helpers",
5
5
  "main": "dist/index.js",
6
- "browser": {
7
- "./dist/node.js": "./dist/browser.js"
6
+ "module": "dist/index.js",
7
+ "browser": "dist/browser.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./conversion": {
15
+ "types": "./dist/conversion/index.d.ts",
16
+ "import": "./dist/conversion/index.js",
17
+ "require": "./dist/conversion/index.cjs"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist/",
22
+ "helper/",
23
+ "src/",
24
+ "binding.gyp",
25
+ "build/",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "workspaces": [],
30
+ "scripts": {
31
+ "test": "vitest run",
32
+ "test:watch": "vitest watch",
33
+ "coverage": "vitest cover ./test/index.js",
34
+ "lint": "gts check",
35
+ "install": "node-gyp rebuild",
36
+ "prepublishOnly": "rm -rf build/Makefile; rm build/gyp-*; rm build/*.mk; rm build/*.Makefile; rm *.tgz",
37
+ "clean:js": "npm clean && rm -rf build/* dist/*",
38
+ "test:browser": "vite test --browser",
39
+ "test:node": "mocha build/src/**/*.spec.js --timeout 40000",
40
+ "declare": "tsc -p . --declaration --emitDeclarationOnly --outDir dist/types",
41
+ "benchmark": "node -r ts-node/register src/index.bench.ts",
42
+ "typedoc": "typedoc --out docs $(pwd)/src $(pwd)/helper --target es6 --mode file --tsconfig ./tsconfig.json --excludePrivate --excludeProtected --excludeNotExported --exclude '**/*+(spec|bench).ts'",
43
+ "rebuild:native": "node-gyp rebuild",
44
+ "build": "vite build && npm run declare && tsc -p . && cpy \"index.d.ts\" ../dist --cwd dist/types && cpy \"conversion/index.d.ts\" ../dist/conversion --cwd dist/types",
45
+ "compile": "vite build && npm run declare && tsc -p . && cpy \"index.d.ts\" ../dist/types --cwd dist/types && cpy \"conversion/index.d.ts\" ../dist/conversion --cwd dist/types",
46
+ "check": "eslint src/**/*.ts src/conversion/**/*.ts src/index.spec.ts src/conversion/test/**/*.ts",
47
+ "test:vitest": "vitest",
48
+ "test:all": "pnpm run test && pnpm run benchmark",
49
+ "clean": "gts clean",
50
+ "fix": "gts fix",
51
+ "pretest": "npm run compile",
52
+ "posttest": "npm run check"
8
53
  },
9
- "types": "dist/index.d.ts",
10
54
  "repository": {
11
55
  "type": "git",
12
56
  "url": "https://github.com/gsknnft/bigint-buffer.git"
@@ -22,49 +66,57 @@
22
66
  "napi"
23
67
  ],
24
68
  "license": "Apache-2.0",
25
- "dependencies": {
69
+ "pnpm": {
70
+ "overrides": {
71
+ "tmp": "0.2.5"
72
+ }
73
+ },
74
+ "optionalDependencies": {
26
75
  "bindings": "^1.5.0"
27
76
  },
28
77
  "devDependencies": {
78
+ "@rollup/plugin-commonjs": "^29.0.0",
79
+ "@rollup/plugin-esm-shim": "0.1.8",
80
+ "@rollup/plugin-json": "^6.1.0",
81
+ "@rollup/plugin-node-resolve": "^16.0.3",
82
+ "@rollup/plugin-replace": "6.0.3",
83
+ "@rollup/plugin-typescript": "^12.1.4",
29
84
  "@types/benchmark": "^2.1.5",
30
85
  "@types/bn.js": "^5.2.0",
31
86
  "@types/chai": "^5.2.3",
32
87
  "@types/mocha": "^10.0.10",
33
- "@types/node": "^24.9.1",
88
+ "@types/node": "^24.10.1",
89
+ "@vitest/coverage-v8": "4.0.14",
90
+ "assertion-error": "^2.0.1",
34
91
  "benchmark": "^2.1.4",
92
+ "bindings": "1.5.0",
35
93
  "bn.js": "^5.2.2",
36
- "chai": "^4.1.2",
37
- "coveralls": "^3.1.1",
38
94
  "cpy-cli": "^6.0.0",
39
- "cross-env": "^6.0.3",
40
- "gts": "^0.8.0",
41
- "istanbul": "^0.4.1",
42
- "karma": "^3.0.0",
43
- "karma-chrome-launcher": "^2.2.0",
95
+ "cross-env": "^10.1.0",
96
+ "eslint": "^9.39.1",
97
+ "globals": "^16.5.0",
98
+ "gts": "^6.0.2",
99
+ "jiti": "^2.6.1",
100
+ "karma": "^6.4.4",
101
+ "karma-chrome-launcher": "^3.2.0",
44
102
  "karma-env-preprocessor": "^0.1.1",
45
- "karma-mocha": "^1.3.0",
103
+ "karma-mocha": "^2.0.1",
46
104
  "karma-mocha-reporter": "^2.2.5",
47
- "karma-webpack": "^3.0.0",
105
+ "karma-webpack": "^5.0.1",
48
106
  "microtime": "^3.0.0",
49
- "mkdirp": "^0.5.1",
50
- "mocha": "^5.2.0",
51
- "pre-commit": "^1.2.2",
52
- "rollup": "^4.52.5",
53
- "@rollup/plugin-replace": "6.0.3",
107
+ "mkdirp": "^3.0.1",
108
+ "rollup": "^4.53.3",
54
109
  "ts-loader": "^9.5.4",
55
110
  "ts-node": "^10.9.2",
56
111
  "typedoc": "^0.28.14",
57
112
  "typescript": "5.9.3",
58
- "webpack": "5.102.1",
113
+ "typescript-eslint": "^8.48.0",
114
+ "undici-types": "^7.16.0",
115
+ "vite": "7.2.4",
116
+ "vitest": "^4.0.14",
117
+ "webpack": "5.103.0",
59
118
  "webpack-cli": "6.0.1"
60
119
  },
61
- "exports": {
62
- ".": {
63
- "import": "./dist/index.js",
64
- "require": "./dist/index.cjs",
65
- "types": "./dist/index.d.ts"
66
- }
67
- },
68
120
  "engines": {
69
121
  "node": ">=24.0.0"
70
122
  },
@@ -74,23 +126,5 @@
74
126
  "contributors": [
75
127
  "Gordon Skinner <gsknnft@gmail.com> (https://github.com/gsknnft)",
76
128
  "Michael Wei <mwei@vmware.com> (https://github.com/no2chem)"
77
- ],
78
- "scripts": {
79
- "test": "npm run test:node && npm run test:browser",
80
- "coverage": "istanbul cover ./test/index.js",
81
- "coveralls": "npm run coverage && coveralls <coverage/lcov.info",
82
- "lint": "gts check",
83
- "install": "npm run rebuild || echo \"Couldn't build bindings. Non-native version used.\"",
84
- "test:browser": "karma start karma.conf.js",
85
- "test:node": "mocha build/src/**/*.spec.js --timeout 40000",
86
- "benchmark": "node -r ts-node/register src/index.bench.ts",
87
- "typedoc": "typedoc --out docs $(pwd)/src $(pwd)/helper --target es6 --mode file --tsconfig ./tsconfig.json --excludePrivate --excludeProtected --excludeNotExported --exclude '**/*+(spec|bench).ts'",
88
- "rebuild": "node-gyp rebuild",
89
- "check": "gts check",
90
- "clean": "gts clean",
91
- "compile": "tsc -p . && rollup -c rollup.cjs.config.js && rollup -c rollup.esm.config.js && cp build/src/index.d.ts dist/index.d.ts",
92
- "fix": "gts fix",
93
- "pretest": "npm run compile",
94
- "posttest": "npm run check"
95
- }
96
- }
129
+ ]
130
+ }
@@ -0,0 +1,11 @@
1
+ import {describe, expect, it} from 'vitest';
2
+
3
+ describe('bigint-buffer', () => {
4
+ it('should convert bigint to buffer and back', () => {
5
+ // Example test, replace with real logic
6
+ const big = BigInt('12345678901234567890');
7
+ const buf = Buffer.from(big.toString(16), 'hex');
8
+ const result = BigInt('0x' + buf.toString('hex'));
9
+ expect(result).toBe(big);
10
+ });
11
+ });
@@ -0,0 +1,116 @@
1
+ # name: build, test (node and browser), coverage, publish to NPM
2
+
3
+ # on:
4
+ # push:
5
+ # tags:
6
+ # - "v*.*.*"
7
+ # workflow_dispatch:
8
+
9
+ # jobs:
10
+ # build:
11
+ # name: build
12
+ # runs-on: ubuntu-latest
13
+ # steps:
14
+ # - name: Git checkout
15
+ # uses: actions/checkout@v3
16
+
17
+ # - name: Use Node.js 24
18
+ # uses: actions/setup-node@v3
19
+ # with:
20
+ # node-version: 24.x
21
+ # registry-url: "https://registry.npmjs.org"
22
+
23
+ # - name: install
24
+ # run: pnpm ci
25
+
26
+ # - name: build
27
+ # run: pnpm run build
28
+
29
+ # nodetests:
30
+ # name: tests in Node.js
31
+ # needs: [build]
32
+ # runs-on: ${{ matrix.os }}
33
+ # strategy:
34
+ # matrix:
35
+ # os: [ubuntu-latest, windows-latest, macos-latest]
36
+ # node-version: [18.x, 20.x, 21.x]
37
+ # # When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
38
+ # fail-fast: false
39
+ # # The maximum number of jobs that can run simultaneously. Set to 1 if you can't run tests in parallel
40
+ # # max-parallel: 1
41
+ # steps:
42
+ # - name: Git checkout
43
+ # uses: actions/checkout@v3
44
+
45
+ # - name: Use Node.js ${{ matrix.node-version }}
46
+ # uses: actions/setup-node@v3
47
+ # with:
48
+ # node-version: ${{ matrix.node-version }}
49
+ # registry-url: "https://registry.npmjs.org"
50
+
51
+ # - name: install
52
+ # run: pnpm i
53
+
54
+ # - name: node esm tests
55
+ # run: pnpm run test:node-esm
56
+ # # env:
57
+ # # VARIABLE1: ${{ secrets.VARIABLE1 }}
58
+ # # VARIABLE2: ${{ secrets.VARIABLE2 }}
59
+
60
+ # - name: node cjs tests
61
+ # run: pnpm run test:node-cjs
62
+ # # env:
63
+ # # VARIABLE1: ${{ secrets.VARIABLE1 }}
64
+ # # VARIABLE2: ${{ secrets.VARIABLE2 }}
65
+
66
+ # browsertests:
67
+ # needs: [build]
68
+ # name: tests in browser
69
+ # runs-on: ubuntu-latest
70
+ # steps:
71
+ # - name: Git checkout
72
+ # uses: actions/checkout@v3
73
+
74
+ # - name: Use Node.js 20
75
+ # uses: actions/setup-node@v3
76
+ # with:
77
+ # node-version: 20.x
78
+ # registry-url: "https://registry.npmjs.org"
79
+
80
+ # - name: install
81
+ # run: npm ci
82
+
83
+ # - name: browser tests
84
+ # run: npm run test:browser-headless
85
+ # # env:
86
+ # # VARIABLE1: ${{ secrets.VARIABLE1 }}
87
+ # # VARIABLE2: ${{ secrets.VARIABLE2 }}
88
+
89
+ # publish:
90
+ # needs: [nodetests, browsertests]
91
+ # runs-on: ubuntu-latest
92
+ # steps:
93
+ # - name: Git checkout
94
+ # uses: actions/checkout@v3
95
+
96
+ # - name: Install Node.js
97
+ # uses: actions/setup-node@v3
98
+ # with:
99
+ # node-version: "20.x"
100
+ # registry-url: "https://registry.npmjs.org"
101
+
102
+ # - name: install
103
+ # run: npm ci
104
+
105
+ # - name: coverage
106
+ # run: npm run coverage
107
+
108
+ # - name: send report to coveralls.io
109
+ # uses: coverallsapp/github-action@master
110
+ # with:
111
+ # github-token: ${{ secrets.GITHUB_TOKEN }}
112
+
113
+ # - name: NPM publish
114
+ # run: npm publish --access public
115
+ # env:
116
+ # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -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.