remove setOps operation
parent
adc4f78e99
commit
543dce5721
|
@ -281,25 +281,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"": {
|
|
||||||
"module": "Default",
|
|
||||||
"description": "",
|
|
||||||
"inputType": "string",
|
|
||||||
"outputType": "string",
|
|
||||||
"flowControl": false,
|
|
||||||
"args": [
|
|
||||||
{
|
|
||||||
"name": "Sample delimiter",
|
|
||||||
"type": "binaryString",
|
|
||||||
"value": "\n\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Item delimiter",
|
|
||||||
"type": "binaryString",
|
|
||||||
"value": ","
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Set Union": {
|
"Set Union": {
|
||||||
"module": "Default",
|
"module": "Default",
|
||||||
"description": "Get the union of two sets",
|
"description": "Get the union of two sets",
|
||||||
|
|
|
@ -13,7 +13,6 @@ import PowerSet from "../../operations/PowerSet";
|
||||||
import RawDeflate from "../../operations/RawDeflate";
|
import RawDeflate from "../../operations/RawDeflate";
|
||||||
import SetDifference from "../../operations/SetDifference";
|
import SetDifference from "../../operations/SetDifference";
|
||||||
import SetIntersection from "../../operations/SetIntersection";
|
import SetIntersection from "../../operations/SetIntersection";
|
||||||
import SetOps from "../../operations/SetOps";
|
|
||||||
import SetUnion from "../../operations/SetUnion";
|
import SetUnion from "../../operations/SetUnion";
|
||||||
import ShowBase64Offsets from "../../operations/ShowBase64Offsets";
|
import ShowBase64Offsets from "../../operations/ShowBase64Offsets";
|
||||||
import SymmetricDifference from "../../operations/SymmetricDifference";
|
import SymmetricDifference from "../../operations/SymmetricDifference";
|
||||||
|
@ -32,7 +31,6 @@ OpModules.Default = {
|
||||||
"Raw Deflate": RawDeflate,
|
"Raw Deflate": RawDeflate,
|
||||||
"Set Difference": SetDifference,
|
"Set Difference": SetDifference,
|
||||||
"Set Intersection": SetIntersection,
|
"Set Intersection": SetIntersection,
|
||||||
"": SetOps,
|
|
||||||
"Set Union": SetUnion,
|
"Set Union": SetUnion,
|
||||||
"Show Base64 offsets": ShowBase64Offsets,
|
"Show Base64 offsets": ShowBase64Offsets,
|
||||||
"Symmetric Difference": SymmetricDifference,
|
"Symmetric Difference": SymmetricDifference,
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
import Operation from "../Operation";
|
|
||||||
import Utils from "../Utils";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class SetOp extends Operation {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {*} runOp
|
|
||||||
*/
|
|
||||||
constructor(runOp) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.module = "Default";
|
|
||||||
this.inputType = "string";
|
|
||||||
this.outputType = "string";
|
|
||||||
this.args = [
|
|
||||||
{
|
|
||||||
name: "Sample delimiter",
|
|
||||||
type: "binaryString",
|
|
||||||
value: "\n\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Item delimiter",
|
|
||||||
type: "binaryString",
|
|
||||||
value: ","
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
this.runOp = runOp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param sets
|
|
||||||
*/
|
|
||||||
validateSampleNumbers(sets) {
|
|
||||||
if (!sets || (sets.length !== 2)) {
|
|
||||||
throw "Incorrect number of sets, perhaps you need to modify the sample delimiter or add more samples?";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {*} input
|
|
||||||
* @param {*} args
|
|
||||||
*/
|
|
||||||
run(input, args) {
|
|
||||||
|
|
||||||
[this.sampleDelim, this.itemDelimiter] = args;
|
|
||||||
const sets = input.split(this.sampleDelim);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.validateSampleNumbers(sets);
|
|
||||||
} catch (e) {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = this.setOp.apply(this, sets.map(s => s.split(this.itemDelimiter)));
|
|
||||||
|
|
||||||
// let result = {
|
|
||||||
// "Union": this.runUnion,
|
|
||||||
// "Intersection": this.runIntersect,
|
|
||||||
// "Set Difference": this.runSetDifference,
|
|
||||||
// "Symmetric Difference": this.runSymmetricDifference,
|
|
||||||
// "Cartesian Product": this.runCartesianProduct,
|
|
||||||
// "Power Set": this.runPowerSet.bind(undefined, itemDelimiter),
|
|
||||||
// }[operation]
|
|
||||||
// .apply(this, sets.map(s => s.split(itemDelimiter)));
|
|
||||||
|
|
||||||
// Formatting issues due to the nested characteristics of power set.
|
|
||||||
// if (operation === "Power Set") {
|
|
||||||
// result = result.map(i => `${i}\n`).join("");
|
|
||||||
// } else {
|
|
||||||
// result = result.join(itemDelimiter);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return Utils.escapeHtml(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default SetOp;
|
|
|
@ -16,7 +16,6 @@ import RawDeflate from "./RawDeflate";
|
||||||
import RawInflate from "./RawInflate";
|
import RawInflate from "./RawInflate";
|
||||||
import SetDifference from "./SetDifference";
|
import SetDifference from "./SetDifference";
|
||||||
import SetIntersection from "./SetIntersection";
|
import SetIntersection from "./SetIntersection";
|
||||||
import SetOps from "./SetOps";
|
|
||||||
import SetUnion from "./SetUnion";
|
import SetUnion from "./SetUnion";
|
||||||
import ShowBase64Offsets from "./ShowBase64Offsets";
|
import ShowBase64Offsets from "./ShowBase64Offsets";
|
||||||
import SymmetricDifference from "./SymmetricDifference";
|
import SymmetricDifference from "./SymmetricDifference";
|
||||||
|
@ -40,7 +39,6 @@ export {
|
||||||
RawInflate,
|
RawInflate,
|
||||||
SetDifference,
|
SetDifference,
|
||||||
SetIntersection,
|
SetIntersection,
|
||||||
SetOps,
|
|
||||||
SetUnion,
|
SetUnion,
|
||||||
ShowBase64Offsets,
|
ShowBase64Offsets,
|
||||||
SymmetricDifference,
|
SymmetricDifference,
|
||||||
|
|
Loading…
Reference in New Issue