@bian-womp/spark-graph 0.1.24 → 0.1.25
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/cjs/index.cjs +38 -23
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/base.d.ts.map +1 -1
- package/lib/esm/index.js +38 -23
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/base.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/misc/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,eAAe,CAAC;AA2HvB,wBAAgB,uBAAuB,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/misc/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,eAAe,CAAC;AA2HvB,wBAAgB,uBAAuB,IAAI,QAAQ,CAg1BlD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,QA+BnD;AAqBD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,QA6BvD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,6BAUrE"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1990,6 +1990,16 @@ function setupBasicGraphRegistry() {
|
|
|
1990
1990
|
{ value: 13, label: "Avg" },
|
|
1991
1991
|
{ value: 14, label: "MinAll" },
|
|
1992
1992
|
{ value: 15, label: "MaxAll" },
|
|
1993
|
+
// Trig and other unary functions on A
|
|
1994
|
+
{ value: 16, label: "Sin" },
|
|
1995
|
+
{ value: 17, label: "Cos" },
|
|
1996
|
+
{ value: 18, label: "Tan" },
|
|
1997
|
+
{ value: 19, label: "ASin" },
|
|
1998
|
+
{ value: 20, label: "ACos" },
|
|
1999
|
+
{ value: 21, label: "ATan" },
|
|
2000
|
+
{ value: 22, label: "Sqrt" },
|
|
2001
|
+
{ value: 23, label: "Exp" },
|
|
2002
|
+
{ value: 24, label: "Log" },
|
|
1993
2003
|
],
|
|
1994
2004
|
});
|
|
1995
2005
|
// Enums: Compare Operation
|
|
@@ -2132,30 +2142,35 @@ function setupBasicGraphRegistry() {
|
|
|
2132
2142
|
const b = ins.B === undefined ? [] : asArray(ins.B);
|
|
2133
2143
|
const op = Number(ins.Operation ?? 0) | 0;
|
|
2134
2144
|
// Unary ops on A
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2145
|
+
const unary = {
|
|
2146
|
+
8: (x) => Math.round(x),
|
|
2147
|
+
9: (x) => Math.floor(x),
|
|
2148
|
+
10: (x) => Math.ceil(x),
|
|
2149
|
+
11: (x) => Math.abs(x),
|
|
2150
|
+
16: (x) => Math.sin(x),
|
|
2151
|
+
17: (x) => Math.cos(x),
|
|
2152
|
+
18: (x) => Math.tan(x),
|
|
2153
|
+
19: (x) => Math.asin(x),
|
|
2154
|
+
20: (x) => Math.acos(x),
|
|
2155
|
+
21: (x) => Math.atan(x),
|
|
2156
|
+
22: (x) => Math.sqrt(x),
|
|
2157
|
+
23: (x) => Math.exp(x),
|
|
2158
|
+
24: (x) => Math.log(x),
|
|
2159
|
+
};
|
|
2160
|
+
if (op in unary)
|
|
2161
|
+
return { Result: a.map((x) => unary[op](Number(x))) };
|
|
2143
2162
|
// Aggregate ops on A -> single-element array
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
};
|
|
2155
|
-
if (op === 15)
|
|
2156
|
-
return {
|
|
2157
|
-
Result: [a.length ? Math.max(...a.map((x) => Number(x))) : 0],
|
|
2158
|
-
};
|
|
2163
|
+
const aggregates = {
|
|
2164
|
+
12: (arr) => arr.reduce((s, x) => s + Number(x || 0), 0),
|
|
2165
|
+
13: (arr) => {
|
|
2166
|
+
const sum = arr.reduce((s, x) => s + Number(x || 0), 0);
|
|
2167
|
+
return arr.length ? sum / arr.length : 0;
|
|
2168
|
+
},
|
|
2169
|
+
14: (arr) => (arr.length ? Math.min(...arr.map((x) => Number(x))) : 0),
|
|
2170
|
+
15: (arr) => (arr.length ? Math.max(...arr.map((x) => Number(x))) : 0),
|
|
2171
|
+
};
|
|
2172
|
+
if (op in aggregates)
|
|
2173
|
+
return { Result: [aggregates[op](a)] };
|
|
2159
2174
|
// Binary ops A (broadcast) B
|
|
2160
2175
|
const len = Math.max(a.length, b.length);
|
|
2161
2176
|
const ops = [
|