mirror of
https://github.com/gchq/CyberChef
synced 2025-01-26 03:05:06 +00:00
add join delimiter
This commit is contained in:
parent
4e6efead61
commit
6197523735
1 changed files with 12 additions and 4 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import {JOIN_DELIM_OPTIONS} from "../lib/Delim.mjs";
|
||||
|
||||
/**
|
||||
* ngram operation
|
||||
|
@ -29,6 +30,11 @@ class Ngram extends Operation {
|
|||
type: "number",
|
||||
value: 3
|
||||
},
|
||||
{
|
||||
"name": "Join delimiter",
|
||||
"type": "editableOptionShort",
|
||||
"value": JOIN_DELIM_OPTIONS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -38,13 +44,15 @@ class Ngram extends Operation {
|
|||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const n = args[0];
|
||||
const nGramSize = args[0],
|
||||
joinDelim = args[1];
|
||||
|
||||
const ngrams = [];
|
||||
for (let i = 0; i <= input.length - n; i++) {
|
||||
ngrams.push(input.slice(i, i + n));
|
||||
for (let i = 0; i <= input.length - nGramSize; i++) {
|
||||
ngrams.push(input.slice(i, i + nGramSize));
|
||||
}
|
||||
|
||||
return ngrams.join("\n");
|
||||
return ngrams.join(joinDelim);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue