Separated observables from components

This commit is contained in:
squidfunk
2020-02-12 19:13:03 +01:00
parent a018ed0297
commit 306530f668
84 changed files with 1523 additions and 1418 deletions

View File

@@ -20,7 +20,7 @@
* IN THE SOFTWARE.
*/
import { getElement } from "../agent"
import { getElement } from "observables"
/* ----------------------------------------------------------------------------
* Data
@@ -35,23 +35,6 @@ let lang: Record<string, string>
* Functions
* ------------------------------------------------------------------------- */
/**
* Truncate a string after the given number of characters
*
* @param value - Value to be truncated
* @param n - Number of characters
*
* @return Truncated value
*/
export function truncate(value: string, n: number): string {
let i = n
if (value.length > i) {
while (value[i] !== " " && --i > 0); // tslint:disable-line
return `${value.substring(0, i)}...`
}
return value
}
/**
* Translate the given key
*
@@ -72,3 +55,20 @@ export function translate(key: string, value?: string): string {
? lang[key].replace("#", value)
: lang[key]
}
/**
* Truncate a string after the given number of characters
*
* @param value - Value to be truncated
* @param n - Number of characters
*
* @return Truncated value
*/
export function truncate(value: string, n: number): string {
let i = n
if (value.length > i) {
while (value[i] !== " " && --i > 0); // tslint:disable-line
return `${value.substring(0, i)}...`
}
return value
}