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


TypeScript utils.isNone函數代碼示例

本文整理匯總了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)
  );
}
開發者ID:orbitjs,項目名稱:orbit.js,代碼行數:12,代碼來源:record.ts

示例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;
 });
開發者ID:orbitjs,項目名稱:orbit.js,代碼行數:16,代碼來源:async-query-operators.ts

示例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;
  }
開發者ID:orbitjs,項目名稱:orbit.js,代碼行數:39,代碼來源:cache.ts

示例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({
開發者ID:SmuliS,項目名稱:orbit.js,代碼行數:31,代碼來源:pull-operators.ts


注:本文中的@orbit/utils.isNone函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。