本文整理汇总了TypeScript中@lib/object.library类的典型用法代码示例。如果您正苦于以下问题:TypeScript library类的具体用法?TypeScript library怎么用?TypeScript library使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了library类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
return (colRef: Query) => { // return a Query-function
if (query.where)
asArray<IWhere>(query.where)
.forEach(qry => colRef = colRef.where(qry.fieldPath, qry.opStr as WhereFilterOp, qry.value));
if (query.orderBy)
asArray(query.orderBy)
.forEach(order => colRef = colRef.orderBy(order.fieldPath, order.directionStr));
if (isNumeric(query.limitTo))
colRef = colRef.limit(query.limitTo as number);
return colRef;
}
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:14,代码来源:fire.library.ts
示例2: 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
}
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:7,代码来源:logger.library.ts
示例3: asArray
.filter((row: IObject<any>) => { // for each row, ...
return asArray(filters) // apply each filter...
.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;
}
})
})
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:27,代码来源:app.library.ts
示例4: filterTable
export const asAt = <T>(table: T[], cond: IWhere | IWhere[] = [], date?: string | number) => {
const stamp = isNumber(date) ? date : fmtDate(date, DATE_FMT.yearMonthDayFmt).stamp;
return filterTable(table, cond) // return the rows where date is between _effect and IMeta
.filter((row: IMeta) => stamp < (row[FIELD.expire] || Number.MAX_SAFE_INTEGER))
.filter((row: IMeta) => (row[FIELD.effect] || Number.MIN_SAFE_INTEGER) <= stamp)
}
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:7,代码来源:member.library.ts
示例5: asArray
export const toHex = (num: number | number[] = [], len: number = 40) => {
return asArray(num)
.map(val => (val + 0x100).toString(16).slice(-2))
.join('')
.toLowerCase()
.substring(0, len)
}
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:7,代码来源:number.library.ts
示例6: 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()
}
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:9,代码来源:logger.library.ts
示例7:
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));
}
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:9,代码来源:logger.library.ts
示例8: isObject
.map(arg => isObject(arg) ? '%j' : '%s')
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:1,代码来源:logger.library.ts
示例9: toHex
export const cryptoHash = async (source: string | Object, len: number = 64) => {
const buffer = asBuffer(asString(source));
const hash = await crypto.subtle.digest('SHA-256', buffer);
return toHex([...(new Uint8Array(hash))], len);
}
开发者ID:magmacomputing,项目名称:whiteBook,代码行数:6,代码来源:crypto.library.ts
注:本文中的@lib/object.library类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论