當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。