mirror of
https://github.com/gchq/CyberChef.git
synced 2025-06-16 03:05:16 -04:00
ESM: Ported SeqUtils operations
This commit is contained in:
parent
66c768fe31
commit
d327dd47b2
7 changed files with 447 additions and 0 deletions
48
src/core/operations/Unique.mjs
Normal file
48
src/core/operations/Unique.mjs
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import Utils from "../Utils";
|
||||
import {INPUT_DELIM_OPTIONS} from "../lib/Delim";
|
||||
|
||||
/**
|
||||
* Unique operation
|
||||
*/
|
||||
class Unique extends Operation {
|
||||
|
||||
/**
|
||||
* Unique constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Unique";
|
||||
this.module = "Default";
|
||||
this.description = "Removes duplicate strings from the input.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Delimiter",
|
||||
"type": "option",
|
||||
"value": INPUT_DELIM_OPTIONS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const delim = Utils.charRep(args[0]);
|
||||
return input.split(delim).unique().join(delim);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Unique;
|
Loading…
Add table
Add a link
Reference in a new issue