dazscript-framework
Version:
The **DazScript Framework** is a TypeScript-based framework for writing Daz Studio scripts. It provides all the advantages of a typed language such as autocompletion, error checking, and method parameter documentation and hinting. The framework also inclu
32 lines (27 loc) • 1.04 kB
text/typescript
export const isNumeric = (value: string | number): boolean => {
return ((value != null) &&
(value !== '') &&
!isNaN(Number(value.toString())))
}
export const contains = (source: string, search: string | string[]): boolean => {
if (Array.isArray(search)) {
for (const s of search) {
if (source.indexOf(s) >= 0) return true
}
return false
}
return source.indexOf(search) >= 0
}
export const remove = (source: string, search: string): string => {
return source.replace(search, "")
}
export const trimEnd = (source: string, search: string): string => {
return source.endsWith(search) ? source.slice(0, -search.length) : source
}
export const count = (source: string, search: string): number => {
return source.split(search).length - 1
}
export const isGUID = (str: string): boolean => {
const GUIDPattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
return GUIDPattern.test(str);
}