当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript utils.isArray函数代码示例

本文整理汇总了TypeScript中@orbit/utils.isArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isArray函数的具体用法?TypeScript isArray怎么用?TypeScript isArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isArray函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: deepGet

        Object.keys(replacement.relationships).forEach(field => {
          let data = deepGet(replacement, ['relationships', field, 'data']);
          if (data !== undefined) {
            let currentData = deepGet(current, [
              'relationships',
              field,
              'data'
            ]);
            let relationshipChanged;

            if (isArray(data)) {
              if (currentData) {
                relationshipChanged = !equalRecordIdentitySets(
                  currentData,
                  data
                );
              } else {
                relationshipChanged = true;
                currentData = [];
              }
            } else {
              if (currentData) {
                relationshipChanged = !equalRecordIdentities(currentData, data);
              } else {
                relationshipChanged = true;
                currentData = null;
              }
            }

            if (relationshipChanged) {
              changed = true;
              deepSet(result, ['relationships', field, 'data'], currentData);
            }
          }
        });
开发者ID:orbitjs,项目名称:orbit.js,代码行数:35,代码来源:sync-inverse-patch-operators.ts

示例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 };
  }
}
开发者ID:SmuliS,项目名称:orbit.js,代码行数:29,代码来源:transform.ts

示例3: patch

  /**
   * Patches the cache with an operation or operations.
   */
  patch(
    operationOrOperations:
      | RecordOperation
      | RecordOperation[]
      | TransformBuilderFunc
  ): PatchResult {
    if (typeof operationOrOperations === 'function') {
      operationOrOperations = operationOrOperations(this._transformBuilder) as
        | RecordOperation
        | RecordOperation[];
    }

    const result: PatchResult = {
      inverse: [],
      data: []
    };

    if (isArray(operationOrOperations)) {
      this._applyPatchOperations(
        operationOrOperations as RecordOperation[],
        result,
        true
      );
    } else {
      this._applyPatchOperation(
        operationOrOperations as RecordOperation,
        result,
        true
      );
    }

    result.inverse.reverse();

    return result;
  }
开发者ID:orbitjs,项目名称:orbit.js,代码行数:38,代码来源:sync-record-cache.ts

示例4: recordArrayFromData

export function recordArrayFromData(data: any): RecordIdentity[] {
  if (isArray(data)) {
    return data;
  } else if (data) {
    return [data];
  } else {
    return [];
  }
}
开发者ID:orbitjs,项目名称:orbit.js,代码行数:9,代码来源:schema-consistency-utils.ts

示例5: deepSet

  ['filter', 'include', 'page', 'sort'].forEach(param => {
    let value = (options as any)[param];
    if (value) {
      if (param === 'include' && isArray(value)) {
        value = value.join(',');
      }

      deepSet(settings, ['params', param], value);
    }
  });
开发者ID:orbitjs,项目名称:orbit.js,代码行数:10,代码来源:request-settings.ts

示例6: RecordIdentityMap

 Object.keys(record.relationships).forEach(name => {
   let rel = record.relationships[name];
   if (rel.data !== undefined) {
     if (isArray(rel.data)) {
       let relMap = rels[name] = new RecordIdentityMap();
       (rel.data as RecordIdentity[]).forEach(r => relMap.add(r));
     } else {
       rels[name] = rel.data;
     }
   }
 });
开发者ID:SmuliS,项目名称:orbit.js,代码行数:11,代码来源:relationship-accessor.ts

示例7:

 Object.keys(relationships).forEach(relationship => {
   const relationshipData = relationships[relationship] && relationships[relationship].data;
   if (relationshipData) {
     if (isArray(relationshipData)) {
       const relatedRecords = relationshipData as Record[];
       relatedRecords.forEach(relatedRecord => {
         this.remove(relatedRecord, { record, relationship })
       });
     } else {
       const relatedRecord = relationshipData as Record;
       this.remove(relatedRecord, { record, relationship })
     }
   }
 });
开发者ID:SmuliS,项目名称:orbit.js,代码行数:14,代码来源:inverse-relationship-accessor.ts

示例8: deepGet

        Object.keys(replacement.relationships).forEach(field => {
          let currentValue = deepGet(current, ['relationships', field]);
          let value = replacement.relationships[field];
          let data = value && value.data;

          let relationshipMatch;
          if (isArray(data)) {
            relationshipMatch = cache.relationships.relatedRecordsMatch(op.record, field, data as RecordIdentity[]);
          } else {
            relationshipMatch = eq(value, currentValue);
          }

          if (!relationshipMatch) {
            changed = true;
            deepSet(result, ['relationships', field], currentValue === undefined ? null : currentValue);
          }
        });
开发者ID:SmuliS,项目名称:orbit.js,代码行数:17,代码来源:inverse-transforms.ts

示例9: function

  proto.sync = function(
    transformOrTransforms: Transform | Transform[]
  ): Promise<void> {
    if (isArray(transformOrTransforms)) {
      const transforms = transformOrTransforms as Transform[];

      return transforms.reduce((chain, transform) => {
        return chain.then(() => this.sync(transform));
      }, Promise.resolve());
    } else {
      const transform = transformOrTransforms as Transform;

      if (this.transformLog.contains(transform.id)) {
        return Promise.resolve();
      }

      return this._enqueueSync('sync', transform);
    }
  };
开发者ID:orbitjs,项目名称:orbit.js,代码行数:19,代码来源:syncable.ts

示例10:

 Object.keys(relationships).forEach(relationship => {
   const relationshipData =
     relationships[relationship] && relationships[relationship].data;
   if (relationshipData) {
     if (isArray(relationshipData)) {
       const relatedRecords = relationshipData as Record[];
       relatedRecords.forEach(relatedRecord => {
         inverseRelationships.push({
           record: recordIdentity,
           relationship,
           relatedRecord
         });
       });
     } else {
       const relatedRecord = relationshipData as Record;
       inverseRelationships.push({
         record: recordIdentity,
         relationship,
         relatedRecord
       });
     }
   }
 });
开发者ID:orbitjs,项目名称:orbit.js,代码行数:23,代码来源:cache-integrity-utils.ts


注:本文中的@orbit/utils.isArray函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。