Remove multi-line operations

This commit is contained in:
GCHQ 77703 2018-08-26 18:06:02 +01:00
parent a1b1059ad1
commit 001f3f30cd
4 changed files with 57 additions and 17 deletions

View file

@ -34,10 +34,8 @@ class FromGeohash extends Operation {
* @returns {string}
*/
run(input, args) {
return input.split("\n").map(line => {
const coords = geohash.decode(line);
return [coords.latitude, coords.longitude].join(",");
}).join("\n");
const coords = geohash.decode(input);
return [coords.latitude, coords.longitude].join(",");
}
}

View file

@ -41,11 +41,9 @@ class ToGeohash extends Operation {
run(input, args) {
const [precision] = args;
return input.split("\n").map(line => {
line = line.replace(/ /g, "");
if (line === "") return "";
return geohash.encode(...line.split(",").map(num => parseFloat(num)), precision);
}).join("\n");
input = input.replace(/ /g, "");
if (input === "") return "";
return geohash.encode(...input.split(",").map(num => parseFloat(num)), precision);
}
}