use crypto for JS
This commit is contained in:
@@ -581,20 +581,24 @@ Pkg.add("Dates")
|
||||
### JavaScript Dependencies (Node.js)
|
||||
|
||||
```bash
|
||||
npm install nats uuid apache-arrow node-fetch
|
||||
npm install nats apache-arrow node-fetch
|
||||
# or
|
||||
yarn add nats uuid apache-arrow node-fetch
|
||||
yarn add nats apache-arrow node-fetch
|
||||
```
|
||||
|
||||
**Note:** Node.js has a built-in `crypto` module for UUID generation, so no external `uuid` package is needed.
|
||||
|
||||
### JavaScript Dependencies (Browser)
|
||||
|
||||
```bash
|
||||
npm install nats uuid apache-arrow
|
||||
npm install nats apache-arrow
|
||||
# or use CDN:
|
||||
# https://unpkg.com/nats-js/dist/bundle/nats.min.js
|
||||
# https://unpkg.com/apache-arrow/arrow.min.js
|
||||
```
|
||||
|
||||
**Note:** For browser UUID generation, use the built-in `crypto.randomUUID()` API (available in modern browsers) or a lightweight alternative like `uuidv4` package.
|
||||
|
||||
### Python Dependencies (Desktop)
|
||||
|
||||
```bash
|
||||
@@ -1099,9 +1103,12 @@ end
|
||||
```javascript
|
||||
// natsbridge.js
|
||||
const nats = require('nats');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const crypto = require('crypto');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
// UUID generation using built-in crypto module
|
||||
const uuidv4 = () => crypto.randomUUID();
|
||||
|
||||
const DEFAULT_SIZE_THRESHOLD = 1_000_000;
|
||||
const DEFAULT_BROKER_URL = 'nats://localhost:4222';
|
||||
const DEFAULT_FILESERVER_URL = 'http://localhost:8080';
|
||||
@@ -1152,10 +1159,13 @@ module.exports = {
|
||||
|
||||
```javascript
|
||||
const nats = require('nats');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const crypto = require('crypto');
|
||||
const fetch = require('node-fetch');
|
||||
const arrow = require('apache-arrow');
|
||||
|
||||
// UUID generation using built-in crypto module
|
||||
const uuidv4 = () => crypto.randomUUID();
|
||||
|
||||
const DEFAULT_SIZE_THRESHOLD = 1_000_000;
|
||||
const DEFAULT_BROKER_URL = 'nats://localhost:4222';
|
||||
const DEFAULT_FILESERVER_URL = 'http://localhost:8080';
|
||||
|
||||
Reference in New Issue
Block a user