mirror of
https://github.com/gchq/CyberChef.git
synced 2025-06-18 12:15:14 -04:00
ESM: Ported StrUtils and NetBIOS operations.
This commit is contained in:
parent
a98d37e61c
commit
037e2f3771
15 changed files with 907 additions and 6 deletions
55
src/core/operations/Split.mjs
Normal file
55
src/core/operations/Split.mjs
Normal file
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import {SPLIT_DELIM_OPTIONS, JOIN_DELIM_OPTIONS} from "../lib/Delim";
|
||||
|
||||
/**
|
||||
* Split operation
|
||||
*/
|
||||
class Split extends Operation {
|
||||
|
||||
/**
|
||||
* Split constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Split";
|
||||
this.module = "Default";
|
||||
this.description = "Splits a string into sections around a given delimiter.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Split delimiter",
|
||||
"type": "editableOption",
|
||||
"value": SPLIT_DELIM_OPTIONS
|
||||
},
|
||||
{
|
||||
"name": "Join delimiter",
|
||||
"type": "editableOption",
|
||||
"value": JOIN_DELIM_OPTIONS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const splitDelim = args[0],
|
||||
joinDelim = args[1],
|
||||
sections = input.split(splitDelim);
|
||||
|
||||
return sections.join(joinDelim);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Split;
|
Loading…
Add table
Add a link
Reference in a new issue