本文整理汇总了TypeScript中@orbit/utils.isNone函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNone函数的具体用法?TypeScript isNone怎么用?TypeScript isNone使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isNone函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: if
return records.sort((record1, record2) => {
const values1 = comparisonValues.get(record1);
const values2 = comparisonValues.get(record2);
for (let i = 0; i < sortSpecifiers.length; i++) {
if (values1[i] < values2[i]) {
return -comparisonOrders[i];
} else if (values1[i] > values2[i]) {
return comparisonOrders[i];
} else if (isNone(values1[i]) && !isNone(values2[i])) {
return comparisonOrders[i];
} else if (isNone(values2[i]) && !isNone(values1[i])) {
return -comparisonOrders[i];
}
}
return 0;
});
示例3: getRecordsSync
getRecordsSync(typeOrIdentities?: string | RecordIdentity[]): Record[] {
const records: Record[] = [];
if (Array.isArray(typeOrIdentities)) {
const identities: RecordIdentity[] = typeOrIdentities;
for (let identity of identities) {
let record: Record = this.getRecordSync(identity);
if (record) {
records.push(record);
}
}
} else {
const type: string = typeOrIdentities;
for (let key in Orbit.globals.localStorage) {
if (key.indexOf(this.namespace + this.delimiter) === 0) {
let typesMatch = isNone(type);
if (!typesMatch) {
let fragments = key.split(this.delimiter);
let recordType = fragments[1];
typesMatch = recordType === type;
}
if (typesMatch) {
let record = JSON.parse(Orbit.globals.localStorage.getItem(key));
if (this.keyMap) {
this.keyMap.pushRecord(record);
}
records.push(record);
}
}
}
}
return records;
}
示例4: findRecords
} from '@orbit/data';
import LocalStorageSource from '../source';
export interface PullOperator {
(source: LocalStorageSource, expression: QueryExpression): Promise<Transform[]>;
}
export const PullOperators: Dict<PullOperator> = {
findRecords(source: LocalStorageSource, expression: FindRecords): Promise<Transform[]> {
const operations = [];
const typeFilter = expression.type;
for (let key in Orbit.globals.localStorage) {
if (key.indexOf(source.namespace) === 0) {
let typesMatch = isNone(typeFilter);
if (!typesMatch) {
let fragments = key.split(source.delimiter);
let type = fragments[1];
typesMatch = (typeFilter === type);
}
if (typesMatch) {
let record = JSON.parse(Orbit.globals.localStorage.getItem(key));
if (source.keyMap) {
source.keyMap.pushRecord(record);
}
operations.push({