本文整理匯總了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({