Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/core/lib/Arithmetic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ export function mean(data) {
* @returns {BigNumber}
*/
export function median(data) {
if ((data.length % 2) === 0 && data.length > 0) {
data.sort(function(a, b) {
return a.minus(b);
});
if (data.length === 0) return data[0];
data.sort(function(a, b) {
return a.minus(b);
});
if ((data.length % 2) === 0) {
const first = data[Math.floor(data.length / 2)];
const second = data[Math.floor(data.length / 2) - 1];
return mean([first, second]);
Expand Down
2 changes: 1 addition & 1 deletion src/core/operations/SetDifference.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SetDifference extends Operation {
* @returns {Object[]}
*/
runSetDifference(a, b) {
return a
return [...new Set(a)]
.filter((item) => {
return b.indexOf(item) === -1;
})
Expand Down
2 changes: 1 addition & 1 deletion src/core/operations/SetIntersection.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SetIntersection extends Operation {
* @returns {Object[]}
*/
runIntersect(a, b) {
return a
return [...new Set(a)]
.filter((item) => {
return b.indexOf(item) > -1;
})
Expand Down
3 changes: 2 additions & 1 deletion src/core/operations/UnescapeUnicodeCharacters.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class UnescapeUnicodeCharacters extends Operation {
*/
run(input, args) {
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 = "",
m,
i = 0;
Expand Down