本文整理匯總了TypeScript中@lib/object.library.isString方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript library.isString方法的具體用法?TypeScript library.isString怎麽用?TypeScript library.isString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@lib/object.library
的用法示例。
在下文中一共展示了library.isString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: dbg
export function dbg(fmt?: any, ...msg: any[]): void {
let name = this && this.constructor && this.constructor.name || '';
let sep = isString(fmt) && (fmt.includes(':') || msg.length === 0)
? '.' : ': ';
log(name + sep + fmt, ...msg);// prepend the current Module name to aid debugging
}
示例2:
export const log = (fmt?: any, ...msg: any[]): void => {
let out = 'log';
if (isString(fmt)) {
let match = fmt.match(/(\w*):/i) || [];
if (['log', 'info', 'debug', 'warn', 'error'].includes(match[1]))
out = match[1];
}
(console as any)[out](sprintf(fmt, ...msg));
}
示例3: format
export const sprintf = (fmt: any, ...msg: any[]): string => {
if (isString(fmt) && !fmt.includes('%')) {
msg.unshift(fmt); // put the format into the msg array
fmt = msg // and build a new format string
.map(arg => isObject(arg) ? '%j' : '%s')
.join(', ') // reassemble as a comma-separated string
}
return format(fmt, ...msg); // NodeJS.format()
}
示例4: isString
.every(clause => { // and return only rows that match every clause
const key = row[clause.fieldPath as string];
const field = isString(key) ? key.toLowerCase() : key;
const value = isString(clause.value) ? clause.value.toLowerCase() : clause.value;
switch (clause.opStr) { // standard firestore query-operators, and '!='
case '==':
return isUndefined(field)
? !value // if field not present, compare to 'falsy'
: field == value; // use '==' to allow for string/number match, instead of '==='
case '>':
return field > value;
case '>=':
return field >= value;
case '<':
return field < value;
case '<=':
return field <= value;
case '!=': // non-standard operator
return isUndefined(field) || field != value;
default:
return false;
}
})