init
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import {formatDistanceToNow, parseJSON} from "date-fns";
|
||||
|
||||
export function friendlyDate(date) {
|
||||
|
||||
return formatDistanceToNow(parseJSON(date), {addSuffix: true});
|
||||
}
|
||||
|
||||
export function stripHtml(html = "") {
|
||||
let tmp = document.createElement("div");
|
||||
tmp.innerHTML = html;
|
||||
return tmp.textContent || tmp.innerText || "";
|
||||
}
|
||||
|
||||
|
||||
export function randomId(length = 10) {
|
||||
return Math.random().toString(36).substring(2, length + 2);
|
||||
}
|
||||
Reference in New Issue
Block a user