本文整理匯總了TypeScript中@lib/object.library.asArray方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript library.asArray方法的具體用法?TypeScript library.asArray怎麽用?TypeScript library.asArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@lib/object.library
的用法示例。
在下文中一共展示了library.asArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: return
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;
}
示例2: 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;
}
})
})
示例3: 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)
}