fixed issue with workers in node 10

This commit is contained in:
Juan Hernández Serrano 2021-08-04 12:50:36 +02:00
parent 954321199d
commit d8080ace91
6 changed files with 745 additions and 14 deletions

View File

@ -27,6 +27,12 @@ Then either require (Node.js CJS):
const bigintCryptoUtils = require('bigint-crypto-utils')
```
> **Node >=10.4 <11**. `bigint-crypto-utils` uses workers to speed up some operations. Workers are enabled by default with Node.js from version 11. In order to use them with Node >=10.4 and <11, you need to execute node with the flag `--experimental-worker`, and require the .js file manually (otherwise .cjs is required by default and would not be supported by the workers)
>
> ```javascript
> const bigintCryptoUtils = require('bigint-crypto-utils/dist/cjs/index.node') // ONLY FOR node >=10.4 <11 !
> ```
or import (JavaScript ES module):
```javascript

View File

@ -115,12 +115,18 @@ module.exports = [
},
{ // Node CJS
input: input,
output: {
dir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.require)),
entryFileNames: path.basename(pkgJson.exports['.'].node.require),
...sourcemapOutputOptions,
format: 'cjs'
},
output: [
{
file: path.join(rootDir, pkgJson.exports['.'].node.require),
...sourcemapOutputOptions,
format: 'cjs'
},
{
file: path.join(rootDir, pkgJson.exports['./node-js']),
...sourcemapOutputOptions,
format: 'cjs'
}
],
plugins: [
replace({
IS_BROWSER: false,

712
dist/cjs/index.node.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -133,7 +133,7 @@ w MUST be >= 0
A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
Defined in: [src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/isProbablyPrime.ts#L21)
Defined in: [src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/isProbablyPrime.ts#L21)
___
@ -273,7 +273,7 @@ bitLength MUST be > 0
A promise that resolves to a bigint probable prime of bitLength bits.
Defined in: [src/ts/prime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/prime.ts#L21)
Defined in: [src/ts/prime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/prime.ts#L21)
___
@ -298,7 +298,7 @@ bitLength MUST be > 0
A bigint probable prime of bitLength bits.
Defined in: [src/ts/prime.ts:100](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/prime.ts#L100)
Defined in: [src/ts/prime.ts:100](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/prime.ts#L100)
___
@ -322,7 +322,7 @@ Arguments MUST be: max > 0 && min >=0 && max > min
A cryptographically secure random bigint between [min,max]
Defined in: [src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/randBetween.ts#L15)
Defined in: [src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/randBetween.ts#L15)
___
@ -346,7 +346,7 @@ bitLength MUST be > 0
A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
Defined in: [src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/randBits.ts#L14)
Defined in: [src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/randBits.ts#L14)
___
@ -370,7 +370,7 @@ bitLength MUST be > 0
A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
Defined in: [src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/randBits.ts#L45)
Defined in: [src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/randBits.ts#L45)
___
@ -394,7 +394,7 @@ byteLength MUST be > 0
A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
Defined in: [src/ts/randBytes.ts:12](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/randBytes.ts#L12)
Defined in: [src/ts/randBytes.ts:12](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/randBytes.ts#L12)
___
@ -418,7 +418,7 @@ byteLength MUST be > 0
A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
Defined in: [src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/365e92e/src/ts/randBytes.ts#L46)
Defined in: [src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/9543211/src/ts/randBytes.ts#L46)
___

View File

@ -36,6 +36,7 @@
},
"default": "./dist/esm/index.browser.js"
},
"./node-js": "./dist/cjs/index.node.js",
"./esm-browser-bundle": "./dist/bundles/bigint-crypto-utils.esm.js",
"./iife-browser-bundle": "./dist/bundles/bigint-crypto-utils.iife.js",
"./umd-browser-bundle": "./dist/bundles/bigint-crypto-utils.umd.js",

View File

@ -26,6 +26,12 @@ Then either require (Node.js CJS):
const {{PKG_CAMELCASE}} = require('{{PKG_NAME}}')
```
> **Node >=10.4 <11**. `bigint-crypto-utils` uses workers to speed up some operations. Workers are enabled by default with Node.js from version 11. In order to use them with Node >=10.4 and <11, you need to execute node with the flag `--experimental-worker`, and require the .js file manually (otherwise .cjs is required by default and would not be supported by the workers)
>
> ```javascript
> const bigintCryptoUtils = require('bigint-crypto-utils/dist/cjs/index.node') // ONLY FOR node >=10.4 <11 !
> ```
or import (JavaScript ES module):
```javascript