Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
timonson committed May 14, 2024
1 parent cec36ab commit 2eb0e16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 0 additions & 10 deletions strings/split.js
Original file line number Diff line number Diff line change
@@ -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);
}
Expand All @@ -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);
9 changes: 9 additions & 0 deletions strings/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2eb0e16

Please sign in to comment.