当前位置: 首页>>代码示例>>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;未经允许,请勿转载。