@lakutata/math 3.1.3 → 3.1.5
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.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/cjs/lib/Distribution.js +2 -1
- package/dist/esm/lib/Distribution.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ npm install @lakutata/math
|
|
|
26
26
|
yet covered by allowScripts": `npm install-scripts approve @lakutata/math` records that you allow it. Bun and pnpm run
|
|
27
27
|
it only for the dependencies they are told to trust (`trustedDependencies` in the package.json for Bun,
|
|
28
28
|
`pnpm approve-builds` for pnpm); without it, loading the package throws an error telling how to build the addon.
|
|
29
|
-
- Node.js
|
|
29
|
+
- Node.js `>=18.10.0`.
|
|
30
30
|
- The addon uses Node-API, so Bun and the main process of Electron load the addon node-gyp built for Node.js, without a
|
|
31
31
|
rebuild. In Bun, terminating a worker thread while operations of the addon are still running in it ends the whole
|
|
32
32
|
process with a fatal error of Node-API (a bug of Bun 1.4); Node.js and Electron drop those operations.
|
package/README.zh-CN.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install @lakutata/math
|
|
|
12
12
|
|
|
13
13
|
- 原生插件在安装时编译(node-gyp),所以机器上需要 Python 3 和支持 C++17 的编译器:macOS 上是 Xcode 的命令行工具,Linux 上是 `build-essential`(Debian、Ubuntu)或 `build-base`(Alpine),Windows 上是 Visual Studio 生成工具(“使用 C++ 的桌面开发”)。编译需要半分钟到几分钟;编译失败时,安装也会失败。
|
|
14
14
|
- 包管理器需要执行这个包的安装脚本。npm 会执行,但可能提示这个脚本“not yet covered by allowScripts”:用 `npm install-scripts approve @lakutata/math` 记下你允许它执行。Bun 和 pnpm 只为信任的依赖执行,需要先允许它(Bun 在 package.json 的 `trustedDependencies` 里加上它,pnpm 用 `pnpm approve-builds`);没有允许时,加载这个包会抛出错误,说明怎样编译原生插件。
|
|
15
|
-
- Node.js
|
|
15
|
+
- Node.js `>=18.10.0`。
|
|
16
16
|
- 原生插件用的是 Node-API,所以 Bun 和 Electron 的主进程可以直接加载 node-gyp 为 Node.js 编译的插件,不用重新编译。在 Bun 里,worker 线程里的原生插件运算还没结束就终止这个线程的话,整个进程会因为 Node-API 的致命错误退出(这是 Bun 1.4 的问题);Node.js 和 Electron 会丢弃这些运算。
|
|
17
17
|
|
|
18
18
|
## 用法
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Distribution = exports.RandomGenerator = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
4
5
|
const MathArgumentException_js_1 = require("../exceptions/MathArgumentException.js");
|
|
5
6
|
const Matrix_js_1 = require("./Matrix.js");
|
|
6
7
|
const Native_js_1 = require("./Native.js");
|
|
@@ -60,7 +61,7 @@ class RandomGenerator {
|
|
|
60
61
|
constructor(seed) {
|
|
61
62
|
const word = new BigUint64Array(1);
|
|
62
63
|
if (seed === undefined) {
|
|
63
|
-
|
|
64
|
+
(0, node_crypto_1.randomFillSync)(word);
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
67
|
if (!(typeof seed === 'bigint' || Number.isSafeInteger(seed)))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomFillSync } from 'node:crypto';
|
|
1
2
|
import { MathArgumentException } from '../exceptions/MathArgumentException.js';
|
|
2
3
|
import { vectorOf } from './Matrix.js';
|
|
3
4
|
import { nativeCall } from './Native.js';
|
|
@@ -57,7 +58,7 @@ export class RandomGenerator {
|
|
|
57
58
|
constructor(seed) {
|
|
58
59
|
const word = new BigUint64Array(1);
|
|
59
60
|
if (seed === undefined) {
|
|
60
|
-
|
|
61
|
+
randomFillSync(word);
|
|
61
62
|
}
|
|
62
63
|
else {
|
|
63
64
|
if (!(typeof seed === 'bigint' || Number.isSafeInteger(seed)))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakutata/math",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "Mathematics for Node.js: symbolic computation (equations, derivatives, integrals, limits, Laplace transforms, factoring, simplification) and numerical computation (matrices, statistics, probability, numeric solutions, units, decimals of any precision) in a native addon built on SymEngine, Boost, Eigen and mpdecimal, used as functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lakutata",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"test:electron": "electron test-env/electron/main.mjs"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
|
-
"node": "
|
|
70
|
+
"node": ">=18.10.0"
|
|
71
71
|
},
|
|
72
72
|
"files": [
|
|
73
73
|
"dist",
|