當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript object.library類代碼示例

本文整理匯總了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;未經允許,請勿轉載。