@fileverse-dev/formulajs 4.4.11-mod-16 → 4.4.11-mod-18
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/lib/browser/formula.js +58 -37
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +46 -21
- package/lib/esm/crypto-constants.mjs +2 -4
- package/lib/esm/index.mjs +46 -21
- package/package.json +1 -1
- package/types/cjs/index.d.cts +1 -1
- package/types/esm/index.d.mts +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -5182,39 +5182,65 @@ Z.TEST = (array, x, sigma) => {
|
|
|
5182
5182
|
return 1 - NORM.S.DIST((AVERAGE(array) - x) / (sigma / Math.sqrt(n)), true)
|
|
5183
5183
|
};
|
|
5184
5184
|
|
|
5185
|
-
function PNL(){
|
|
5186
|
-
|
|
5185
|
+
function PNL() {
|
|
5186
|
+
const [A, B] = argsToArray(arguments);
|
|
5187
5187
|
|
|
5188
|
-
|
|
5188
|
+
const toNumberOrThrow = (val) => {
|
|
5189
|
+
const num = Number(val);
|
|
5190
|
+
if (isNaN(num)) throw new Error(`Invalid number value: ${val}`);
|
|
5191
|
+
return num;
|
|
5192
|
+
};
|
|
5193
|
+
|
|
5194
|
+
// Single numbers
|
|
5189
5195
|
if (typeof A === "number" && typeof B === "number") {
|
|
5190
5196
|
return A - B;
|
|
5191
5197
|
}
|
|
5192
5198
|
|
|
5193
|
-
//
|
|
5194
|
-
if (Array.isArray(A) && Array.isArray(B) && typeof A[0]
|
|
5195
|
-
|
|
5196
|
-
|
|
5199
|
+
// 1D arrays
|
|
5200
|
+
if (Array.isArray(A) && Array.isArray(B) && typeof A[0] !== "object") {
|
|
5201
|
+
const maxLen = Math.max(A.length, B.length);
|
|
5202
|
+
let total = 0;
|
|
5203
|
+
for (let i = 0; i < maxLen; i++) {
|
|
5204
|
+
const aVal = i < A.length ? toNumberOrThrow(A[i]) : 0;
|
|
5205
|
+
const bVal = i < B.length ? toNumberOrThrow(B[i]) : 0;
|
|
5206
|
+
total += aVal - bVal;
|
|
5207
|
+
}
|
|
5208
|
+
return total;
|
|
5197
5209
|
}
|
|
5198
5210
|
|
|
5199
|
-
//
|
|
5200
|
-
if (Array.isArray(A[0]) && typeof A[0][0]
|
|
5211
|
+
// 2D arrays
|
|
5212
|
+
if (Array.isArray(A[0]) && typeof A[0][0] !== "object") {
|
|
5201
5213
|
let total = 0;
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5214
|
+
const maxRows = Math.max(A.length, B.length);
|
|
5215
|
+
for (let i = 0; i < maxRows; i++) {
|
|
5216
|
+
const rowA = A[i] || [];
|
|
5217
|
+
const rowB = B[i] || [];
|
|
5218
|
+
const maxCols = Math.max(rowA.length, rowB.length);
|
|
5219
|
+
for (let j = 0; j < maxCols; j++) {
|
|
5220
|
+
const aVal = j < rowA.length ? toNumberOrThrow(rowA[j]) : 0;
|
|
5221
|
+
const bVal = j < rowB.length ? toNumberOrThrow(rowB[j]) : 0;
|
|
5222
|
+
total += aVal - bVal;
|
|
5206
5223
|
}
|
|
5207
5224
|
}
|
|
5208
5225
|
return total;
|
|
5209
5226
|
}
|
|
5210
5227
|
|
|
5211
|
-
//
|
|
5228
|
+
// 3D arrays
|
|
5212
5229
|
if (Array.isArray(A[0][0])) {
|
|
5213
5230
|
let total = 0;
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5231
|
+
const maxX = Math.max(A.length, B.length);
|
|
5232
|
+
for (let i = 0; i < maxX; i++) {
|
|
5233
|
+
const matA = A[i] || [];
|
|
5234
|
+
const matB = B[i] || [];
|
|
5235
|
+
const maxY = Math.max(matA.length, matB.length);
|
|
5236
|
+
for (let j = 0; j < maxY; j++) {
|
|
5237
|
+
const rowA = matA[j] || [];
|
|
5238
|
+
const rowB = matB[j] || [];
|
|
5239
|
+
const maxZ = Math.max(rowA.length, rowB.length);
|
|
5240
|
+
for (let k = 0; k < maxZ; k++) {
|
|
5241
|
+
const aVal = k < rowA.length ? toNumberOrThrow(rowA[k]) : 0;
|
|
5242
|
+
const bVal = k < rowB.length ? toNumberOrThrow(rowB[k]) : 0;
|
|
5243
|
+
total += aVal - bVal;
|
|
5218
5244
|
}
|
|
5219
5245
|
}
|
|
5220
5246
|
}
|
|
@@ -5222,9 +5248,10 @@ function PNL(){
|
|
|
5222
5248
|
}
|
|
5223
5249
|
|
|
5224
5250
|
throw new Error("Unsupported or mismatched structure");
|
|
5225
|
-
|
|
5226
5251
|
}
|
|
5227
5252
|
|
|
5253
|
+
|
|
5254
|
+
|
|
5228
5255
|
/**
|
|
5229
5256
|
* Returns the absolute value of a number.
|
|
5230
5257
|
*
|
|
@@ -12997,8 +13024,6 @@ function SWITCH() {
|
|
|
12997
13024
|
const SERVICE_API_KEY = {
|
|
12998
13025
|
Etherscan: "ETHERSCAN_API_KEY",
|
|
12999
13026
|
Coingecko: "COINGECKO_API_KEY",
|
|
13000
|
-
Gnosisscan: 'GNOSISSSCAN',
|
|
13001
|
-
BASESCAN: 'Basescan'
|
|
13002
13027
|
};
|
|
13003
13028
|
|
|
13004
13029
|
const CHAIN_ID_MAP = {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// src/crypto-constants.js
|
|
2
2
|
var SERVICE_API_KEY = {
|
|
3
3
|
Etherscan: "ETHERSCAN_API_KEY",
|
|
4
|
-
Coingecko: "COINGECKO_API_KEY"
|
|
5
|
-
Gnosisscan: "GNOSISSSCAN",
|
|
6
|
-
BASESCAN: "Basescan"
|
|
4
|
+
Coingecko: "COINGECKO_API_KEY"
|
|
7
5
|
};
|
|
8
6
|
var FUNCTION_LOCALE = [
|
|
9
7
|
{
|
|
@@ -45,7 +43,7 @@ var FUNCTION_LOCALE = [
|
|
|
45
43
|
LOGO: "https://raw.githubusercontent.com/mritunjayz/github-storage/refs/heads/main/1689874988430.jpeg",
|
|
46
44
|
BRAND_COLOR: "#F6F7F8",
|
|
47
45
|
BRAND_SECONDARY_COLOR: "#21325B",
|
|
48
|
-
n: "
|
|
46
|
+
n: "0x",
|
|
49
47
|
t: 20,
|
|
50
48
|
d: "Fetches address data like transactions, balances, or portfolio info from multiple supported chains.",
|
|
51
49
|
a: "Dynamically queries blockchain data such as transactions, balances by resolving time ranges to block ranges.",
|
package/lib/esm/index.mjs
CHANGED
|
@@ -5180,39 +5180,65 @@ Z.TEST = (array, x, sigma) => {
|
|
|
5180
5180
|
return 1 - NORM.S.DIST((AVERAGE(array) - x) / (sigma / Math.sqrt(n)), true)
|
|
5181
5181
|
};
|
|
5182
5182
|
|
|
5183
|
-
function PNL(){
|
|
5184
|
-
|
|
5183
|
+
function PNL() {
|
|
5184
|
+
const [A, B] = argsToArray(arguments);
|
|
5185
5185
|
|
|
5186
|
-
|
|
5186
|
+
const toNumberOrThrow = (val) => {
|
|
5187
|
+
const num = Number(val);
|
|
5188
|
+
if (isNaN(num)) throw new Error(`Invalid number value: ${val}`);
|
|
5189
|
+
return num;
|
|
5190
|
+
};
|
|
5191
|
+
|
|
5192
|
+
// Single numbers
|
|
5187
5193
|
if (typeof A === "number" && typeof B === "number") {
|
|
5188
5194
|
return A - B;
|
|
5189
5195
|
}
|
|
5190
5196
|
|
|
5191
|
-
//
|
|
5192
|
-
if (Array.isArray(A) && Array.isArray(B) && typeof A[0]
|
|
5193
|
-
|
|
5194
|
-
|
|
5197
|
+
// 1D arrays
|
|
5198
|
+
if (Array.isArray(A) && Array.isArray(B) && typeof A[0] !== "object") {
|
|
5199
|
+
const maxLen = Math.max(A.length, B.length);
|
|
5200
|
+
let total = 0;
|
|
5201
|
+
for (let i = 0; i < maxLen; i++) {
|
|
5202
|
+
const aVal = i < A.length ? toNumberOrThrow(A[i]) : 0;
|
|
5203
|
+
const bVal = i < B.length ? toNumberOrThrow(B[i]) : 0;
|
|
5204
|
+
total += aVal - bVal;
|
|
5205
|
+
}
|
|
5206
|
+
return total;
|
|
5195
5207
|
}
|
|
5196
5208
|
|
|
5197
|
-
//
|
|
5198
|
-
if (Array.isArray(A[0]) && typeof A[0][0]
|
|
5209
|
+
// 2D arrays
|
|
5210
|
+
if (Array.isArray(A[0]) && typeof A[0][0] !== "object") {
|
|
5199
5211
|
let total = 0;
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5212
|
+
const maxRows = Math.max(A.length, B.length);
|
|
5213
|
+
for (let i = 0; i < maxRows; i++) {
|
|
5214
|
+
const rowA = A[i] || [];
|
|
5215
|
+
const rowB = B[i] || [];
|
|
5216
|
+
const maxCols = Math.max(rowA.length, rowB.length);
|
|
5217
|
+
for (let j = 0; j < maxCols; j++) {
|
|
5218
|
+
const aVal = j < rowA.length ? toNumberOrThrow(rowA[j]) : 0;
|
|
5219
|
+
const bVal = j < rowB.length ? toNumberOrThrow(rowB[j]) : 0;
|
|
5220
|
+
total += aVal - bVal;
|
|
5204
5221
|
}
|
|
5205
5222
|
}
|
|
5206
5223
|
return total;
|
|
5207
5224
|
}
|
|
5208
5225
|
|
|
5209
|
-
//
|
|
5226
|
+
// 3D arrays
|
|
5210
5227
|
if (Array.isArray(A[0][0])) {
|
|
5211
5228
|
let total = 0;
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5229
|
+
const maxX = Math.max(A.length, B.length);
|
|
5230
|
+
for (let i = 0; i < maxX; i++) {
|
|
5231
|
+
const matA = A[i] || [];
|
|
5232
|
+
const matB = B[i] || [];
|
|
5233
|
+
const maxY = Math.max(matA.length, matB.length);
|
|
5234
|
+
for (let j = 0; j < maxY; j++) {
|
|
5235
|
+
const rowA = matA[j] || [];
|
|
5236
|
+
const rowB = matB[j] || [];
|
|
5237
|
+
const maxZ = Math.max(rowA.length, rowB.length);
|
|
5238
|
+
for (let k = 0; k < maxZ; k++) {
|
|
5239
|
+
const aVal = k < rowA.length ? toNumberOrThrow(rowA[k]) : 0;
|
|
5240
|
+
const bVal = k < rowB.length ? toNumberOrThrow(rowB[k]) : 0;
|
|
5241
|
+
total += aVal - bVal;
|
|
5216
5242
|
}
|
|
5217
5243
|
}
|
|
5218
5244
|
}
|
|
@@ -5220,9 +5246,10 @@ function PNL(){
|
|
|
5220
5246
|
}
|
|
5221
5247
|
|
|
5222
5248
|
throw new Error("Unsupported or mismatched structure");
|
|
5223
|
-
|
|
5224
5249
|
}
|
|
5225
5250
|
|
|
5251
|
+
|
|
5252
|
+
|
|
5226
5253
|
/**
|
|
5227
5254
|
* Returns the absolute value of a number.
|
|
5228
5255
|
*
|
|
@@ -12995,8 +13022,6 @@ function SWITCH() {
|
|
|
12995
13022
|
const SERVICE_API_KEY = {
|
|
12996
13023
|
Etherscan: "ETHERSCAN_API_KEY",
|
|
12997
13024
|
Coingecko: "COINGECKO_API_KEY",
|
|
12998
|
-
Gnosisscan: 'GNOSISSSCAN',
|
|
12999
|
-
BASESCAN: 'Basescan'
|
|
13000
13025
|
};
|
|
13001
13026
|
|
|
13002
13027
|
const CHAIN_ID_MAP = {
|
package/package.json
CHANGED
package/types/cjs/index.d.cts
CHANGED
|
@@ -3157,7 +3157,7 @@ export function PI(): number;
|
|
|
3157
3157
|
* @returns
|
|
3158
3158
|
*/
|
|
3159
3159
|
export function PMT(rate: any, nper: any, pv: any, fv: any, type: any): number | Error;
|
|
3160
|
-
export function PNL(...args: any[]):
|
|
3160
|
+
export function PNL(...args: any[]): number;
|
|
3161
3161
|
export namespace POISSON {
|
|
3162
3162
|
/**
|
|
3163
3163
|
* Returns the Poisson distribution.
|
package/types/esm/index.d.mts
CHANGED
|
@@ -3157,7 +3157,7 @@ export function PI(): number;
|
|
|
3157
3157
|
* @returns
|
|
3158
3158
|
*/
|
|
3159
3159
|
export function PMT(rate: any, nper: any, pv: any, fv: any, type: any): number | Error;
|
|
3160
|
-
export function PNL(...args: any[]):
|
|
3160
|
+
export function PNL(...args: any[]): number;
|
|
3161
3161
|
export namespace POISSON {
|
|
3162
3162
|
/**
|
|
3163
3163
|
* Returns the Poisson distribution.
|