本文整理汇总了TypeScript中@orbit/utils.isObject函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isObject函数的具体用法?TypeScript isObject怎么用?TypeScript isObject使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isObject函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: equalRecordIdentities
export function equalRecordIdentities(
record1: RecordIdentity,
record2: RecordIdentity
): boolean {
return (
(isNone(record1) && isNone(record2)) ||
(isObject(record1) &&
isObject(record2) &&
record1.type === record2.type &&
record1.id === record2.id)
);
}
示例2: buildTransform
export function buildTransform(transformOrOperations: TransformOrOperations, transformOptions?: object, transformId?: string, transformBuilder?: TransformBuilder): Transform {
if (typeof transformOrOperations === 'function') {
return buildTransform(transformOrOperations(transformBuilder), transformOptions, transformId);
} else {
let transform = transformOrOperations as Transform;
let operations: Operation[];
let options: object;
if (isObject(transform) && transform.operations) {
if (transform.id && !transformOptions && !transformId) {
return transform;
}
operations = transform.operations;
options = transformOptions || transform.options;
} else {
if (isArray(transformOrOperations)) {
operations = transformOrOperations as Operation[];
} else {
operations = [transformOrOperations as Operation];
}
options = transformOptions;
}
let id: string = transformId || Orbit.uuid();
return { operations, options, id };
}
}
示例3: buildQuery
export function buildQuery(
queryOrExpression: QueryOrExpression,
queryOptions?: object,
queryId?: string,
queryBuilder?: QueryBuilder
): Query {
if (typeof queryOrExpression === 'function') {
return buildQuery(queryOrExpression(queryBuilder), queryOptions, queryId);
} else {
let query = queryOrExpression as Query;
let expression: QueryExpression;
let options: object;
if (isObject(query) && query.expression) {
if (query.id && !queryOptions && !queryId) {
return query;
}
expression = query.expression;
options = queryOptions || query.options;
} else {
if (queryOrExpression instanceof QueryTerm) {
expression = queryOrExpression.toQueryExpression();
} else {
expression = queryOrExpression as QueryExpression;
}
options = queryOptions;
}
let id: string = queryId || Orbit.uuid();
return { expression, options, id };
}
}
示例4: parseFilterSpecifier
function parseFilterSpecifier(filterSpecifier: FilterSpecifier): FilterSpecifier {
if (isObject(filterSpecifier)) {
let s = filterSpecifier as FilterSpecifier;
s.kind = s.kind || 'attribute';
s.op = s.op || 'equal';
return s;
}
}
示例5: parseSortSpecifier
function parseSortSpecifier(sortSpecifier: SortSpecifier | string): SortSpecifier {
if (isObject(sortSpecifier)) {
let s = sortSpecifier as SortSpecifier;
s.kind = s.kind || 'attribute';
s.order = s.order || 'ascending';
return s;
} else if (typeof sortSpecifier === 'string') {
return parseSortSpecifierString(sortSpecifier);
}
throw new Error('Sort expression must be either an object or a string.');
}
示例6: sortParamToSpecifier
function sortParamToSpecifier(param: SortQBParam): SortSpecifier {
if (isObject(param)) {
if (param.hasOwnProperty('kind')) {
return param as SortSpecifier;
} else if (param.hasOwnProperty('attribute')) {
return {
kind: 'attribute',
attribute: (param as AttributeSortQBParam).attribute,
order: (param as AttributeSortQBParam).order || 'ascending'
} as AttributeSortSpecifier;
}
} else if (typeof param === 'string') {
return parseSortParamString(param);
}
throw new Error('Unrecognized sort param.');
}