Merge 618863ecf14b99e12ad9a055f91db2fe74d651a9 into ddbe9141322baf88b575ac1615b8e68d3c53b412

This commit is contained in:
Vignesh Rajan 2026-06-19 22:22:30 +02:00 committed by GitHub
commit 6875e58040
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 7 deletions

View File

@ -108,10 +108,11 @@ export function mean(data) {
* @returns {BigNumber} * @returns {BigNumber}
*/ */
export function median(data) { export function median(data) {
if ((data.length % 2) === 0 && data.length > 0) { if (data.length === 0) return data[0];
data.sort(function(a, b) { data.sort(function(a, b) {
return a.minus(b); return a.minus(b);
}); });
if ((data.length % 2) === 0) {
const first = data[Math.floor(data.length / 2)]; const first = data[Math.floor(data.length / 2)];
const second = data[Math.floor(data.length / 2) - 1]; const second = data[Math.floor(data.length / 2) - 1];
return mean([first, second]); return mean([first, second]);

View File

@ -75,7 +75,7 @@ class SetDifference extends Operation {
* @returns {Object[]} * @returns {Object[]}
*/ */
runSetDifference(a, b) { runSetDifference(a, b) {
return a return [...new Set(a)]
.filter((item) => { .filter((item) => {
return b.indexOf(item) === -1; return b.indexOf(item) === -1;
}) })

View File

@ -75,7 +75,7 @@ class SetIntersection extends Operation {
* @returns {Object[]} * @returns {Object[]}
*/ */
runIntersect(a, b) { runIntersect(a, b) {
return a return [...new Set(a)]
.filter((item) => { .filter((item) => {
return b.indexOf(item) > -1; return b.indexOf(item) > -1;
}) })

View File

@ -56,7 +56,8 @@ class UnescapeUnicodeCharacters extends Operation {
*/ */
run(input, args) { run(input, args) {
const prefix = prefixToRegex[args[0]], const prefix = prefixToRegex[args[0]],
regex = new RegExp(prefix+"([a-f\\d]{4})", "ig"); quantifier = args[0] === "U+" ? "{4,6}" : "{4}",
regex = new RegExp(prefix+"([a-f\\d]"+quantifier+")", "ig");
let output = "", let output = "",
m, m,
i = 0; i = 0;