From 2eb0e16378922fdae460391e2e8ac9e45a610cb2 Mon Sep 17 00:00:00 2001 From: timonson Date: Tue, 14 May 2024 14:37:30 +0200 Subject: [PATCH] Update --- strings/split.js | 10 ---------- strings/update.js | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/strings/split.js b/strings/split.js index dd48d04..33df0f5 100644 --- a/strings/split.js +++ b/strings/split.js @@ -1,6 +1,3 @@ -import { removeLast } from "./update.js"; -import { last } from "../collections/single_access.js"; - export function split(separator) { return (s) => s.split(separator); } @@ -18,10 +15,3 @@ export const splitByNewline = split("\n"); export const splitByEqualitySign = split("="); export const splitByPlus = split("+"); export const splitByPipe = split("|"); - -export function removeFromLastSeparator(splitFunction) { - return (input) => removeLast(`.${last(splitFunction(input))}`)(input); -} - -export const removeFromLastDot = removeFromLastSeparator(splitByDot); -export const removeFromLastDash = removeFromLastSeparator(splitByDash); diff --git a/strings/update.js b/strings/update.js index 6be70b0..acedffa 100644 --- a/strings/update.js +++ b/strings/update.js @@ -2,6 +2,7 @@ import { length } from "../collections/length.js"; import { first, last } from "../collections/single_access.js"; import { repeat } from "./mapping.js"; +import { splitByDash, splitByDot } from "./split.js"; function surroundWith(beginning) { return (end) => (str) => beginning + str + end; @@ -118,6 +119,14 @@ function removeLastIf(pattern) { }; } +export function removeFromLastDash(websiteName) { + return removeLast(`-${last(splitByDash(websiteName))}`)(websiteName); +} + +export function removeFromLastDot(domain) { + return removeLast(`.${last(splitByDot(domain))}`)(domain); +} + export { pad, removeAll,