-
Notifications
You must be signed in to change notification settings - Fork 0
Utility String
Yakov Veromeev edited this page Nov 14, 2022
·
1 revision
Module: sldt/utilsString
Each function is imported as an import member (there is no default export)
import { generateUUID } from "sldt/utilsString";
Create a random number and form it as UUID v4 string. Useful for creating the ids in arrays you need to display, or HTML element ids you don't need to name any specific way.
function generateUUID(): string
a shortcut for typeof variable === "string"
, returns true
if var is string.
function isString(probableString: any): boolean
In fact, returns typescript's probableString is string
, such notation helps in if clauses, because embedded IDE tools will recognize it and hint you with string methods.
if (isString(response)) {
console.log(response. /// here you'll see the string methods like split and replace
}
function isStringFilled(probableString: any): boolean
As well, returns probableString is string
to help IDE type system recognize a string.
function isStringNotBlank(probableString: any): boolean
As well, returns probableString is string
to help IDE type system recognize a string.