[REM] utils: remove findInTree and htmlTrim

They were not used and are not in the scope of this project.
This commit is contained in:
Géry Debongnie
2019-04-27 11:44:37 +02:00
parent b08e876136
commit 1701d5aa86
2 changed files with 0 additions and 69 deletions
-40
View File
@@ -13,20 +13,6 @@ export function escape(str: string | number | undefined): string {
.replace(/`/g, "`");
}
/**
* Remove trailing and leading spaces
*/
export function htmlTrim(s: string): string {
let result = s.replace(/(^\s+|\s+$)/g, "");
if (s[0] === " ") {
result = " " + result;
}
if (result !== " " && s[s.length - 1] === " ") {
result = result + " ";
}
return result;
}
export type HashFn = (args: any[]) => string;
export function memoize<R, T extends (...args: any[]) => R>(
@@ -79,32 +65,6 @@ export function debounce(
};
}
interface Tree<T> {
children: T[];
}
/**
* Find a node in a tree.
*
* This will traverse the tree (depth first) and return the first child that
* matches the predicate, if any
*/
export function findInTree<T extends Tree<T>>(
tree: T,
predicate: (t: T) => boolean
): T | null {
if (predicate(tree)) {
return tree;
}
for (let child of tree.children) {
let match = findInTree(child, predicate);
if (match) {
return match;
}
}
return null;
}
export function patch(C: any, patchName: string, patch: any) {
const proto = C.prototype;
if (!proto.__patches) {