mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 08:58:30 +01:00
34 lines
629 B
JavaScript
34 lines
629 B
JavaScript
|
import SetOp from "./SetOps";
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
class SetIntersection extends SetOp {
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
constructor() {
|
||
|
super();
|
||
|
this.setOp = this.runIntersection;
|
||
|
|
||
|
this.name = "Set Intersection";
|
||
|
this.description = "Get the intersection of two sets";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get the intersection of the two sets.
|
||
|
*
|
||
|
* @param {Object[]} a
|
||
|
* @param {Object[]} b
|
||
|
* @returns {Object[]}
|
||
|
*/
|
||
|
runIntersection(a, b) {
|
||
|
return a.filter((item) => {
|
||
|
return b.indexOf(item) > -1;
|
||
|
}).join(this.itemDelimiter);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default SetIntersection;
|